repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
196
| func_name
stringlengths 7
107
| whole_func_string
stringlengths 76
3.82k
| language
stringclasses 1
value | func_code_string
stringlengths 76
3.82k
| func_code_tokens
listlengths 22
717
| func_documentation_string
stringlengths 61
1.98k
| func_documentation_tokens
listlengths 1
508
| split_name
stringclasses 1
value | func_code_url
stringlengths 111
310
|
---|---|---|---|---|---|---|---|---|---|---|
reactor/reactor-netty | src/main/java/reactor/netty/http/client/HttpClient.java | HttpClient.wiretap | public final HttpClient wiretap(boolean enable) {
if (enable) {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(b -> BootstrapHandlers.updateLogSupport(b, LOGGING_HANDLER)));
}
else {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(
b -> BootstrapHandlers.removeConfiguration(b, NettyPipeline.LoggingHandler)));
}
} | java | public final HttpClient wiretap(boolean enable) {
if (enable) {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(b -> BootstrapHandlers.updateLogSupport(b, LOGGING_HANDLER)));
}
else {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(
b -> BootstrapHandlers.removeConfiguration(b, NettyPipeline.LoggingHandler)));
}
} | [
"public",
"final",
"HttpClient",
"wiretap",
"(",
"boolean",
"enable",
")",
"{",
"if",
"(",
"enable",
")",
"{",
"return",
"tcpConfiguration",
"(",
"tcpClient",
"->",
"tcpClient",
".",
"bootstrap",
"(",
"b",
"->",
"BootstrapHandlers",
".",
"updateLogSupport",
"(",
"b",
",",
"LOGGING_HANDLER",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"tcpConfiguration",
"(",
"tcpClient",
"->",
"tcpClient",
".",
"bootstrap",
"(",
"b",
"->",
"BootstrapHandlers",
".",
"removeConfiguration",
"(",
"b",
",",
"NettyPipeline",
".",
"LoggingHandler",
")",
")",
")",
";",
"}",
"}"
] | Apply or remove a wire logger configuration using {@link HttpClient} category
and {@code DEBUG} logger level
@param enable Specifies whether the wire logger configuration will be added to
the pipeline
@return a new {@link HttpClient} | [
"Apply",
"or",
"remove",
"a",
"wire",
"logger",
"configuration",
"using",
"{",
"@link",
"HttpClient",
"}",
"category",
"and",
"{",
"@code",
"DEBUG",
"}",
"logger",
"level"
] | train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/http/client/HttpClient.java#L813-L821 |
anotheria/moskito | moskito-webui/src/main/java/net/anotheria/moskito/webui/producers/action/ShowCumulatedProducersAction.java | ShowCumulatedProducersAction.setAccumulatorAttributes | private void setAccumulatorAttributes(List<String> accumulatorIds, HttpServletRequest request) throws APIException {
if (accumulatorIds == null || accumulatorIds.isEmpty()) {
return;
}
request.setAttribute("accumulatorsPresent", Boolean.TRUE);
//create multiple graphs with one line each.
List<AccumulatedSingleGraphAO> singleGraphDataBeans = getAccumulatorAPI().getChartsForMultipleAccumulators(accumulatorIds);
request.setAttribute("singleGraphData", singleGraphDataBeans);
request.setAttribute("accumulatorsColors", AccumulatorUtility.accumulatorsColorsToJSON(singleGraphDataBeans));
List<String> accumulatorsNames = new LinkedList<>();
for (AccumulatedSingleGraphAO ao : singleGraphDataBeans) {
accumulatorsNames.add(ao.getName());
}
request.setAttribute("accNames", accumulatorsNames);
request.setAttribute("accNamesConcat", net.anotheria.util.StringUtils.concatenateTokens(accumulatorsNames, ","));
} | java | private void setAccumulatorAttributes(List<String> accumulatorIds, HttpServletRequest request) throws APIException {
if (accumulatorIds == null || accumulatorIds.isEmpty()) {
return;
}
request.setAttribute("accumulatorsPresent", Boolean.TRUE);
//create multiple graphs with one line each.
List<AccumulatedSingleGraphAO> singleGraphDataBeans = getAccumulatorAPI().getChartsForMultipleAccumulators(accumulatorIds);
request.setAttribute("singleGraphData", singleGraphDataBeans);
request.setAttribute("accumulatorsColors", AccumulatorUtility.accumulatorsColorsToJSON(singleGraphDataBeans));
List<String> accumulatorsNames = new LinkedList<>();
for (AccumulatedSingleGraphAO ao : singleGraphDataBeans) {
accumulatorsNames.add(ao.getName());
}
request.setAttribute("accNames", accumulatorsNames);
request.setAttribute("accNamesConcat", net.anotheria.util.StringUtils.concatenateTokens(accumulatorsNames, ","));
} | [
"private",
"void",
"setAccumulatorAttributes",
"(",
"List",
"<",
"String",
">",
"accumulatorIds",
",",
"HttpServletRequest",
"request",
")",
"throws",
"APIException",
"{",
"if",
"(",
"accumulatorIds",
"==",
"null",
"||",
"accumulatorIds",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"request",
".",
"setAttribute",
"(",
"\"accumulatorsPresent\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"//create multiple graphs with one line each.",
"List",
"<",
"AccumulatedSingleGraphAO",
">",
"singleGraphDataBeans",
"=",
"getAccumulatorAPI",
"(",
")",
".",
"getChartsForMultipleAccumulators",
"(",
"accumulatorIds",
")",
";",
"request",
".",
"setAttribute",
"(",
"\"singleGraphData\"",
",",
"singleGraphDataBeans",
")",
";",
"request",
".",
"setAttribute",
"(",
"\"accumulatorsColors\"",
",",
"AccumulatorUtility",
".",
"accumulatorsColorsToJSON",
"(",
"singleGraphDataBeans",
")",
")",
";",
"List",
"<",
"String",
">",
"accumulatorsNames",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"AccumulatedSingleGraphAO",
"ao",
":",
"singleGraphDataBeans",
")",
"{",
"accumulatorsNames",
".",
"add",
"(",
"ao",
".",
"getName",
"(",
")",
")",
";",
"}",
"request",
".",
"setAttribute",
"(",
"\"accNames\"",
",",
"accumulatorsNames",
")",
";",
"request",
".",
"setAttribute",
"(",
"\"accNamesConcat\"",
",",
"net",
".",
"anotheria",
".",
"util",
".",
"StringUtils",
".",
"concatenateTokens",
"(",
"accumulatorsNames",
",",
"\",\"",
")",
")",
";",
"}"
] | Sets accumulator specific attributes, required to show accumulator charts on page.
@param accumulatorIds Accumulator IDs, tied to given producers
@param request {@link HttpServletRequest} | [
"Sets",
"accumulator",
"specific",
"attributes",
"required",
"to",
"show",
"accumulator",
"charts",
"on",
"page",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-webui/src/main/java/net/anotheria/moskito/webui/producers/action/ShowCumulatedProducersAction.java#L143-L162 |
kuujo/vertigo | core/src/main/java/net/kuujo/vertigo/Vertigo.java | Vertigo.deployNetwork | public Vertigo deployNetwork(String cluster, JsonObject network) {
return deployNetwork(cluster, network, null);
} | java | public Vertigo deployNetwork(String cluster, JsonObject network) {
return deployNetwork(cluster, network, null);
} | [
"public",
"Vertigo",
"deployNetwork",
"(",
"String",
"cluster",
",",
"JsonObject",
"network",
")",
"{",
"return",
"deployNetwork",
"(",
"cluster",
",",
"network",
",",
"null",
")",
";",
"}"
] | Deploys a json network to a specific cluster.<p>
The JSON network configuration will be converted to a {@link NetworkConfig} before
being deployed to the cluster. The conversion is done synchronously, so if the
configuration is invalid then this method may throw an exception.
@param cluster The cluster to which to deploy the network.
@param network The JSON network configuration. For the configuration format see
the project documentation.
@return The Vertigo instance. | [
"Deploys",
"a",
"json",
"network",
"to",
"a",
"specific",
"cluster",
".",
"<p",
">"
] | train | https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/Vertigo.java#L500-L502 |
Whiley/WhileyCompiler | src/main/java/wyil/interpreter/Interpreter.java | Interpreter.checkInvariants | public void checkInvariants(CallStack frame, Expr... invariants) {
for (int i = 0; i != invariants.length; ++i) {
RValue.Bool b = executeExpression(BOOL_T, invariants[i], frame);
if (b == RValue.False) {
// FIXME: need to do more here
throw new AssertionError();
}
}
} | java | public void checkInvariants(CallStack frame, Expr... invariants) {
for (int i = 0; i != invariants.length; ++i) {
RValue.Bool b = executeExpression(BOOL_T, invariants[i], frame);
if (b == RValue.False) {
// FIXME: need to do more here
throw new AssertionError();
}
}
} | [
"public",
"void",
"checkInvariants",
"(",
"CallStack",
"frame",
",",
"Expr",
"...",
"invariants",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"!=",
"invariants",
".",
"length",
";",
"++",
"i",
")",
"{",
"RValue",
".",
"Bool",
"b",
"=",
"executeExpression",
"(",
"BOOL_T",
",",
"invariants",
"[",
"i",
"]",
",",
"frame",
")",
";",
"if",
"(",
"b",
"==",
"RValue",
".",
"False",
")",
"{",
"// FIXME: need to do more here",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}",
"}",
"}"
] | Evaluate zero or more conditional expressions, and check whether any is
false. If so, raise an exception indicating a runtime fault.
@param frame
@param context
@param invariants | [
"Evaluate",
"zero",
"or",
"more",
"conditional",
"expressions",
"and",
"check",
"whether",
"any",
"is",
"false",
".",
"If",
"so",
"raise",
"an",
"exception",
"indicating",
"a",
"runtime",
"fault",
"."
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/interpreter/Interpreter.java#L1258-L1266 |
box/box-android-sdk | box-content-sdk/src/main/java/com/box/androidsdk/content/utils/SdkUtils.java | SdkUtils.setColorForInitialsThumb | public static void setColorForInitialsThumb(TextView initialsView, int position) {
int backgroundColor = THUMB_COLORS[(position) % THUMB_COLORS.length];
setColorsThumb(initialsView, backgroundColor, Color.WHITE);
} | java | public static void setColorForInitialsThumb(TextView initialsView, int position) {
int backgroundColor = THUMB_COLORS[(position) % THUMB_COLORS.length];
setColorsThumb(initialsView, backgroundColor, Color.WHITE);
} | [
"public",
"static",
"void",
"setColorForInitialsThumb",
"(",
"TextView",
"initialsView",
",",
"int",
"position",
")",
"{",
"int",
"backgroundColor",
"=",
"THUMB_COLORS",
"[",
"(",
"position",
")",
"%",
"THUMB_COLORS",
".",
"length",
"]",
";",
"setColorsThumb",
"(",
"initialsView",
",",
"backgroundColor",
",",
"Color",
".",
"WHITE",
")",
";",
"}"
] | Sets the thumb color that displays users initials
@param initialsView TextView used to display number of collaborators
@param position Used to pick a material color from an array | [
"Sets",
"the",
"thumb",
"color",
"that",
"displays",
"users",
"initials"
] | train | https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/utils/SdkUtils.java#L617-L620 |
alkacon/opencms-core | src/org/opencms/workplace/CmsWorkplace.java | CmsWorkplace.storeSettings | static void storeSettings(HttpSession session, CmsWorkplaceSettings settings) {
// save the workplace settings in the session
session.setAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS, settings);
} | java | static void storeSettings(HttpSession session, CmsWorkplaceSettings settings) {
// save the workplace settings in the session
session.setAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS, settings);
} | [
"static",
"void",
"storeSettings",
"(",
"HttpSession",
"session",
",",
"CmsWorkplaceSettings",
"settings",
")",
"{",
"// save the workplace settings in the session",
"session",
".",
"setAttribute",
"(",
"CmsWorkplaceManager",
".",
"SESSION_WORKPLACE_SETTINGS",
",",
"settings",
")",
";",
"}"
] | Stores the settings in the given session.<p>
@param session the session to store the settings in
@param settings the settings | [
"Stores",
"the",
"settings",
"in",
"the",
"given",
"session",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L1012-L1016 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/context/DefaultBeanContext.java | DefaultBeanContext.getBean | @UsedByGeneratedCode
public @Nonnull <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @Nonnull Class<T> beanType) {
ArgumentUtils.requireNonNull("beanType", beanType);
return getBeanInternal(resolutionContext, beanType, null, true, true);
} | java | @UsedByGeneratedCode
public @Nonnull <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @Nonnull Class<T> beanType) {
ArgumentUtils.requireNonNull("beanType", beanType);
return getBeanInternal(resolutionContext, beanType, null, true, true);
} | [
"@",
"UsedByGeneratedCode",
"public",
"@",
"Nonnull",
"<",
"T",
">",
"T",
"getBean",
"(",
"@",
"Nullable",
"BeanResolutionContext",
"resolutionContext",
",",
"@",
"Nonnull",
"Class",
"<",
"T",
">",
"beanType",
")",
"{",
"ArgumentUtils",
".",
"requireNonNull",
"(",
"\"beanType\"",
",",
"beanType",
")",
";",
"return",
"getBeanInternal",
"(",
"resolutionContext",
",",
"beanType",
",",
"null",
",",
"true",
",",
"true",
")",
";",
"}"
] | Get a bean of the given type.
@param resolutionContext The bean context resolution
@param beanType The bean type
@param <T> The bean type parameter
@return The found bean | [
"Get",
"a",
"bean",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java#L996-L1000 |
bazaarvoice/emodb | common/uuid/src/main/java/com/bazaarvoice/emodb/common/uuid/TimeUUIDs.java | TimeUUIDs.compareTimestamps | public static int compareTimestamps(UUID uuid1, UUID uuid2) {
return Longs.compare(uuid1.timestamp(), uuid2.timestamp());
} | java | public static int compareTimestamps(UUID uuid1, UUID uuid2) {
return Longs.compare(uuid1.timestamp(), uuid2.timestamp());
} | [
"public",
"static",
"int",
"compareTimestamps",
"(",
"UUID",
"uuid1",
",",
"UUID",
"uuid2",
")",
"{",
"return",
"Longs",
".",
"compare",
"(",
"uuid1",
".",
"timestamp",
"(",
")",
",",
"uuid2",
".",
"timestamp",
"(",
")",
")",
";",
"}"
] | Compare the embedded timestamps of the given UUIDs. This is used when it is OK to return
an equality based on timestamps alone
@throws UnsupportedOperationException if either uuid is not a timestamp UUID | [
"Compare",
"the",
"embedded",
"timestamps",
"of",
"the",
"given",
"UUIDs",
".",
"This",
"is",
"used",
"when",
"it",
"is",
"OK",
"to",
"return",
"an",
"equality",
"based",
"on",
"timestamps",
"alone"
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/common/uuid/src/main/java/com/bazaarvoice/emodb/common/uuid/TimeUUIDs.java#L176-L178 |
briandilley/jsonrpc4j | src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java | JsonRpcHttpAsyncClient.addHeaders | private void addHeaders(HttpRequest request, Map<String, String> headers) {
for (Map.Entry<String, String> key : headers.entrySet()) {
request.addHeader(key.getKey(), key.getValue());
}
} | java | private void addHeaders(HttpRequest request, Map<String, String> headers) {
for (Map.Entry<String, String> key : headers.entrySet()) {
request.addHeader(key.getKey(), key.getValue());
}
} | [
"private",
"void",
"addHeaders",
"(",
"HttpRequest",
"request",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"key",
":",
"headers",
".",
"entrySet",
"(",
")",
")",
"{",
"request",
".",
"addHeader",
"(",
"key",
".",
"getKey",
"(",
")",
",",
"key",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Set the request headers.
@param request the request object
@param headers to be used | [
"Set",
"the",
"request",
"headers",
"."
] | train | https://github.com/briandilley/jsonrpc4j/blob/d749762c9295b92d893677a8c7be2a14dd43b3bb/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java#L261-L265 |
davidmoten/rxjava-extras | src/main/java/com/github/davidmoten/rx/Transformers.java | Transformers.doOnFirst | public static <T> Transformer<T, T> doOnFirst(final Action1<? super T> action) {
return doOnNext(1, action);
} | java | public static <T> Transformer<T, T> doOnFirst(final Action1<? super T> action) {
return doOnNext(1, action);
} | [
"public",
"static",
"<",
"T",
">",
"Transformer",
"<",
"T",
",",
"T",
">",
"doOnFirst",
"(",
"final",
"Action1",
"<",
"?",
"super",
"T",
">",
"action",
")",
"{",
"return",
"doOnNext",
"(",
"1",
",",
"action",
")",
";",
"}"
] | Returns a {@link Transformer} that applied to a source {@link Observable}
calls the given action on the first onNext emission.
@param action
is performed on first onNext
@param <T>
the generic type of the Observable being transformed
@return Transformer that applied to a source Observable calls the given
action on the first onNext emission. | [
"Returns",
"a",
"{",
"@link",
"Transformer",
"}",
"that",
"applied",
"to",
"a",
"source",
"{",
"@link",
"Observable",
"}",
"calls",
"the",
"given",
"action",
"on",
"the",
"first",
"onNext",
"emission",
"."
] | train | https://github.com/davidmoten/rxjava-extras/blob/a91d2ba7d454843250e0b0fce36084f9fb02a551/src/main/java/com/github/davidmoten/rx/Transformers.java#L648-L650 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/cmp/cmppolicylabel.java | cmppolicylabel.get | public static cmppolicylabel get(nitro_service service, String labelname) throws Exception{
cmppolicylabel obj = new cmppolicylabel();
obj.set_labelname(labelname);
cmppolicylabel response = (cmppolicylabel) obj.get_resource(service);
return response;
} | java | public static cmppolicylabel get(nitro_service service, String labelname) throws Exception{
cmppolicylabel obj = new cmppolicylabel();
obj.set_labelname(labelname);
cmppolicylabel response = (cmppolicylabel) obj.get_resource(service);
return response;
} | [
"public",
"static",
"cmppolicylabel",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"labelname",
")",
"throws",
"Exception",
"{",
"cmppolicylabel",
"obj",
"=",
"new",
"cmppolicylabel",
"(",
")",
";",
"obj",
".",
"set_labelname",
"(",
"labelname",
")",
";",
"cmppolicylabel",
"response",
"=",
"(",
"cmppolicylabel",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch cmppolicylabel resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"cmppolicylabel",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/cmp/cmppolicylabel.java#L337-L342 |
landawn/AbacusUtil | src/com/landawn/abacus/util/FilenameUtil.java | FilenameUtil.isExtension | public static boolean isExtension(final String filename, final String extension) {
if (filename == null) {
return false;
}
if (extension == null || extension.isEmpty()) {
return indexOfExtension(filename) == NOT_FOUND;
}
final String fileExt = getExtension(filename);
return fileExt.equals(extension);
} | java | public static boolean isExtension(final String filename, final String extension) {
if (filename == null) {
return false;
}
if (extension == null || extension.isEmpty()) {
return indexOfExtension(filename) == NOT_FOUND;
}
final String fileExt = getExtension(filename);
return fileExt.equals(extension);
} | [
"public",
"static",
"boolean",
"isExtension",
"(",
"final",
"String",
"filename",
",",
"final",
"String",
"extension",
")",
"{",
"if",
"(",
"filename",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"extension",
"==",
"null",
"||",
"extension",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"indexOfExtension",
"(",
"filename",
")",
"==",
"NOT_FOUND",
";",
"}",
"final",
"String",
"fileExt",
"=",
"getExtension",
"(",
"filename",
")",
";",
"return",
"fileExt",
".",
"equals",
"(",
"extension",
")",
";",
"}"
] | Checks whether the extension of the filename is that specified.
<p>
This method obtains the extension as the textual part of the filename
after the last dot. There must be no directory separator after the dot.
The extension check is case-sensitive on all platforms.
@param filename the filename to query, null returns false
@param extension the extension to check for, null or empty checks for no extension
@return true if the filename has the specified extension | [
"Checks",
"whether",
"the",
"extension",
"of",
"the",
"filename",
"is",
"that",
"specified",
".",
"<p",
">",
"This",
"method",
"obtains",
"the",
"extension",
"as",
"the",
"textual",
"part",
"of",
"the",
"filename",
"after",
"the",
"last",
"dot",
".",
"There",
"must",
"be",
"no",
"directory",
"separator",
"after",
"the",
"dot",
".",
"The",
"extension",
"check",
"is",
"case",
"-",
"sensitive",
"on",
"all",
"platforms",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/FilenameUtil.java#L1168-L1177 |
line/armeria | saml/src/main/java/com/linecorp/armeria/server/saml/HttpRedirectBindingUtil.java | HttpRedirectBindingUtil.fromDeflatedBase64 | static XMLObject fromDeflatedBase64(String base64Encoded) {
requireNonNull(base64Encoded, "base64Encoded");
final byte[] base64decoded;
try {
base64decoded = Base64.getMimeDecoder().decode(base64Encoded);
} catch (IllegalArgumentException e) {
throw new SamlException("failed to decode a deflated base64 string", e);
}
final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
try (InflaterOutputStream inflaterOutputStream =
new InflaterOutputStream(bytesOut, new Inflater(true))) {
inflaterOutputStream.write(base64decoded);
} catch (IOException e) {
throw new SamlException("failed to inflate a SAML message", e);
}
return SamlMessageUtil.deserialize(bytesOut.toByteArray());
} | java | static XMLObject fromDeflatedBase64(String base64Encoded) {
requireNonNull(base64Encoded, "base64Encoded");
final byte[] base64decoded;
try {
base64decoded = Base64.getMimeDecoder().decode(base64Encoded);
} catch (IllegalArgumentException e) {
throw new SamlException("failed to decode a deflated base64 string", e);
}
final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
try (InflaterOutputStream inflaterOutputStream =
new InflaterOutputStream(bytesOut, new Inflater(true))) {
inflaterOutputStream.write(base64decoded);
} catch (IOException e) {
throw new SamlException("failed to inflate a SAML message", e);
}
return SamlMessageUtil.deserialize(bytesOut.toByteArray());
} | [
"static",
"XMLObject",
"fromDeflatedBase64",
"(",
"String",
"base64Encoded",
")",
"{",
"requireNonNull",
"(",
"base64Encoded",
",",
"\"base64Encoded\"",
")",
";",
"final",
"byte",
"[",
"]",
"base64decoded",
";",
"try",
"{",
"base64decoded",
"=",
"Base64",
".",
"getMimeDecoder",
"(",
")",
".",
"decode",
"(",
"base64Encoded",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"SamlException",
"(",
"\"failed to decode a deflated base64 string\"",
",",
"e",
")",
";",
"}",
"final",
"ByteArrayOutputStream",
"bytesOut",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"(",
"InflaterOutputStream",
"inflaterOutputStream",
"=",
"new",
"InflaterOutputStream",
"(",
"bytesOut",
",",
"new",
"Inflater",
"(",
"true",
")",
")",
")",
"{",
"inflaterOutputStream",
".",
"write",
"(",
"base64decoded",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SamlException",
"(",
"\"failed to inflate a SAML message\"",
",",
"e",
")",
";",
"}",
"return",
"SamlMessageUtil",
".",
"deserialize",
"(",
"bytesOut",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] | Decodes, inflates and deserializes the specified base64-encoded message to an {@link XMLObject}. | [
"Decodes",
"inflates",
"and",
"deserializes",
"the",
"specified",
"base64",
"-",
"encoded",
"message",
"to",
"an",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/saml/src/main/java/com/linecorp/armeria/server/saml/HttpRedirectBindingUtil.java#L210-L229 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/event/InitFieldHandler.java | InitFieldHandler.fieldChanged | public int fieldChanged(boolean bDisplayOption, int iMoveMode)
{
if (m_fldSource != null)
{
if (((m_bInitIfSourceNull == true) || (!m_fldSource.isNull()))
&& ((m_bOnlyInitIfDestNull == false)
|| (m_bOnlyInitIfDestNull == true) && (this.getOwner().isNull())))
{
boolean bModified = this.getOwner().isModified();
int iErrorCode = this.getOwner().moveFieldToThis(m_fldSource, bDisplayOption, iMoveMode);
this.getOwner().setModified(bModified);
return iErrorCode;
}
else
return super.fieldChanged(bDisplayOption, iMoveMode);
}
else
{
if (m_objSource instanceof String)
return this.getOwner().setString(m_objSource.toString(), bDisplayOption, iMoveMode);
else
return this.getOwner().setData(m_objSource, bDisplayOption, iMoveMode);
}
} | java | public int fieldChanged(boolean bDisplayOption, int iMoveMode)
{
if (m_fldSource != null)
{
if (((m_bInitIfSourceNull == true) || (!m_fldSource.isNull()))
&& ((m_bOnlyInitIfDestNull == false)
|| (m_bOnlyInitIfDestNull == true) && (this.getOwner().isNull())))
{
boolean bModified = this.getOwner().isModified();
int iErrorCode = this.getOwner().moveFieldToThis(m_fldSource, bDisplayOption, iMoveMode);
this.getOwner().setModified(bModified);
return iErrorCode;
}
else
return super.fieldChanged(bDisplayOption, iMoveMode);
}
else
{
if (m_objSource instanceof String)
return this.getOwner().setString(m_objSource.toString(), bDisplayOption, iMoveMode);
else
return this.getOwner().setData(m_objSource, bDisplayOption, iMoveMode);
}
} | [
"public",
"int",
"fieldChanged",
"(",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"if",
"(",
"m_fldSource",
"!=",
"null",
")",
"{",
"if",
"(",
"(",
"(",
"m_bInitIfSourceNull",
"==",
"true",
")",
"||",
"(",
"!",
"m_fldSource",
".",
"isNull",
"(",
")",
")",
")",
"&&",
"(",
"(",
"m_bOnlyInitIfDestNull",
"==",
"false",
")",
"||",
"(",
"m_bOnlyInitIfDestNull",
"==",
"true",
")",
"&&",
"(",
"this",
".",
"getOwner",
"(",
")",
".",
"isNull",
"(",
")",
")",
")",
")",
"{",
"boolean",
"bModified",
"=",
"this",
".",
"getOwner",
"(",
")",
".",
"isModified",
"(",
")",
";",
"int",
"iErrorCode",
"=",
"this",
".",
"getOwner",
"(",
")",
".",
"moveFieldToThis",
"(",
"m_fldSource",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"this",
".",
"getOwner",
"(",
")",
".",
"setModified",
"(",
"bModified",
")",
";",
"return",
"iErrorCode",
";",
"}",
"else",
"return",
"super",
".",
"fieldChanged",
"(",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}",
"else",
"{",
"if",
"(",
"m_objSource",
"instanceof",
"String",
")",
"return",
"this",
".",
"getOwner",
"(",
")",
".",
"setString",
"(",
"m_objSource",
".",
"toString",
"(",
")",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"else",
"return",
"this",
".",
"getOwner",
"(",
")",
".",
"setData",
"(",
"m_objSource",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}",
"}"
] | The Field has Changed.
Move the source field or string to this listener's owner.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
Field Changed, init the field. | [
"The",
"Field",
"has",
"Changed",
".",
"Move",
"the",
"source",
"field",
"or",
"string",
"to",
"this",
"listener",
"s",
"owner",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/InitFieldHandler.java#L157-L180 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/SimpleTimeZone.java | SimpleTimeZone.setEndRule | public void setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after) {
if (isFrozen()) {
throw new UnsupportedOperationException("Attempt to modify a frozen SimpleTimeZone instance.");
}
getSTZInfo().setEnd(month, -1, dayOfWeek, time, dayOfMonth, after);
setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after);
} | java | public void setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after) {
if (isFrozen()) {
throw new UnsupportedOperationException("Attempt to modify a frozen SimpleTimeZone instance.");
}
getSTZInfo().setEnd(month, -1, dayOfWeek, time, dayOfMonth, after);
setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after);
} | [
"public",
"void",
"setEndRule",
"(",
"int",
"month",
",",
"int",
"dayOfMonth",
",",
"int",
"dayOfWeek",
",",
"int",
"time",
",",
"boolean",
"after",
")",
"{",
"if",
"(",
"isFrozen",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Attempt to modify a frozen SimpleTimeZone instance.\"",
")",
";",
"}",
"getSTZInfo",
"(",
")",
".",
"setEnd",
"(",
"month",
",",
"-",
"1",
",",
"dayOfWeek",
",",
"time",
",",
"dayOfMonth",
",",
"after",
")",
";",
"setEndRule",
"(",
"month",
",",
"dayOfMonth",
",",
"dayOfWeek",
",",
"time",
",",
"WALL_TIME",
",",
"after",
")",
";",
"}"
] | Sets the DST end rule to a weekday before or after a give date within
a month, e.g., the first Monday on or after the 8th.
@param month The month in which this rule occurs (0-based).
@param dayOfMonth A date within that month (1-based).
@param dayOfWeek The day of the week on which this rule occurs.
@param time The time of that day (number of millis after midnight)
when DST ends in local wall time, which is daylight
time in this case.
@param after If true, this rule selects the first dayOfWeek on
or after dayOfMonth. If false, this rule selects
the last dayOfWeek on or before dayOfMonth.
@throws IllegalArgumentException the month, dayOfMonth,
dayOfWeek, or time parameters are out of range | [
"Sets",
"the",
"DST",
"end",
"rule",
"to",
"a",
"weekday",
"before",
"or",
"after",
"a",
"give",
"date",
"within",
"a",
"month",
"e",
".",
"g",
".",
"the",
"first",
"Monday",
"on",
"or",
"after",
"the",
"8th",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/SimpleTimeZone.java#L477-L484 |
yanzhenjie/Album | album/src/main/java/com/yanzhenjie/album/util/AlbumUtils.java | AlbumUtils.getAlphaColor | @ColorInt
public static int getAlphaColor(@ColorInt int color, @IntRange(from = 0, to = 255) int alpha) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
return Color.argb(alpha, red, green, blue);
} | java | @ColorInt
public static int getAlphaColor(@ColorInt int color, @IntRange(from = 0, to = 255) int alpha) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
return Color.argb(alpha, red, green, blue);
} | [
"@",
"ColorInt",
"public",
"static",
"int",
"getAlphaColor",
"(",
"@",
"ColorInt",
"int",
"color",
",",
"@",
"IntRange",
"(",
"from",
"=",
"0",
",",
"to",
"=",
"255",
")",
"int",
"alpha",
")",
"{",
"int",
"red",
"=",
"Color",
".",
"red",
"(",
"color",
")",
";",
"int",
"green",
"=",
"Color",
".",
"green",
"(",
"color",
")",
";",
"int",
"blue",
"=",
"Color",
".",
"blue",
"(",
"color",
")",
";",
"return",
"Color",
".",
"argb",
"(",
"alpha",
",",
"red",
",",
"green",
",",
"blue",
")",
";",
"}"
] | Return a color-int from alpha, red, green, blue components.
@param color color.
@param alpha alpha, alpha component [0..255] of the color. | [
"Return",
"a",
"color",
"-",
"int",
"from",
"alpha",
"red",
"green",
"blue",
"components",
"."
] | train | https://github.com/yanzhenjie/Album/blob/b17506440d32909d42aba41f6a388041a25c8363/album/src/main/java/com/yanzhenjie/album/util/AlbumUtils.java#L364-L370 |
JodaOrg/joda-time | src/main/java/org/joda/time/field/FieldUtils.java | FieldUtils.verifyValueBounds | public static void verifyValueBounds(DateTimeFieldType fieldType,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(fieldType, Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
} | java | public static void verifyValueBounds(DateTimeFieldType fieldType,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(fieldType, Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
} | [
"public",
"static",
"void",
"verifyValueBounds",
"(",
"DateTimeFieldType",
"fieldType",
",",
"int",
"value",
",",
"int",
"lowerBound",
",",
"int",
"upperBound",
")",
"{",
"if",
"(",
"(",
"value",
"<",
"lowerBound",
")",
"||",
"(",
"value",
">",
"upperBound",
")",
")",
"{",
"throw",
"new",
"IllegalFieldValueException",
"(",
"fieldType",
",",
"Integer",
".",
"valueOf",
"(",
"value",
")",
",",
"Integer",
".",
"valueOf",
"(",
"lowerBound",
")",
",",
"Integer",
".",
"valueOf",
"(",
"upperBound",
")",
")",
";",
"}",
"}"
] | Verify that input values are within specified bounds.
@param value the value to check
@param lowerBound the lower bound allowed for value
@param upperBound the upper bound allowed for value
@throws IllegalFieldValueException if value is not in the specified bounds
@since 1.1 | [
"Verify",
"that",
"input",
"values",
"are",
"within",
"specified",
"bounds",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L272-L279 |
intel/jndn-utils | src/main/java/com/intel/jndn/utils/server/impl/SimpleServer.java | SimpleServer.respondUsing | public void respondUsing(final RespondWithBlob callback) throws IOException {
RespondWithData dataCallback = new RespondWithData() {
@Override
public Data onInterest(Name prefix, Interest interest) throws Exception {
Data data = new Data(interest.getName());
Blob content = callback.onInterest(prefix, interest);
data.setContent(content);
return data;
}
};
respondUsing(dataCallback);
} | java | public void respondUsing(final RespondWithBlob callback) throws IOException {
RespondWithData dataCallback = new RespondWithData() {
@Override
public Data onInterest(Name prefix, Interest interest) throws Exception {
Data data = new Data(interest.getName());
Blob content = callback.onInterest(prefix, interest);
data.setContent(content);
return data;
}
};
respondUsing(dataCallback);
} | [
"public",
"void",
"respondUsing",
"(",
"final",
"RespondWithBlob",
"callback",
")",
"throws",
"IOException",
"{",
"RespondWithData",
"dataCallback",
"=",
"new",
"RespondWithData",
"(",
")",
"{",
"@",
"Override",
"public",
"Data",
"onInterest",
"(",
"Name",
"prefix",
",",
"Interest",
"interest",
")",
"throws",
"Exception",
"{",
"Data",
"data",
"=",
"new",
"Data",
"(",
"interest",
".",
"getName",
"(",
")",
")",
";",
"Blob",
"content",
"=",
"callback",
".",
"onInterest",
"(",
"prefix",
",",
"interest",
")",
";",
"data",
".",
"setContent",
"(",
"content",
")",
";",
"return",
"data",
";",
"}",
"}",
";",
"respondUsing",
"(",
"dataCallback",
")",
";",
"}"
] | Convenience method for responding to an {@link Interest} by returning the
{@link Blob} content only; when an Interest arrives, this method wraps the
returned Blob with a {@link Data} using the exact {@link Name} of the
incoming Interest.
@param callback the callback function to retrieve content when an
{@link Interest} arrives
@throws java.io.IOException if the server fails to register a prefix | [
"Convenience",
"method",
"for",
"responding",
"to",
"an",
"{",
"@link",
"Interest",
"}",
"by",
"returning",
"the",
"{",
"@link",
"Blob",
"}",
"content",
"only",
";",
"when",
"an",
"Interest",
"arrives",
"this",
"method",
"wraps",
"the",
"returned",
"Blob",
"with",
"a",
"{",
"@link",
"Data",
"}",
"using",
"the",
"exact",
"{",
"@link",
"Name",
"}",
"of",
"the",
"incoming",
"Interest",
"."
] | train | https://github.com/intel/jndn-utils/blob/7f670b259484c35d51a6c5acce5715b0573faedd/src/main/java/com/intel/jndn/utils/server/impl/SimpleServer.java#L70-L81 |
Whiley/WhileyCompiler | src/main/java/wyil/util/AbstractTypedVisitor.java | AbstractTypedVisitor.selectCandidate | public <T extends Type> T selectCandidate(T candidate, T next, T actual, Environment environment) {
// Found a viable candidate
boolean left = subtypeOperator.isSubtype(candidate, next, environment);
boolean right = subtypeOperator.isSubtype(next, candidate, environment);
if (left && !right) {
// Yes, is better than current candidate
return next;
} else if (right && !left) {
return candidate;
}
// Unable to distinguish options based on subtyping alone
left = isDerivation(next, actual);
right = isDerivation(candidate, actual);
if (left && !right) {
// Yes, is better than current candidate
return next;
} else if (right && !left) {
return candidate;
} else {
return null;
}
} | java | public <T extends Type> T selectCandidate(T candidate, T next, T actual, Environment environment) {
// Found a viable candidate
boolean left = subtypeOperator.isSubtype(candidate, next, environment);
boolean right = subtypeOperator.isSubtype(next, candidate, environment);
if (left && !right) {
// Yes, is better than current candidate
return next;
} else if (right && !left) {
return candidate;
}
// Unable to distinguish options based on subtyping alone
left = isDerivation(next, actual);
right = isDerivation(candidate, actual);
if (left && !right) {
// Yes, is better than current candidate
return next;
} else if (right && !left) {
return candidate;
} else {
return null;
}
} | [
"public",
"<",
"T",
"extends",
"Type",
">",
"T",
"selectCandidate",
"(",
"T",
"candidate",
",",
"T",
"next",
",",
"T",
"actual",
",",
"Environment",
"environment",
")",
"{",
"// Found a viable candidate",
"boolean",
"left",
"=",
"subtypeOperator",
".",
"isSubtype",
"(",
"candidate",
",",
"next",
",",
"environment",
")",
";",
"boolean",
"right",
"=",
"subtypeOperator",
".",
"isSubtype",
"(",
"next",
",",
"candidate",
",",
"environment",
")",
";",
"if",
"(",
"left",
"&&",
"!",
"right",
")",
"{",
"// Yes, is better than current candidate",
"return",
"next",
";",
"}",
"else",
"if",
"(",
"right",
"&&",
"!",
"left",
")",
"{",
"return",
"candidate",
";",
"}",
"// Unable to distinguish options based on subtyping alone",
"left",
"=",
"isDerivation",
"(",
"next",
",",
"actual",
")",
";",
"right",
"=",
"isDerivation",
"(",
"candidate",
",",
"actual",
")",
";",
"if",
"(",
"left",
"&&",
"!",
"right",
")",
"{",
"// Yes, is better than current candidate",
"return",
"next",
";",
"}",
"else",
"if",
"(",
"right",
"&&",
"!",
"left",
")",
"{",
"return",
"candidate",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Given two candidates, return the more precise one. If no viable candidate,
return null;
@param candidate
The current best candidate.
@param next
The next candidate being considered
@param environment
@return
@throws ResolutionError | [
"Given",
"two",
"candidates",
"return",
"the",
"more",
"precise",
"one",
".",
"If",
"no",
"viable",
"candidate",
"return",
"null",
";"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/util/AbstractTypedVisitor.java#L1258-L1280 |
osglworks/java-mvc | src/main/java/org/osgl/mvc/result/BadRequest.java | BadRequest.of | public static BadRequest of(Throwable cause) {
if (_localizedErrorMsg()) {
return of(cause, defaultMessage(BAD_REQUEST));
} else {
touchPayload().cause(cause);
return _INSTANCE;
}
} | java | public static BadRequest of(Throwable cause) {
if (_localizedErrorMsg()) {
return of(cause, defaultMessage(BAD_REQUEST));
} else {
touchPayload().cause(cause);
return _INSTANCE;
}
} | [
"public",
"static",
"BadRequest",
"of",
"(",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"_localizedErrorMsg",
"(",
")",
")",
"{",
"return",
"of",
"(",
"cause",
",",
"defaultMessage",
"(",
"BAD_REQUEST",
")",
")",
";",
"}",
"else",
"{",
"touchPayload",
"(",
")",
".",
"cause",
"(",
"cause",
")",
";",
"return",
"_INSTANCE",
";",
"}",
"}"
] | Returns a static BadRequest instance and set the {@link #payload} thread local
with cause specified.
When calling the instance on {@link #getMessage()} method, it will return whatever
stored in the {@link #payload} thread local
@param cause the cause
@return a static BadRequest instance as described above | [
"Returns",
"a",
"static",
"BadRequest",
"instance",
"and",
"set",
"the",
"{",
"@link",
"#payload",
"}",
"thread",
"local",
"with",
"cause",
"specified",
"."
] | train | https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/BadRequest.java#L126-L133 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/lang/ServiceLoaderHelper.java | ServiceLoaderHelper.getAllSPIImplementations | @Nonnull
@ReturnsMutableCopy
public static <T> ICommonsList <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass)
{
return getAllSPIImplementations (aSPIClass, ClassLoaderHelper.getDefaultClassLoader (), null);
} | java | @Nonnull
@ReturnsMutableCopy
public static <T> ICommonsList <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass)
{
return getAllSPIImplementations (aSPIClass, ClassLoaderHelper.getDefaultClassLoader (), null);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"T",
">",
"ICommonsList",
"<",
"T",
">",
"getAllSPIImplementations",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aSPIClass",
")",
"{",
"return",
"getAllSPIImplementations",
"(",
"aSPIClass",
",",
"ClassLoaderHelper",
".",
"getDefaultClassLoader",
"(",
")",
",",
"null",
")",
";",
"}"
] | Uses the {@link ServiceLoader} to load all SPI implementations of the
passed class
@param <T>
The implementation type to be loaded
@param aSPIClass
The SPI interface class. May not be <code>null</code>.
@return A list of all currently available plugins | [
"Uses",
"the",
"{",
"@link",
"ServiceLoader",
"}",
"to",
"load",
"all",
"SPI",
"implementations",
"of",
"the",
"passed",
"class"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/lang/ServiceLoaderHelper.java#L63-L68 |
ltearno/hexa.tools | hexa.binding/src/main/java/fr/lteconsulting/hexa/databinding/properties/PropertyValues.java | PropertyValues.hasObjectDynamicProperty | boolean hasObjectDynamicProperty( Object object, String propertyName )
{
DynamicPropertyBag bag = propertyBagAccess.getObjectDynamicPropertyBag( object );
return bag != null && bag.contains( propertyName );
} | java | boolean hasObjectDynamicProperty( Object object, String propertyName )
{
DynamicPropertyBag bag = propertyBagAccess.getObjectDynamicPropertyBag( object );
return bag != null && bag.contains( propertyName );
} | [
"boolean",
"hasObjectDynamicProperty",
"(",
"Object",
"object",
",",
"String",
"propertyName",
")",
"{",
"DynamicPropertyBag",
"bag",
"=",
"propertyBagAccess",
".",
"getObjectDynamicPropertyBag",
"(",
"object",
")",
";",
"return",
"bag",
"!=",
"null",
"&&",
"bag",
".",
"contains",
"(",
"propertyName",
")",
";",
"}"
] | Whether a dynamic property value has already been set on this object | [
"Whether",
"a",
"dynamic",
"property",
"value",
"has",
"already",
"been",
"set",
"on",
"this",
"object"
] | train | https://github.com/ltearno/hexa.tools/blob/604c804901b1bb13fe10b3823cc4a639f8993363/hexa.binding/src/main/java/fr/lteconsulting/hexa/databinding/properties/PropertyValues.java#L229-L233 |
OpenLiberty/open-liberty | dev/com.ibm.ws.management.j2ee/src/com/ibm/websphere/management/j2ee/J2EEManagementObjectNameFactory.java | J2EEManagementObjectNameFactory.createResourceObjectName | public static ObjectName createResourceObjectName(String serverName, String resourceType, String keyName) {
ObjectName objectName;
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(TYPE_SERVER, serverName);
objectName = createObjectName(resourceType, keyName, props);
return objectName;
} | java | public static ObjectName createResourceObjectName(String serverName, String resourceType, String keyName) {
ObjectName objectName;
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(TYPE_SERVER, serverName);
objectName = createObjectName(resourceType, keyName, props);
return objectName;
} | [
"public",
"static",
"ObjectName",
"createResourceObjectName",
"(",
"String",
"serverName",
",",
"String",
"resourceType",
",",
"String",
"keyName",
")",
"{",
"ObjectName",
"objectName",
";",
"Hashtable",
"<",
"String",
",",
"String",
">",
"props",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"props",
".",
"put",
"(",
"TYPE_SERVER",
",",
"serverName",
")",
";",
"objectName",
"=",
"createObjectName",
"(",
"resourceType",
",",
"keyName",
",",
"props",
")",
";",
"return",
"objectName",
";",
"}"
] | Creates a Resource ObjectName for a Resource MBean
@param serverName
@param keyName
@return ObjectName is the JSR77 spec naming convention for Resource MBeans | [
"Creates",
"a",
"Resource",
"ObjectName",
"for",
"a",
"Resource",
"MBean"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.management.j2ee/src/com/ibm/websphere/management/j2ee/J2EEManagementObjectNameFactory.java#L200-L209 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VirtualNetworkTapsInner.java | VirtualNetworkTapsInner.updateTags | public VirtualNetworkTapInner updateTags(String resourceGroupName, String tapName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, tapName).toBlocking().last().body();
} | java | public VirtualNetworkTapInner updateTags(String resourceGroupName, String tapName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, tapName).toBlocking().last().body();
} | [
"public",
"VirtualNetworkTapInner",
"updateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"tapName",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"tapName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates an VirtualNetworkTap tags.
@param resourceGroupName The name of the resource group.
@param tapName The name of the tap.
@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 VirtualNetworkTapInner object if successful. | [
"Updates",
"an",
"VirtualNetworkTap",
"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/VirtualNetworkTapsInner.java#L529-L531 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/idemix/WeakBB.java | WeakBB.weakBBSign | public static ECP weakBBSign(BIG sk, BIG m) {
BIG exp = IdemixUtils.modAdd(sk, m, IdemixUtils.GROUP_ORDER);
exp.invmodp(IdemixUtils.GROUP_ORDER);
return IdemixUtils.genG1.mul(exp);
} | java | public static ECP weakBBSign(BIG sk, BIG m) {
BIG exp = IdemixUtils.modAdd(sk, m, IdemixUtils.GROUP_ORDER);
exp.invmodp(IdemixUtils.GROUP_ORDER);
return IdemixUtils.genG1.mul(exp);
} | [
"public",
"static",
"ECP",
"weakBBSign",
"(",
"BIG",
"sk",
",",
"BIG",
"m",
")",
"{",
"BIG",
"exp",
"=",
"IdemixUtils",
".",
"modAdd",
"(",
"sk",
",",
"m",
",",
"IdemixUtils",
".",
"GROUP_ORDER",
")",
";",
"exp",
".",
"invmodp",
"(",
"IdemixUtils",
".",
"GROUP_ORDER",
")",
";",
"return",
"IdemixUtils",
".",
"genG1",
".",
"mul",
"(",
"exp",
")",
";",
"}"
] | Produces a WBB signature for a give message
@param sk Secret key
@param m Message
@return Signature | [
"Produces",
"a",
"WBB",
"signature",
"for",
"a",
"give",
"message"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/WeakBB.java#L71-L76 |
ops4j/org.ops4j.pax.web | pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/tracker/AbstractTracker.java | AbstractTracker.createFilter | private static Filter createFilter(final BundleContext bundleContext, final Class<?> trackedClass) {
final String filter = "(" + Constants.OBJECTCLASS + "=" + trackedClass.getName() + ")";
try {
return bundleContext.createFilter(filter);
} catch (InvalidSyntaxException e) {
throw new IllegalArgumentException("Unexpected InvalidSyntaxException: " + e.getMessage());
}
} | java | private static Filter createFilter(final BundleContext bundleContext, final Class<?> trackedClass) {
final String filter = "(" + Constants.OBJECTCLASS + "=" + trackedClass.getName() + ")";
try {
return bundleContext.createFilter(filter);
} catch (InvalidSyntaxException e) {
throw new IllegalArgumentException("Unexpected InvalidSyntaxException: " + e.getMessage());
}
} | [
"private",
"static",
"Filter",
"createFilter",
"(",
"final",
"BundleContext",
"bundleContext",
",",
"final",
"Class",
"<",
"?",
">",
"trackedClass",
")",
"{",
"final",
"String",
"filter",
"=",
"\"(\"",
"+",
"Constants",
".",
"OBJECTCLASS",
"+",
"\"=\"",
"+",
"trackedClass",
".",
"getName",
"(",
")",
"+",
"\")\"",
";",
"try",
"{",
"return",
"bundleContext",
".",
"createFilter",
"(",
"filter",
")",
";",
"}",
"catch",
"(",
"InvalidSyntaxException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected InvalidSyntaxException: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Creates an OSGi filter for the classes.
@param bundleContext
a bundle context
@param trackedClass
the class being tracked
@return osgi filter | [
"Creates",
"an",
"OSGi",
"filter",
"for",
"the",
"classes",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.web/blob/9ecf3676c1d316be0d43ea7fcfdc8f0defffc2a2/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/tracker/AbstractTracker.java#L119-L126 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java | DTMDefaultBase.getTypedNextSibling | public int getTypedNextSibling(int nodeHandle, int nodeType)
{
if (nodeHandle == DTM.NULL)
return DTM.NULL;
int node = makeNodeIdentity(nodeHandle);
int eType;
while ((node = _nextsib(node)) != DTM.NULL &&
((eType = _exptype(node)) != nodeType &&
m_expandedNameTable.getType(eType)!= nodeType));
//_type(node) != nodeType));
return (node == DTM.NULL ? DTM.NULL : makeNodeHandle(node));
} | java | public int getTypedNextSibling(int nodeHandle, int nodeType)
{
if (nodeHandle == DTM.NULL)
return DTM.NULL;
int node = makeNodeIdentity(nodeHandle);
int eType;
while ((node = _nextsib(node)) != DTM.NULL &&
((eType = _exptype(node)) != nodeType &&
m_expandedNameTable.getType(eType)!= nodeType));
//_type(node) != nodeType));
return (node == DTM.NULL ? DTM.NULL : makeNodeHandle(node));
} | [
"public",
"int",
"getTypedNextSibling",
"(",
"int",
"nodeHandle",
",",
"int",
"nodeType",
")",
"{",
"if",
"(",
"nodeHandle",
"==",
"DTM",
".",
"NULL",
")",
"return",
"DTM",
".",
"NULL",
";",
"int",
"node",
"=",
"makeNodeIdentity",
"(",
"nodeHandle",
")",
";",
"int",
"eType",
";",
"while",
"(",
"(",
"node",
"=",
"_nextsib",
"(",
"node",
")",
")",
"!=",
"DTM",
".",
"NULL",
"&&",
"(",
"(",
"eType",
"=",
"_exptype",
"(",
"node",
")",
")",
"!=",
"nodeType",
"&&",
"m_expandedNameTable",
".",
"getType",
"(",
"eType",
")",
"!=",
"nodeType",
")",
")",
";",
"//_type(node) != nodeType));",
"return",
"(",
"node",
"==",
"DTM",
".",
"NULL",
"?",
"DTM",
".",
"NULL",
":",
"makeNodeHandle",
"(",
"node",
")",
")",
";",
"}"
] | Given a node handle, advance to its next sibling.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
@param nodeHandle int Handle of the node.
@return int Node-number of next sibling,
or DTM.NULL to indicate none exists. | [
"Given",
"a",
"node",
"handle",
"advance",
"to",
"its",
"next",
"sibling",
".",
"If",
"not",
"yet",
"resolved",
"waits",
"for",
"more",
"nodes",
"to",
"be",
"added",
"to",
"the",
"document",
"and",
"tries",
"again",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java#L1153-L1165 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/query/dsl/functions/PatternMatchingFunctions.java | PatternMatchingFunctions.regexpLike | public static Expression regexpLike(String expression, String pattern) {
return regexpLike(x(expression), pattern);
} | java | public static Expression regexpLike(String expression, String pattern) {
return regexpLike(x(expression), pattern);
} | [
"public",
"static",
"Expression",
"regexpLike",
"(",
"String",
"expression",
",",
"String",
"pattern",
")",
"{",
"return",
"regexpLike",
"(",
"x",
"(",
"expression",
")",
",",
"pattern",
")",
";",
"}"
] | Returned expression results in True if the string value matches the regular expression pattern | [
"Returned",
"expression",
"results",
"in",
"True",
"if",
"the",
"string",
"value",
"matches",
"the",
"regular",
"expression",
"pattern"
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/PatternMatchingFunctions.java#L63-L65 |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java | OIndexMVRBTreeAbstract.getEntriesBetween | public Collection<ODocument> getEntriesBetween(final Object iRangeFrom, final Object iRangeTo) {
return getEntriesBetween(iRangeFrom, iRangeTo, true);
} | java | public Collection<ODocument> getEntriesBetween(final Object iRangeFrom, final Object iRangeTo) {
return getEntriesBetween(iRangeFrom, iRangeTo, true);
} | [
"public",
"Collection",
"<",
"ODocument",
">",
"getEntriesBetween",
"(",
"final",
"Object",
"iRangeFrom",
",",
"final",
"Object",
"iRangeTo",
")",
"{",
"return",
"getEntriesBetween",
"(",
"iRangeFrom",
",",
"iRangeTo",
",",
"true",
")",
";",
"}"
] | Returns a set of documents with key between the range passed as parameter. Range bounds are included.
@param iRangeFrom
Starting range
@param iRangeTo
Ending range
@see #getEntriesBetween(Object, Object, boolean)
@return | [
"Returns",
"a",
"set",
"of",
"documents",
"with",
"key",
"between",
"the",
"range",
"passed",
"as",
"parameter",
".",
"Range",
"bounds",
"are",
"included",
"."
] | train | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java#L287-L289 |
hal/elemento | core/src/main/java/org/jboss/gwt/elemento/core/Elements.java | Elements.innerHtml | public static void innerHtml(HTMLElement element, SafeHtml html) {
if (element != null) {
element.innerHTML = html.asString();
}
} | java | public static void innerHtml(HTMLElement element, SafeHtml html) {
if (element != null) {
element.innerHTML = html.asString();
}
} | [
"public",
"static",
"void",
"innerHtml",
"(",
"HTMLElement",
"element",
",",
"SafeHtml",
"html",
")",
"{",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"element",
".",
"innerHTML",
"=",
"html",
".",
"asString",
"(",
")",
";",
"}",
"}"
] | Convenience method to set the inner HTML of the given element. | [
"Convenience",
"method",
"to",
"set",
"the",
"inner",
"HTML",
"of",
"the",
"given",
"element",
"."
] | train | https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L798-L802 |
michael-rapp/AndroidBottomSheet | library/src/main/java/de/mrapp/android/bottomsheet/model/Divider.java | Divider.setTitle | public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
setTitle(context.getText(resourceId));
} | java | public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
setTitle(context.getText(resourceId));
} | [
"public",
"final",
"void",
"setTitle",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StringRes",
"final",
"int",
"resourceId",
")",
"{",
"setTitle",
"(",
"context",
".",
"getText",
"(",
"resourceId",
")",
")",
";",
"}"
] | Sets the divider's title.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the title, which should be set, as an {@link Integer} value. The
resource id must correspond to a valid string resource | [
"Sets",
"the",
"divider",
"s",
"title",
"."
] | train | https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/model/Divider.java#L55-L57 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java | FaceListsImpl.createWithServiceResponseAsync | public Observable<ServiceResponse<Void>> createWithServiceResponseAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter) {
if (this.client.azureRegion() == null) {
throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null.");
}
if (faceListId == null) {
throw new IllegalArgumentException("Parameter faceListId is required and cannot be null.");
}
final String name = createOptionalParameter != null ? createOptionalParameter.name() : null;
final String userData = createOptionalParameter != null ? createOptionalParameter.userData() : null;
return createWithServiceResponseAsync(faceListId, name, userData);
} | java | public Observable<ServiceResponse<Void>> createWithServiceResponseAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter) {
if (this.client.azureRegion() == null) {
throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null.");
}
if (faceListId == null) {
throw new IllegalArgumentException("Parameter faceListId is required and cannot be null.");
}
final String name = createOptionalParameter != null ? createOptionalParameter.name() : null;
final String userData = createOptionalParameter != null ? createOptionalParameter.userData() : null;
return createWithServiceResponseAsync(faceListId, name, userData);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Void",
">",
">",
"createWithServiceResponseAsync",
"(",
"String",
"faceListId",
",",
"CreateFaceListsOptionalParameter",
"createOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"azureRegion",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.azureRegion() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"faceListId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter faceListId is required and cannot be null.\"",
")",
";",
"}",
"final",
"String",
"name",
"=",
"createOptionalParameter",
"!=",
"null",
"?",
"createOptionalParameter",
".",
"name",
"(",
")",
":",
"null",
";",
"final",
"String",
"userData",
"=",
"createOptionalParameter",
"!=",
"null",
"?",
"createOptionalParameter",
".",
"userData",
"(",
")",
":",
"null",
";",
"return",
"createWithServiceResponseAsync",
"(",
"faceListId",
",",
"name",
",",
"userData",
")",
";",
"}"
] | Create an empty face list. Up to 64 face lists are allowed to exist in one subscription.
@param faceListId Id referencing a particular face list.
@param createOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Create",
"an",
"empty",
"face",
"list",
".",
"Up",
"to",
"64",
"face",
"lists",
"are",
"allowed",
"to",
"exist",
"in",
"one",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java#L161-L172 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/BrokerHelper.java | BrokerHelper.getKeyValues | public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy) throws PersistenceBrokerException
{
return getKeyValues(cld, objectOrProxy, true);
} | java | public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy) throws PersistenceBrokerException
{
return getKeyValues(cld, objectOrProxy, true);
} | [
"public",
"ValueContainer",
"[",
"]",
"getKeyValues",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"objectOrProxy",
")",
"throws",
"PersistenceBrokerException",
"{",
"return",
"getKeyValues",
"(",
"cld",
",",
"objectOrProxy",
",",
"true",
")",
";",
"}"
] | returns an Array with an Objects PK VALUES, with any java-to-sql
FieldConversion applied. If the Object is a Proxy or a VirtualProxy NO
conversion is necessary.
@param objectOrProxy
@return Object[]
@throws PersistenceBrokerException | [
"returns",
"an",
"Array",
"with",
"an",
"Objects",
"PK",
"VALUES",
"with",
"any",
"java",
"-",
"to",
"-",
"sql",
"FieldConversion",
"applied",
".",
"If",
"the",
"Object",
"is",
"a",
"Proxy",
"or",
"a",
"VirtualProxy",
"NO",
"conversion",
"is",
"necessary",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L239-L242 |
saxsys/SynchronizeFX | synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ReplaceInListRepairer.java | ReplaceInListRepairer.repairCommand | public ListCommand repairCommand(final ReplaceInList toRepair, final RemoveFromList repairAgainst) {
final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition();
if (indicesBefore <= 0) {
return toRepair;
}
final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst
.getRemoveCount();
if (repairAgainst.getStartPosition() + repairAgainst.getRemoveCount() <= toRepair.getPosition()) {
return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(),
toRepair.getPosition() - indicesToDecrese);
}
return new AddToList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(),
toRepair.getPosition() - indicesToDecrese);
} | java | public ListCommand repairCommand(final ReplaceInList toRepair, final RemoveFromList repairAgainst) {
final int indicesBefore = toRepair.getPosition() - repairAgainst.getStartPosition();
if (indicesBefore <= 0) {
return toRepair;
}
final int indicesToDecrese = indicesBefore < repairAgainst.getRemoveCount() ? indicesBefore : repairAgainst
.getRemoveCount();
if (repairAgainst.getStartPosition() + repairAgainst.getRemoveCount() <= toRepair.getPosition()) {
return new ReplaceInList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(),
toRepair.getPosition() - indicesToDecrese);
}
return new AddToList(toRepair.getListId(), toRepair.getListVersionChange(), toRepair.getValue(),
toRepair.getPosition() - indicesToDecrese);
} | [
"public",
"ListCommand",
"repairCommand",
"(",
"final",
"ReplaceInList",
"toRepair",
",",
"final",
"RemoveFromList",
"repairAgainst",
")",
"{",
"final",
"int",
"indicesBefore",
"=",
"toRepair",
".",
"getPosition",
"(",
")",
"-",
"repairAgainst",
".",
"getStartPosition",
"(",
")",
";",
"if",
"(",
"indicesBefore",
"<=",
"0",
")",
"{",
"return",
"toRepair",
";",
"}",
"final",
"int",
"indicesToDecrese",
"=",
"indicesBefore",
"<",
"repairAgainst",
".",
"getRemoveCount",
"(",
")",
"?",
"indicesBefore",
":",
"repairAgainst",
".",
"getRemoveCount",
"(",
")",
";",
"if",
"(",
"repairAgainst",
".",
"getStartPosition",
"(",
")",
"+",
"repairAgainst",
".",
"getRemoveCount",
"(",
")",
"<=",
"toRepair",
".",
"getPosition",
"(",
")",
")",
"{",
"return",
"new",
"ReplaceInList",
"(",
"toRepair",
".",
"getListId",
"(",
")",
",",
"toRepair",
".",
"getListVersionChange",
"(",
")",
",",
"toRepair",
".",
"getValue",
"(",
")",
",",
"toRepair",
".",
"getPosition",
"(",
")",
"-",
"indicesToDecrese",
")",
";",
"}",
"return",
"new",
"AddToList",
"(",
"toRepair",
".",
"getListId",
"(",
")",
",",
"toRepair",
".",
"getListVersionChange",
"(",
")",
",",
"toRepair",
".",
"getValue",
"(",
")",
",",
"toRepair",
".",
"getPosition",
"(",
")",
"-",
"indicesToDecrese",
")",
";",
"}"
] | Repairs a {@link ReplaceInList} in relation to an {@link RemoveFromList} command.
<p>
Repairing a {@link ReplaceInList} command can result in an {@link AddToList} command in the case that the element
that should be replaced was removed. Therefore this methods return a {@link ListCommand} which is either a
{@link ReplaceInList} or {@link AddToList}.
</p>
@param toRepair
The command to repair.
@param repairAgainst
The command to repair against.
@return The repaired command. | [
"Repairs",
"a",
"{",
"@link",
"ReplaceInList",
"}",
"in",
"relation",
"to",
"an",
"{",
"@link",
"RemoveFromList",
"}",
"command",
"."
] | train | https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ReplaceInListRepairer.java#L69-L83 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/ui/A_CmsListTab.java | A_CmsListTab.createUploadButtonForTarget | protected CmsUploadButton createUploadButtonForTarget(String target, boolean isRootPath) {
CmsDialogUploadButtonHandler buttonHandler = new CmsDialogUploadButtonHandler(
new Supplier<I_CmsUploadContext>() {
public I_CmsUploadContext get() {
return new I_CmsUploadContext() {
public void onUploadFinished(List<String> uploadedFiles) {
getTabHandler().updateIndex();
}
};
}
});
buttonHandler.setTargetFolder(target);
buttonHandler.setIsTargetRootPath(isRootPath);
CmsUploadButton uploadButton = new CmsUploadButton(buttonHandler);
uploadButton.setText(null);
uploadButton.setTitle(Messages.get().key(Messages.GUI_GALLERY_UPLOAD_TITLE_1, target));
uploadButton.setButtonStyle(ButtonStyle.FONT_ICON, null);
uploadButton.setImageClass(I_CmsButton.UPLOAD_SMALL);
return uploadButton;
} | java | protected CmsUploadButton createUploadButtonForTarget(String target, boolean isRootPath) {
CmsDialogUploadButtonHandler buttonHandler = new CmsDialogUploadButtonHandler(
new Supplier<I_CmsUploadContext>() {
public I_CmsUploadContext get() {
return new I_CmsUploadContext() {
public void onUploadFinished(List<String> uploadedFiles) {
getTabHandler().updateIndex();
}
};
}
});
buttonHandler.setTargetFolder(target);
buttonHandler.setIsTargetRootPath(isRootPath);
CmsUploadButton uploadButton = new CmsUploadButton(buttonHandler);
uploadButton.setText(null);
uploadButton.setTitle(Messages.get().key(Messages.GUI_GALLERY_UPLOAD_TITLE_1, target));
uploadButton.setButtonStyle(ButtonStyle.FONT_ICON, null);
uploadButton.setImageClass(I_CmsButton.UPLOAD_SMALL);
return uploadButton;
} | [
"protected",
"CmsUploadButton",
"createUploadButtonForTarget",
"(",
"String",
"target",
",",
"boolean",
"isRootPath",
")",
"{",
"CmsDialogUploadButtonHandler",
"buttonHandler",
"=",
"new",
"CmsDialogUploadButtonHandler",
"(",
"new",
"Supplier",
"<",
"I_CmsUploadContext",
">",
"(",
")",
"{",
"public",
"I_CmsUploadContext",
"get",
"(",
")",
"{",
"return",
"new",
"I_CmsUploadContext",
"(",
")",
"{",
"public",
"void",
"onUploadFinished",
"(",
"List",
"<",
"String",
">",
"uploadedFiles",
")",
"{",
"getTabHandler",
"(",
")",
".",
"updateIndex",
"(",
")",
";",
"}",
"}",
";",
"}",
"}",
")",
";",
"buttonHandler",
".",
"setTargetFolder",
"(",
"target",
")",
";",
"buttonHandler",
".",
"setIsTargetRootPath",
"(",
"isRootPath",
")",
";",
"CmsUploadButton",
"uploadButton",
"=",
"new",
"CmsUploadButton",
"(",
"buttonHandler",
")",
";",
"uploadButton",
".",
"setText",
"(",
"null",
")",
";",
"uploadButton",
".",
"setTitle",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_GALLERY_UPLOAD_TITLE_1",
",",
"target",
")",
")",
";",
"uploadButton",
".",
"setButtonStyle",
"(",
"ButtonStyle",
".",
"FONT_ICON",
",",
"null",
")",
";",
"uploadButton",
".",
"setImageClass",
"(",
"I_CmsButton",
".",
"UPLOAD_SMALL",
")",
";",
"return",
"uploadButton",
";",
"}"
] | Creates an upload button for the given target.<p>
@param target the upload target folder
@param isRootPath true if target is a root path
@return the upload button | [
"Creates",
"an",
"upload",
"button",
"for",
"the",
"given",
"target",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/ui/A_CmsListTab.java#L572-L599 |
jbundle/jbundle | thin/opt/chat/src/main/java/org/jbundle/thin/opt/chat/ChatScreen.java | ChatScreen.init | public void init(Object parent, Object obj)
{
super.init(parent, obj);
BaseApplet baseApplet = (BaseApplet)parent;
this.addSubPanels(this);
MessageManager messageManager = baseApplet.getApplication().getMessageManager();
BaseMessageReceiver receiver = (BaseMessageReceiver)messageManager.getMessageQueue(CHAT_TYPE, MessageConstants.INTRANET_QUEUE).getMessageReceiver();
new BaseMessageListener(receiver) // Listener automatically added to receiver
{
public int handleMessage(BaseMessage message)
{
String strMessage = (String)message.get(MESSAGE_PARAM);
addText(strMessage);
return Constants.NORMAL_RETURN;
}
};
} | java | public void init(Object parent, Object obj)
{
super.init(parent, obj);
BaseApplet baseApplet = (BaseApplet)parent;
this.addSubPanels(this);
MessageManager messageManager = baseApplet.getApplication().getMessageManager();
BaseMessageReceiver receiver = (BaseMessageReceiver)messageManager.getMessageQueue(CHAT_TYPE, MessageConstants.INTRANET_QUEUE).getMessageReceiver();
new BaseMessageListener(receiver) // Listener automatically added to receiver
{
public int handleMessage(BaseMessage message)
{
String strMessage = (String)message.get(MESSAGE_PARAM);
addText(strMessage);
return Constants.NORMAL_RETURN;
}
};
} | [
"public",
"void",
"init",
"(",
"Object",
"parent",
",",
"Object",
"obj",
")",
"{",
"super",
".",
"init",
"(",
"parent",
",",
"obj",
")",
";",
"BaseApplet",
"baseApplet",
"=",
"(",
"BaseApplet",
")",
"parent",
";",
"this",
".",
"addSubPanels",
"(",
"this",
")",
";",
"MessageManager",
"messageManager",
"=",
"baseApplet",
".",
"getApplication",
"(",
")",
".",
"getMessageManager",
"(",
")",
";",
"BaseMessageReceiver",
"receiver",
"=",
"(",
"BaseMessageReceiver",
")",
"messageManager",
".",
"getMessageQueue",
"(",
"CHAT_TYPE",
",",
"MessageConstants",
".",
"INTRANET_QUEUE",
")",
".",
"getMessageReceiver",
"(",
")",
";",
"new",
"BaseMessageListener",
"(",
"receiver",
")",
"// Listener automatically added to receiver",
"{",
"public",
"int",
"handleMessage",
"(",
"BaseMessage",
"message",
")",
"{",
"String",
"strMessage",
"=",
"(",
"String",
")",
"message",
".",
"get",
"(",
"MESSAGE_PARAM",
")",
";",
"addText",
"(",
"strMessage",
")",
";",
"return",
"Constants",
".",
"NORMAL_RETURN",
";",
"}",
"}",
";",
"}"
] | Chat Screen Constructor.
@param parent Typically, you pass the BaseApplet as the parent.
@param @record and the record or GridTableModel as the parent. | [
"Chat",
"Screen",
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/opt/chat/src/main/java/org/jbundle/thin/opt/chat/ChatScreen.java#L92-L111 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/runtime/SARLRuntime.java | SARLRuntime.containsUnpackedBootstrap | public static boolean containsUnpackedBootstrap(File directory) {
final String[] elements = SREConstants.SERVICE_SRE_BOOTSTRAP.split("/"); //$NON-NLS-1$
File serviceFile = directory;
for (final String element : elements) {
serviceFile = new File(serviceFile, element);
}
if (serviceFile.isFile() && serviceFile.canRead()) {
try (InputStream is = new FileInputStream(serviceFile)) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line = reader.readLine();
if (line != null) {
line = line.trim();
if (!line.isEmpty()) {
return true;
}
}
}
} catch (Throwable exception) {
//
}
}
return false;
} | java | public static boolean containsUnpackedBootstrap(File directory) {
final String[] elements = SREConstants.SERVICE_SRE_BOOTSTRAP.split("/"); //$NON-NLS-1$
File serviceFile = directory;
for (final String element : elements) {
serviceFile = new File(serviceFile, element);
}
if (serviceFile.isFile() && serviceFile.canRead()) {
try (InputStream is = new FileInputStream(serviceFile)) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line = reader.readLine();
if (line != null) {
line = line.trim();
if (!line.isEmpty()) {
return true;
}
}
}
} catch (Throwable exception) {
//
}
}
return false;
} | [
"public",
"static",
"boolean",
"containsUnpackedBootstrap",
"(",
"File",
"directory",
")",
"{",
"final",
"String",
"[",
"]",
"elements",
"=",
"SREConstants",
".",
"SERVICE_SRE_BOOTSTRAP",
".",
"split",
"(",
"\"/\"",
")",
";",
"//$NON-NLS-1$",
"File",
"serviceFile",
"=",
"directory",
";",
"for",
"(",
"final",
"String",
"element",
":",
"elements",
")",
"{",
"serviceFile",
"=",
"new",
"File",
"(",
"serviceFile",
",",
"element",
")",
";",
"}",
"if",
"(",
"serviceFile",
".",
"isFile",
"(",
")",
"&&",
"serviceFile",
".",
"canRead",
"(",
")",
")",
"{",
"try",
"(",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"serviceFile",
")",
")",
"{",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"is",
")",
")",
")",
"{",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"!=",
"null",
")",
"{",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"line",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"//",
"}",
"}",
"return",
"false",
";",
"}"
] | Replies if the given directory contains a SRE bootstrap.
<p>The SRE bootstrap detection is based on the service definition within META-INF folder.
@param directory the directory.
@return <code>true</code> if the given directory contains a SRE. Otherwise <code>false</code>.=
@since 0.7
@see #containsPackedBootstrap(File) | [
"Replies",
"if",
"the",
"given",
"directory",
"contains",
"a",
"SRE",
"bootstrap",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/runtime/SARLRuntime.java#L987-L1009 |
Scout24/appmon4j | core/src/main/java/de/is24/util/monitoring/CorePlugin.java | CorePlugin.addHistorizable | public void addHistorizable(String name, Historizable historizable) {
HistorizableList listToAddTo = getHistorizableList(name);
listToAddTo.add(historizable);
} | java | public void addHistorizable(String name, Historizable historizable) {
HistorizableList listToAddTo = getHistorizableList(name);
listToAddTo.add(historizable);
} | [
"public",
"void",
"addHistorizable",
"(",
"String",
"name",
",",
"Historizable",
"historizable",
")",
"{",
"HistorizableList",
"listToAddTo",
"=",
"getHistorizableList",
"(",
"name",
")",
";",
"listToAddTo",
".",
"add",
"(",
"historizable",
")",
";",
"}"
] | add a {@link de.is24.util.monitoring.Historizable} instance to the list identified by historizable.getName()
@param name key of the historizbale metric
@param historizable the historizable to add | [
"add",
"a",
"{",
"@link",
"de",
".",
"is24",
".",
"util",
".",
"monitoring",
".",
"Historizable",
"}",
"instance",
"to",
"the",
"list",
"identified",
"by",
"historizable",
".",
"getName",
"()"
] | train | https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/CorePlugin.java#L375-L378 |
geomajas/geomajas-project-client-gwt2 | common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/Dom.java | Dom.setElementAttributeNS | public static void setElementAttributeNS(String ns, Element element, String attr, String value) {
IMPL.setElementAttributeNS(ns, element, attr, value);
} | java | public static void setElementAttributeNS(String ns, Element element, String attr, String value) {
IMPL.setElementAttributeNS(ns, element, attr, value);
} | [
"public",
"static",
"void",
"setElementAttributeNS",
"(",
"String",
"ns",
",",
"Element",
"element",
",",
"String",
"attr",
",",
"String",
"value",
")",
"{",
"IMPL",
".",
"setElementAttributeNS",
"(",
"ns",
",",
"element",
",",
"attr",
",",
"value",
")",
";",
"}"
] | <p> Adds a new attribute in the given name-space to an element. </p> <p> There is an exception when using
Internet Explorer! For Internet Explorer the attribute of type "namespace:attr" will be set. </p>
@param ns The name-space to be used in the element creation.
@param element The element to which the attribute is to be set.
@param attr The name of the attribute.
@param value The new value for the attribute. | [
"<p",
">",
"Adds",
"a",
"new",
"attribute",
"in",
"the",
"given",
"name",
"-",
"space",
"to",
"an",
"element",
".",
"<",
"/",
"p",
">",
"<p",
">",
"There",
"is",
"an",
"exception",
"when",
"using",
"Internet",
"Explorer!",
"For",
"Internet",
"Explorer",
"the",
"attribute",
"of",
"type",
"namespace",
":",
"attr",
"will",
"be",
"set",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/Dom.java#L139-L141 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/AvailabilitySetsInner.java | AvailabilitySetsInner.listAvailableSizesAsync | public Observable<List<VirtualMachineSizeInner>> listAvailableSizesAsync(String resourceGroupName, String availabilitySetName) {
return listAvailableSizesWithServiceResponseAsync(resourceGroupName, availabilitySetName).map(new Func1<ServiceResponse<List<VirtualMachineSizeInner>>, List<VirtualMachineSizeInner>>() {
@Override
public List<VirtualMachineSizeInner> call(ServiceResponse<List<VirtualMachineSizeInner>> response) {
return response.body();
}
});
} | java | public Observable<List<VirtualMachineSizeInner>> listAvailableSizesAsync(String resourceGroupName, String availabilitySetName) {
return listAvailableSizesWithServiceResponseAsync(resourceGroupName, availabilitySetName).map(new Func1<ServiceResponse<List<VirtualMachineSizeInner>>, List<VirtualMachineSizeInner>>() {
@Override
public List<VirtualMachineSizeInner> call(ServiceResponse<List<VirtualMachineSizeInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"VirtualMachineSizeInner",
">",
">",
"listAvailableSizesAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"availabilitySetName",
")",
"{",
"return",
"listAvailableSizesWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"availabilitySetName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"VirtualMachineSizeInner",
">",
">",
",",
"List",
"<",
"VirtualMachineSizeInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"VirtualMachineSizeInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"VirtualMachineSizeInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set.
@param resourceGroupName The name of the resource group.
@param availabilitySetName The name of the availability set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<VirtualMachineSizeInner> object | [
"Lists",
"all",
"available",
"virtual",
"machine",
"sizes",
"that",
"can",
"be",
"used",
"to",
"create",
"a",
"new",
"virtual",
"machine",
"in",
"an",
"existing",
"availability",
"set",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/AvailabilitySetsInner.java#L475-L482 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.mixin | public static void mixin(MetaClass self, Class[] categoryClass) {
mixin(self, Arrays.asList(categoryClass));
} | java | public static void mixin(MetaClass self, Class[] categoryClass) {
mixin(self, Arrays.asList(categoryClass));
} | [
"public",
"static",
"void",
"mixin",
"(",
"MetaClass",
"self",
",",
"Class",
"[",
"]",
"categoryClass",
")",
"{",
"mixin",
"(",
"self",
",",
"Arrays",
".",
"asList",
"(",
"categoryClass",
")",
")",
";",
"}"
] | Extend class globally with category methods.
@param self any Class
@param categoryClass a category class to use
@since 1.6.0 | [
"Extend",
"class",
"globally",
"with",
"category",
"methods",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L622-L624 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Flowable.java | Flowable.concatMapMaybe | @CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> concatMapMaybe(Function<? super T, ? extends MaybeSource<? extends R>> mapper, int prefetch) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
ObjectHelper.verifyPositive(prefetch, "prefetch");
return RxJavaPlugins.onAssembly(new FlowableConcatMapMaybe<T, R>(this, mapper, ErrorMode.IMMEDIATE, prefetch));
} | java | @CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> concatMapMaybe(Function<? super T, ? extends MaybeSource<? extends R>> mapper, int prefetch) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
ObjectHelper.verifyPositive(prefetch, "prefetch");
return RxJavaPlugins.onAssembly(new FlowableConcatMapMaybe<T, R>(this, mapper, ErrorMode.IMMEDIATE, prefetch));
} | [
"@",
"CheckReturnValue",
"@",
"BackpressureSupport",
"(",
"BackpressureKind",
".",
"FULL",
")",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"<",
"R",
">",
"Flowable",
"<",
"R",
">",
"concatMapMaybe",
"(",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"MaybeSource",
"<",
"?",
"extends",
"R",
">",
">",
"mapper",
",",
"int",
"prefetch",
")",
"{",
"ObjectHelper",
".",
"requireNonNull",
"(",
"mapper",
",",
"\"mapper is null\"",
")",
";",
"ObjectHelper",
".",
"verifyPositive",
"(",
"prefetch",
",",
"\"prefetch\"",
")",
";",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"FlowableConcatMapMaybe",
"<",
"T",
",",
"R",
">",
"(",
"this",
",",
"mapper",
",",
"ErrorMode",
".",
"IMMEDIATE",
",",
"prefetch",
")",
")",
";",
"}"
] | Maps the upstream items into {@link MaybeSource}s and subscribes to them one after the
other succeeds or completes, emits their success value if available or terminates immediately if
either this {@code Flowable} or the current inner {@code MaybeSource} fail.
<p>
<img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMap.png" alt="">
<dl>
<dt><b>Backpressure:</b></dt>
<dd>The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this {@code Flowable} violates the rule, the operator will
signal a {@code MissingBackpressureException}.</dd>
<dt><b>Scheduler:</b></dt>
<dd>{@code concatMapMaybe} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
<p>History: 2.1.11 - experimental
@param <R> the result type of the inner {@code MaybeSource}s
@param mapper the function called with the upstream item and should return
a {@code MaybeSource} to become the next source to
be subscribed to
@param prefetch The number of upstream items to prefetch so that fresh items are
ready to be mapped when a previous {@code MaybeSource} terminates.
The operator replenishes after half of the prefetch amount has been consumed
and turned into {@code MaybeSource}s.
@return a new Flowable instance
@see #concatMapMaybe(Function)
@see #concatMapMaybeDelayError(Function, boolean, int)
@since 2.2 | [
"Maps",
"the",
"upstream",
"items",
"into",
"{"
] | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Flowable.java#L7615-L7622 |
upwork/java-upwork | src/com/Upwork/api/Routers/Hr/Jobs.java | Jobs.editJob | public JSONObject editJob(String key, HashMap<String, String> params) throws JSONException {
return oClient.put("/hr/v2/jobs/" + key, params);
} | java | public JSONObject editJob(String key, HashMap<String, String> params) throws JSONException {
return oClient.put("/hr/v2/jobs/" + key, params);
} | [
"public",
"JSONObject",
"editJob",
"(",
"String",
"key",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"put",
"(",
"\"/hr/v2/jobs/\"",
"+",
"key",
",",
"params",
")",
";",
"}"
] | Edit existent job
@param key Job key
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Edit",
"existent",
"job"
] | train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Hr/Jobs.java#L87-L89 |
square/okhttp | okhttp/src/main/java/okhttp3/internal/ws/WebSocketWriter.java | WebSocketWriter.newMessageSink | Sink newMessageSink(int formatOpcode, long contentLength) {
if (activeWriter) {
throw new IllegalStateException("Another message writer is active. Did you call close()?");
}
activeWriter = true;
// Reset FrameSink state for a new writer.
frameSink.formatOpcode = formatOpcode;
frameSink.contentLength = contentLength;
frameSink.isFirstFrame = true;
frameSink.closed = false;
return frameSink;
} | java | Sink newMessageSink(int formatOpcode, long contentLength) {
if (activeWriter) {
throw new IllegalStateException("Another message writer is active. Did you call close()?");
}
activeWriter = true;
// Reset FrameSink state for a new writer.
frameSink.formatOpcode = formatOpcode;
frameSink.contentLength = contentLength;
frameSink.isFirstFrame = true;
frameSink.closed = false;
return frameSink;
} | [
"Sink",
"newMessageSink",
"(",
"int",
"formatOpcode",
",",
"long",
"contentLength",
")",
"{",
"if",
"(",
"activeWriter",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Another message writer is active. Did you call close()?\"",
")",
";",
"}",
"activeWriter",
"=",
"true",
";",
"// Reset FrameSink state for a new writer.",
"frameSink",
".",
"formatOpcode",
"=",
"formatOpcode",
";",
"frameSink",
".",
"contentLength",
"=",
"contentLength",
";",
"frameSink",
".",
"isFirstFrame",
"=",
"true",
";",
"frameSink",
".",
"closed",
"=",
"false",
";",
"return",
"frameSink",
";",
"}"
] | Stream a message payload as a series of frames. This allows control frames to be interleaved
between parts of the message. | [
"Stream",
"a",
"message",
"payload",
"as",
"a",
"series",
"of",
"frames",
".",
"This",
"allows",
"control",
"frames",
"to",
"be",
"interleaved",
"between",
"parts",
"of",
"the",
"message",
"."
] | train | https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/okhttp/src/main/java/okhttp3/internal/ws/WebSocketWriter.java#L153-L166 |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java | ManagementClient.createSubscription | public SubscriptionDescription createSubscription(SubscriptionDescription subscriptionDescription, RuleDescription defaultRule) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.createSubscriptionAsync(subscriptionDescription, defaultRule));
} | java | public SubscriptionDescription createSubscription(SubscriptionDescription subscriptionDescription, RuleDescription defaultRule) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.createSubscriptionAsync(subscriptionDescription, defaultRule));
} | [
"public",
"SubscriptionDescription",
"createSubscription",
"(",
"SubscriptionDescription",
"subscriptionDescription",
",",
"RuleDescription",
"defaultRule",
")",
"throws",
"ServiceBusException",
",",
"InterruptedException",
"{",
"return",
"Utils",
".",
"completeFuture",
"(",
"this",
".",
"asyncClient",
".",
"createSubscriptionAsync",
"(",
"subscriptionDescription",
",",
"defaultRule",
")",
")",
";",
"}"
] | Creates a new subscription in the service namespace with the provided default rule.
See {@link SubscriptionDescription} for default values of subscription properties.
@param subscriptionDescription - A {@link SubscriptionDescription} object describing the attributes with which the new subscription will be created.
@param defaultRule - A {@link RuleDescription} object describing the default rule. If null, then pass-through filter will be created.
@return {@link SubscriptionDescription} of the newly created subscription.
@throws MessagingEntityAlreadyExistsException - An entity with the same name exists under the same service namespace.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws QuotaExceededException - Either the specified size in the description is not supported or the maximum allowed quota has been reached.
@throws InterruptedException if the current thread was interrupted | [
"Creates",
"a",
"new",
"subscription",
"in",
"the",
"service",
"namespace",
"with",
"the",
"provided",
"default",
"rule",
".",
"See",
"{"
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java#L434-L436 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java | BufferUtils.flipToFlush | public static void flipToFlush(ByteBuffer buffer, int position) {
buffer.limit(buffer.position());
buffer.position(position);
} | java | public static void flipToFlush(ByteBuffer buffer, int position) {
buffer.limit(buffer.position());
buffer.position(position);
} | [
"public",
"static",
"void",
"flipToFlush",
"(",
"ByteBuffer",
"buffer",
",",
"int",
"position",
")",
"{",
"buffer",
".",
"limit",
"(",
"buffer",
".",
"position",
"(",
")",
")",
";",
"buffer",
".",
"position",
"(",
"position",
")",
";",
"}"
] | Flip the buffer to Flush mode.
The limit is set to the first unused byte(the old position) and
the position is set to the passed position.
<p>
This method is used as a replacement of {@link Buffer#flip()}.
@param buffer the buffer to be flipped
@param position The position of valid data to flip to. This should
be the return value of the previous call to {@link #flipToFill(ByteBuffer)} | [
"Flip",
"the",
"buffer",
"to",
"Flush",
"mode",
".",
"The",
"limit",
"is",
"set",
"to",
"the",
"first",
"unused",
"byte",
"(",
"the",
"old",
"position",
")",
"and",
"the",
"position",
"is",
"set",
"to",
"the",
"passed",
"position",
".",
"<p",
">",
"This",
"method",
"is",
"used",
"as",
"a",
"replacement",
"of",
"{",
"@link",
"Buffer#flip",
"()",
"}",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L206-L209 |
line/armeria | core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedHttpServiceFactory.java | AnnotatedHttpServiceFactory.httpMethodAnnotations | private static Set<Annotation> httpMethodAnnotations(Method method) {
return getAnnotations(method, FindOption.LOOKUP_SUPER_CLASSES)
.stream()
.filter(annotation -> HTTP_METHOD_MAP.containsKey(annotation.annotationType()))
.collect(Collectors.toSet());
} | java | private static Set<Annotation> httpMethodAnnotations(Method method) {
return getAnnotations(method, FindOption.LOOKUP_SUPER_CLASSES)
.stream()
.filter(annotation -> HTTP_METHOD_MAP.containsKey(annotation.annotationType()))
.collect(Collectors.toSet());
} | [
"private",
"static",
"Set",
"<",
"Annotation",
">",
"httpMethodAnnotations",
"(",
"Method",
"method",
")",
"{",
"return",
"getAnnotations",
"(",
"method",
",",
"FindOption",
".",
"LOOKUP_SUPER_CLASSES",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"annotation",
"->",
"HTTP_METHOD_MAP",
".",
"containsKey",
"(",
"annotation",
".",
"annotationType",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"}"
] | Returns {@link Set} of HTTP method annotations of a given method.
The annotations are as follows.
@see Options
@see Get
@see Head
@see Post
@see Put
@see Patch
@see Delete
@see Trace | [
"Returns",
"{",
"@link",
"Set",
"}",
"of",
"HTTP",
"method",
"annotations",
"of",
"a",
"given",
"method",
".",
"The",
"annotations",
"are",
"as",
"follows",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedHttpServiceFactory.java#L421-L426 |
apache/flink | flink-core/src/main/java/org/apache/flink/configuration/Configuration.java | Configuration.getFloat | public float getFloat(String key, float defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToFloat(o, defaultValue);
} | java | public float getFloat(String key, float defaultValue) {
Object o = getRawValue(key);
if (o == null) {
return defaultValue;
}
return convertToFloat(o, defaultValue);
} | [
"public",
"float",
"getFloat",
"(",
"String",
"key",
",",
"float",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getRawValue",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"convertToFloat",
"(",
"o",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value associated with the given key as a float.
@param key
the key pointing to the associated value
@param defaultValue
the default value which is returned in case there is no value associated with the given key
@return the (default) value associated with the given key | [
"Returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"a",
"float",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L426-L433 |
JRebirth/JRebirth | org.jrebirth.af/component/src/main/java/org/jrebirth/af/component/ui/stack/StackModel.java | StackModel.doShowPageModel | public void doShowPageModel(final UniqueKey<? extends Model> pageModelKey, final String stackName, final Wave wave) {
if (getStackName() != null && getStackName().equals(stackName)) {
showPage(pageModelKey, wave);
}
} | java | public void doShowPageModel(final UniqueKey<? extends Model> pageModelKey, final String stackName, final Wave wave) {
if (getStackName() != null && getStackName().equals(stackName)) {
showPage(pageModelKey, wave);
}
} | [
"public",
"void",
"doShowPageModel",
"(",
"final",
"UniqueKey",
"<",
"?",
"extends",
"Model",
">",
"pageModelKey",
",",
"final",
"String",
"stackName",
",",
"final",
"Wave",
"wave",
")",
"{",
"if",
"(",
"getStackName",
"(",
")",
"!=",
"null",
"&&",
"getStackName",
"(",
")",
".",
"equals",
"(",
"stackName",
")",
")",
"{",
"showPage",
"(",
"pageModelKey",
",",
"wave",
")",
";",
"}",
"}"
] | Show page.
Called when model received a SHOW_PAGE wave type.
@param pageModelKey the modelKey for the page to show
@param stackName the unique string tha t identify the stack
@param wave the wave | [
"Show",
"page",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/component/src/main/java/org/jrebirth/af/component/ui/stack/StackModel.java#L73-L79 |
JodaOrg/joda-time | src/main/java/org/joda/time/field/BaseDateTimeField.java | BaseDateTimeField.addWrapField | public int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) {
int current = values[fieldIndex];
int wrapped = FieldUtils.getWrappedValue
(current, valueToAdd, getMinimumValue(instant), getMaximumValue(instant));
return set(instant, fieldIndex, values, wrapped); // adjusts smaller fields
} | java | public int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) {
int current = values[fieldIndex];
int wrapped = FieldUtils.getWrappedValue
(current, valueToAdd, getMinimumValue(instant), getMaximumValue(instant));
return set(instant, fieldIndex, values, wrapped); // adjusts smaller fields
} | [
"public",
"int",
"[",
"]",
"addWrapField",
"(",
"ReadablePartial",
"instant",
",",
"int",
"fieldIndex",
",",
"int",
"[",
"]",
"values",
",",
"int",
"valueToAdd",
")",
"{",
"int",
"current",
"=",
"values",
"[",
"fieldIndex",
"]",
";",
"int",
"wrapped",
"=",
"FieldUtils",
".",
"getWrappedValue",
"(",
"current",
",",
"valueToAdd",
",",
"getMinimumValue",
"(",
"instant",
")",
",",
"getMaximumValue",
"(",
"instant",
")",
")",
";",
"return",
"set",
"(",
"instant",
",",
"fieldIndex",
",",
"values",
",",
"wrapped",
")",
";",
"// adjusts smaller fields",
"}"
] | Adds a value (which may be negative) to the partial instant,
wrapping within this field.
<p>
The value will be added to this field. If the value is too large to be
added solely to this field then it wraps. Larger fields are always
unaffected. Smaller fields should be unaffected, except where the
result would be an invalid value for a smaller field. In this case the
smaller field is adjusted to be in range.
<p>
For example, in the ISO chronology:<br>
2000-08-20 addWrapField six months is 2000-02-20<br>
2000-08-20 addWrapField twenty months is 2000-04-20<br>
2000-08-20 addWrapField minus nine months is 2000-11-20<br>
2001-01-31 addWrapField one month is 2001-02-28<br>
2001-01-31 addWrapField two months is 2001-03-31<br>
<p>
The default implementation internally calls set. Subclasses are
encouraged to provide a more efficient implementation.
@param instant the partial instant
@param fieldIndex the index of this field in the instant
@param values the values of the partial instant which should be updated
@param valueToAdd the value to add, in the units of the field
@return the passed in values
@throws IllegalArgumentException if the value is invalid | [
"Adds",
"a",
"value",
"(",
"which",
"may",
"be",
"negative",
")",
"to",
"the",
"partial",
"instant",
"wrapping",
"within",
"this",
"field",
".",
"<p",
">",
"The",
"value",
"will",
"be",
"added",
"to",
"this",
"field",
".",
"If",
"the",
"value",
"is",
"too",
"large",
"to",
"be",
"added",
"solely",
"to",
"this",
"field",
"then",
"it",
"wraps",
".",
"Larger",
"fields",
"are",
"always",
"unaffected",
".",
"Smaller",
"fields",
"should",
"be",
"unaffected",
"except",
"where",
"the",
"result",
"would",
"be",
"an",
"invalid",
"value",
"for",
"a",
"smaller",
"field",
".",
"In",
"this",
"case",
"the",
"smaller",
"field",
"is",
"adjusted",
"to",
"be",
"in",
"range",
".",
"<p",
">",
"For",
"example",
"in",
"the",
"ISO",
"chronology",
":",
"<br",
">",
"2000",
"-",
"08",
"-",
"20",
"addWrapField",
"six",
"months",
"is",
"2000",
"-",
"02",
"-",
"20<br",
">",
"2000",
"-",
"08",
"-",
"20",
"addWrapField",
"twenty",
"months",
"is",
"2000",
"-",
"04",
"-",
"20<br",
">",
"2000",
"-",
"08",
"-",
"20",
"addWrapField",
"minus",
"nine",
"months",
"is",
"2000",
"-",
"11",
"-",
"20<br",
">",
"2001",
"-",
"01",
"-",
"31",
"addWrapField",
"one",
"month",
"is",
"2001",
"-",
"02",
"-",
"28<br",
">",
"2001",
"-",
"01",
"-",
"31",
"addWrapField",
"two",
"months",
"is",
"2001",
"-",
"03",
"-",
"31<br",
">",
"<p",
">",
"The",
"default",
"implementation",
"internally",
"calls",
"set",
".",
"Subclasses",
"are",
"encouraged",
"to",
"provide",
"a",
"more",
"efficient",
"implementation",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/BaseDateTimeField.java#L494-L499 |
devcon5io/common | cli/src/main/java/io/devcon5/cli/OptionInjector.java | OptionInjector.getEffectiveValue | private String getEffectiveValue(Map<String, Option> options, CliOption opt) {
final String shortOpt = opt.value();
if (opt.hasArg()) {
if (options.containsKey(shortOpt)) {
return options.get(shortOpt).getValue();
}
return opt.defaultValue();
}
return Boolean.toString(options.containsKey(opt.value()));
} | java | private String getEffectiveValue(Map<String, Option> options, CliOption opt) {
final String shortOpt = opt.value();
if (opt.hasArg()) {
if (options.containsKey(shortOpt)) {
return options.get(shortOpt).getValue();
}
return opt.defaultValue();
}
return Boolean.toString(options.containsKey(opt.value()));
} | [
"private",
"String",
"getEffectiveValue",
"(",
"Map",
"<",
"String",
",",
"Option",
">",
"options",
",",
"CliOption",
"opt",
")",
"{",
"final",
"String",
"shortOpt",
"=",
"opt",
".",
"value",
"(",
")",
";",
"if",
"(",
"opt",
".",
"hasArg",
"(",
")",
")",
"{",
"if",
"(",
"options",
".",
"containsKey",
"(",
"shortOpt",
")",
")",
"{",
"return",
"options",
".",
"get",
"(",
"shortOpt",
")",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"opt",
".",
"defaultValue",
"(",
")",
";",
"}",
"return",
"Boolean",
".",
"toString",
"(",
"options",
".",
"containsKey",
"(",
"opt",
".",
"value",
"(",
")",
")",
")",
";",
"}"
] | Returns the effective value for the specified option.
@param options
the parsed option
@param opt
the cli option annotation for which the actual argument should be retrieved
@return the effective value for the given option <ul> <li>If the option should have an argument, and an argument
is provided, the provided argument is returned</li> <li>If the option should have an argument, and none is
specified, the default value is returned</li> <li>If the option has no argument, and is specified, "true" is
returned</li> <li>If the option has no argument, and is not specifeid, "false" is returned</li> </ul> | [
"Returns",
"the",
"effective",
"value",
"for",
"the",
"specified",
"option",
"."
] | train | https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/cli/src/main/java/io/devcon5/cli/OptionInjector.java#L165-L174 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/CLARA.java | CLARA.randomSample | static DBIDs randomSample(DBIDs ids, int samplesize, Random rnd, DBIDs previous) {
if(previous == null) {
return DBIDUtil.randomSample(ids, samplesize, rnd);
}
ModifiableDBIDs sample = DBIDUtil.newHashSet(samplesize);
sample.addDBIDs(previous);
sample.addDBIDs(DBIDUtil.randomSample(ids, samplesize - previous.size(), rnd));
// If these two were not disjoint, we can be short of the desired size!
if(sample.size() < samplesize) {
// Draw a large enough sample to make sure to be able to fill it now.
// This can be less random though, because the iterator may impose an
// order; but this is a rare code path.
for(DBIDIter it = DBIDUtil.randomSample(ids, samplesize, rnd).iter(); sample.size() < samplesize && it.valid(); it.advance()) {
sample.add(it);
}
}
return sample;
} | java | static DBIDs randomSample(DBIDs ids, int samplesize, Random rnd, DBIDs previous) {
if(previous == null) {
return DBIDUtil.randomSample(ids, samplesize, rnd);
}
ModifiableDBIDs sample = DBIDUtil.newHashSet(samplesize);
sample.addDBIDs(previous);
sample.addDBIDs(DBIDUtil.randomSample(ids, samplesize - previous.size(), rnd));
// If these two were not disjoint, we can be short of the desired size!
if(sample.size() < samplesize) {
// Draw a large enough sample to make sure to be able to fill it now.
// This can be less random though, because the iterator may impose an
// order; but this is a rare code path.
for(DBIDIter it = DBIDUtil.randomSample(ids, samplesize, rnd).iter(); sample.size() < samplesize && it.valid(); it.advance()) {
sample.add(it);
}
}
return sample;
} | [
"static",
"DBIDs",
"randomSample",
"(",
"DBIDs",
"ids",
",",
"int",
"samplesize",
",",
"Random",
"rnd",
",",
"DBIDs",
"previous",
")",
"{",
"if",
"(",
"previous",
"==",
"null",
")",
"{",
"return",
"DBIDUtil",
".",
"randomSample",
"(",
"ids",
",",
"samplesize",
",",
"rnd",
")",
";",
"}",
"ModifiableDBIDs",
"sample",
"=",
"DBIDUtil",
".",
"newHashSet",
"(",
"samplesize",
")",
";",
"sample",
".",
"addDBIDs",
"(",
"previous",
")",
";",
"sample",
".",
"addDBIDs",
"(",
"DBIDUtil",
".",
"randomSample",
"(",
"ids",
",",
"samplesize",
"-",
"previous",
".",
"size",
"(",
")",
",",
"rnd",
")",
")",
";",
"// If these two were not disjoint, we can be short of the desired size!",
"if",
"(",
"sample",
".",
"size",
"(",
")",
"<",
"samplesize",
")",
"{",
"// Draw a large enough sample to make sure to be able to fill it now.",
"// This can be less random though, because the iterator may impose an",
"// order; but this is a rare code path.",
"for",
"(",
"DBIDIter",
"it",
"=",
"DBIDUtil",
".",
"randomSample",
"(",
"ids",
",",
"samplesize",
",",
"rnd",
")",
".",
"iter",
"(",
")",
";",
"sample",
".",
"size",
"(",
")",
"<",
"samplesize",
"&&",
"it",
".",
"valid",
"(",
")",
";",
"it",
".",
"advance",
"(",
")",
")",
"{",
"sample",
".",
"add",
"(",
"it",
")",
";",
"}",
"}",
"return",
"sample",
";",
"}"
] | Draw a random sample of the desired size.
@param ids IDs to sample from
@param samplesize Sample size
@param rnd Random generator
@param previous Previous medoids to always include in the sample.
@return Sample | [
"Draw",
"a",
"random",
"sample",
"of",
"the",
"desired",
"size",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/CLARA.java#L205-L222 |
janus-project/guava.janusproject.io | guava/src/com/google/common/base/CharMatcher.java | CharMatcher.replaceFrom | @CheckReturnValue
public String replaceFrom(CharSequence sequence, CharSequence replacement) {
int replacementLen = replacement.length();
if (replacementLen == 0) {
return removeFrom(sequence);
}
if (replacementLen == 1) {
return replaceFrom(sequence, replacement.charAt(0));
}
String string = sequence.toString();
int pos = indexIn(string);
if (pos == -1) {
return string;
}
int len = string.length();
StringBuilder buf = new StringBuilder((len * 3 / 2) + 16);
int oldpos = 0;
do {
buf.append(string, oldpos, pos);
buf.append(replacement);
oldpos = pos + 1;
pos = indexIn(string, oldpos);
} while (pos != -1);
buf.append(string, oldpos, len);
return buf.toString();
} | java | @CheckReturnValue
public String replaceFrom(CharSequence sequence, CharSequence replacement) {
int replacementLen = replacement.length();
if (replacementLen == 0) {
return removeFrom(sequence);
}
if (replacementLen == 1) {
return replaceFrom(sequence, replacement.charAt(0));
}
String string = sequence.toString();
int pos = indexIn(string);
if (pos == -1) {
return string;
}
int len = string.length();
StringBuilder buf = new StringBuilder((len * 3 / 2) + 16);
int oldpos = 0;
do {
buf.append(string, oldpos, pos);
buf.append(replacement);
oldpos = pos + 1;
pos = indexIn(string, oldpos);
} while (pos != -1);
buf.append(string, oldpos, len);
return buf.toString();
} | [
"@",
"CheckReturnValue",
"public",
"String",
"replaceFrom",
"(",
"CharSequence",
"sequence",
",",
"CharSequence",
"replacement",
")",
"{",
"int",
"replacementLen",
"=",
"replacement",
".",
"length",
"(",
")",
";",
"if",
"(",
"replacementLen",
"==",
"0",
")",
"{",
"return",
"removeFrom",
"(",
"sequence",
")",
";",
"}",
"if",
"(",
"replacementLen",
"==",
"1",
")",
"{",
"return",
"replaceFrom",
"(",
"sequence",
",",
"replacement",
".",
"charAt",
"(",
"0",
")",
")",
";",
"}",
"String",
"string",
"=",
"sequence",
".",
"toString",
"(",
")",
";",
"int",
"pos",
"=",
"indexIn",
"(",
"string",
")",
";",
"if",
"(",
"pos",
"==",
"-",
"1",
")",
"{",
"return",
"string",
";",
"}",
"int",
"len",
"=",
"string",
".",
"length",
"(",
")",
";",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"(",
"len",
"*",
"3",
"/",
"2",
")",
"+",
"16",
")",
";",
"int",
"oldpos",
"=",
"0",
";",
"do",
"{",
"buf",
".",
"append",
"(",
"string",
",",
"oldpos",
",",
"pos",
")",
";",
"buf",
".",
"append",
"(",
"replacement",
")",
";",
"oldpos",
"=",
"pos",
"+",
"1",
";",
"pos",
"=",
"indexIn",
"(",
"string",
",",
"oldpos",
")",
";",
"}",
"while",
"(",
"pos",
"!=",
"-",
"1",
")",
";",
"buf",
".",
"append",
"(",
"string",
",",
"oldpos",
",",
"len",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Returns a string copy of the input character sequence, with each character that matches this
matcher replaced by a given replacement sequence. For example: <pre> {@code
CharMatcher.is('a').replaceFrom("yaha", "oo")}</pre>
... returns {@code "yoohoo"}.
<p><b>Note:</b> If the replacement is a fixed string with only one character, you are better
off calling {@link #replaceFrom(CharSequence, char)} directly.
@param sequence the character sequence to replace matching characters in
@param replacement the characters to append to the result string in place of each matching
character in {@code sequence}
@return the new string | [
"Returns",
"a",
"string",
"copy",
"of",
"the",
"input",
"character",
"sequence",
"with",
"each",
"character",
"that",
"matches",
"this",
"matcher",
"replaced",
"by",
"a",
"given",
"replacement",
"sequence",
".",
"For",
"example",
":",
"<pre",
">",
"{",
"@code"
] | train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/base/CharMatcher.java#L1146-L1175 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/parser/lexparser/Options.java | Options.setOptions | public void setOptions(final String[] flags, final int startIndex, final int endIndexPlusOne) {
for (int i = startIndex; i < endIndexPlusOne;) {
i = setOption(flags, i);
}
} | java | public void setOptions(final String[] flags, final int startIndex, final int endIndexPlusOne) {
for (int i = startIndex; i < endIndexPlusOne;) {
i = setOption(flags, i);
}
} | [
"public",
"void",
"setOptions",
"(",
"final",
"String",
"[",
"]",
"flags",
",",
"final",
"int",
"startIndex",
",",
"final",
"int",
"endIndexPlusOne",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"startIndex",
";",
"i",
"<",
"endIndexPlusOne",
";",
")",
"{",
"i",
"=",
"setOption",
"(",
"flags",
",",
"i",
")",
";",
"}",
"}"
] | Set options based on a String array in the style of
commandline flags. This method goes through the array until it ends,
processing options, as for {@link #setOption}.
@param flags Array of options. The options passed in should
be specified like command-line arguments, including with an initial
minus sign for example,
{"-outputFormat", "typedDependencies", "-maxLength", "70"}
@param startIndex The index in the array to begin processing options at
@param endIndexPlusOne A number one greater than the last array index at
which options should be processed
@throws IllegalArgumentException If an unknown flag is passed in | [
"Set",
"options",
"based",
"on",
"a",
"String",
"array",
"in",
"the",
"style",
"of",
"commandline",
"flags",
".",
"This",
"method",
"goes",
"through",
"the",
"array",
"until",
"it",
"ends",
"processing",
"options",
"as",
"for",
"{",
"@link",
"#setOption",
"}",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/parser/lexparser/Options.java#L64-L68 |
jayantk/jklol | src/com/jayantkrish/jklol/ccg/lambda2/Expression2.java | Expression2.substitute | public Expression2 substitute(int index, String newConstantExpression) {
return substitute(index, Expression2.constant(newConstantExpression));
} | java | public Expression2 substitute(int index, String newConstantExpression) {
return substitute(index, Expression2.constant(newConstantExpression));
} | [
"public",
"Expression2",
"substitute",
"(",
"int",
"index",
",",
"String",
"newConstantExpression",
")",
"{",
"return",
"substitute",
"(",
"index",
",",
"Expression2",
".",
"constant",
"(",
"newConstantExpression",
")",
")",
";",
"}"
] | Replaces the expression at {@code index} in this expression
with {@code newConstantExpression} (as a constant expression).
@param index
@param newConstantExpression
@return | [
"Replaces",
"the",
"expression",
"at",
"{",
"@code",
"index",
"}",
"in",
"this",
"expression",
"with",
"{",
"@code",
"newConstantExpression",
"}",
"(",
"as",
"a",
"constant",
"expression",
")",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/lambda2/Expression2.java#L217-L219 |
offbynull/coroutines | instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/DebugGenerators.java | DebugGenerators.debugPrint | public static InsnList debugPrint(InsnList text) {
Validate.notNull(text);
InsnList ret = new InsnList();
ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"));
ret.add(text);
ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false));
return ret;
} | java | public static InsnList debugPrint(InsnList text) {
Validate.notNull(text);
InsnList ret = new InsnList();
ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"));
ret.add(text);
ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false));
return ret;
} | [
"public",
"static",
"InsnList",
"debugPrint",
"(",
"InsnList",
"text",
")",
"{",
"Validate",
".",
"notNull",
"(",
"text",
")",
";",
"InsnList",
"ret",
"=",
"new",
"InsnList",
"(",
")",
";",
"ret",
".",
"add",
"(",
"new",
"FieldInsnNode",
"(",
"Opcodes",
".",
"GETSTATIC",
",",
"\"java/lang/System\"",
",",
"\"out\"",
",",
"\"Ljava/io/PrintStream;\"",
")",
")",
";",
"ret",
".",
"add",
"(",
"text",
")",
";",
"ret",
".",
"add",
"(",
"new",
"MethodInsnNode",
"(",
"Opcodes",
".",
"INVOKEVIRTUAL",
",",
"\"java/io/PrintStream\"",
",",
"\"println\"",
",",
"\"(Ljava/lang/String;)V\"",
",",
"false",
")",
")",
";",
"return",
"ret",
";",
"}"
] | Generates instructions for printing out a string using {@link System#out}. This is useful for debugging. For example, you
can print out lines around your instrumented code to make sure that what you think is being run is actually being run.
@param text debug text generation instruction list -- must leave a String on the stack
@return instructions to call System.out.println with a string constant
@throws NullPointerException if any argument is {@code null} | [
"Generates",
"instructions",
"for",
"printing",
"out",
"a",
"string",
"using",
"{"
] | train | https://github.com/offbynull/coroutines/blob/b1b83c293945f53a2f63fca8f15a53e88b796bf5/instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/DebugGenerators.java#L96-L106 |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java | ActionHistoryGrid.setColumnsSize | private void setColumnsSize(final double min, final double max, final String... columnPropertyIds) {
for (final String columnPropertyId : columnPropertyIds) {
getColumn(columnPropertyId).setMinimumWidth(min);
getColumn(columnPropertyId).setMaximumWidth(max);
}
} | java | private void setColumnsSize(final double min, final double max, final String... columnPropertyIds) {
for (final String columnPropertyId : columnPropertyIds) {
getColumn(columnPropertyId).setMinimumWidth(min);
getColumn(columnPropertyId).setMaximumWidth(max);
}
} | [
"private",
"void",
"setColumnsSize",
"(",
"final",
"double",
"min",
",",
"final",
"double",
"max",
",",
"final",
"String",
"...",
"columnPropertyIds",
")",
"{",
"for",
"(",
"final",
"String",
"columnPropertyId",
":",
"columnPropertyIds",
")",
"{",
"getColumn",
"(",
"columnPropertyId",
")",
".",
"setMinimumWidth",
"(",
"min",
")",
";",
"getColumn",
"(",
"columnPropertyId",
")",
".",
"setMaximumWidth",
"(",
"max",
")",
";",
"}",
"}"
] | Conveniently sets min- and max-width for a bunch of columns.
@param min
minimum width
@param max
maximum width
@param columnPropertyIds
all the columns the min and max should be set for. | [
"Conveniently",
"sets",
"min",
"-",
"and",
"max",
"-",
"width",
"for",
"a",
"bunch",
"of",
"columns",
"."
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java#L496-L501 |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapters.java | PowerAdapters.toListAdapter | @CheckResult
@NonNull
public static ListAdapter toListAdapter(@NonNull PowerAdapter powerAdapter) {
// HACK: We simply have to use a magic number here and hope we never exceed it.
// ListAdapter interface gives us no other choice, since it requires knowledge of all possible view types
// in advance, and a PowerAdapter cannot provide this.
// In practise, this means wastefully creating X ArrayLists in AbsListView, which isn't much compared to
// the memory overhead of a single View.
return new ListAdapterConverterAdapter(checkNotNull(powerAdapter, "powerAdapter"), 50);
} | java | @CheckResult
@NonNull
public static ListAdapter toListAdapter(@NonNull PowerAdapter powerAdapter) {
// HACK: We simply have to use a magic number here and hope we never exceed it.
// ListAdapter interface gives us no other choice, since it requires knowledge of all possible view types
// in advance, and a PowerAdapter cannot provide this.
// In practise, this means wastefully creating X ArrayLists in AbsListView, which isn't much compared to
// the memory overhead of a single View.
return new ListAdapterConverterAdapter(checkNotNull(powerAdapter, "powerAdapter"), 50);
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"static",
"ListAdapter",
"toListAdapter",
"(",
"@",
"NonNull",
"PowerAdapter",
"powerAdapter",
")",
"{",
"// HACK: We simply have to use a magic number here and hope we never exceed it.",
"// ListAdapter interface gives us no other choice, since it requires knowledge of all possible view types",
"// in advance, and a PowerAdapter cannot provide this.",
"// In practise, this means wastefully creating X ArrayLists in AbsListView, which isn't much compared to",
"// the memory overhead of a single View.",
"return",
"new",
"ListAdapterConverterAdapter",
"(",
"checkNotNull",
"(",
"powerAdapter",
",",
"\"powerAdapter\"",
")",
",",
"50",
")",
";",
"}"
] | Returns the specified {@link PowerAdapter} as a {@link ListAdapter}.
@param powerAdapter The adapter to be converted.
@return A list adapter that presents the same views as {@code powerAdapter}.
@see ListView#setAdapter(ListAdapter) | [
"Returns",
"the",
"specified",
"{"
] | train | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapters.java#L23-L32 |
google/error-prone-javac | src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java | ClassFileReader.newInstance | public static ClassFileReader newInstance(FileSystem fs, Path path) throws IOException {
return new DirectoryReader(fs, path);
} | java | public static ClassFileReader newInstance(FileSystem fs, Path path) throws IOException {
return new DirectoryReader(fs, path);
} | [
"public",
"static",
"ClassFileReader",
"newInstance",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"return",
"new",
"DirectoryReader",
"(",
"fs",
",",
"path",
")",
";",
"}"
] | Returns a ClassFileReader instance of a given FileSystem and path.
This method is used for reading classes from jrtfs. | [
"Returns",
"a",
"ClassFileReader",
"instance",
"of",
"a",
"given",
"FileSystem",
"and",
"path",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java#L92-L94 |
ops4j/org.ops4j.pax.web | pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/util/TypeUtil.java | TypeUtil.parseInt | public static int parseInt(byte[] b, int offset, int length, int base) {
int value = 0;
//CHECKSTYLE:OFF
if (length < 0) {
length = b.length - offset;
}
//CHECKSTYLE:ON
for (int i = 0; i < length; i++) {
char c = (char) (_0XFF & b[offset + i]);
int digit = c - '0';
if (digit < 0 || digit >= base || digit >= TEN) {
digit = TEN + c - 'A';
if (digit < TEN || digit >= base) {
digit = TEN + c - 'a';
}
}
if (digit < 0 || digit >= base) {
throw new NumberFormatException(new String(b, offset, length));
}
value = value * base + digit;
}
return value;
} | java | public static int parseInt(byte[] b, int offset, int length, int base) {
int value = 0;
//CHECKSTYLE:OFF
if (length < 0) {
length = b.length - offset;
}
//CHECKSTYLE:ON
for (int i = 0; i < length; i++) {
char c = (char) (_0XFF & b[offset + i]);
int digit = c - '0';
if (digit < 0 || digit >= base || digit >= TEN) {
digit = TEN + c - 'A';
if (digit < TEN || digit >= base) {
digit = TEN + c - 'a';
}
}
if (digit < 0 || digit >= base) {
throw new NumberFormatException(new String(b, offset, length));
}
value = value * base + digit;
}
return value;
} | [
"public",
"static",
"int",
"parseInt",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"offset",
",",
"int",
"length",
",",
"int",
"base",
")",
"{",
"int",
"value",
"=",
"0",
";",
"//CHECKSTYLE:OFF",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"length",
"=",
"b",
".",
"length",
"-",
"offset",
";",
"}",
"//CHECKSTYLE:ON",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"(",
"char",
")",
"(",
"_0XFF",
"&",
"b",
"[",
"offset",
"+",
"i",
"]",
")",
";",
"int",
"digit",
"=",
"c",
"-",
"'",
"'",
";",
"if",
"(",
"digit",
"<",
"0",
"||",
"digit",
">=",
"base",
"||",
"digit",
">=",
"TEN",
")",
"{",
"digit",
"=",
"TEN",
"+",
"c",
"-",
"'",
"'",
";",
"if",
"(",
"digit",
"<",
"TEN",
"||",
"digit",
">=",
"base",
")",
"{",
"digit",
"=",
"TEN",
"+",
"c",
"-",
"'",
"'",
";",
"}",
"}",
"if",
"(",
"digit",
"<",
"0",
"||",
"digit",
">=",
"base",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"new",
"String",
"(",
"b",
",",
"offset",
",",
"length",
")",
")",
";",
"}",
"value",
"=",
"value",
"*",
"base",
"+",
"digit",
";",
"}",
"return",
"value",
";",
"}"
] | Parse an int from a byte array of ascii characters. Negative numbers are
not handled.
@param b byte array
@param offset Offset within string
@param length Length of integer or -1 for remainder of string
@param base base of the integer
@return the parsed integer
@throws NumberFormatException if the array cannot be parsed into an integer | [
"Parse",
"an",
"int",
"from",
"a",
"byte",
"array",
"of",
"ascii",
"characters",
".",
"Negative",
"numbers",
"are",
"not",
"handled",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.web/blob/9ecf3676c1d316be0d43ea7fcfdc8f0defffc2a2/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/util/TypeUtil.java#L322-L347 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/RandomUtils.java | RandomUtils.nextInt | public static int nextInt(final int startInclusive, final int endExclusive) {
Validate.isTrue(endExclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endExclusive) {
return startInclusive;
}
return startInclusive + RANDOM.nextInt(endExclusive - startInclusive);
} | java | public static int nextInt(final int startInclusive, final int endExclusive) {
Validate.isTrue(endExclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endExclusive) {
return startInclusive;
}
return startInclusive + RANDOM.nextInt(endExclusive - startInclusive);
} | [
"public",
"static",
"int",
"nextInt",
"(",
"final",
"int",
"startInclusive",
",",
"final",
"int",
"endExclusive",
")",
"{",
"Validate",
".",
"isTrue",
"(",
"endExclusive",
">=",
"startInclusive",
",",
"\"Start value must be smaller or equal to end value.\"",
")",
";",
"Validate",
".",
"isTrue",
"(",
"startInclusive",
">=",
"0",
",",
"\"Both range values must be non-negative.\"",
")",
";",
"if",
"(",
"startInclusive",
"==",
"endExclusive",
")",
"{",
"return",
"startInclusive",
";",
"}",
"return",
"startInclusive",
"+",
"RANDOM",
".",
"nextInt",
"(",
"endExclusive",
"-",
"startInclusive",
")",
";",
"}"
] | <p>
Returns a random integer within the specified range.
</p>
@param startInclusive
the smallest value that can be returned, must be non-negative
@param endExclusive
the upper bound (not included)
@throws IllegalArgumentException
if {@code startInclusive > endExclusive} or if
{@code startInclusive} is negative
@return the random integer | [
"<p",
">",
"Returns",
"a",
"random",
"integer",
"within",
"the",
"specified",
"range",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/RandomUtils.java#L94-L104 |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FragmentTaskMessage.java | FragmentTaskMessage.addFragment | public void addFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet) {
addFragment(planHash, null, outputDepId, parameterSet);
} | java | public void addFragment(byte[] planHash, int outputDepId, ByteBuffer parameterSet) {
addFragment(planHash, null, outputDepId, parameterSet);
} | [
"public",
"void",
"addFragment",
"(",
"byte",
"[",
"]",
"planHash",
",",
"int",
"outputDepId",
",",
"ByteBuffer",
"parameterSet",
")",
"{",
"addFragment",
"(",
"planHash",
",",
"null",
",",
"outputDepId",
",",
"parameterSet",
")",
";",
"}"
] | Add a pre-planned fragment.
@param fragmentId
@param outputDepId
@param parameterSet | [
"Add",
"a",
"pre",
"-",
"planned",
"fragment",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FragmentTaskMessage.java#L289-L291 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java | MultiFileJournalHelper.parseParametersForPollingInterval | static long parseParametersForPollingInterval(Map<String, String> parameters)
throws JournalException {
String intervalString =
parameters.get(PARAMETER_FOLLOW_POLLING_INTERVAL);
if (intervalString == null) {
intervalString = DEFAULT_FOLLOW_POLLING_INTERVAL;
}
Pattern p = Pattern.compile("([0-9]+)([HM]?)");
Matcher m = p.matcher(intervalString);
if (!m.matches()) {
throw new JournalException("Parameter '"
+ PARAMETER_FOLLOW_POLLING_INTERVAL
+ "' must be an positive integer number of seconds, "
+ "optionally followed by 'H'(hours), or 'M'(minutes)");
}
long interval = Long.parseLong(m.group(1)) * 1000;
String factor = m.group(2);
if ("H".equals(factor)) {
interval *= 60 * 60;
} else if ("M".equals(factor)) {
interval *= 60;
}
return interval;
} | java | static long parseParametersForPollingInterval(Map<String, String> parameters)
throws JournalException {
String intervalString =
parameters.get(PARAMETER_FOLLOW_POLLING_INTERVAL);
if (intervalString == null) {
intervalString = DEFAULT_FOLLOW_POLLING_INTERVAL;
}
Pattern p = Pattern.compile("([0-9]+)([HM]?)");
Matcher m = p.matcher(intervalString);
if (!m.matches()) {
throw new JournalException("Parameter '"
+ PARAMETER_FOLLOW_POLLING_INTERVAL
+ "' must be an positive integer number of seconds, "
+ "optionally followed by 'H'(hours), or 'M'(minutes)");
}
long interval = Long.parseLong(m.group(1)) * 1000;
String factor = m.group(2);
if ("H".equals(factor)) {
interval *= 60 * 60;
} else if ("M".equals(factor)) {
interval *= 60;
}
return interval;
} | [
"static",
"long",
"parseParametersForPollingInterval",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"throws",
"JournalException",
"{",
"String",
"intervalString",
"=",
"parameters",
".",
"get",
"(",
"PARAMETER_FOLLOW_POLLING_INTERVAL",
")",
";",
"if",
"(",
"intervalString",
"==",
"null",
")",
"{",
"intervalString",
"=",
"DEFAULT_FOLLOW_POLLING_INTERVAL",
";",
"}",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"\"([0-9]+)([HM]?)\"",
")",
";",
"Matcher",
"m",
"=",
"p",
".",
"matcher",
"(",
"intervalString",
")",
";",
"if",
"(",
"!",
"m",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"Parameter '\"",
"+",
"PARAMETER_FOLLOW_POLLING_INTERVAL",
"+",
"\"' must be an positive integer number of seconds, \"",
"+",
"\"optionally followed by 'H'(hours), or 'M'(minutes)\"",
")",
";",
"}",
"long",
"interval",
"=",
"Long",
".",
"parseLong",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"*",
"1000",
";",
"String",
"factor",
"=",
"m",
".",
"group",
"(",
"2",
")",
";",
"if",
"(",
"\"H\"",
".",
"equals",
"(",
"factor",
")",
")",
"{",
"interval",
"*=",
"60",
"*",
"60",
";",
"}",
"else",
"if",
"(",
"\"M\"",
".",
"equals",
"(",
"factor",
")",
")",
"{",
"interval",
"*=",
"60",
";",
"}",
"return",
"interval",
";",
"}"
] | Find the polling interval that we will choose when checking for new
journal files to appear. | [
"Find",
"the",
"polling",
"interval",
"that",
"we",
"will",
"choose",
"when",
"checking",
"for",
"new",
"journal",
"files",
"to",
"appear",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java#L50-L73 |
Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.matches | public static boolean matches(Class<? extends Annotation> anno, String consName) {
return VALIDATORS.get(anno).equals(consName);
} | java | public static boolean matches(Class<? extends Annotation> anno, String consName) {
return VALIDATORS.get(anno).equals(consName);
} | [
"public",
"static",
"boolean",
"matches",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"anno",
",",
"String",
"consName",
")",
"{",
"return",
"VALIDATORS",
".",
"get",
"(",
"anno",
")",
".",
"equals",
"(",
"consName",
")",
";",
"}"
] | Verifies that the given annotation type corresponds to a known constraint.
@param anno annotation type
@param consName constraint name
@return true if known | [
"Verifies",
"that",
"the",
"given",
"annotation",
"type",
"corresponds",
"to",
"a",
"known",
"constraint",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L144-L146 |
sundrio/sundrio | annotations/builder/src/main/java/io/sundr/builder/internal/functions/ToPojo.java | ToPojo.readObjectValue | private static String readObjectValue(String ref, TypeDef source, Property property) {
return indent(ref) + "("+property.getTypeRef().toString()+")(" + ref + " instanceof Map ? ((Map)" + ref + ").getOrDefault(\"" + getterOf(source, property).getName() + "\", " + getDefaultValue(property)+") : "+ getDefaultValue(property)+")";
} | java | private static String readObjectValue(String ref, TypeDef source, Property property) {
return indent(ref) + "("+property.getTypeRef().toString()+")(" + ref + " instanceof Map ? ((Map)" + ref + ").getOrDefault(\"" + getterOf(source, property).getName() + "\", " + getDefaultValue(property)+") : "+ getDefaultValue(property)+")";
} | [
"private",
"static",
"String",
"readObjectValue",
"(",
"String",
"ref",
",",
"TypeDef",
"source",
",",
"Property",
"property",
")",
"{",
"return",
"indent",
"(",
"ref",
")",
"+",
"\"(\"",
"+",
"property",
".",
"getTypeRef",
"(",
")",
".",
"toString",
"(",
")",
"+",
"\")(\"",
"+",
"ref",
"+",
"\" instanceof Map ? ((Map)\"",
"+",
"ref",
"+",
"\").getOrDefault(\\\"\"",
"+",
"getterOf",
"(",
"source",
",",
"property",
")",
".",
"getName",
"(",
")",
"+",
"\"\\\", \"",
"+",
"getDefaultValue",
"(",
"property",
")",
"+",
"\") : \"",
"+",
"getDefaultValue",
"(",
"property",
")",
"+",
"\")\"",
";",
"}"
] | Returns the string representation of the code that reads an object property from a reference using a getter.
@param ref The reference.
@param source The type of the reference.
@param property The property to read.
@return The code. | [
"Returns",
"the",
"string",
"representation",
"of",
"the",
"code",
"that",
"reads",
"an",
"object",
"property",
"from",
"a",
"reference",
"using",
"a",
"getter",
"."
] | train | https://github.com/sundrio/sundrio/blob/4e38368f4db0d950f7c41a8c75e15b0baff1f69a/annotations/builder/src/main/java/io/sundr/builder/internal/functions/ToPojo.java#L756-L758 |
tommyettinger/RegExodus | src/main/java/regexodus/ds/CharCharMap.java | CharCharMap.arraySize | public static int arraySize(final int expected, final float f) {
final long s = Math.max(2, HashCommon.nextPowerOfTwo((long) Math.ceil(expected / f)));
if (s > (1 << 30))
throw new IllegalArgumentException("Too large (" + expected + " expected elements with load factor " + f + ")");
return (int) s;
} | java | public static int arraySize(final int expected, final float f) {
final long s = Math.max(2, HashCommon.nextPowerOfTwo((long) Math.ceil(expected / f)));
if (s > (1 << 30))
throw new IllegalArgumentException("Too large (" + expected + " expected elements with load factor " + f + ")");
return (int) s;
} | [
"public",
"static",
"int",
"arraySize",
"(",
"final",
"int",
"expected",
",",
"final",
"float",
"f",
")",
"{",
"final",
"long",
"s",
"=",
"Math",
".",
"max",
"(",
"2",
",",
"HashCommon",
".",
"nextPowerOfTwo",
"(",
"(",
"long",
")",
"Math",
".",
"ceil",
"(",
"expected",
"/",
"f",
")",
")",
")",
";",
"if",
"(",
"s",
">",
"(",
"1",
"<<",
"30",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Too large (\"",
"+",
"expected",
"+",
"\" expected elements with load factor \"",
"+",
"f",
"+",
"\")\"",
")",
";",
"return",
"(",
"int",
")",
"s",
";",
"}"
] | Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>.
@param expected the expected number of elements in a hash table.
@param f the load factor.
@return the minimum possible size for a backing array.
@throws IllegalArgumentException if the necessary size is larger than 2<sup>30</sup>. | [
"Returns",
"the",
"least",
"power",
"of",
"two",
"smaller",
"than",
"or",
"equal",
"to",
"2<sup",
">",
"30<",
"/",
"sup",
">",
"and",
"larger",
"than",
"or",
"equal",
"to",
"<code",
">",
"Math",
".",
"ceil",
"(",
"expected",
"/",
"f",
")",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/ds/CharCharMap.java#L465-L470 |
fedups/com.obdobion.algebrain | src/main/java/com/obdobion/algebrain/operator/OpChain.java | OpChain.resolve | @Override
public void resolve(final ValueStack values) throws Exception
{
if (values.size() < 2)
throw new ParseException("missing operand", 0);
try
{
final Object rightSideResult = values.popWhatever();
values.popWhatever();
values.push(rightSideResult);
} catch (final ParseException e)
{
e.fillInStackTrace();
throw new Exception(toString() + "; " + e.getMessage(), e);
}
} | java | @Override
public void resolve(final ValueStack values) throws Exception
{
if (values.size() < 2)
throw new ParseException("missing operand", 0);
try
{
final Object rightSideResult = values.popWhatever();
values.popWhatever();
values.push(rightSideResult);
} catch (final ParseException e)
{
e.fillInStackTrace();
throw new Exception(toString() + "; " + e.getMessage(), e);
}
} | [
"@",
"Override",
"public",
"void",
"resolve",
"(",
"final",
"ValueStack",
"values",
")",
"throws",
"Exception",
"{",
"if",
"(",
"values",
".",
"size",
"(",
")",
"<",
"2",
")",
"throw",
"new",
"ParseException",
"(",
"\"missing operand\"",
",",
"0",
")",
";",
"try",
"{",
"final",
"Object",
"rightSideResult",
"=",
"values",
".",
"popWhatever",
"(",
")",
";",
"values",
".",
"popWhatever",
"(",
")",
";",
"values",
".",
"push",
"(",
"rightSideResult",
")",
";",
"}",
"catch",
"(",
"final",
"ParseException",
"e",
")",
"{",
"e",
".",
"fillInStackTrace",
"(",
")",
";",
"throw",
"new",
"Exception",
"(",
"toString",
"(",
")",
"+",
"\"; \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | {@inheritDoc}
This is an intermediate result. Its result is not directly returned.
Assign the value to a variable if you need access to it later. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/fedups/com.obdobion.algebrain/blob/d0adaa9fbbba907bdcf820961e9058b0d2b15a8a/src/main/java/com/obdobion/algebrain/operator/OpChain.java#L71-L88 |
openskynetwork/java-adsb | src/main/java/org/opensky/libadsb/Position.java | Position.fromECEF | public static Position fromECEF (double x, double y, double z) {
double p = sqrt(x*x + y*y);
double th = atan2(a * z, b * p);
double lon = atan2(y, x);
double lat = atan2(
(z + (a*a - b*b) / (b*b) * b * pow(sin(th), 3)),
p - e2 * a * pow(cos(th), 3));
double N = a / sqrt(1 - pow(sqrt(e2) * sin(lat), 2));
double alt = p / cos(lat) - N;
// correct for numerical instability in altitude near exact poles:
// after this correction, error is about 2 millimeters, which is about
// the same as the numerical precision of the overall function
if (abs(x) < 1 & abs(y) < 1)
alt = abs(z) - b;
return new Position(toDegrees(lon), toDegrees(lat), tools.meters2Feet(alt));
} | java | public static Position fromECEF (double x, double y, double z) {
double p = sqrt(x*x + y*y);
double th = atan2(a * z, b * p);
double lon = atan2(y, x);
double lat = atan2(
(z + (a*a - b*b) / (b*b) * b * pow(sin(th), 3)),
p - e2 * a * pow(cos(th), 3));
double N = a / sqrt(1 - pow(sqrt(e2) * sin(lat), 2));
double alt = p / cos(lat) - N;
// correct for numerical instability in altitude near exact poles:
// after this correction, error is about 2 millimeters, which is about
// the same as the numerical precision of the overall function
if (abs(x) < 1 & abs(y) < 1)
alt = abs(z) - b;
return new Position(toDegrees(lon), toDegrees(lat), tools.meters2Feet(alt));
} | [
"public",
"static",
"Position",
"fromECEF",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"double",
"p",
"=",
"sqrt",
"(",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
")",
";",
"double",
"th",
"=",
"atan2",
"(",
"a",
"*",
"z",
",",
"b",
"*",
"p",
")",
";",
"double",
"lon",
"=",
"atan2",
"(",
"y",
",",
"x",
")",
";",
"double",
"lat",
"=",
"atan2",
"(",
"(",
"z",
"+",
"(",
"a",
"*",
"a",
"-",
"b",
"*",
"b",
")",
"/",
"(",
"b",
"*",
"b",
")",
"*",
"b",
"*",
"pow",
"(",
"sin",
"(",
"th",
")",
",",
"3",
")",
")",
",",
"p",
"-",
"e2",
"*",
"a",
"*",
"pow",
"(",
"cos",
"(",
"th",
")",
",",
"3",
")",
")",
";",
"double",
"N",
"=",
"a",
"/",
"sqrt",
"(",
"1",
"-",
"pow",
"(",
"sqrt",
"(",
"e2",
")",
"*",
"sin",
"(",
"lat",
")",
",",
"2",
")",
")",
";",
"double",
"alt",
"=",
"p",
"/",
"cos",
"(",
"lat",
")",
"-",
"N",
";",
"// correct for numerical instability in altitude near exact poles:",
"// after this correction, error is about 2 millimeters, which is about",
"// the same as the numerical precision of the overall function",
"if",
"(",
"abs",
"(",
"x",
")",
"<",
"1",
"&",
"abs",
"(",
"y",
")",
"<",
"1",
")",
"alt",
"=",
"abs",
"(",
"z",
")",
"-",
"b",
";",
"return",
"new",
"Position",
"(",
"toDegrees",
"(",
"lon",
")",
",",
"toDegrees",
"(",
"lat",
")",
",",
"tools",
".",
"meters2Feet",
"(",
"alt",
")",
")",
";",
"}"
] | Converts a cartesian earth-centered earth-fixed coordinate into an WGS84 LLA position
@param x coordinate in meters
@param y coordinate in meters
@param z coordinate in meters
@return a position object representing the WGS84 position | [
"Converts",
"a",
"cartesian",
"earth",
"-",
"centered",
"earth",
"-",
"fixed",
"coordinate",
"into",
"an",
"WGS84",
"LLA",
"position"
] | train | https://github.com/openskynetwork/java-adsb/blob/01d497d3e74ad10063ab443ab583e9c8653a8b8d/src/main/java/org/opensky/libadsb/Position.java#L146-L164 |
alkacon/opencms-core | src/org/opencms/util/CmsFileUtil.java | CmsFileUtil.formatFilesize | public static String formatFilesize(long filesize, Locale locale) {
String result;
filesize = Math.abs(filesize);
if (Math.abs(filesize) < 1024) {
result = Messages.get().getBundle(locale).key(Messages.GUI_FILEUTIL_FILESIZE_BYTES_1, new Long(filesize));
} else if (Math.abs(filesize) < 1048576) {
// 1048576 = 1024.0 * 1024.0
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_KBYTES_1,
new Double(filesize / 1024.0));
} else if (Math.abs(filesize) < 1073741824) {
// 1024.0^3 = 1073741824
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_MBYTES_1,
new Double(filesize / 1048576.0));
} else {
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_GBYTES_1,
new Double(filesize / 1073741824.0));
}
return result;
} | java | public static String formatFilesize(long filesize, Locale locale) {
String result;
filesize = Math.abs(filesize);
if (Math.abs(filesize) < 1024) {
result = Messages.get().getBundle(locale).key(Messages.GUI_FILEUTIL_FILESIZE_BYTES_1, new Long(filesize));
} else if (Math.abs(filesize) < 1048576) {
// 1048576 = 1024.0 * 1024.0
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_KBYTES_1,
new Double(filesize / 1024.0));
} else if (Math.abs(filesize) < 1073741824) {
// 1024.0^3 = 1073741824
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_MBYTES_1,
new Double(filesize / 1048576.0));
} else {
result = Messages.get().getBundle(locale).key(
Messages.GUI_FILEUTIL_FILESIZE_GBYTES_1,
new Double(filesize / 1073741824.0));
}
return result;
} | [
"public",
"static",
"String",
"formatFilesize",
"(",
"long",
"filesize",
",",
"Locale",
"locale",
")",
"{",
"String",
"result",
";",
"filesize",
"=",
"Math",
".",
"abs",
"(",
"filesize",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"filesize",
")",
"<",
"1024",
")",
"{",
"result",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
"locale",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_FILEUTIL_FILESIZE_BYTES_1",
",",
"new",
"Long",
"(",
"filesize",
")",
")",
";",
"}",
"else",
"if",
"(",
"Math",
".",
"abs",
"(",
"filesize",
")",
"<",
"1048576",
")",
"{",
"// 1048576 = 1024.0 * 1024.0",
"result",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
"locale",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_FILEUTIL_FILESIZE_KBYTES_1",
",",
"new",
"Double",
"(",
"filesize",
"/",
"1024.0",
")",
")",
";",
"}",
"else",
"if",
"(",
"Math",
".",
"abs",
"(",
"filesize",
")",
"<",
"1073741824",
")",
"{",
"// 1024.0^3 = 1073741824",
"result",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
"locale",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_FILEUTIL_FILESIZE_MBYTES_1",
",",
"new",
"Double",
"(",
"filesize",
"/",
"1048576.0",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
"locale",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_FILEUTIL_FILESIZE_GBYTES_1",
",",
"new",
"Double",
"(",
"filesize",
"/",
"1073741824.0",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Returns the formatted filesize to Bytes, KB, MB or GB depending on the given value.<p>
@param filesize in bytes
@param locale the locale of the current OpenCms user or the System's default locale if the first choice
is not at hand.
@return the formatted filesize to Bytes, KB, MB or GB depending on the given value | [
"Returns",
"the",
"formatted",
"filesize",
"to",
"Bytes",
"KB",
"MB",
"or",
"GB",
"depending",
"on",
"the",
"given",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsFileUtil.java#L229-L252 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/inbound/HttpInboundServiceContextImpl.java | HttpInboundServiceContextImpl.finishRawResponseMessage | @Override
public VirtualConnection finishRawResponseMessage(WsByteBuffer[] body, InterChannelCallback cb, boolean bForce) throws MessageSentException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "finishRawResponseMessage(async)");
}
setRawBody(true);
VirtualConnection vc = finishResponseMessage(body, cb, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "finishRawResponseMessage(async): " + vc);
}
return vc;
} | java | @Override
public VirtualConnection finishRawResponseMessage(WsByteBuffer[] body, InterChannelCallback cb, boolean bForce) throws MessageSentException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "finishRawResponseMessage(async)");
}
setRawBody(true);
VirtualConnection vc = finishResponseMessage(body, cb, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "finishRawResponseMessage(async): " + vc);
}
return vc;
} | [
"@",
"Override",
"public",
"VirtualConnection",
"finishRawResponseMessage",
"(",
"WsByteBuffer",
"[",
"]",
"body",
",",
"InterChannelCallback",
"cb",
",",
"boolean",
"bForce",
")",
"throws",
"MessageSentException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"finishRawResponseMessage(async)\"",
")",
";",
"}",
"setRawBody",
"(",
"true",
")",
";",
"VirtualConnection",
"vc",
"=",
"finishResponseMessage",
"(",
"body",
",",
"cb",
",",
"bForce",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"finishRawResponseMessage(async): \"",
"+",
"vc",
")",
";",
"}",
"return",
"vc",
";",
"}"
] | Finish sending the response message asynchronously. The body buffers can
be null if there is no more actual body. This method will avoid any
body modifications, such as compression or chunked-encoding. If the
headers have not been sent yet, then they will be prepended to the input
data.
<p>
If the asynchronous write can be done immediately, then this will return a
VirtualConnection and the caller's callback will not be used. If this
returns null, then the callback will be used when complete.
<p>
The force flag allows the caller to force the asynchronous communication
such that the callback is always used.
@param body
-- null if there is no more body data
@param cb
@param bForce
@return VirtualConnection
@throws MessageSentException
-- if a finishMessage API was already used | [
"Finish",
"sending",
"the",
"response",
"message",
"asynchronously",
".",
"The",
"body",
"buffers",
"can",
"be",
"null",
"if",
"there",
"is",
"no",
"more",
"actual",
"body",
".",
"This",
"method",
"will",
"avoid",
"any",
"body",
"modifications",
"such",
"as",
"compression",
"or",
"chunked",
"-",
"encoding",
".",
"If",
"the",
"headers",
"have",
"not",
"been",
"sent",
"yet",
"then",
"they",
"will",
"be",
"prepended",
"to",
"the",
"input",
"data",
".",
"<p",
">",
"If",
"the",
"asynchronous",
"write",
"can",
"be",
"done",
"immediately",
"then",
"this",
"will",
"return",
"a",
"VirtualConnection",
"and",
"the",
"caller",
"s",
"callback",
"will",
"not",
"be",
"used",
".",
"If",
"this",
"returns",
"null",
"then",
"the",
"callback",
"will",
"be",
"used",
"when",
"complete",
".",
"<p",
">",
"The",
"force",
"flag",
"allows",
"the",
"caller",
"to",
"force",
"the",
"asynchronous",
"communication",
"such",
"that",
"the",
"callback",
"is",
"always",
"used",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/inbound/HttpInboundServiceContextImpl.java#L1184-L1195 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java | JDBCRepositoryBuilder.setAutoVersioningEnabled | public void setAutoVersioningEnabled(boolean enabled, String className) {
if (mAutoVersioningMap == null) {
mAutoVersioningMap = new HashMap<String, Boolean>();
}
mAutoVersioningMap.put(className, enabled);
} | java | public void setAutoVersioningEnabled(boolean enabled, String className) {
if (mAutoVersioningMap == null) {
mAutoVersioningMap = new HashMap<String, Boolean>();
}
mAutoVersioningMap.put(className, enabled);
} | [
"public",
"void",
"setAutoVersioningEnabled",
"(",
"boolean",
"enabled",
",",
"String",
"className",
")",
"{",
"if",
"(",
"mAutoVersioningMap",
"==",
"null",
")",
"{",
"mAutoVersioningMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Boolean",
">",
"(",
")",
";",
"}",
"mAutoVersioningMap",
".",
"put",
"(",
"className",
",",
"enabled",
")",
";",
"}"
] | By default, JDBCRepository assumes that {@link
com.amazon.carbonado.Version version numbers} are initialized and
incremented by triggers installed on the database. Enabling automatic
versioning here causes the JDBCRepository to manage these operations
itself.
@param enabled true to enable, false to disable
@param className name of Storable type to enable automatic version
management on; pass null to enable all
@since 1.2 | [
"By",
"default",
"JDBCRepository",
"assumes",
"that",
"{",
"@link",
"com",
".",
"amazon",
".",
"carbonado",
".",
"Version",
"version",
"numbers",
"}",
"are",
"initialized",
"and",
"incremented",
"by",
"triggers",
"installed",
"on",
"the",
"database",
".",
"Enabling",
"automatic",
"versioning",
"here",
"causes",
"the",
"JDBCRepository",
"to",
"manage",
"these",
"operations",
"itself",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java#L329-L334 |
thinkaurelius/titan | titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/Mutation.java | Mutation.isConsolidated | public<V> boolean isConsolidated(Function<E,V> convertAdds, Function<K,V> convertDels) {
int delBefore = getDeletions().size();
consolidate(convertAdds,convertDels);
return getDeletions().size()==delBefore;
} | java | public<V> boolean isConsolidated(Function<E,V> convertAdds, Function<K,V> convertDels) {
int delBefore = getDeletions().size();
consolidate(convertAdds,convertDels);
return getDeletions().size()==delBefore;
} | [
"public",
"<",
"V",
">",
"boolean",
"isConsolidated",
"(",
"Function",
"<",
"E",
",",
"V",
">",
"convertAdds",
",",
"Function",
"<",
"K",
",",
"V",
">",
"convertDels",
")",
"{",
"int",
"delBefore",
"=",
"getDeletions",
"(",
")",
".",
"size",
"(",
")",
";",
"consolidate",
"(",
"convertAdds",
",",
"convertDels",
")",
";",
"return",
"getDeletions",
"(",
")",
".",
"size",
"(",
")",
"==",
"delBefore",
";",
"}"
] | Checks whether this mutation is consolidated in the sense of {@link #consolidate(com.google.common.base.Function, com.google.common.base.Function)}.
This should only be used in assertions and tests due to the performance penalty.
@param convertAdds
@param convertDels
@param <V>
@return | [
"Checks",
"whether",
"this",
"mutation",
"is",
"consolidated",
"in",
"the",
"sense",
"of",
"{",
"@link",
"#consolidate",
"(",
"com",
".",
"google",
".",
"common",
".",
"base",
".",
"Function",
"com",
".",
"google",
".",
"common",
".",
"base",
".",
"Function",
")",
"}",
".",
"This",
"should",
"only",
"be",
"used",
"in",
"assertions",
"and",
"tests",
"due",
"to",
"the",
"performance",
"penalty",
"."
] | train | https://github.com/thinkaurelius/titan/blob/ee226e52415b8bf43b700afac75fa5b9767993a5/titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/Mutation.java#L158-L162 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.readString | public static String readString(String filePath, String charsetName) {
return readString(getPath(filePath), charsetName);
} | java | public static String readString(String filePath, String charsetName) {
return readString(getPath(filePath), charsetName);
} | [
"public",
"static",
"String",
"readString",
"(",
"String",
"filePath",
",",
"String",
"charsetName",
")",
"{",
"return",
"readString",
"(",
"getPath",
"(",
"filePath",
")",
",",
"charsetName",
")",
";",
"}"
] | Read string string.
@param filePath the file path
@param charsetName the charset name
@return the string | [
"Read",
"string",
"string",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L173-L175 |
Red5/red5-io | src/main/java/org/red5/io/utils/BufferUtils.java | BufferUtils.writeMediumInt | public static void writeMediumInt(IoBuffer out, int value) {
byte[] bytes = new byte[3];
bytes[0] = (byte) ((value >>> 16) & 0x000000FF);
bytes[1] = (byte) ((value >>> 8) & 0x000000FF);
bytes[2] = (byte) (value & 0x00FF);
out.put(bytes);
} | java | public static void writeMediumInt(IoBuffer out, int value) {
byte[] bytes = new byte[3];
bytes[0] = (byte) ((value >>> 16) & 0x000000FF);
bytes[1] = (byte) ((value >>> 8) & 0x000000FF);
bytes[2] = (byte) (value & 0x00FF);
out.put(bytes);
} | [
"public",
"static",
"void",
"writeMediumInt",
"(",
"IoBuffer",
"out",
",",
"int",
"value",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"3",
"]",
";",
"bytes",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"16",
")",
"&",
"0x000000FF",
")",
";",
"bytes",
"[",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"8",
")",
"&",
"0x000000FF",
")",
";",
"bytes",
"[",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
"&",
"0x00FF",
")",
";",
"out",
".",
"put",
"(",
"bytes",
")",
";",
"}"
] | Writes a Medium Int to the output buffer
@param out
Container to write to
@param value
Integer to write | [
"Writes",
"a",
"Medium",
"Int",
"to",
"the",
"output",
"buffer"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/utils/BufferUtils.java#L44-L50 |
JodaOrg/joda-time | src/main/java/org/joda/time/field/PreciseDateTimeField.java | PreciseDateTimeField.addWrapField | public long addWrapField(long instant, int amount) {
int thisValue = get(instant);
int wrappedValue = FieldUtils.getWrappedValue
(thisValue, amount, getMinimumValue(), getMaximumValue());
// copy code from set() to avoid repeat call to get()
return instant + (wrappedValue - thisValue) * getUnitMillis();
} | java | public long addWrapField(long instant, int amount) {
int thisValue = get(instant);
int wrappedValue = FieldUtils.getWrappedValue
(thisValue, amount, getMinimumValue(), getMaximumValue());
// copy code from set() to avoid repeat call to get()
return instant + (wrappedValue - thisValue) * getUnitMillis();
} | [
"public",
"long",
"addWrapField",
"(",
"long",
"instant",
",",
"int",
"amount",
")",
"{",
"int",
"thisValue",
"=",
"get",
"(",
"instant",
")",
";",
"int",
"wrappedValue",
"=",
"FieldUtils",
".",
"getWrappedValue",
"(",
"thisValue",
",",
"amount",
",",
"getMinimumValue",
"(",
")",
",",
"getMaximumValue",
"(",
")",
")",
";",
"// copy code from set() to avoid repeat call to get()",
"return",
"instant",
"+",
"(",
"wrappedValue",
"-",
"thisValue",
")",
"*",
"getUnitMillis",
"(",
")",
";",
"}"
] | Add to the component of the specified time instant, wrapping around
within that component if necessary.
@param instant the milliseconds from 1970-01-01T00:00:00Z to add to
@param amount the amount of units to add (can be negative).
@return the updated time instant. | [
"Add",
"to",
"the",
"component",
"of",
"the",
"specified",
"time",
"instant",
"wrapping",
"around",
"within",
"that",
"component",
"if",
"necessary",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/PreciseDateTimeField.java#L95-L101 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Flowable.java | Flowable.switchMapSingle | @CheckReturnValue
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> switchMapSingle(@NonNull Function<? super T, ? extends SingleSource<? extends R>> mapper) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new FlowableSwitchMapSingle<T, R>(this, mapper, false));
} | java | @CheckReturnValue
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> switchMapSingle(@NonNull Function<? super T, ? extends SingleSource<? extends R>> mapper) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new FlowableSwitchMapSingle<T, R>(this, mapper, false));
} | [
"@",
"CheckReturnValue",
"@",
"BackpressureSupport",
"(",
"BackpressureKind",
".",
"UNBOUNDED_IN",
")",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"<",
"R",
">",
"Flowable",
"<",
"R",
">",
"switchMapSingle",
"(",
"@",
"NonNull",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"SingleSource",
"<",
"?",
"extends",
"R",
">",
">",
"mapper",
")",
"{",
"ObjectHelper",
".",
"requireNonNull",
"(",
"mapper",
",",
"\"mapper is null\"",
")",
";",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"FlowableSwitchMapSingle",
"<",
"T",
",",
"R",
">",
"(",
"this",
",",
"mapper",
",",
"false",
")",
")",
";",
"}"
] | Maps the upstream items into {@link SingleSource}s and switches (subscribes) to the newer ones
while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one
while failing immediately if this {@code Flowable} or any of the
active inner {@code SingleSource}s fail.
<p>
<img width="640" height="350" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/switchMap.png" alt="">
<dl>
<dt><b>Backpressure:</b></dt>
<dd>The operator honors backpressure from downstream. The main {@code Flowable} is consumed in an
unbounded manner (i.e., without backpressure).</dd>
<dt><b>Scheduler:</b></dt>
<dd>{@code switchMapSingle} does not operate by default on a particular {@link Scheduler}.</dd>
<dt><b>Error handling:</b></dt>
<dd>This operator terminates with an {@code onError} if this {@code Flowable} or any of
the inner {@code SingleSource}s fail while they are active. When this happens concurrently, their
individual {@code Throwable} errors may get combined and emitted as a single
{@link io.reactivex.exceptions.CompositeException CompositeException}. Otherwise, a late
(i.e., inactive or switched out) {@code onError} from this {@code Flowable} or from any of
the inner {@code SingleSource}s will be forwarded to the global error handler via
{@link io.reactivex.plugins.RxJavaPlugins#onError(Throwable)} as
{@link io.reactivex.exceptions.UndeliverableException UndeliverableException}</dd>
</dl>
<p>History: 2.1.11 - experimental
@param <R> the output value type
@param mapper the function called with the current upstream event and should
return a {@code SingleSource} to replace the current active inner source
and get subscribed to.
@return the new Flowable instance
@see #switchMapSingle(Function)
@since 2.2 | [
"Maps",
"the",
"upstream",
"items",
"into",
"{"
] | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Flowable.java#L14987-L14993 |
banq/jdonframework | src/main/java/com/jdon/util/UtilDateTime.java | UtilDateTime.toSqlTime | public static java.sql.Time toSqlTime(int hour, int minute, int second) {
java.util.Date newDate = toDate(0, 0, 0, hour, minute, second);
if (newDate != null)
return new java.sql.Time(newDate.getTime());
else
return null;
} | java | public static java.sql.Time toSqlTime(int hour, int minute, int second) {
java.util.Date newDate = toDate(0, 0, 0, hour, minute, second);
if (newDate != null)
return new java.sql.Time(newDate.getTime());
else
return null;
} | [
"public",
"static",
"java",
".",
"sql",
".",
"Time",
"toSqlTime",
"(",
"int",
"hour",
",",
"int",
"minute",
",",
"int",
"second",
")",
"{",
"java",
".",
"util",
".",
"Date",
"newDate",
"=",
"toDate",
"(",
"0",
",",
"0",
",",
"0",
",",
"hour",
",",
"minute",
",",
"second",
")",
";",
"if",
"(",
"newDate",
"!=",
"null",
")",
"return",
"new",
"java",
".",
"sql",
".",
"Time",
"(",
"newDate",
".",
"getTime",
"(",
")",
")",
";",
"else",
"return",
"null",
";",
"}"
] | Makes a java.sql.Time from separate ints for hour, minute, and second.
@param hour
The hour int
@param minute
The minute int
@param second
The second int
@return A java.sql.Time made from separate ints for hour, minute, and
second. | [
"Makes",
"a",
"java",
".",
"sql",
".",
"Time",
"from",
"separate",
"ints",
"for",
"hour",
"minute",
"and",
"second",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/UtilDateTime.java#L195-L202 |
attribyte/wpdb | src/main/java/org/attribyte/wp/db/DB.java | DB.touchPost | public void touchPost(final long postId, final TimeZone tz) throws SQLException {
if(postId < 1L) {
throw new SQLException("The post id must be specified for update");
}
long modifiedTimestamp = System.currentTimeMillis();
int offset = tz.getOffset(modifiedTimestamp);
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.updatePostTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(updatePostModifiedSQL);
stmt.setTimestamp(1, new Timestamp(modifiedTimestamp));
stmt.setTimestamp(2, new Timestamp(modifiedTimestamp - offset));
stmt.setLong(3, postId);
stmt.executeUpdate();
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | java | public void touchPost(final long postId, final TimeZone tz) throws SQLException {
if(postId < 1L) {
throw new SQLException("The post id must be specified for update");
}
long modifiedTimestamp = System.currentTimeMillis();
int offset = tz.getOffset(modifiedTimestamp);
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.updatePostTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(updatePostModifiedSQL);
stmt.setTimestamp(1, new Timestamp(modifiedTimestamp));
stmt.setTimestamp(2, new Timestamp(modifiedTimestamp - offset));
stmt.setLong(3, postId);
stmt.executeUpdate();
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | [
"public",
"void",
"touchPost",
"(",
"final",
"long",
"postId",
",",
"final",
"TimeZone",
"tz",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"postId",
"<",
"1L",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"The post id must be specified for update\"",
")",
";",
"}",
"long",
"modifiedTimestamp",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"int",
"offset",
"=",
"tz",
".",
"getOffset",
"(",
"modifiedTimestamp",
")",
";",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"Timer",
".",
"Context",
"ctx",
"=",
"metrics",
".",
"updatePostTimer",
".",
"time",
"(",
")",
";",
"try",
"{",
"conn",
"=",
"connectionSupplier",
".",
"getConnection",
"(",
")",
";",
"stmt",
"=",
"conn",
".",
"prepareStatement",
"(",
"updatePostModifiedSQL",
")",
";",
"stmt",
".",
"setTimestamp",
"(",
"1",
",",
"new",
"Timestamp",
"(",
"modifiedTimestamp",
")",
")",
";",
"stmt",
".",
"setTimestamp",
"(",
"2",
",",
"new",
"Timestamp",
"(",
"modifiedTimestamp",
"-",
"offset",
")",
")",
";",
"stmt",
".",
"setLong",
"(",
"3",
",",
"postId",
")",
";",
"stmt",
".",
"executeUpdate",
"(",
")",
";",
"}",
"finally",
"{",
"ctx",
".",
"stop",
"(",
")",
";",
"SQLUtil",
".",
"closeQuietly",
"(",
"conn",
",",
"stmt",
")",
";",
"}",
"}"
] | "Touches" the last modified time for a post.
@param postId The post id.
@param tz The local time zone.
@throws SQLException on database error or invalid post id. | [
"Touches",
"the",
"last",
"modified",
"time",
"for",
"a",
"post",
"."
] | train | https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1746-L1768 |
deeplearning4j/deeplearning4j | datavec/datavec-spark/src/main/java/org/datavec/spark/transform/Normalization.java | Normalization.zeroMeanUnitVarianceSequence | public static JavaRDD<List<List<Writable>>> zeroMeanUnitVarianceSequence(Schema schema,
JavaRDD<List<List<Writable>>> sequence) {
return zeroMeanUnitVarianceSequence(schema, sequence, null);
} | java | public static JavaRDD<List<List<Writable>>> zeroMeanUnitVarianceSequence(Schema schema,
JavaRDD<List<List<Writable>>> sequence) {
return zeroMeanUnitVarianceSequence(schema, sequence, null);
} | [
"public",
"static",
"JavaRDD",
"<",
"List",
"<",
"List",
"<",
"Writable",
">",
">",
">",
"zeroMeanUnitVarianceSequence",
"(",
"Schema",
"schema",
",",
"JavaRDD",
"<",
"List",
"<",
"List",
"<",
"Writable",
">",
">",
">",
"sequence",
")",
"{",
"return",
"zeroMeanUnitVarianceSequence",
"(",
"schema",
",",
"sequence",
",",
"null",
")",
";",
"}"
] | Normalize the sequence by zero mean unit variance
@param schema Schema of the data to normalize
@param sequence Sequence data
@return Normalized sequence | [
"Normalize",
"the",
"sequence",
"by",
"zero",
"mean",
"unit",
"variance"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/transform/Normalization.java#L166-L169 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateCertificateIssuerAsync | public ServiceFuture<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback<IssuerBundle> serviceCallback) {
return ServiceFuture.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback);
} | java | public ServiceFuture<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback<IssuerBundle> serviceCallback) {
return ServiceFuture.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"IssuerBundle",
">",
"updateCertificateIssuerAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"issuerName",
",",
"final",
"ServiceCallback",
"<",
"IssuerBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"updateCertificateIssuerWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"issuerName",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Updates the specified certificate issuer.
The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires the certificates/setissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Updates",
"the",
"specified",
"certificate",
"issuer",
".",
"The",
"UpdateCertificateIssuer",
"operation",
"performs",
"an",
"update",
"on",
"the",
"specified",
"certificate",
"issuer",
"entity",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"setissuers",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L6124-L6126 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/io/DOMHandle.java | DOMHandle.evaluateXPath | public <T> T evaluateXPath(String xpathExpression, Node context, Class<T> as)
throws XPathExpressionException {
checkContext(context);
return castAs(
getXPathProcessor().evaluate(xpathExpression, context, returnXPathConstant(as)),
as
);
} | java | public <T> T evaluateXPath(String xpathExpression, Node context, Class<T> as)
throws XPathExpressionException {
checkContext(context);
return castAs(
getXPathProcessor().evaluate(xpathExpression, context, returnXPathConstant(as)),
as
);
} | [
"public",
"<",
"T",
">",
"T",
"evaluateXPath",
"(",
"String",
"xpathExpression",
",",
"Node",
"context",
",",
"Class",
"<",
"T",
">",
"as",
")",
"throws",
"XPathExpressionException",
"{",
"checkContext",
"(",
"context",
")",
";",
"return",
"castAs",
"(",
"getXPathProcessor",
"(",
")",
".",
"evaluate",
"(",
"xpathExpression",
",",
"context",
",",
"returnXPathConstant",
"(",
"as",
")",
")",
",",
"as",
")",
";",
"}"
] | Evaluate a string XPath expression relative to a node such as a node
returned by a previous XPath expression.
An XPath expression can return a Node or subinterface such as
Element or Text, a NodeList, or a Boolean, Number, or String value.
@param xpathExpression the XPath expression as a string
@param context the node for evaluating the expression
@param as the type expected to be matched by the xpath
@param <T> the type to return
@return the value produced by the XPath expression
@throws XPathExpressionException if xpathExpression cannot be evaluated | [
"Evaluate",
"a",
"string",
"XPath",
"expression",
"relative",
"to",
"a",
"node",
"such",
"as",
"a",
"node",
"returned",
"by",
"a",
"previous",
"XPath",
"expression",
".",
"An",
"XPath",
"expression",
"can",
"return",
"a",
"Node",
"or",
"subinterface",
"such",
"as",
"Element",
"or",
"Text",
"a",
"NodeList",
"or",
"a",
"Boolean",
"Number",
"or",
"String",
"value",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/io/DOMHandle.java#L288-L295 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java | AmazonS3Client.populateSSE_C | private static void populateSSE_C(Request<?> request, SSECustomerKey sseKey) {
if (sseKey == null) return;
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
sseKey.getAlgorithm());
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY,
sseKey.getKey());
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5,
sseKey.getMd5());
// Calculate the MD5 hash of the encryption key and fill it in the
// header, if the user didn't specify it in the metadata
if (sseKey.getKey() != null
&& sseKey.getMd5() == null) {
String encryptionKey_b64 = sseKey.getKey();
byte[] encryptionKey = Base64.decode(encryptionKey_b64);
request.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5,
Md5Utils.md5AsBase64(encryptionKey));
}
} | java | private static void populateSSE_C(Request<?> request, SSECustomerKey sseKey) {
if (sseKey == null) return;
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
sseKey.getAlgorithm());
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY,
sseKey.getKey());
addHeaderIfNotNull(request, Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5,
sseKey.getMd5());
// Calculate the MD5 hash of the encryption key and fill it in the
// header, if the user didn't specify it in the metadata
if (sseKey.getKey() != null
&& sseKey.getMd5() == null) {
String encryptionKey_b64 = sseKey.getKey();
byte[] encryptionKey = Base64.decode(encryptionKey_b64);
request.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5,
Md5Utils.md5AsBase64(encryptionKey));
}
} | [
"private",
"static",
"void",
"populateSSE_C",
"(",
"Request",
"<",
"?",
">",
"request",
",",
"SSECustomerKey",
"sseKey",
")",
"{",
"if",
"(",
"sseKey",
"==",
"null",
")",
"return",
";",
"addHeaderIfNotNull",
"(",
"request",
",",
"Headers",
".",
"SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM",
",",
"sseKey",
".",
"getAlgorithm",
"(",
")",
")",
";",
"addHeaderIfNotNull",
"(",
"request",
",",
"Headers",
".",
"SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY",
",",
"sseKey",
".",
"getKey",
"(",
")",
")",
";",
"addHeaderIfNotNull",
"(",
"request",
",",
"Headers",
".",
"SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5",
",",
"sseKey",
".",
"getMd5",
"(",
")",
")",
";",
"// Calculate the MD5 hash of the encryption key and fill it in the",
"// header, if the user didn't specify it in the metadata",
"if",
"(",
"sseKey",
".",
"getKey",
"(",
")",
"!=",
"null",
"&&",
"sseKey",
".",
"getMd5",
"(",
")",
"==",
"null",
")",
"{",
"String",
"encryptionKey_b64",
"=",
"sseKey",
".",
"getKey",
"(",
")",
";",
"byte",
"[",
"]",
"encryptionKey",
"=",
"Base64",
".",
"decode",
"(",
"encryptionKey_b64",
")",
";",
"request",
".",
"addHeader",
"(",
"Headers",
".",
"SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5",
",",
"Md5Utils",
".",
"md5AsBase64",
"(",
"encryptionKey",
")",
")",
";",
"}",
"}"
] | <p>
Populates the specified request with the numerous attributes available in
<code>SSEWithCustomerKeyRequest</code>.
</p>
@param request
The request to populate with headers to represent all the
options expressed in the
<code>ServerSideEncryptionWithCustomerKeyRequest</code>
object.
@param sseKey
The request object for an S3 operation that allows server-side
encryption using customer-provided keys. | [
"<p",
">",
"Populates",
"the",
"specified",
"request",
"with",
"the",
"numerous",
"attributes",
"available",
"in",
"<code",
">",
"SSEWithCustomerKeyRequest<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L4359-L4377 |
elastic/elasticsearch-hadoop | mr/src/main/java/org/elasticsearch/hadoop/rest/commonshttp/auth/spnego/SpnegoAuthScheme.java | SpnegoAuthScheme.initializeNegotiator | private void initializeNegotiator(URI requestURI, SpnegoCredentials spnegoCredentials) throws UnknownHostException, AuthenticationException, GSSException {
// Initialize negotiator
if (spnegoNegotiator == null) {
// Determine host principal
String servicePrincipal = spnegoCredentials.getServicePrincipalName();
if (spnegoCredentials.getServicePrincipalName().contains(HOSTNAME_PATTERN)) {
String fqdn = getFQDN(requestURI);
String[] components = spnegoCredentials.getServicePrincipalName().split("[/@]");
if (components.length != 3 || !components[1].equals(HOSTNAME_PATTERN)) {
throw new AuthenticationException("Malformed service principal name [" + spnegoCredentials.getServicePrincipalName()
+ "]. To use host substitution, the principal must be of the format [serviceName/_HOST@REALM.NAME].");
}
servicePrincipal = components[0] + "/" + fqdn.toLowerCase() + "@" + components[2];
}
User userInfo = spnegoCredentials.getUserProvider().getUser();
KerberosPrincipal principal = userInfo.getKerberosPrincipal();
if (principal == null) {
throw new EsHadoopIllegalArgumentException("Could not locate Kerberos Principal on currently logged in user.");
}
spnegoNegotiator = new SpnegoNegotiator(principal.getName(), servicePrincipal);
}
} | java | private void initializeNegotiator(URI requestURI, SpnegoCredentials spnegoCredentials) throws UnknownHostException, AuthenticationException, GSSException {
// Initialize negotiator
if (spnegoNegotiator == null) {
// Determine host principal
String servicePrincipal = spnegoCredentials.getServicePrincipalName();
if (spnegoCredentials.getServicePrincipalName().contains(HOSTNAME_PATTERN)) {
String fqdn = getFQDN(requestURI);
String[] components = spnegoCredentials.getServicePrincipalName().split("[/@]");
if (components.length != 3 || !components[1].equals(HOSTNAME_PATTERN)) {
throw new AuthenticationException("Malformed service principal name [" + spnegoCredentials.getServicePrincipalName()
+ "]. To use host substitution, the principal must be of the format [serviceName/_HOST@REALM.NAME].");
}
servicePrincipal = components[0] + "/" + fqdn.toLowerCase() + "@" + components[2];
}
User userInfo = spnegoCredentials.getUserProvider().getUser();
KerberosPrincipal principal = userInfo.getKerberosPrincipal();
if (principal == null) {
throw new EsHadoopIllegalArgumentException("Could not locate Kerberos Principal on currently logged in user.");
}
spnegoNegotiator = new SpnegoNegotiator(principal.getName(), servicePrincipal);
}
} | [
"private",
"void",
"initializeNegotiator",
"(",
"URI",
"requestURI",
",",
"SpnegoCredentials",
"spnegoCredentials",
")",
"throws",
"UnknownHostException",
",",
"AuthenticationException",
",",
"GSSException",
"{",
"// Initialize negotiator",
"if",
"(",
"spnegoNegotiator",
"==",
"null",
")",
"{",
"// Determine host principal",
"String",
"servicePrincipal",
"=",
"spnegoCredentials",
".",
"getServicePrincipalName",
"(",
")",
";",
"if",
"(",
"spnegoCredentials",
".",
"getServicePrincipalName",
"(",
")",
".",
"contains",
"(",
"HOSTNAME_PATTERN",
")",
")",
"{",
"String",
"fqdn",
"=",
"getFQDN",
"(",
"requestURI",
")",
";",
"String",
"[",
"]",
"components",
"=",
"spnegoCredentials",
".",
"getServicePrincipalName",
"(",
")",
".",
"split",
"(",
"\"[/@]\"",
")",
";",
"if",
"(",
"components",
".",
"length",
"!=",
"3",
"||",
"!",
"components",
"[",
"1",
"]",
".",
"equals",
"(",
"HOSTNAME_PATTERN",
")",
")",
"{",
"throw",
"new",
"AuthenticationException",
"(",
"\"Malformed service principal name [\"",
"+",
"spnegoCredentials",
".",
"getServicePrincipalName",
"(",
")",
"+",
"\"]. To use host substitution, the principal must be of the format [serviceName/_HOST@REALM.NAME].\"",
")",
";",
"}",
"servicePrincipal",
"=",
"components",
"[",
"0",
"]",
"+",
"\"/\"",
"+",
"fqdn",
".",
"toLowerCase",
"(",
")",
"+",
"\"@\"",
"+",
"components",
"[",
"2",
"]",
";",
"}",
"User",
"userInfo",
"=",
"spnegoCredentials",
".",
"getUserProvider",
"(",
")",
".",
"getUser",
"(",
")",
";",
"KerberosPrincipal",
"principal",
"=",
"userInfo",
".",
"getKerberosPrincipal",
"(",
")",
";",
"if",
"(",
"principal",
"==",
"null",
")",
"{",
"throw",
"new",
"EsHadoopIllegalArgumentException",
"(",
"\"Could not locate Kerberos Principal on currently logged in user.\"",
")",
";",
"}",
"spnegoNegotiator",
"=",
"new",
"SpnegoNegotiator",
"(",
"principal",
".",
"getName",
"(",
")",
",",
"servicePrincipal",
")",
";",
"}",
"}"
] | Creates the negotiator if it is not yet created, or does nothing if the negotiator is already initialized.
@param requestURI request being authenticated
@param spnegoCredentials The user and service principals
@throws UnknownHostException If the service principal is host based, and if the request URI cannot be resolved to a FQDN
@throws AuthenticationException If the service principal is malformed
@throws GSSException If the negotiator cannot be created. | [
"Creates",
"the",
"negotiator",
"if",
"it",
"is",
"not",
"yet",
"created",
"or",
"does",
"nothing",
"if",
"the",
"negotiator",
"is",
"already",
"initialized",
"."
] | train | https://github.com/elastic/elasticsearch-hadoop/blob/f3acaba268ff96efae8eb946088c748c777c22cc/mr/src/main/java/org/elasticsearch/hadoop/rest/commonshttp/auth/spnego/SpnegoAuthScheme.java#L101-L122 |
google/closure-compiler | src/com/google/javascript/jscomp/TypeTransformation.java | TypeTransformation.joinRecordTypes | private JSType joinRecordTypes(ImmutableList<ObjectType> recTypes) {
Map<String, JSType> props = new LinkedHashMap<>();
for (ObjectType recType : recTypes) {
for (String newPropName : recType.getOwnPropertyNames()) {
JSType newPropValue = recType.getPropertyType(newPropName);
// Put the new property depending if it already exists in the map
putNewPropInPropertyMap(props, newPropName, newPropValue);
}
}
return createRecordType(ImmutableMap.copyOf(props));
} | java | private JSType joinRecordTypes(ImmutableList<ObjectType> recTypes) {
Map<String, JSType> props = new LinkedHashMap<>();
for (ObjectType recType : recTypes) {
for (String newPropName : recType.getOwnPropertyNames()) {
JSType newPropValue = recType.getPropertyType(newPropName);
// Put the new property depending if it already exists in the map
putNewPropInPropertyMap(props, newPropName, newPropValue);
}
}
return createRecordType(ImmutableMap.copyOf(props));
} | [
"private",
"JSType",
"joinRecordTypes",
"(",
"ImmutableList",
"<",
"ObjectType",
">",
"recTypes",
")",
"{",
"Map",
"<",
"String",
",",
"JSType",
">",
"props",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"ObjectType",
"recType",
":",
"recTypes",
")",
"{",
"for",
"(",
"String",
"newPropName",
":",
"recType",
".",
"getOwnPropertyNames",
"(",
")",
")",
"{",
"JSType",
"newPropValue",
"=",
"recType",
".",
"getPropertyType",
"(",
"newPropName",
")",
";",
"// Put the new property depending if it already exists in the map",
"putNewPropInPropertyMap",
"(",
"props",
",",
"newPropName",
",",
"newPropValue",
")",
";",
"}",
"}",
"return",
"createRecordType",
"(",
"ImmutableMap",
".",
"copyOf",
"(",
"props",
")",
")",
";",
"}"
] | Merges a list of record types.
Example
{r:{s:string, n:number}} and {a:boolean}
is transformed into {r:{s:string, n:number}, a:boolean} | [
"Merges",
"a",
"list",
"of",
"record",
"types",
".",
"Example",
"{",
"r",
":",
"{",
"s",
":",
"string",
"n",
":",
"number",
"}}",
"and",
"{",
"a",
":",
"boolean",
"}",
"is",
"transformed",
"into",
"{",
"r",
":",
"{",
"s",
":",
"string",
"n",
":",
"number",
"}",
"a",
":",
"boolean",
"}"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeTransformation.java#L675-L685 |
wildfly-swarm-archive/ARCHIVE-wildfly-swarm | logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java | LoggingFraction.rootLogger | public LoggingFraction rootLogger(Level level, String... handlers) {
rootLogger(new RootLogger().level(level)
.handlers(handlers));
return this;
} | java | public LoggingFraction rootLogger(Level level, String... handlers) {
rootLogger(new RootLogger().level(level)
.handlers(handlers));
return this;
} | [
"public",
"LoggingFraction",
"rootLogger",
"(",
"Level",
"level",
",",
"String",
"...",
"handlers",
")",
"{",
"rootLogger",
"(",
"new",
"RootLogger",
"(",
")",
".",
"level",
"(",
"level",
")",
".",
"handlers",
"(",
"handlers",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a root logger to this fraction
@param level the log level
@param handlers a list of handlers
@return this fraction | [
"Add",
"a",
"root",
"logger",
"to",
"this",
"fraction"
] | train | https://github.com/wildfly-swarm-archive/ARCHIVE-wildfly-swarm/blob/28ef71bcfa743a7267666e0ed2919c37b356c09b/logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java#L303-L307 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/utils/KerasActivationUtils.java | KerasActivationUtils.getActivationFromConfig | public static Activation getActivationFromConfig(Map<String, Object> layerConfig, KerasLayerConfiguration conf)
throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
Map<String, Object> innerConfig = KerasLayerUtils.getInnerLayerConfigFromConfig(layerConfig, conf);
if (!innerConfig.containsKey(conf.getLAYER_FIELD_ACTIVATION()))
throw new InvalidKerasConfigurationException("Keras layer is missing "
+ conf.getLAYER_FIELD_ACTIVATION() + " field");
return mapToActivation((String) innerConfig.get(conf.getLAYER_FIELD_ACTIVATION()), conf);
} | java | public static Activation getActivationFromConfig(Map<String, Object> layerConfig, KerasLayerConfiguration conf)
throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
Map<String, Object> innerConfig = KerasLayerUtils.getInnerLayerConfigFromConfig(layerConfig, conf);
if (!innerConfig.containsKey(conf.getLAYER_FIELD_ACTIVATION()))
throw new InvalidKerasConfigurationException("Keras layer is missing "
+ conf.getLAYER_FIELD_ACTIVATION() + " field");
return mapToActivation((String) innerConfig.get(conf.getLAYER_FIELD_ACTIVATION()), conf);
} | [
"public",
"static",
"Activation",
"getActivationFromConfig",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"layerConfig",
",",
"KerasLayerConfiguration",
"conf",
")",
"throws",
"InvalidKerasConfigurationException",
",",
"UnsupportedKerasConfigurationException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"innerConfig",
"=",
"KerasLayerUtils",
".",
"getInnerLayerConfigFromConfig",
"(",
"layerConfig",
",",
"conf",
")",
";",
"if",
"(",
"!",
"innerConfig",
".",
"containsKey",
"(",
"conf",
".",
"getLAYER_FIELD_ACTIVATION",
"(",
")",
")",
")",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Keras layer is missing \"",
"+",
"conf",
".",
"getLAYER_FIELD_ACTIVATION",
"(",
")",
"+",
"\" field\"",
")",
";",
"return",
"mapToActivation",
"(",
"(",
"String",
")",
"innerConfig",
".",
"get",
"(",
"conf",
".",
"getLAYER_FIELD_ACTIVATION",
"(",
")",
")",
",",
"conf",
")",
";",
"}"
] | Get activation enum value from Keras layer configuration.
@param layerConfig dictionary containing Keras layer configuration
@return DL4J activation enum value
@throws InvalidKerasConfigurationException Invalid Keras config
@throws UnsupportedKerasConfigurationException Unsupported Keras config | [
"Get",
"activation",
"enum",
"value",
"from",
"Keras",
"layer",
"configuration",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/utils/KerasActivationUtils.java#L108-L115 |
profesorfalken/jPowerShell | src/main/java/com/profesorfalken/jpowershell/PowerShell.java | PowerShell.executeCommand | public PowerShellResponse executeCommand(String command) {
String commandOutput = "";
boolean isError = false;
boolean timeout = false;
checkState();
PowerShellCommandProcessor commandProcessor = new PowerShellCommandProcessor("standard", p.getInputStream(),
this.waitPause, this.scriptMode);
Future<String> result = threadpool.submit(commandProcessor);
// Launch command
commandWriter.println(command);
try {
if (!result.isDone()) {
try {
commandOutput = result.get(maxWait, TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutEx) {
timeout = true;
isError = true;
//Interrupt command after timeout
result.cancel(true);
}
}
} catch (InterruptedException | ExecutionException ex) {
logger.log(Level.SEVERE,
"Unexpected error when processing PowerShell command", ex);
isError = true;
} finally {
// issue #2. Close and cancel processors/threads - Thanks to r4lly
// for helping me here
commandProcessor.close();
}
return new PowerShellResponse(isError, commandOutput, timeout);
} | java | public PowerShellResponse executeCommand(String command) {
String commandOutput = "";
boolean isError = false;
boolean timeout = false;
checkState();
PowerShellCommandProcessor commandProcessor = new PowerShellCommandProcessor("standard", p.getInputStream(),
this.waitPause, this.scriptMode);
Future<String> result = threadpool.submit(commandProcessor);
// Launch command
commandWriter.println(command);
try {
if (!result.isDone()) {
try {
commandOutput = result.get(maxWait, TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutEx) {
timeout = true;
isError = true;
//Interrupt command after timeout
result.cancel(true);
}
}
} catch (InterruptedException | ExecutionException ex) {
logger.log(Level.SEVERE,
"Unexpected error when processing PowerShell command", ex);
isError = true;
} finally {
// issue #2. Close and cancel processors/threads - Thanks to r4lly
// for helping me here
commandProcessor.close();
}
return new PowerShellResponse(isError, commandOutput, timeout);
} | [
"public",
"PowerShellResponse",
"executeCommand",
"(",
"String",
"command",
")",
"{",
"String",
"commandOutput",
"=",
"\"\"",
";",
"boolean",
"isError",
"=",
"false",
";",
"boolean",
"timeout",
"=",
"false",
";",
"checkState",
"(",
")",
";",
"PowerShellCommandProcessor",
"commandProcessor",
"=",
"new",
"PowerShellCommandProcessor",
"(",
"\"standard\"",
",",
"p",
".",
"getInputStream",
"(",
")",
",",
"this",
".",
"waitPause",
",",
"this",
".",
"scriptMode",
")",
";",
"Future",
"<",
"String",
">",
"result",
"=",
"threadpool",
".",
"submit",
"(",
"commandProcessor",
")",
";",
"// Launch command",
"commandWriter",
".",
"println",
"(",
"command",
")",
";",
"try",
"{",
"if",
"(",
"!",
"result",
".",
"isDone",
"(",
")",
")",
"{",
"try",
"{",
"commandOutput",
"=",
"result",
".",
"get",
"(",
"maxWait",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"timeoutEx",
")",
"{",
"timeout",
"=",
"true",
";",
"isError",
"=",
"true",
";",
"//Interrupt command after timeout",
"result",
".",
"cancel",
"(",
"true",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"InterruptedException",
"|",
"ExecutionException",
"ex",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Unexpected error when processing PowerShell command\"",
",",
"ex",
")",
";",
"isError",
"=",
"true",
";",
"}",
"finally",
"{",
"// issue #2. Close and cancel processors/threads - Thanks to r4lly",
"// for helping me here",
"commandProcessor",
".",
"close",
"(",
")",
";",
"}",
"return",
"new",
"PowerShellResponse",
"(",
"isError",
",",
"commandOutput",
",",
"timeout",
")",
";",
"}"
] | Execute a PowerShell command.
<p>
This method launch a thread which will be executed in the already created
PowerShell console context
@param command the command to call. Ex: dir
@return PowerShellResponse the information returned by powerShell | [
"Execute",
"a",
"PowerShell",
"command",
".",
"<p",
">",
"This",
"method",
"launch",
"a",
"thread",
"which",
"will",
"be",
"executed",
"in",
"the",
"already",
"created",
"PowerShell",
"console",
"context"
] | train | https://github.com/profesorfalken/jPowerShell/blob/a0fb9d3b9db12dd5635de810e6366e17b932ee10/src/main/java/com/profesorfalken/jpowershell/PowerShell.java#L186-L222 |
apereo/cas | support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java | OAuth20Utils.isAuthorizedGrantTypeForService | public static boolean isAuthorizedGrantTypeForService(final J2EContext context, final OAuthRegisteredService registeredService) {
return isAuthorizedGrantTypeForService(
context.getRequestParameter(OAuth20Constants.GRANT_TYPE),
registeredService);
} | java | public static boolean isAuthorizedGrantTypeForService(final J2EContext context, final OAuthRegisteredService registeredService) {
return isAuthorizedGrantTypeForService(
context.getRequestParameter(OAuth20Constants.GRANT_TYPE),
registeredService);
} | [
"public",
"static",
"boolean",
"isAuthorizedGrantTypeForService",
"(",
"final",
"J2EContext",
"context",
",",
"final",
"OAuthRegisteredService",
"registeredService",
")",
"{",
"return",
"isAuthorizedGrantTypeForService",
"(",
"context",
".",
"getRequestParameter",
"(",
"OAuth20Constants",
".",
"GRANT_TYPE",
")",
",",
"registeredService",
")",
";",
"}"
] | Is authorized grant type for service?
@param context the context
@param registeredService the registered service
@return true/false | [
"Is",
"authorized",
"grant",
"type",
"for",
"service?"
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java#L312-L316 |
jayantk/jklol | src/com/jayantkrish/jklol/preprocessing/FeatureStandardizer.java | FeatureStandardizer.estimateFrom | public static FeatureStandardizer estimateFrom(Collection<DiscreteFactor> featureFactors,
int featureVariableNum, Assignment biasFeature, double rescalingFactor) {
Preconditions.checkArgument(featureFactors.size() > 0);
DiscreteFactor means = getMeans(featureFactors, featureVariableNum);
DiscreteFactor variances = getVariances(featureFactors, featureVariableNum);
DiscreteFactor stdDev = new TableFactor(variances.getVars(), variances.getWeights().elementwiseSqrt());
VariableNumMap featureVariable = Iterables.getFirst(featureFactors, null).getVars()
.intersection(featureVariableNum);
DiscreteFactor offset = null;
if (biasFeature == null || biasFeature.size() == 0) {
offset = TableFactor.zero(featureVariable);
} else {
offset = TableFactor.pointDistribution(featureVariable, biasFeature);
}
return new FeatureStandardizer(means, stdDev.inverse(), offset, rescalingFactor);
} | java | public static FeatureStandardizer estimateFrom(Collection<DiscreteFactor> featureFactors,
int featureVariableNum, Assignment biasFeature, double rescalingFactor) {
Preconditions.checkArgument(featureFactors.size() > 0);
DiscreteFactor means = getMeans(featureFactors, featureVariableNum);
DiscreteFactor variances = getVariances(featureFactors, featureVariableNum);
DiscreteFactor stdDev = new TableFactor(variances.getVars(), variances.getWeights().elementwiseSqrt());
VariableNumMap featureVariable = Iterables.getFirst(featureFactors, null).getVars()
.intersection(featureVariableNum);
DiscreteFactor offset = null;
if (biasFeature == null || biasFeature.size() == 0) {
offset = TableFactor.zero(featureVariable);
} else {
offset = TableFactor.pointDistribution(featureVariable, biasFeature);
}
return new FeatureStandardizer(means, stdDev.inverse(), offset, rescalingFactor);
} | [
"public",
"static",
"FeatureStandardizer",
"estimateFrom",
"(",
"Collection",
"<",
"DiscreteFactor",
">",
"featureFactors",
",",
"int",
"featureVariableNum",
",",
"Assignment",
"biasFeature",
",",
"double",
"rescalingFactor",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"featureFactors",
".",
"size",
"(",
")",
">",
"0",
")",
";",
"DiscreteFactor",
"means",
"=",
"getMeans",
"(",
"featureFactors",
",",
"featureVariableNum",
")",
";",
"DiscreteFactor",
"variances",
"=",
"getVariances",
"(",
"featureFactors",
",",
"featureVariableNum",
")",
";",
"DiscreteFactor",
"stdDev",
"=",
"new",
"TableFactor",
"(",
"variances",
".",
"getVars",
"(",
")",
",",
"variances",
".",
"getWeights",
"(",
")",
".",
"elementwiseSqrt",
"(",
")",
")",
";",
"VariableNumMap",
"featureVariable",
"=",
"Iterables",
".",
"getFirst",
"(",
"featureFactors",
",",
"null",
")",
".",
"getVars",
"(",
")",
".",
"intersection",
"(",
"featureVariableNum",
")",
";",
"DiscreteFactor",
"offset",
"=",
"null",
";",
"if",
"(",
"biasFeature",
"==",
"null",
"||",
"biasFeature",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"offset",
"=",
"TableFactor",
".",
"zero",
"(",
"featureVariable",
")",
";",
"}",
"else",
"{",
"offset",
"=",
"TableFactor",
".",
"pointDistribution",
"(",
"featureVariable",
",",
"biasFeature",
")",
";",
"}",
"return",
"new",
"FeatureStandardizer",
"(",
"means",
",",
"stdDev",
".",
"inverse",
"(",
")",
",",
"offset",
",",
"rescalingFactor",
")",
";",
"}"
] | Estimates standardization parameters (empirical feature means and
variances) from {@code featureFactors}. Each element of {@code featureFactors}
behaves like an independent set of feature vector observations; if these
factors contain variables other than the feature variable, then each
assignment to these variables defines a single feature vector.
@param featureFactor
@param featureVariableNum
@param biasFeature If {@code null} no bias feature is used.
@param rescalingFactor amount by which to multiply each feature vector after
standardization.
@return | [
"Estimates",
"standardization",
"parameters",
"(",
"empirical",
"feature",
"means",
"and",
"variances",
")",
"from",
"{",
"@code",
"featureFactors",
"}",
".",
"Each",
"element",
"of",
"{",
"@code",
"featureFactors",
"}",
"behaves",
"like",
"an",
"independent",
"set",
"of",
"feature",
"vector",
"observations",
";",
"if",
"these",
"factors",
"contain",
"variables",
"other",
"than",
"the",
"feature",
"variable",
"then",
"each",
"assignment",
"to",
"these",
"variables",
"defines",
"a",
"single",
"feature",
"vector",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/preprocessing/FeatureStandardizer.java#L89-L107 |
google/gwtmockito | gwtmockito/src/main/java/com/google/gwtmockito/fakes/FakeUiBinderProvider.java | FakeUiBinderProvider.getFake | @Override
public UiBinder<?, ?> getFake(final Class<?> type) {
return (UiBinder<?, ?>) Proxy.newProxyInstance(
FakeUiBinderProvider.class.getClassLoader(),
new Class<?>[] {type},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
// createAndBindUi is the only method defined by UiBinder
for (Field field : getAllFields(args[0].getClass())) {
if (field.isAnnotationPresent(UiField.class)
&& !field.getAnnotation(UiField.class).provided()) {
field.setAccessible(true);
field.set(args[0], GWT.create(field.getType()));
}
}
return GWT.create(getUiRootType(type));
}
});
} | java | @Override
public UiBinder<?, ?> getFake(final Class<?> type) {
return (UiBinder<?, ?>) Proxy.newProxyInstance(
FakeUiBinderProvider.class.getClassLoader(),
new Class<?>[] {type},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
// createAndBindUi is the only method defined by UiBinder
for (Field field : getAllFields(args[0].getClass())) {
if (field.isAnnotationPresent(UiField.class)
&& !field.getAnnotation(UiField.class).provided()) {
field.setAccessible(true);
field.set(args[0], GWT.create(field.getType()));
}
}
return GWT.create(getUiRootType(type));
}
});
} | [
"@",
"Override",
"public",
"UiBinder",
"<",
"?",
",",
"?",
">",
"getFake",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"(",
"UiBinder",
"<",
"?",
",",
"?",
">",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"FakeUiBinderProvider",
".",
"class",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"type",
"}",
",",
"new",
"InvocationHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"invoke",
"(",
"Object",
"proxy",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"// createAndBindUi is the only method defined by UiBinder",
"for",
"(",
"Field",
"field",
":",
"getAllFields",
"(",
"args",
"[",
"0",
"]",
".",
"getClass",
"(",
")",
")",
")",
"{",
"if",
"(",
"field",
".",
"isAnnotationPresent",
"(",
"UiField",
".",
"class",
")",
"&&",
"!",
"field",
".",
"getAnnotation",
"(",
"UiField",
".",
"class",
")",
".",
"provided",
"(",
")",
")",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"args",
"[",
"0",
"]",
",",
"GWT",
".",
"create",
"(",
"field",
".",
"getType",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"GWT",
".",
"create",
"(",
"getUiRootType",
"(",
"type",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns a new instance of FakeUiBinder that implements the given interface.
This is accomplished by returning a dynamic proxy object that delegates
calls to a backing FakeUiBinder.
@param type interface to be implemented by the returned type. This must
represent an interface that directly extends {@link UiBinder}. | [
"Returns",
"a",
"new",
"instance",
"of",
"FakeUiBinder",
"that",
"implements",
"the",
"given",
"interface",
".",
"This",
"is",
"accomplished",
"by",
"returning",
"a",
"dynamic",
"proxy",
"object",
"that",
"delegates",
"calls",
"to",
"a",
"backing",
"FakeUiBinder",
"."
] | train | https://github.com/google/gwtmockito/blob/e886a9b9d290169b5f83582dd89b7545c5f198a2/gwtmockito/src/main/java/com/google/gwtmockito/fakes/FakeUiBinderProvider.java#L51-L70 |
icode/ameba | src/main/java/ameba/container/server/Connector.java | Connector.createDefaultConnectors | public static List<Connector> createDefaultConnectors(Map<String, Object> properties) {
List<Connector> connectors = Lists.newArrayList();
Map<String, Map<String, String>> propertiesMap = Maps.newLinkedHashMap();
for (String key : properties.keySet()) {
if (key.startsWith(Connector.CONNECTOR_CONF_PREFIX)) {
String oKey = key;
key = key.substring(Connector.CONNECTOR_CONF_PREFIX.length());
int index = key.indexOf(".");
if (index == -1) {
throw new ConfigErrorException("connector configure error, format connector.{connectorName}.{property}");
}
String name = key.substring(0, index);
Map<String, String> pr = propertiesMap.get(name);
if (pr == null) {
pr = Maps.newLinkedHashMap();
propertiesMap.put(name, pr);
pr.put("name", name);
}
pr.put(key.substring(index + 1), String.valueOf(properties.get(oKey)));
}
}
connectors.addAll(propertiesMap.values().stream().map(Connector::createDefault).collect(Collectors.toList()));
return connectors;
} | java | public static List<Connector> createDefaultConnectors(Map<String, Object> properties) {
List<Connector> connectors = Lists.newArrayList();
Map<String, Map<String, String>> propertiesMap = Maps.newLinkedHashMap();
for (String key : properties.keySet()) {
if (key.startsWith(Connector.CONNECTOR_CONF_PREFIX)) {
String oKey = key;
key = key.substring(Connector.CONNECTOR_CONF_PREFIX.length());
int index = key.indexOf(".");
if (index == -1) {
throw new ConfigErrorException("connector configure error, format connector.{connectorName}.{property}");
}
String name = key.substring(0, index);
Map<String, String> pr = propertiesMap.get(name);
if (pr == null) {
pr = Maps.newLinkedHashMap();
propertiesMap.put(name, pr);
pr.put("name", name);
}
pr.put(key.substring(index + 1), String.valueOf(properties.get(oKey)));
}
}
connectors.addAll(propertiesMap.values().stream().map(Connector::createDefault).collect(Collectors.toList()));
return connectors;
} | [
"public",
"static",
"List",
"<",
"Connector",
">",
"createDefaultConnectors",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"List",
"<",
"Connector",
">",
"connectors",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"propertiesMap",
"=",
"Maps",
".",
"newLinkedHashMap",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"properties",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"startsWith",
"(",
"Connector",
".",
"CONNECTOR_CONF_PREFIX",
")",
")",
"{",
"String",
"oKey",
"=",
"key",
";",
"key",
"=",
"key",
".",
"substring",
"(",
"Connector",
".",
"CONNECTOR_CONF_PREFIX",
".",
"length",
"(",
")",
")",
";",
"int",
"index",
"=",
"key",
".",
"indexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"ConfigErrorException",
"(",
"\"connector configure error, format connector.{connectorName}.{property}\"",
")",
";",
"}",
"String",
"name",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"pr",
"=",
"propertiesMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"pr",
"==",
"null",
")",
"{",
"pr",
"=",
"Maps",
".",
"newLinkedHashMap",
"(",
")",
";",
"propertiesMap",
".",
"put",
"(",
"name",
",",
"pr",
")",
";",
"pr",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"}",
"pr",
".",
"put",
"(",
"key",
".",
"substring",
"(",
"index",
"+",
"1",
")",
",",
"String",
".",
"valueOf",
"(",
"properties",
".",
"get",
"(",
"oKey",
")",
")",
")",
";",
"}",
"}",
"connectors",
".",
"addAll",
"(",
"propertiesMap",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Connector",
"::",
"createDefault",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"return",
"connectors",
";",
"}"
] | <p>createDefaultConnectors.</p>
@param properties a {@link java.util.Map} object.
@return a {@link java.util.List} object. | [
"<p",
">",
"createDefaultConnectors",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/container/server/Connector.java#L121-L145 |
ocelotds/ocelot | ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java | MethodServices.getNonProxiedMethod | public Method getNonProxiedMethod(Class cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
return cls.getMethod(methodName, parameterTypes);
} | java | public Method getNonProxiedMethod(Class cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
return cls.getMethod(methodName, parameterTypes);
} | [
"public",
"Method",
"getNonProxiedMethod",
"(",
"Class",
"cls",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"return",
"cls",
".",
"getMethod",
"(",
"methodName",
",",
"parameterTypes",
")",
";",
"}"
] | Get the method on origin class without proxies
@param cls
@param methodName
@param parameterTypes
@throws NoSuchMethodException
@return | [
"Get",
"the",
"method",
"on",
"origin",
"class",
"without",
"proxies"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java#L79-L81 |
QSFT/Doradus | doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java | OLAPMonoService.addBatch | public BatchResult addBatch(ApplicationDefinition appDef, OlapBatch batch) {
return OLAPService.instance().addBatch(appDef, MONO_SHARD_NAME, batch);
} | java | public BatchResult addBatch(ApplicationDefinition appDef, OlapBatch batch) {
return OLAPService.instance().addBatch(appDef, MONO_SHARD_NAME, batch);
} | [
"public",
"BatchResult",
"addBatch",
"(",
"ApplicationDefinition",
"appDef",
",",
"OlapBatch",
"batch",
")",
"{",
"return",
"OLAPService",
".",
"instance",
"(",
")",
".",
"addBatch",
"(",
"appDef",
",",
"MONO_SHARD_NAME",
",",
"batch",
")",
";",
"}"
] | Add the given batch of object updates for the given application. The updates may
be new, updated, or deleted objects. The updates are applied to the application's
mono shard.
@param appDef Application to which update batch is applied.
@param batch {@link OlapBatch} of object adds, updates, and/or deletes.
@return {@link BatchResult} reflecting status of update. | [
"Add",
"the",
"given",
"batch",
"of",
"object",
"updates",
"for",
"the",
"given",
"application",
".",
"The",
"updates",
"may",
"be",
"new",
"updated",
"or",
"deleted",
"objects",
".",
"The",
"updates",
"are",
"applied",
"to",
"the",
"application",
"s",
"mono",
"shard",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java#L161-L163 |
palaima/DebugDrawer | debugdrawer/src/main/java/io/palaima/debugdrawer/util/UIUtils.java | UIUtils.getCompatDrawable | public static Drawable getCompatDrawable(Context c, int drawableRes) {
Drawable d = null;
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
d = c.getResources().getDrawable(drawableRes);
} else {
d = c.getResources().getDrawable(drawableRes, c.getTheme());
}
} catch (Exception ex) {
}
return d;
} | java | public static Drawable getCompatDrawable(Context c, int drawableRes) {
Drawable d = null;
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
d = c.getResources().getDrawable(drawableRes);
} else {
d = c.getResources().getDrawable(drawableRes, c.getTheme());
}
} catch (Exception ex) {
}
return d;
} | [
"public",
"static",
"Drawable",
"getCompatDrawable",
"(",
"Context",
"c",
",",
"int",
"drawableRes",
")",
"{",
"Drawable",
"d",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"{",
"d",
"=",
"c",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"drawableRes",
")",
";",
"}",
"else",
"{",
"d",
"=",
"c",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"drawableRes",
",",
"c",
".",
"getTheme",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"return",
"d",
";",
"}"
] | helper method to get the drawable by its resource. specific to the correct android version
@param c
@param drawableRes
@return | [
"helper",
"method",
"to",
"get",
"the",
"drawable",
"by",
"its",
"resource",
".",
"specific",
"to",
"the",
"correct",
"android",
"version"
] | train | https://github.com/palaima/DebugDrawer/blob/49b5992a1148757bd740c4a0b7df10ef70ade6d8/debugdrawer/src/main/java/io/palaima/debugdrawer/util/UIUtils.java#L64-L75 |
apache/incubator-zipkin | zipkin/src/main/java/zipkin2/internal/Trace.java | Trace.compareEndpoint | static int compareEndpoint(Endpoint left, Endpoint right) {
if (left == null) { // nulls first
return (right == null) ? 0 : -1;
} else if (right == null) {
return 1;
}
int byService = nullSafeCompareTo(left.serviceName(), right.serviceName(), false);
if (byService != 0) return byService;
int byIpV4 = nullSafeCompareTo(left.ipv4(), right.ipv4(), false);
if (byIpV4 != 0) return byIpV4;
return nullSafeCompareTo(left.ipv6(), right.ipv6(), false);
} | java | static int compareEndpoint(Endpoint left, Endpoint right) {
if (left == null) { // nulls first
return (right == null) ? 0 : -1;
} else if (right == null) {
return 1;
}
int byService = nullSafeCompareTo(left.serviceName(), right.serviceName(), false);
if (byService != 0) return byService;
int byIpV4 = nullSafeCompareTo(left.ipv4(), right.ipv4(), false);
if (byIpV4 != 0) return byIpV4;
return nullSafeCompareTo(left.ipv6(), right.ipv6(), false);
} | [
"static",
"int",
"compareEndpoint",
"(",
"Endpoint",
"left",
",",
"Endpoint",
"right",
")",
"{",
"if",
"(",
"left",
"==",
"null",
")",
"{",
"// nulls first",
"return",
"(",
"right",
"==",
"null",
")",
"?",
"0",
":",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"right",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"int",
"byService",
"=",
"nullSafeCompareTo",
"(",
"left",
".",
"serviceName",
"(",
")",
",",
"right",
".",
"serviceName",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"byService",
"!=",
"0",
")",
"return",
"byService",
";",
"int",
"byIpV4",
"=",
"nullSafeCompareTo",
"(",
"left",
".",
"ipv4",
"(",
")",
",",
"right",
".",
"ipv4",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"byIpV4",
"!=",
"0",
")",
"return",
"byIpV4",
";",
"return",
"nullSafeCompareTo",
"(",
"left",
".",
"ipv6",
"(",
")",
",",
"right",
".",
"ipv6",
"(",
")",
",",
"false",
")",
";",
"}"
] | Put spans with null endpoints first, so that their data can be attached to the first span with
the same ID and endpoint. It is possible that a server can get the same request on a different
port. Not addressing this. | [
"Put",
"spans",
"with",
"null",
"endpoints",
"first",
"so",
"that",
"their",
"data",
"can",
"be",
"attached",
"to",
"the",
"first",
"span",
"with",
"the",
"same",
"ID",
"and",
"endpoint",
".",
"It",
"is",
"possible",
"that",
"a",
"server",
"can",
"get",
"the",
"same",
"request",
"on",
"a",
"different",
"port",
".",
"Not",
"addressing",
"this",
"."
] | train | https://github.com/apache/incubator-zipkin/blob/89b2fab983fc626b3be32ce9d7cf64b3f01f1a87/zipkin/src/main/java/zipkin2/internal/Trace.java#L144-L155 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/PeriodFormatterBuilder.java | PeriodFormatterBuilder.appendSeparator | public PeriodFormatterBuilder appendSeparator(String text, String finalText,
String[] variants) {
return appendSeparator(text, finalText, variants, true, true);
} | java | public PeriodFormatterBuilder appendSeparator(String text, String finalText,
String[] variants) {
return appendSeparator(text, finalText, variants, true, true);
} | [
"public",
"PeriodFormatterBuilder",
"appendSeparator",
"(",
"String",
"text",
",",
"String",
"finalText",
",",
"String",
"[",
"]",
"variants",
")",
"{",
"return",
"appendSeparator",
"(",
"text",
",",
"finalText",
",",
"variants",
",",
"true",
",",
"true",
")",
";",
"}"
] | Append a separator, which is output if fields are printed both before
and after the separator.
<p>
This method changes the separator depending on whether it is the last separator
to be output.
<p>
For example, <code>builder.appendDays().appendSeparator(",", "&").appendHours().appendSeparator(",", "&").appendMinutes()</code>
will output '1,2&3' if all three fields are output, '1&2' if two fields are output
and '1' if just one field is output.
<p>
The text will be parsed case-insensitively.
<p>
Note: appending a separator discontinues any further work on the latest
appended field.
@param text the text to use as a separator
@param finalText the text used used if this is the final separator to be printed
@param variants set of text values which are also acceptable when parsed
@return this PeriodFormatterBuilder
@throws IllegalStateException if this separator follows a previous one | [
"Append",
"a",
"separator",
"which",
"is",
"output",
"if",
"fields",
"are",
"printed",
"both",
"before",
"and",
"after",
"the",
"separator",
".",
"<p",
">",
"This",
"method",
"changes",
"the",
"separator",
"depending",
"on",
"whether",
"it",
"is",
"the",
"last",
"separator",
"to",
"be",
"output",
".",
"<p",
">",
"For",
"example",
"<code",
">",
"builder",
".",
"appendDays",
"()",
".",
"appendSeparator",
"(",
"&",
")",
".",
"appendHours",
"()",
".",
"appendSeparator",
"(",
"&",
")",
".",
"appendMinutes",
"()",
"<",
"/",
"code",
">",
"will",
"output",
"1",
"2&3",
"if",
"all",
"three",
"fields",
"are",
"output",
"1&2",
"if",
"two",
"fields",
"are",
"output",
"and",
"1",
"if",
"just",
"one",
"field",
"is",
"output",
".",
"<p",
">",
"The",
"text",
"will",
"be",
"parsed",
"case",
"-",
"insensitively",
".",
"<p",
">",
"Note",
":",
"appending",
"a",
"separator",
"discontinues",
"any",
"further",
"work",
"on",
"the",
"latest",
"appended",
"field",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java#L818-L821 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/UtilReflection.java | UtilReflection.getMethod | public static <T> T getMethod(Object object, String name, Object... params)
{
Check.notNull(object);
Check.notNull(name);
Check.notNull(params);
try
{
final Class<?> clazz = getClass(object);
final Method method = clazz.getDeclaredMethod(name, getParamTypes(params));
setAccessible(method, true);
@SuppressWarnings("unchecked")
final T value = (T) method.invoke(object, params);
return value;
}
catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException exception)
{
if (exception.getCause() instanceof LionEngineException)
{
throw (LionEngineException) exception.getCause();
}
throw new LionEngineException(exception, ERROR_METHOD + name);
}
} | java | public static <T> T getMethod(Object object, String name, Object... params)
{
Check.notNull(object);
Check.notNull(name);
Check.notNull(params);
try
{
final Class<?> clazz = getClass(object);
final Method method = clazz.getDeclaredMethod(name, getParamTypes(params));
setAccessible(method, true);
@SuppressWarnings("unchecked")
final T value = (T) method.invoke(object, params);
return value;
}
catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException exception)
{
if (exception.getCause() instanceof LionEngineException)
{
throw (LionEngineException) exception.getCause();
}
throw new LionEngineException(exception, ERROR_METHOD + name);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getMethod",
"(",
"Object",
"object",
",",
"String",
"name",
",",
"Object",
"...",
"params",
")",
"{",
"Check",
".",
"notNull",
"(",
"object",
")",
";",
"Check",
".",
"notNull",
"(",
"name",
")",
";",
"Check",
".",
"notNull",
"(",
"params",
")",
";",
"try",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"getClass",
"(",
"object",
")",
";",
"final",
"Method",
"method",
"=",
"clazz",
".",
"getDeclaredMethod",
"(",
"name",
",",
"getParamTypes",
"(",
"params",
")",
")",
";",
"setAccessible",
"(",
"method",
",",
"true",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"T",
"value",
"=",
"(",
"T",
")",
"method",
".",
"invoke",
"(",
"object",
",",
"params",
")",
";",
"return",
"value",
";",
"}",
"catch",
"(",
"final",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"|",
"IllegalAccessException",
"exception",
")",
"{",
"if",
"(",
"exception",
".",
"getCause",
"(",
")",
"instanceof",
"LionEngineException",
")",
"{",
"throw",
"(",
"LionEngineException",
")",
"exception",
".",
"getCause",
"(",
")",
";",
"}",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_METHOD",
"+",
"name",
")",
";",
"}",
"}"
] | Get method and call its return value with parameters.
@param <T> The object type.
@param object The object caller (must not be <code>null</code>).
@param name The method name (must not be <code>null</code>).
@param params The method parameters (must not be <code>null</code>).
@return The value returned.
@throws LionEngineException If invalid parameters. | [
"Get",
"method",
"and",
"call",
"its",
"return",
"value",
"with",
"parameters",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilReflection.java#L220-L243 |
vlingo/vlingo-actors | src/main/java/io/vlingo/actors/Stage.java | Stage.actorFor | public <T> T actorFor(final Class<T> protocol, final Definition definition, final Logger logger) {
return actorFor(
protocol,
definition,
definition.parentOr(world.defaultParent()),
definition.supervisor(),
logger);
} | java | public <T> T actorFor(final Class<T> protocol, final Definition definition, final Logger logger) {
return actorFor(
protocol,
definition,
definition.parentOr(world.defaultParent()),
definition.supervisor(),
logger);
} | [
"public",
"<",
"T",
">",
"T",
"actorFor",
"(",
"final",
"Class",
"<",
"T",
">",
"protocol",
",",
"final",
"Definition",
"definition",
",",
"final",
"Logger",
"logger",
")",
"{",
"return",
"actorFor",
"(",
"protocol",
",",
"definition",
",",
"definition",
".",
"parentOr",
"(",
"world",
".",
"defaultParent",
"(",
")",
")",
",",
"definition",
".",
"supervisor",
"(",
")",
",",
"logger",
")",
";",
"}"
] | Answers the {@code T} protocol of the newly created {@code Actor} that implements the {@code protocol} and
that will be assigned the specific {@code logger}.
@param <T> the protocol type
@param protocol the {@code Class<T>} protocol
@param definition the {@code Definition} used to initialize the newly created {@code Actor}
@param logger the {@code Logger} to assign to the newly created {@code Actor}
@return T | [
"Answers",
"the",
"{"
] | train | https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/Stage.java#L103-L110 |
auth0/java-jwt | lib/src/main/java/com/auth0/jwt/algorithms/CryptoHelper.java | CryptoHelper.verifySignatureFor | boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException {
return MessageDigest.isEqual(createSignatureFor(algorithm, secretBytes, headerBytes, payloadBytes), signatureBytes);
} | java | boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException {
return MessageDigest.isEqual(createSignatureFor(algorithm, secretBytes, headerBytes, payloadBytes), signatureBytes);
} | [
"boolean",
"verifySignatureFor",
"(",
"String",
"algorithm",
",",
"byte",
"[",
"]",
"secretBytes",
",",
"byte",
"[",
"]",
"headerBytes",
",",
"byte",
"[",
"]",
"payloadBytes",
",",
"byte",
"[",
"]",
"signatureBytes",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
"{",
"return",
"MessageDigest",
".",
"isEqual",
"(",
"createSignatureFor",
"(",
"algorithm",
",",
"secretBytes",
",",
"headerBytes",
",",
"payloadBytes",
")",
",",
"signatureBytes",
")",
";",
"}"
] | Verify signature for JWT header and payload.
@param algorithm algorithm name.
@param secretBytes algorithm secret.
@param headerBytes JWT header.
@param payloadBytes JWT payload.
@param signatureBytes JWT signature.
@return true if signature is valid.
@throws NoSuchAlgorithmException if the algorithm is not supported.
@throws InvalidKeyException if the given key is inappropriate for initializing the specified algorithm. | [
"Verify",
"signature",
"for",
"JWT",
"header",
"and",
"payload",
"."
] | train | https://github.com/auth0/java-jwt/blob/890538970a9699b7251a4bfe4f26e8d7605ad530/lib/src/main/java/com/auth0/jwt/algorithms/CryptoHelper.java#L43-L45 |
JOML-CI/JOML | src/org/joml/Matrix4x3f.java | Matrix4x3f.rotateAround | public Matrix4x3f rotateAround(Quaternionfc quat, float ox, float oy, float oz) {
return rotateAround(quat, ox, oy, oz, this);
} | java | public Matrix4x3f rotateAround(Quaternionfc quat, float ox, float oy, float oz) {
return rotateAround(quat, ox, oy, oz, this);
} | [
"public",
"Matrix4x3f",
"rotateAround",
"(",
"Quaternionfc",
"quat",
",",
"float",
"ox",
",",
"float",
"oy",
",",
"float",
"oz",
")",
"{",
"return",
"rotateAround",
"(",
"quat",
",",
"ox",
",",
"oy",
",",
"oz",
",",
"this",
")",
";",
"}"
] | Apply the rotation transformation of the given {@link Quaternionfc} to this matrix while using <code>(ox, oy, oz)</code> as the rotation origin.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>Q</code> the rotation matrix obtained from the given quaternion,
then the new matrix will be <code>M * Q</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * Q * v</code>,
the quaternion rotation will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy, oz).rotate(quat).translate(-ox, -oy, -oz)</code>
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion">http://en.wikipedia.org</a>
@param quat
the {@link Quaternionfc}
@param ox
the x coordinate of the rotation origin
@param oy
the y coordinate of the rotation origin
@param oz
the z coordinate of the rotation origin
@return a matrix holding the result | [
"Apply",
"the",
"rotation",
"transformation",
"of",
"the",
"given",
"{",
"@link",
"Quaternionfc",
"}",
"to",
"this",
"matrix",
"while",
"using",
"<code",
">",
"(",
"ox",
"oy",
"oz",
")",
"<",
"/",
"code",
">",
"as",
"the",
"rotation",
"origin",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"Q<",
"/",
"code",
">",
"the",
"rotation",
"matrix",
"obtained",
"from",
"the",
"given",
"quaternion",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"Q<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"Q",
"*",
"v<",
"/",
"code",
">",
"the",
"quaternion",
"rotation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translate",
"(",
"ox",
"oy",
"oz",
")",
".",
"rotate",
"(",
"quat",
")",
".",
"translate",
"(",
"-",
"ox",
"-",
"oy",
"-",
"oz",
")",
"<",
"/",
"code",
">",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rotation_matrix#Quaternion",
">",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L4008-L4010 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.