repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
218
| func_name
stringlengths 5
140
| whole_func_string
stringlengths 79
3.99k
| language
stringclasses 1
value | func_code_string
stringlengths 79
3.99k
| func_code_tokens
listlengths 20
624
| func_documentation_string
stringlengths 61
1.96k
| func_documentation_tokens
listlengths 1
478
| split_name
stringclasses 1
value | func_code_url
stringlengths 107
339
|
---|---|---|---|---|---|---|---|---|---|---|
lastaflute/lasta-di
|
src/main/java/org/lastaflute/di/util/LdiSrl.java
|
LdiSrl.substringLastFrontIgnoreCase
|
public static String substringLastFrontIgnoreCase(String str, String... delimiters) {
assertStringNotNull(str);
return doSubstringFirstRear(true, false, true, str, delimiters);
}
|
java
|
public static String substringLastFrontIgnoreCase(String str, String... delimiters) {
assertStringNotNull(str);
return doSubstringFirstRear(true, false, true, str, delimiters);
}
|
[
"public",
"static",
"String",
"substringLastFrontIgnoreCase",
"(",
"String",
"str",
",",
"String",
"...",
"delimiters",
")",
"{",
"assertStringNotNull",
"(",
"str",
")",
";",
"return",
"doSubstringFirstRear",
"(",
"true",
",",
"false",
",",
"true",
",",
"str",
",",
"delimiters",
")",
";",
"}"
] |
Extract front sub-string from last-found delimiter ignoring case.
<pre>
substringLastFront("foo.bar/baz.qux", "A", "U")
returns "foo.bar/baz.q"
</pre>
@param str The target string. (NotNull)
@param delimiters The array of delimiters. (NotNull)
@return The part of string. (NotNull: if delimiter not found, returns argument-plain string)
|
[
"Extract",
"front",
"sub",
"-",
"string",
"from",
"last",
"-",
"found",
"delimiter",
"ignoring",
"case",
".",
"<pre",
">",
"substringLastFront",
"(",
"foo",
".",
"bar",
"/",
"baz",
".",
"qux",
"A",
"U",
")",
"returns",
"foo",
".",
"bar",
"/",
"baz",
".",
"q",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/lastaflute/lasta-di/blob/c4e123610c53a04cc836c5e456660e32d613447b/src/main/java/org/lastaflute/di/util/LdiSrl.java#L702-L705
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/swing/actions/OpenFileAction.java
|
OpenFileAction.onFileChoose
|
protected void onFileChoose(JFileChooser fileChooser, ActionEvent actionEvent)
{
final int returnVal = fileChooser.showOpenDialog(parent);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
final File file = fileChooser.getSelectedFile();
onApproveOption(file, actionEvent);
}
else
{
onCancel(actionEvent);
}
}
|
java
|
protected void onFileChoose(JFileChooser fileChooser, ActionEvent actionEvent)
{
final int returnVal = fileChooser.showOpenDialog(parent);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
final File file = fileChooser.getSelectedFile();
onApproveOption(file, actionEvent);
}
else
{
onCancel(actionEvent);
}
}
|
[
"protected",
"void",
"onFileChoose",
"(",
"JFileChooser",
"fileChooser",
",",
"ActionEvent",
"actionEvent",
")",
"{",
"final",
"int",
"returnVal",
"=",
"fileChooser",
".",
"showOpenDialog",
"(",
"parent",
")",
";",
"if",
"(",
"returnVal",
"==",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"final",
"File",
"file",
"=",
"fileChooser",
".",
"getSelectedFile",
"(",
")",
";",
"onApproveOption",
"(",
"file",
",",
"actionEvent",
")",
";",
"}",
"else",
"{",
"onCancel",
"(",
"actionEvent",
")",
";",
"}",
"}"
] |
Callback method to interact on file choose.
@param fileChooser
the file chooser
@param actionEvent
the action event
|
[
"Callback",
"method",
"to",
"interact",
"on",
"file",
"choose",
"."
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/actions/OpenFileAction.java#L105-L118
|
googleads/googleads-java-lib
|
modules/ads_lib_appengine/src/main/java/com/google/api/ads/common/lib/soap/jaxws/JaxWsSoapContextHandler.java
|
JaxWsSoapContextHandler.handleMessage
|
@Override
public boolean handleMessage(SOAPMessageContext context) {
if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
// Outbound message (request), so reset the last request and response builders.
lastRequestInfo = new RequestInfo.Builder();
lastResponseInfo = new ResponseInfo.Builder();
SOAPMessage soapMessage = context.getMessage();
try {
SOAPHeader soapHeader = soapMessage.getSOAPHeader();
if (soapHeader == null) {
soapHeader = soapMessage.getSOAPPart().getEnvelope().addHeader();
}
for (SOAPElement header : soapHeaders) {
soapHeader.addChildElement(header);
}
} catch (SOAPException e) {
throw new ServiceException("Error setting SOAP headers on outbound message.", e);
}
captureServiceAndOperationNames(context);
}
captureSoapXml(context);
return true;
}
|
java
|
@Override
public boolean handleMessage(SOAPMessageContext context) {
if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
// Outbound message (request), so reset the last request and response builders.
lastRequestInfo = new RequestInfo.Builder();
lastResponseInfo = new ResponseInfo.Builder();
SOAPMessage soapMessage = context.getMessage();
try {
SOAPHeader soapHeader = soapMessage.getSOAPHeader();
if (soapHeader == null) {
soapHeader = soapMessage.getSOAPPart().getEnvelope().addHeader();
}
for (SOAPElement header : soapHeaders) {
soapHeader.addChildElement(header);
}
} catch (SOAPException e) {
throw new ServiceException("Error setting SOAP headers on outbound message.", e);
}
captureServiceAndOperationNames(context);
}
captureSoapXml(context);
return true;
}
|
[
"@",
"Override",
"public",
"boolean",
"handleMessage",
"(",
"SOAPMessageContext",
"context",
")",
"{",
"if",
"(",
"(",
"Boolean",
")",
"context",
".",
"get",
"(",
"MessageContext",
".",
"MESSAGE_OUTBOUND_PROPERTY",
")",
")",
"{",
"// Outbound message (request), so reset the last request and response builders.",
"lastRequestInfo",
"=",
"new",
"RequestInfo",
".",
"Builder",
"(",
")",
";",
"lastResponseInfo",
"=",
"new",
"ResponseInfo",
".",
"Builder",
"(",
")",
";",
"SOAPMessage",
"soapMessage",
"=",
"context",
".",
"getMessage",
"(",
")",
";",
"try",
"{",
"SOAPHeader",
"soapHeader",
"=",
"soapMessage",
".",
"getSOAPHeader",
"(",
")",
";",
"if",
"(",
"soapHeader",
"==",
"null",
")",
"{",
"soapHeader",
"=",
"soapMessage",
".",
"getSOAPPart",
"(",
")",
".",
"getEnvelope",
"(",
")",
".",
"addHeader",
"(",
")",
";",
"}",
"for",
"(",
"SOAPElement",
"header",
":",
"soapHeaders",
")",
"{",
"soapHeader",
".",
"addChildElement",
"(",
"header",
")",
";",
"}",
"}",
"catch",
"(",
"SOAPException",
"e",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"\"Error setting SOAP headers on outbound message.\"",
",",
"e",
")",
";",
"}",
"captureServiceAndOperationNames",
"(",
"context",
")",
";",
"}",
"captureSoapXml",
"(",
"context",
")",
";",
"return",
"true",
";",
"}"
] |
Captures pertinent information from SOAP messages exchanged by the SOAP
service this handler is attached to. Also responsible for placing custom
(implicit) SOAP headers on outgoing messages.
@see SOAPHandler#handleMessage(MessageContext)
@param context the context of the SOAP message passing through this handler
@return whether this SOAP interaction should continue
|
[
"Captures",
"pertinent",
"information",
"from",
"SOAP",
"messages",
"exchanged",
"by",
"the",
"SOAP",
"service",
"this",
"handler",
"is",
"attached",
"to",
".",
"Also",
"responsible",
"for",
"placing",
"custom",
"(",
"implicit",
")",
"SOAP",
"headers",
"on",
"outgoing",
"messages",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib_appengine/src/main/java/com/google/api/ads/common/lib/soap/jaxws/JaxWsSoapContextHandler.java#L70-L93
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/authorization/providers/YamlProvider.java
|
YamlProvider.sourceFromStream
|
public static CacheableYamlSource sourceFromStream(
final String identity,
final InputStream stream,
final Date modified,
final ValidationSet validationSet
)
{
return new CacheableYamlStreamSource(stream, identity, modified, validationSet);
}
|
java
|
public static CacheableYamlSource sourceFromStream(
final String identity,
final InputStream stream,
final Date modified,
final ValidationSet validationSet
)
{
return new CacheableYamlStreamSource(stream, identity, modified, validationSet);
}
|
[
"public",
"static",
"CacheableYamlSource",
"sourceFromStream",
"(",
"final",
"String",
"identity",
",",
"final",
"InputStream",
"stream",
",",
"final",
"Date",
"modified",
",",
"final",
"ValidationSet",
"validationSet",
")",
"{",
"return",
"new",
"CacheableYamlStreamSource",
"(",
"stream",
",",
"identity",
",",
"modified",
",",
"validationSet",
")",
";",
"}"
] |
Source from a stream
@param identity identity
@param stream stream
@param modified date the content was last modified, for caching purposes
@param validationSet
@return source
|
[
"Source",
"from",
"a",
"stream"
] |
train
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/authorization/providers/YamlProvider.java#L255-L263
|
aws/aws-sdk-java
|
aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/util/SignatureChecker.java
|
SignatureChecker.verifySignature
|
public boolean verifySignature(Map<String, String> parsedMessage, PublicKey publicKey) {
boolean valid = false;
String version = parsedMessage.get(SIGNATURE_VERSION);
if (version.equals("1")) {
// construct the canonical signed string
String type = parsedMessage.get(TYPE);
String signature = parsedMessage.get(SIGNATURE);
String signed;
if (type.equals(NOTIFICATION_TYPE)) {
signed = stringToSign(publishMessageValues(parsedMessage));
} else if (type.equals(SUBSCRIBE_TYPE)) {
signed = stringToSign(subscribeMessageValues(parsedMessage));
} else if (type.equals(UNSUBSCRIBE_TYPE)) {
signed = stringToSign(subscribeMessageValues(parsedMessage)); // no difference, for now
} else {
throw new RuntimeException("Cannot process message of type " + type);
}
valid = verifySignature(signed, signature, publicKey);
}
return valid;
}
|
java
|
public boolean verifySignature(Map<String, String> parsedMessage, PublicKey publicKey) {
boolean valid = false;
String version = parsedMessage.get(SIGNATURE_VERSION);
if (version.equals("1")) {
// construct the canonical signed string
String type = parsedMessage.get(TYPE);
String signature = parsedMessage.get(SIGNATURE);
String signed;
if (type.equals(NOTIFICATION_TYPE)) {
signed = stringToSign(publishMessageValues(parsedMessage));
} else if (type.equals(SUBSCRIBE_TYPE)) {
signed = stringToSign(subscribeMessageValues(parsedMessage));
} else if (type.equals(UNSUBSCRIBE_TYPE)) {
signed = stringToSign(subscribeMessageValues(parsedMessage)); // no difference, for now
} else {
throw new RuntimeException("Cannot process message of type " + type);
}
valid = verifySignature(signed, signature, publicKey);
}
return valid;
}
|
[
"public",
"boolean",
"verifySignature",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parsedMessage",
",",
"PublicKey",
"publicKey",
")",
"{",
"boolean",
"valid",
"=",
"false",
";",
"String",
"version",
"=",
"parsedMessage",
".",
"get",
"(",
"SIGNATURE_VERSION",
")",
";",
"if",
"(",
"version",
".",
"equals",
"(",
"\"1\"",
")",
")",
"{",
"// construct the canonical signed string",
"String",
"type",
"=",
"parsedMessage",
".",
"get",
"(",
"TYPE",
")",
";",
"String",
"signature",
"=",
"parsedMessage",
".",
"get",
"(",
"SIGNATURE",
")",
";",
"String",
"signed",
";",
"if",
"(",
"type",
".",
"equals",
"(",
"NOTIFICATION_TYPE",
")",
")",
"{",
"signed",
"=",
"stringToSign",
"(",
"publishMessageValues",
"(",
"parsedMessage",
")",
")",
";",
"}",
"else",
"if",
"(",
"type",
".",
"equals",
"(",
"SUBSCRIBE_TYPE",
")",
")",
"{",
"signed",
"=",
"stringToSign",
"(",
"subscribeMessageValues",
"(",
"parsedMessage",
")",
")",
";",
"}",
"else",
"if",
"(",
"type",
".",
"equals",
"(",
"UNSUBSCRIBE_TYPE",
")",
")",
"{",
"signed",
"=",
"stringToSign",
"(",
"subscribeMessageValues",
"(",
"parsedMessage",
")",
")",
";",
"// no difference, for now",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot process message of type \"",
"+",
"type",
")",
";",
"}",
"valid",
"=",
"verifySignature",
"(",
"signed",
",",
"signature",
",",
"publicKey",
")",
";",
"}",
"return",
"valid",
";",
"}"
] |
Validates the signature on a Simple Notification Service message. No
Amazon-specific dependencies, just plain Java crypto
@param parsedMessage
A map of Simple Notification Service message.
@param publicKey
The Simple Notification Service public key, exactly as you'd
see it when retrieved from the cert.
@return True if the message was correctly validated, otherwise false.
|
[
"Validates",
"the",
"signature",
"on",
"a",
"Simple",
"Notification",
"Service",
"message",
".",
"No",
"Amazon",
"-",
"specific",
"dependencies",
"just",
"plain",
"Java",
"crypto"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/util/SignatureChecker.java#L111-L131
|
before/quality-check
|
modules/quality-check/src/main/java/net/sf/qualitycheck/ConditionalCheck.java
|
ConditionalCheck.notEmpty
|
@ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalEmptyArgumentException.class })
public static void notEmpty(final boolean condition, final boolean expression) {
if (condition) {
Check.notEmpty(expression);
}
}
|
java
|
@ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalEmptyArgumentException.class })
public static void notEmpty(final boolean condition, final boolean expression) {
if (condition) {
Check.notEmpty(expression);
}
}
|
[
"@",
"ArgumentsChecked",
"@",
"Throws",
"(",
"{",
"IllegalNullArgumentException",
".",
"class",
",",
"IllegalEmptyArgumentException",
".",
"class",
"}",
")",
"public",
"static",
"void",
"notEmpty",
"(",
"final",
"boolean",
"condition",
",",
"final",
"boolean",
"expression",
")",
"{",
"if",
"(",
"condition",
")",
"{",
"Check",
".",
"notEmpty",
"(",
"expression",
")",
";",
"}",
"}"
] |
Ensures that a passed parameter of the calling method is not empty, using the passed expression to evaluate the
emptiness.
<p>
We recommend to use the overloaded method {@link Check#notEmpty(boolean, String)} and pass as second argument the
name of the parameter to enhance the exception message.
@param condition
condition must be {@code true}^ so that the check will be performed
@param expression
the result of the expression to verify the emptiness of a reference ({@code true} means empty,
{@code false} means not empty)
@throws IllegalNullArgumentException
if the given argument {@code reference} is {@code null}
@throws IllegalEmptyArgumentException
if the given argument {@code reference} is empty
|
[
"Ensures",
"that",
"a",
"passed",
"parameter",
"of",
"the",
"calling",
"method",
"is",
"not",
"empty",
"using",
"the",
"passed",
"expression",
"to",
"evaluate",
"the",
"emptiness",
"."
] |
train
|
https://github.com/before/quality-check/blob/a75c32c39434ddb1f89bece57acae0536724c15a/modules/quality-check/src/main/java/net/sf/qualitycheck/ConditionalCheck.java#L1160-L1166
|
FaritorKang/unmz-common-util
|
src/main/java/net/unmz/java/util/http/HttpUtils.java
|
HttpUtils.doPutResponse
|
public static HttpResponse doPutResponse(String host, String path,
Map<String, String> headers,
Map<String, String> queries) throws Exception {
return doPutResponse(host, path, headers, queries, "");
}
|
java
|
public static HttpResponse doPutResponse(String host, String path,
Map<String, String> headers,
Map<String, String> queries) throws Exception {
return doPutResponse(host, path, headers, queries, "");
}
|
[
"public",
"static",
"HttpResponse",
"doPutResponse",
"(",
"String",
"host",
",",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Map",
"<",
"String",
",",
"String",
">",
"queries",
")",
"throws",
"Exception",
"{",
"return",
"doPutResponse",
"(",
"host",
",",
"path",
",",
"headers",
",",
"queries",
",",
"\"\"",
")",
";",
"}"
] |
Put String
@param host
@param path
@param headers
@param queries
@param body
@return
@throws Exception
|
[
"Put",
"String"
] |
train
|
https://github.com/FaritorKang/unmz-common-util/blob/2912b8889b85ed910d536f85b24b6fa68035814a/src/main/java/net/unmz/java/util/http/HttpUtils.java#L281-L285
|
finmath/finmath-lib
|
src/main/java6/net/finmath/marketdata/model/curves/HazardCurve.java
|
HazardCurve.createHazardCurveFromSurvivalProbabilities
|
public static HazardCurve createHazardCurveFromSurvivalProbabilities(
String name, LocalDate referenceDate,
double[] times, double[] givenSurvivalProbabilities, boolean[] isParameter,
InterpolationMethod interpolationMethod, ExtrapolationMethod extrapolationMethod, InterpolationEntity interpolationEntity) {
//We check that all input survival probabilities are in the range [0,1]
for( int i = 0; i < givenSurvivalProbabilities.length; i++){
if(givenSurvivalProbabilities[i] < 0 || givenSurvivalProbabilities[i] > 1) {
throw new IllegalArgumentException("Survival Probabilities must be between 0 and 1");
}
}
HazardCurve survivalProbabilities = new HazardCurve(name, referenceDate, interpolationMethod, extrapolationMethod, interpolationEntity);
for(int timeIndex=0; timeIndex<times.length;timeIndex++) {
survivalProbabilities.addSurvivalProbability(times[timeIndex], givenSurvivalProbabilities[timeIndex], isParameter != null && isParameter[timeIndex]);
}
return survivalProbabilities;
}
|
java
|
public static HazardCurve createHazardCurveFromSurvivalProbabilities(
String name, LocalDate referenceDate,
double[] times, double[] givenSurvivalProbabilities, boolean[] isParameter,
InterpolationMethod interpolationMethod, ExtrapolationMethod extrapolationMethod, InterpolationEntity interpolationEntity) {
//We check that all input survival probabilities are in the range [0,1]
for( int i = 0; i < givenSurvivalProbabilities.length; i++){
if(givenSurvivalProbabilities[i] < 0 || givenSurvivalProbabilities[i] > 1) {
throw new IllegalArgumentException("Survival Probabilities must be between 0 and 1");
}
}
HazardCurve survivalProbabilities = new HazardCurve(name, referenceDate, interpolationMethod, extrapolationMethod, interpolationEntity);
for(int timeIndex=0; timeIndex<times.length;timeIndex++) {
survivalProbabilities.addSurvivalProbability(times[timeIndex], givenSurvivalProbabilities[timeIndex], isParameter != null && isParameter[timeIndex]);
}
return survivalProbabilities;
}
|
[
"public",
"static",
"HazardCurve",
"createHazardCurveFromSurvivalProbabilities",
"(",
"String",
"name",
",",
"LocalDate",
"referenceDate",
",",
"double",
"[",
"]",
"times",
",",
"double",
"[",
"]",
"givenSurvivalProbabilities",
",",
"boolean",
"[",
"]",
"isParameter",
",",
"InterpolationMethod",
"interpolationMethod",
",",
"ExtrapolationMethod",
"extrapolationMethod",
",",
"InterpolationEntity",
"interpolationEntity",
")",
"{",
"//We check that all input survival probabilities are in the range [0,1]",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"givenSurvivalProbabilities",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"givenSurvivalProbabilities",
"[",
"i",
"]",
"<",
"0",
"||",
"givenSurvivalProbabilities",
"[",
"i",
"]",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Survival Probabilities must be between 0 and 1\"",
")",
";",
"}",
"}",
"HazardCurve",
"survivalProbabilities",
"=",
"new",
"HazardCurve",
"(",
"name",
",",
"referenceDate",
",",
"interpolationMethod",
",",
"extrapolationMethod",
",",
"interpolationEntity",
")",
";",
"for",
"(",
"int",
"timeIndex",
"=",
"0",
";",
"timeIndex",
"<",
"times",
".",
"length",
";",
"timeIndex",
"++",
")",
"{",
"survivalProbabilities",
".",
"addSurvivalProbability",
"(",
"times",
"[",
"timeIndex",
"]",
",",
"givenSurvivalProbabilities",
"[",
"timeIndex",
"]",
",",
"isParameter",
"!=",
"null",
"&&",
"isParameter",
"[",
"timeIndex",
"]",
")",
";",
"}",
"return",
"survivalProbabilities",
";",
"}"
] |
Create a hazard curve from given times and given survival probabilities using given interpolation and extrapolation methods.
@param name The name of this hazard curve.
@param referenceDate The reference date for this curve, i.e., the date which defined t=0.
@param times Array of times as doubles.
@param givenSurvivalProbabilities Array of corresponding survival probabilities.
@param isParameter Array of booleans specifying whether this point is served "as as parameter", e.g., whether it is calibrates (e.g. using CalibratedCurves).
@param interpolationMethod The interpolation method used for the curve.
@param extrapolationMethod The extrapolation method used for the curve.
@param interpolationEntity The entity interpolated/extrapolated.
@return A new hazard curve object.
|
[
"Create",
"a",
"hazard",
"curve",
"from",
"given",
"times",
"and",
"given",
"survival",
"probabilities",
"using",
"given",
"interpolation",
"and",
"extrapolation",
"methods",
"."
] |
train
|
https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java6/net/finmath/marketdata/model/curves/HazardCurve.java#L76-L95
|
baratine/baratine
|
kraken/src/main/java/com/caucho/v5/kraken/query/SelectQueryLocal.java
|
SelectQueryLocal.onFindAll
|
private Iterable<Cursor> onFindAll(EnvKelp envKelp,
Iterable<RowCursor> rowIter)
{
if (rowIter == null) {
return null;
}
return new CursorIterable(envKelp, rowIter, _results);
}
|
java
|
private Iterable<Cursor> onFindAll(EnvKelp envKelp,
Iterable<RowCursor> rowIter)
{
if (rowIter == null) {
return null;
}
return new CursorIterable(envKelp, rowIter, _results);
}
|
[
"private",
"Iterable",
"<",
"Cursor",
">",
"onFindAll",
"(",
"EnvKelp",
"envKelp",
",",
"Iterable",
"<",
"RowCursor",
">",
"rowIter",
")",
"{",
"if",
"(",
"rowIter",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"CursorIterable",
"(",
"envKelp",
",",
"rowIter",
",",
"_results",
")",
";",
"}"
] |
/*
private class FindAllResult extends Result.Wrapper<Iterable<RowCursor>,Iterable<Cursor>>
{
private EnvKelp _envKelp;
FindAllResult(EnvKelp envKelp, Result<Iterable<Cursor>> result)
{
super(result);
_envKelp = envKelp;
}
@Override
public void complete(Iterable<RowCursor> rowIter)
{
if (rowIter == null) {
getNext().complete(null);
return;
}
getNext().complete(new CursorIterable(_envKelp, rowIter, _results));
}
}
|
[
"/",
"*",
"private",
"class",
"FindAllResult",
"extends",
"Result",
".",
"Wrapper<Iterable<RowCursor",
">",
"Iterable<Cursor",
">>",
"{",
"private",
"EnvKelp",
"_envKelp",
";"
] |
train
|
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/query/SelectQueryLocal.java#L420-L428
|
alkacon/opencms-core
|
src/org/opencms/gwt/CmsAliasHelper.java
|
CmsAliasHelper.checkValidAliasPath
|
protected String checkValidAliasPath(String path, Locale locale) {
if (org.opencms.db.CmsAlias.ALIAS_PATTERN.matcher(path).matches()) {
return null;
} else {
return Messages.get().getBundle(locale).key(Messages.ERR_ALIAS_INVALID_PATH_0);
}
}
|
java
|
protected String checkValidAliasPath(String path, Locale locale) {
if (org.opencms.db.CmsAlias.ALIAS_PATTERN.matcher(path).matches()) {
return null;
} else {
return Messages.get().getBundle(locale).key(Messages.ERR_ALIAS_INVALID_PATH_0);
}
}
|
[
"protected",
"String",
"checkValidAliasPath",
"(",
"String",
"path",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"org",
".",
"opencms",
".",
"db",
".",
"CmsAlias",
".",
"ALIAS_PATTERN",
".",
"matcher",
"(",
"path",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
"locale",
")",
".",
"key",
"(",
"Messages",
".",
"ERR_ALIAS_INVALID_PATH_0",
")",
";",
"}",
"}"
] |
Checks whether a given string is a valid alias path.<p>
@param path the path to check
@param locale the locale to use for validation messages
@return null if the string is a valid alias path, else an error message
|
[
"Checks",
"whether",
"a",
"given",
"string",
"is",
"a",
"valid",
"alias",
"path",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/gwt/CmsAliasHelper.java#L154-L161
|
VoltDB/voltdb
|
third_party/java/src/com/google_voltpatches/common/collect/MapConstraints.java
|
MapConstraints.constrainedEntries
|
private static <K, V> Collection<Entry<K, V>> constrainedEntries(
Collection<Entry<K, V>> entries, MapConstraint<? super K, ? super V> constraint) {
if (entries instanceof Set) {
return constrainedEntrySet((Set<Entry<K, V>>) entries, constraint);
}
return new ConstrainedEntries<K, V>(entries, constraint);
}
|
java
|
private static <K, V> Collection<Entry<K, V>> constrainedEntries(
Collection<Entry<K, V>> entries, MapConstraint<? super K, ? super V> constraint) {
if (entries instanceof Set) {
return constrainedEntrySet((Set<Entry<K, V>>) entries, constraint);
}
return new ConstrainedEntries<K, V>(entries, constraint);
}
|
[
"private",
"static",
"<",
"K",
",",
"V",
">",
"Collection",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"constrainedEntries",
"(",
"Collection",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"entries",
",",
"MapConstraint",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"V",
">",
"constraint",
")",
"{",
"if",
"(",
"entries",
"instanceof",
"Set",
")",
"{",
"return",
"constrainedEntrySet",
"(",
"(",
"Set",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
")",
"entries",
",",
"constraint",
")",
";",
"}",
"return",
"new",
"ConstrainedEntries",
"<",
"K",
",",
"V",
">",
"(",
"entries",
",",
"constraint",
")",
";",
"}"
] |
Returns a constrained view of the specified collection (or set) of entries,
using the specified constraint. The {@link Entry#setValue} operation will
be verified with the constraint, along with add operations on the returned
collection. The {@code add} and {@code addAll} operations simply forward to
the underlying collection, which throws an {@link
UnsupportedOperationException} per the map and multimap specification.
@param entries the entries to constrain
@param constraint the constraint for the entries
@return a constrained view of the specified entries
|
[
"Returns",
"a",
"constrained",
"view",
"of",
"the",
"specified",
"collection",
"(",
"or",
"set",
")",
"of",
"entries",
"using",
"the",
"specified",
"constraint",
".",
"The",
"{",
"@link",
"Entry#setValue",
"}",
"operation",
"will",
"be",
"verified",
"with",
"the",
"constraint",
"along",
"with",
"add",
"operations",
"on",
"the",
"returned",
"collection",
".",
"The",
"{",
"@code",
"add",
"}",
"and",
"{",
"@code",
"addAll",
"}",
"operations",
"simply",
"forward",
"to",
"the",
"underlying",
"collection",
"which",
"throws",
"an",
"{",
"@link",
"UnsupportedOperationException",
"}",
"per",
"the",
"map",
"and",
"multimap",
"specification",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/collect/MapConstraints.java#L182-L188
|
JadiraOrg/jadira
|
jms/src/main/java/org/jadira/jms/template/BatchedJmsTemplate.java
|
BatchedJmsTemplate.receiveBatch
|
public List<Message> receiveBatch(int batchSize) throws JmsException {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
return receiveBatch(defaultDestination, batchSize);
} else {
return receiveBatch(getRequiredDefaultDestinationName(), batchSize);
}
}
|
java
|
public List<Message> receiveBatch(int batchSize) throws JmsException {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
return receiveBatch(defaultDestination, batchSize);
} else {
return receiveBatch(getRequiredDefaultDestinationName(), batchSize);
}
}
|
[
"public",
"List",
"<",
"Message",
">",
"receiveBatch",
"(",
"int",
"batchSize",
")",
"throws",
"JmsException",
"{",
"Destination",
"defaultDestination",
"=",
"getDefaultDestination",
"(",
")",
";",
"if",
"(",
"defaultDestination",
"!=",
"null",
")",
"{",
"return",
"receiveBatch",
"(",
"defaultDestination",
",",
"batchSize",
")",
";",
"}",
"else",
"{",
"return",
"receiveBatch",
"(",
"getRequiredDefaultDestinationName",
"(",
")",
",",
"batchSize",
")",
";",
"}",
"}"
] |
Receive a batch of up to batchSize. Other than batching this method is the same as {@link JmsTemplate#receive()}
@return A list of {@link Message}
@param batchSize The batch size
@throws JmsException The {@link JmsException}
|
[
"Receive",
"a",
"batch",
"of",
"up",
"to",
"batchSize",
".",
"Other",
"than",
"batching",
"this",
"method",
"is",
"the",
"same",
"as",
"{"
] |
train
|
https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/jms/src/main/java/org/jadira/jms/template/BatchedJmsTemplate.java#L121-L130
|
osiam/connector4java
|
src/main/java/org/osiam/client/OsiamConnector.java
|
OsiamConnector.createGroup
|
public Group createGroup(Group group, AccessToken accessToken) {
return getGroupService().createGroup(group, accessToken);
}
|
java
|
public Group createGroup(Group group, AccessToken accessToken) {
return getGroupService().createGroup(group, accessToken);
}
|
[
"public",
"Group",
"createGroup",
"(",
"Group",
"group",
",",
"AccessToken",
"accessToken",
")",
"{",
"return",
"getGroupService",
"(",
")",
".",
"createGroup",
"(",
"group",
",",
"accessToken",
")",
";",
"}"
] |
saves the given {@link Group} to the OSIAM DB.
@param group group to be saved
@param accessToken the OSIAM access token from for the current session
@return the same group Object like the given but with filled metadata and a new valid id
@throws UnauthorizedException if the request could not be authorized.
@throws ConflictException if the Group could not be created
@throws ForbiddenException if the scope doesn't allow this request
@throws ConnectionInitializationException if the connection to the given OSIAM service could not be initialized
@throws IllegalStateException if OSIAM's endpoint(s) are not properly configured
|
[
"saves",
"the",
"given",
"{",
"@link",
"Group",
"}",
"to",
"the",
"OSIAM",
"DB",
"."
] |
train
|
https://github.com/osiam/connector4java/blob/a5e6ae1e706f4889d662a069fe2f3bf8e3848d12/src/main/java/org/osiam/client/OsiamConnector.java#L470-L472
|
aerogear/aerogear-android-pipe
|
library/src/main/java/org/jboss/aerogear/android/pipe/PipeManager.java
|
PipeManager.getPipe
|
public static LoaderPipe getPipe(String name, android.support.v4.app.Fragment fragment, Context applicationContext) {
Pipe pipe = pipes.get(name);
LoaderAdapter adapter = new LoaderAdapter(fragment, applicationContext, pipe, name);
adapter.setLoaderIds(loaderIdsForNamed);
return adapter;
}
|
java
|
public static LoaderPipe getPipe(String name, android.support.v4.app.Fragment fragment, Context applicationContext) {
Pipe pipe = pipes.get(name);
LoaderAdapter adapter = new LoaderAdapter(fragment, applicationContext, pipe, name);
adapter.setLoaderIds(loaderIdsForNamed);
return adapter;
}
|
[
"public",
"static",
"LoaderPipe",
"getPipe",
"(",
"String",
"name",
",",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"Fragment",
"fragment",
",",
"Context",
"applicationContext",
")",
"{",
"Pipe",
"pipe",
"=",
"pipes",
".",
"get",
"(",
"name",
")",
";",
"LoaderAdapter",
"adapter",
"=",
"new",
"LoaderAdapter",
"(",
"fragment",
",",
"applicationContext",
",",
"pipe",
",",
"name",
")",
";",
"adapter",
".",
"setLoaderIds",
"(",
"loaderIdsForNamed",
")",
";",
"return",
"adapter",
";",
"}"
] |
Look up for a pipe object. This will wrap the Pipe in a Loader.
@param name the name of the actual pipe
@param fragment the Fragment whose lifecycle the activity will follow
@param applicationContext the Context of the application.
@return the new created Pipe object
|
[
"Look",
"up",
"for",
"a",
"pipe",
"object",
".",
"This",
"will",
"wrap",
"the",
"Pipe",
"in",
"a",
"Loader",
"."
] |
train
|
https://github.com/aerogear/aerogear-android-pipe/blob/ac747965c2d06d6ad46dd8abfbabf3d793f06fa5/library/src/main/java/org/jboss/aerogear/android/pipe/PipeManager.java#L152-L157
|
alkacon/opencms-core
|
src/org/opencms/importexport/CmsExport.java
|
CmsExport.addRelationNode
|
protected void addRelationNode(Element relationsElement, String structureId, String sitePath, String relationType) {
if ((structureId != null) && (sitePath != null) && (relationType != null)) {
Element relationElement = relationsElement.addElement(CmsImportVersion10.N_RELATION);
relationElement.addElement(CmsImportVersion10.N_ID).addText(structureId);
relationElement.addElement(CmsImportVersion10.N_PATH).addText(sitePath);
relationElement.addElement(CmsImportVersion10.N_TYPE).addText(relationType);
}
}
|
java
|
protected void addRelationNode(Element relationsElement, String structureId, String sitePath, String relationType) {
if ((structureId != null) && (sitePath != null) && (relationType != null)) {
Element relationElement = relationsElement.addElement(CmsImportVersion10.N_RELATION);
relationElement.addElement(CmsImportVersion10.N_ID).addText(structureId);
relationElement.addElement(CmsImportVersion10.N_PATH).addText(sitePath);
relationElement.addElement(CmsImportVersion10.N_TYPE).addText(relationType);
}
}
|
[
"protected",
"void",
"addRelationNode",
"(",
"Element",
"relationsElement",
",",
"String",
"structureId",
",",
"String",
"sitePath",
",",
"String",
"relationType",
")",
"{",
"if",
"(",
"(",
"structureId",
"!=",
"null",
")",
"&&",
"(",
"sitePath",
"!=",
"null",
")",
"&&",
"(",
"relationType",
"!=",
"null",
")",
")",
"{",
"Element",
"relationElement",
"=",
"relationsElement",
".",
"addElement",
"(",
"CmsImportVersion10",
".",
"N_RELATION",
")",
";",
"relationElement",
".",
"addElement",
"(",
"CmsImportVersion10",
".",
"N_ID",
")",
".",
"addText",
"(",
"structureId",
")",
";",
"relationElement",
".",
"addElement",
"(",
"CmsImportVersion10",
".",
"N_PATH",
")",
".",
"addText",
"(",
"sitePath",
")",
";",
"relationElement",
".",
"addElement",
"(",
"CmsImportVersion10",
".",
"N_TYPE",
")",
".",
"addText",
"(",
"relationType",
")",
";",
"}",
"}"
] |
Adds a relation node to the <code>manifest.xml</code>.<p>
@param relationsElement the parent element to append the node to
@param structureId the structure id of the target relation
@param sitePath the site path of the target relation
@param relationType the type of the relation
|
[
"Adds",
"a",
"relation",
"node",
"to",
"the",
"<code",
">",
"manifest",
".",
"xml<",
"/",
"code",
">",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/importexport/CmsExport.java#L470-L479
|
Azure/azure-sdk-for-java
|
edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/OrdersInner.java
|
OrdersInner.listByDataBoxEdgeDeviceAsync
|
public Observable<Page<OrderInner>> listByDataBoxEdgeDeviceAsync(final String deviceName, final String resourceGroupName) {
return listByDataBoxEdgeDeviceWithServiceResponseAsync(deviceName, resourceGroupName)
.map(new Func1<ServiceResponse<Page<OrderInner>>, Page<OrderInner>>() {
@Override
public Page<OrderInner> call(ServiceResponse<Page<OrderInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<Page<OrderInner>> listByDataBoxEdgeDeviceAsync(final String deviceName, final String resourceGroupName) {
return listByDataBoxEdgeDeviceWithServiceResponseAsync(deviceName, resourceGroupName)
.map(new Func1<ServiceResponse<Page<OrderInner>>, Page<OrderInner>>() {
@Override
public Page<OrderInner> call(ServiceResponse<Page<OrderInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Page",
"<",
"OrderInner",
">",
">",
"listByDataBoxEdgeDeviceAsync",
"(",
"final",
"String",
"deviceName",
",",
"final",
"String",
"resourceGroupName",
")",
"{",
"return",
"listByDataBoxEdgeDeviceWithServiceResponseAsync",
"(",
"deviceName",
",",
"resourceGroupName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"OrderInner",
">",
">",
",",
"Page",
"<",
"OrderInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"OrderInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"OrderInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Lists all the orders related to a data box edge/gateway device.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<OrderInner> object
|
[
"Lists",
"all",
"the",
"orders",
"related",
"to",
"a",
"data",
"box",
"edge",
"/",
"gateway",
"device",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/OrdersInner.java#L144-L152
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java
|
ApiOvhRouter.serviceName_privateLink_peerServiceName_route_network_GET
|
public OvhPrivateLinkRoute serviceName_privateLink_peerServiceName_route_network_GET(String serviceName, String peerServiceName, String network) throws IOException {
String qPath = "/router/{serviceName}/privateLink/{peerServiceName}/route/{network}";
StringBuilder sb = path(qPath, serviceName, peerServiceName, network);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrivateLinkRoute.class);
}
|
java
|
public OvhPrivateLinkRoute serviceName_privateLink_peerServiceName_route_network_GET(String serviceName, String peerServiceName, String network) throws IOException {
String qPath = "/router/{serviceName}/privateLink/{peerServiceName}/route/{network}";
StringBuilder sb = path(qPath, serviceName, peerServiceName, network);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrivateLinkRoute.class);
}
|
[
"public",
"OvhPrivateLinkRoute",
"serviceName_privateLink_peerServiceName_route_network_GET",
"(",
"String",
"serviceName",
",",
"String",
"peerServiceName",
",",
"String",
"network",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/router/{serviceName}/privateLink/{peerServiceName}/route/{network}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"peerServiceName",
",",
"network",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPrivateLinkRoute",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /router/{serviceName}/privateLink/{peerServiceName}/route/{network}
@param serviceName [required] The internal name of your Router offer
@param peerServiceName [required] Service name of the other side of this link
@param network [required] Network allowed to be routed outside
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java#L421-L426
|
hawkular/hawkular-apm
|
client/opentracing/src/main/java/io/opentracing/impl/APMSpan.java
|
APMSpan.initTopLevelState
|
protected void initTopLevelState(APMSpan topSpan, TraceRecorder recorder, ContextSampler sampler) {
nodeBuilder = new NodeBuilder();
traceContext = new TraceContext(topSpan, nodeBuilder, recorder, sampler);
}
|
java
|
protected void initTopLevelState(APMSpan topSpan, TraceRecorder recorder, ContextSampler sampler) {
nodeBuilder = new NodeBuilder();
traceContext = new TraceContext(topSpan, nodeBuilder, recorder, sampler);
}
|
[
"protected",
"void",
"initTopLevelState",
"(",
"APMSpan",
"topSpan",
",",
"TraceRecorder",
"recorder",
",",
"ContextSampler",
"sampler",
")",
"{",
"nodeBuilder",
"=",
"new",
"NodeBuilder",
"(",
")",
";",
"traceContext",
"=",
"new",
"TraceContext",
"(",
"topSpan",
",",
"nodeBuilder",
",",
"recorder",
",",
"sampler",
")",
";",
"}"
] |
This method initialises the node builder and trace context for a top level
trace fragment.
@param topSpan The top level span in the trace
@param recorder The trace recorder
@param sampler The sampler
|
[
"This",
"method",
"initialises",
"the",
"node",
"builder",
"and",
"trace",
"context",
"for",
"a",
"top",
"level",
"trace",
"fragment",
"."
] |
train
|
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/client/opentracing/src/main/java/io/opentracing/impl/APMSpan.java#L166-L169
|
zaproxy/zaproxy
|
src/org/zaproxy/zap/extension/brk/BreakpointMessageHandler2.java
|
BreakpointMessageHandler2.handleMessageReceivedFromClient
|
public boolean handleMessageReceivedFromClient(Message aMessage, boolean onlyIfInScope) {
if ( ! isBreakpoint(aMessage, true, onlyIfInScope)) {
return true;
}
// Do this outside of the semaphore loop so that the 'continue' button can apply to all queued break points
// but be reset when the next break point is hit
breakMgmt.breakpointHit();
BreakEventPublisher.getPublisher().publishHitEvent(aMessage);
synchronized(SEMAPHORE) {
if (breakMgmt.isHoldMessage(aMessage)) {
BreakEventPublisher.getPublisher().publishActiveEvent(aMessage);
setBreakDisplay(aMessage, true);
waitUntilContinue(aMessage, true);
BreakEventPublisher.getPublisher().publishInactiveEvent(aMessage);
}
}
breakMgmt.clearAndDisableRequest();
return ! breakMgmt.isToBeDropped();
}
|
java
|
public boolean handleMessageReceivedFromClient(Message aMessage, boolean onlyIfInScope) {
if ( ! isBreakpoint(aMessage, true, onlyIfInScope)) {
return true;
}
// Do this outside of the semaphore loop so that the 'continue' button can apply to all queued break points
// but be reset when the next break point is hit
breakMgmt.breakpointHit();
BreakEventPublisher.getPublisher().publishHitEvent(aMessage);
synchronized(SEMAPHORE) {
if (breakMgmt.isHoldMessage(aMessage)) {
BreakEventPublisher.getPublisher().publishActiveEvent(aMessage);
setBreakDisplay(aMessage, true);
waitUntilContinue(aMessage, true);
BreakEventPublisher.getPublisher().publishInactiveEvent(aMessage);
}
}
breakMgmt.clearAndDisableRequest();
return ! breakMgmt.isToBeDropped();
}
|
[
"public",
"boolean",
"handleMessageReceivedFromClient",
"(",
"Message",
"aMessage",
",",
"boolean",
"onlyIfInScope",
")",
"{",
"if",
"(",
"!",
"isBreakpoint",
"(",
"aMessage",
",",
"true",
",",
"onlyIfInScope",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Do this outside of the semaphore loop so that the 'continue' button can apply to all queued break points\r",
"// but be reset when the next break point is hit\r",
"breakMgmt",
".",
"breakpointHit",
"(",
")",
";",
"BreakEventPublisher",
".",
"getPublisher",
"(",
")",
".",
"publishHitEvent",
"(",
"aMessage",
")",
";",
"synchronized",
"(",
"SEMAPHORE",
")",
"{",
"if",
"(",
"breakMgmt",
".",
"isHoldMessage",
"(",
"aMessage",
")",
")",
"{",
"BreakEventPublisher",
".",
"getPublisher",
"(",
")",
".",
"publishActiveEvent",
"(",
"aMessage",
")",
";",
"setBreakDisplay",
"(",
"aMessage",
",",
"true",
")",
";",
"waitUntilContinue",
"(",
"aMessage",
",",
"true",
")",
";",
"BreakEventPublisher",
".",
"getPublisher",
"(",
")",
".",
"publishInactiveEvent",
"(",
"aMessage",
")",
";",
"}",
"}",
"breakMgmt",
".",
"clearAndDisableRequest",
"(",
")",
";",
"return",
"!",
"breakMgmt",
".",
"isToBeDropped",
"(",
")",
";",
"}"
] |
Do not call if in {@link Mode#safe}.
@param aMessage
@param onlyIfInScope
@return False if message should be dropped.
|
[
"Do",
"not",
"call",
"if",
"in",
"{",
"@link",
"Mode#safe",
"}",
"."
] |
train
|
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/brk/BreakpointMessageHandler2.java#L65-L85
|
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java
|
NorthArrowGraphic.createRaster
|
private static URI createRaster(
final Dimension targetSize, final RasterReference rasterReference,
final Double rotation, final Color backgroundColor,
final File workingDir) throws IOException {
final File path = File.createTempFile("north-arrow-", ".png", workingDir);
final BufferedImage newImage =
new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_4BYTE_ABGR);
final Graphics2D graphics2d = newImage.createGraphics();
try {
final BufferedImage originalImage = ImageIO.read(rasterReference.inputStream);
if (originalImage == null) {
LOGGER.warn("Unable to load NorthArrow graphic: {}, it is not an image format that can be " +
"decoded",
rasterReference.uri);
throw new IllegalArgumentException();
}
// set background color
graphics2d.setColor(backgroundColor);
graphics2d.fillRect(0, 0, targetSize.width, targetSize.height);
// scale the original image to fit the new size
int newWidth;
int newHeight;
if (originalImage.getWidth() > originalImage.getHeight()) {
newWidth = targetSize.width;
newHeight = Math.min(
targetSize.height,
(int) Math.ceil(newWidth / (originalImage.getWidth() /
(double) originalImage.getHeight())));
} else {
newHeight = targetSize.height;
newWidth = Math.min(
targetSize.width,
(int) Math.ceil(newHeight / (originalImage.getHeight() /
(double) originalImage.getWidth())));
}
// position the original image in the center of the new
int deltaX = (int) Math.floor((targetSize.width - newWidth) / 2.0);
int deltaY = (int) Math.floor((targetSize.height - newHeight) / 2.0);
if (!FloatingPointUtil.equals(rotation, 0.0)) {
final AffineTransform rotate = AffineTransform.getRotateInstance(
rotation, targetSize.width / 2.0, targetSize.height / 2.0);
graphics2d.setTransform(rotate);
}
graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics2d.drawImage(originalImage, deltaX, deltaY, newWidth, newHeight, null);
ImageUtils.writeImage(newImage, "png", path);
} finally {
graphics2d.dispose();
}
return path.toURI();
}
|
java
|
private static URI createRaster(
final Dimension targetSize, final RasterReference rasterReference,
final Double rotation, final Color backgroundColor,
final File workingDir) throws IOException {
final File path = File.createTempFile("north-arrow-", ".png", workingDir);
final BufferedImage newImage =
new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_4BYTE_ABGR);
final Graphics2D graphics2d = newImage.createGraphics();
try {
final BufferedImage originalImage = ImageIO.read(rasterReference.inputStream);
if (originalImage == null) {
LOGGER.warn("Unable to load NorthArrow graphic: {}, it is not an image format that can be " +
"decoded",
rasterReference.uri);
throw new IllegalArgumentException();
}
// set background color
graphics2d.setColor(backgroundColor);
graphics2d.fillRect(0, 0, targetSize.width, targetSize.height);
// scale the original image to fit the new size
int newWidth;
int newHeight;
if (originalImage.getWidth() > originalImage.getHeight()) {
newWidth = targetSize.width;
newHeight = Math.min(
targetSize.height,
(int) Math.ceil(newWidth / (originalImage.getWidth() /
(double) originalImage.getHeight())));
} else {
newHeight = targetSize.height;
newWidth = Math.min(
targetSize.width,
(int) Math.ceil(newHeight / (originalImage.getHeight() /
(double) originalImage.getWidth())));
}
// position the original image in the center of the new
int deltaX = (int) Math.floor((targetSize.width - newWidth) / 2.0);
int deltaY = (int) Math.floor((targetSize.height - newHeight) / 2.0);
if (!FloatingPointUtil.equals(rotation, 0.0)) {
final AffineTransform rotate = AffineTransform.getRotateInstance(
rotation, targetSize.width / 2.0, targetSize.height / 2.0);
graphics2d.setTransform(rotate);
}
graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics2d.drawImage(originalImage, deltaX, deltaY, newWidth, newHeight, null);
ImageUtils.writeImage(newImage, "png", path);
} finally {
graphics2d.dispose();
}
return path.toURI();
}
|
[
"private",
"static",
"URI",
"createRaster",
"(",
"final",
"Dimension",
"targetSize",
",",
"final",
"RasterReference",
"rasterReference",
",",
"final",
"Double",
"rotation",
",",
"final",
"Color",
"backgroundColor",
",",
"final",
"File",
"workingDir",
")",
"throws",
"IOException",
"{",
"final",
"File",
"path",
"=",
"File",
".",
"createTempFile",
"(",
"\"north-arrow-\"",
",",
"\".png\"",
",",
"workingDir",
")",
";",
"final",
"BufferedImage",
"newImage",
"=",
"new",
"BufferedImage",
"(",
"targetSize",
".",
"width",
",",
"targetSize",
".",
"height",
",",
"BufferedImage",
".",
"TYPE_4BYTE_ABGR",
")",
";",
"final",
"Graphics2D",
"graphics2d",
"=",
"newImage",
".",
"createGraphics",
"(",
")",
";",
"try",
"{",
"final",
"BufferedImage",
"originalImage",
"=",
"ImageIO",
".",
"read",
"(",
"rasterReference",
".",
"inputStream",
")",
";",
"if",
"(",
"originalImage",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to load NorthArrow graphic: {}, it is not an image format that can be \"",
"+",
"\"decoded\"",
",",
"rasterReference",
".",
"uri",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"// set background color",
"graphics2d",
".",
"setColor",
"(",
"backgroundColor",
")",
";",
"graphics2d",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"targetSize",
".",
"width",
",",
"targetSize",
".",
"height",
")",
";",
"// scale the original image to fit the new size",
"int",
"newWidth",
";",
"int",
"newHeight",
";",
"if",
"(",
"originalImage",
".",
"getWidth",
"(",
")",
">",
"originalImage",
".",
"getHeight",
"(",
")",
")",
"{",
"newWidth",
"=",
"targetSize",
".",
"width",
";",
"newHeight",
"=",
"Math",
".",
"min",
"(",
"targetSize",
".",
"height",
",",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"newWidth",
"/",
"(",
"originalImage",
".",
"getWidth",
"(",
")",
"/",
"(",
"double",
")",
"originalImage",
".",
"getHeight",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"newHeight",
"=",
"targetSize",
".",
"height",
";",
"newWidth",
"=",
"Math",
".",
"min",
"(",
"targetSize",
".",
"width",
",",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"newHeight",
"/",
"(",
"originalImage",
".",
"getHeight",
"(",
")",
"/",
"(",
"double",
")",
"originalImage",
".",
"getWidth",
"(",
")",
")",
")",
")",
";",
"}",
"// position the original image in the center of the new",
"int",
"deltaX",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"targetSize",
".",
"width",
"-",
"newWidth",
")",
"/",
"2.0",
")",
";",
"int",
"deltaY",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"targetSize",
".",
"height",
"-",
"newHeight",
")",
"/",
"2.0",
")",
";",
"if",
"(",
"!",
"FloatingPointUtil",
".",
"equals",
"(",
"rotation",
",",
"0.0",
")",
")",
"{",
"final",
"AffineTransform",
"rotate",
"=",
"AffineTransform",
".",
"getRotateInstance",
"(",
"rotation",
",",
"targetSize",
".",
"width",
"/",
"2.0",
",",
"targetSize",
".",
"height",
"/",
"2.0",
")",
";",
"graphics2d",
".",
"setTransform",
"(",
"rotate",
")",
";",
"}",
"graphics2d",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_INTERPOLATION",
",",
"RenderingHints",
".",
"VALUE_INTERPOLATION_BICUBIC",
")",
";",
"graphics2d",
".",
"drawImage",
"(",
"originalImage",
",",
"deltaX",
",",
"deltaY",
",",
"newWidth",
",",
"newHeight",
",",
"null",
")",
";",
"ImageUtils",
".",
"writeImage",
"(",
"newImage",
",",
"\"png\"",
",",
"path",
")",
";",
"}",
"finally",
"{",
"graphics2d",
".",
"dispose",
"(",
")",
";",
"}",
"return",
"path",
".",
"toURI",
"(",
")",
";",
"}"
] |
Renders a given graphic into a new image, scaled to fit the new size and rotated.
|
[
"Renders",
"a",
"given",
"graphic",
"into",
"a",
"new",
"image",
"scaled",
"to",
"fit",
"the",
"new",
"size",
"and",
"rotated",
"."
] |
train
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java#L113-L171
|
google/closure-templates
|
java/src/com/google/template/soy/internal/i18n/BidiFormatter.java
|
BidiFormatter.spanWrappingText
|
public BidiWrappingText spanWrappingText(@Nullable Dir dir, String str, boolean isHtml) {
if (dir == null) {
dir = estimateDirection(str, isHtml);
}
StringBuilder beforeText = new StringBuilder();
StringBuilder afterText = new StringBuilder();
boolean dirCondition = (dir != Dir.NEUTRAL && dir != contextDir);
if (dirCondition) {
beforeText.append("<span dir=\"").append(dir == Dir.RTL ? "rtl" : "ltr").append("\">");
afterText.append("</span>");
}
afterText.append(markAfter(dir, str, isHtml));
return BidiWrappingText.create(beforeText.toString(), afterText.toString());
}
|
java
|
public BidiWrappingText spanWrappingText(@Nullable Dir dir, String str, boolean isHtml) {
if (dir == null) {
dir = estimateDirection(str, isHtml);
}
StringBuilder beforeText = new StringBuilder();
StringBuilder afterText = new StringBuilder();
boolean dirCondition = (dir != Dir.NEUTRAL && dir != contextDir);
if (dirCondition) {
beforeText.append("<span dir=\"").append(dir == Dir.RTL ? "rtl" : "ltr").append("\">");
afterText.append("</span>");
}
afterText.append(markAfter(dir, str, isHtml));
return BidiWrappingText.create(beforeText.toString(), afterText.toString());
}
|
[
"public",
"BidiWrappingText",
"spanWrappingText",
"(",
"@",
"Nullable",
"Dir",
"dir",
",",
"String",
"str",
",",
"boolean",
"isHtml",
")",
"{",
"if",
"(",
"dir",
"==",
"null",
")",
"{",
"dir",
"=",
"estimateDirection",
"(",
"str",
",",
"isHtml",
")",
";",
"}",
"StringBuilder",
"beforeText",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"StringBuilder",
"afterText",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"dirCondition",
"=",
"(",
"dir",
"!=",
"Dir",
".",
"NEUTRAL",
"&&",
"dir",
"!=",
"contextDir",
")",
";",
"if",
"(",
"dirCondition",
")",
"{",
"beforeText",
".",
"append",
"(",
"\"<span dir=\\\"\"",
")",
".",
"append",
"(",
"dir",
"==",
"Dir",
".",
"RTL",
"?",
"\"rtl\"",
":",
"\"ltr\"",
")",
".",
"append",
"(",
"\"\\\">\"",
")",
";",
"afterText",
".",
"append",
"(",
"\"</span>\"",
")",
";",
"}",
"afterText",
".",
"append",
"(",
"markAfter",
"(",
"dir",
",",
"str",
",",
"isHtml",
")",
")",
";",
"return",
"BidiWrappingText",
".",
"create",
"(",
"beforeText",
".",
"toString",
"(",
")",
",",
"afterText",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Operates like {@link #spanWrap(Dir, String, boolean)} but only returns the text that would be
prepended and appended to {@code str}.
@param dir {@code str}'s directionality. If null, i.e. unknown, it is estimated.
@param str The input string
@param isHtml Whether {@code str} is HTML / HTML-escaped
|
[
"Operates",
"like",
"{",
"@link",
"#spanWrap",
"(",
"Dir",
"String",
"boolean",
")",
"}",
"but",
"only",
"returns",
"the",
"text",
"that",
"would",
"be",
"prepended",
"and",
"appended",
"to",
"{",
"@code",
"str",
"}",
"."
] |
train
|
https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/internal/i18n/BidiFormatter.java#L140-L154
|
apereo/cas
|
support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java
|
LdapUtils.executeModifyOperation
|
public static boolean executeModifyOperation(final String currentDn, final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (val modifyConnection = createConnection(connectionFactory)) {
val operation = new ModifyOperation(modifyConnection);
val mods = attributes.entrySet()
.stream()
.map(entry -> {
val values = entry.getValue().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
val attr = new LdapAttribute(entry.getKey(), values);
return new AttributeModification(AttributeModificationType.REPLACE, attr);
})
.toArray(value -> new AttributeModification[attributes.size()]);
val request = new ModifyRequest(currentDn, mods);
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
|
java
|
public static boolean executeModifyOperation(final String currentDn, final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (val modifyConnection = createConnection(connectionFactory)) {
val operation = new ModifyOperation(modifyConnection);
val mods = attributes.entrySet()
.stream()
.map(entry -> {
val values = entry.getValue().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
val attr = new LdapAttribute(entry.getKey(), values);
return new AttributeModification(AttributeModificationType.REPLACE, attr);
})
.toArray(value -> new AttributeModification[attributes.size()]);
val request = new ModifyRequest(currentDn, mods);
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
|
[
"public",
"static",
"boolean",
"executeModifyOperation",
"(",
"final",
"String",
"currentDn",
",",
"final",
"ConnectionFactory",
"connectionFactory",
",",
"final",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"attributes",
")",
"{",
"try",
"(",
"val",
"modifyConnection",
"=",
"createConnection",
"(",
"connectionFactory",
")",
")",
"{",
"val",
"operation",
"=",
"new",
"ModifyOperation",
"(",
"modifyConnection",
")",
";",
"val",
"mods",
"=",
"attributes",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"entry",
"->",
"{",
"val",
"values",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"toArray",
"(",
"ArrayUtils",
".",
"EMPTY_STRING_ARRAY",
")",
";",
"val",
"attr",
"=",
"new",
"LdapAttribute",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"values",
")",
";",
"return",
"new",
"AttributeModification",
"(",
"AttributeModificationType",
".",
"REPLACE",
",",
"attr",
")",
";",
"}",
")",
".",
"toArray",
"(",
"value",
"->",
"new",
"AttributeModification",
"[",
"attributes",
".",
"size",
"(",
")",
"]",
")",
";",
"val",
"request",
"=",
"new",
"ModifyRequest",
"(",
"currentDn",
",",
"mods",
")",
";",
"request",
".",
"setReferralHandler",
"(",
"new",
"ModifyReferralHandler",
"(",
")",
")",
";",
"operation",
".",
"execute",
"(",
"request",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"LdapException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Execute modify operation boolean.
@param currentDn the current dn
@param connectionFactory the connection factory
@param attributes the attributes
@return true/false
|
[
"Execute",
"modify",
"operation",
"boolean",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java#L355-L375
|
ThreeTen/threetenbp
|
src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java
|
ZoneOffsetTransitionRule.readExternal
|
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
int data = in.readInt();
Month month = Month.of(data >>> 28);
int dom = ((data & (63 << 22)) >>> 22) - 32;
int dowByte = (data & (7 << 19)) >>> 19;
DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
int timeByte = (data & (31 << 14)) >>> 14;
TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
int stdByte = (data & (255 << 4)) >>> 4;
int beforeByte = (data & (3 << 2)) >>> 2;
int afterByte = (data & 3);
int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600);
ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
// only bit of validation that we need to copy from public of() method
if (dom < -28 || dom > 31 || dom == 0) {
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
}
LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY));
int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY);
return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after);
}
|
java
|
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
int data = in.readInt();
Month month = Month.of(data >>> 28);
int dom = ((data & (63 << 22)) >>> 22) - 32;
int dowByte = (data & (7 << 19)) >>> 19;
DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
int timeByte = (data & (31 << 14)) >>> 14;
TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
int stdByte = (data & (255 << 4)) >>> 4;
int beforeByte = (data & (3 << 2)) >>> 2;
int afterByte = (data & 3);
int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600);
ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
// only bit of validation that we need to copy from public of() method
if (dom < -28 || dom > 31 || dom == 0) {
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
}
LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY));
int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY);
return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after);
}
|
[
"static",
"ZoneOffsetTransitionRule",
"readExternal",
"(",
"DataInput",
"in",
")",
"throws",
"IOException",
"{",
"int",
"data",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"Month",
"month",
"=",
"Month",
".",
"of",
"(",
"data",
">>>",
"28",
")",
";",
"int",
"dom",
"=",
"(",
"(",
"data",
"&",
"(",
"63",
"<<",
"22",
")",
")",
">>>",
"22",
")",
"-",
"32",
";",
"int",
"dowByte",
"=",
"(",
"data",
"&",
"(",
"7",
"<<",
"19",
")",
")",
">>>",
"19",
";",
"DayOfWeek",
"dow",
"=",
"dowByte",
"==",
"0",
"?",
"null",
":",
"DayOfWeek",
".",
"of",
"(",
"dowByte",
")",
";",
"int",
"timeByte",
"=",
"(",
"data",
"&",
"(",
"31",
"<<",
"14",
")",
")",
">>>",
"14",
";",
"TimeDefinition",
"defn",
"=",
"TimeDefinition",
".",
"values",
"(",
")",
"[",
"(",
"data",
"&",
"(",
"3",
"<<",
"12",
")",
")",
">>>",
"12",
"]",
";",
"int",
"stdByte",
"=",
"(",
"data",
"&",
"(",
"255",
"<<",
"4",
")",
")",
">>>",
"4",
";",
"int",
"beforeByte",
"=",
"(",
"data",
"&",
"(",
"3",
"<<",
"2",
")",
")",
">>>",
"2",
";",
"int",
"afterByte",
"=",
"(",
"data",
"&",
"3",
")",
";",
"int",
"timeOfDaysSecs",
"=",
"(",
"timeByte",
"==",
"31",
"?",
"in",
".",
"readInt",
"(",
")",
":",
"timeByte",
"*",
"3600",
")",
";",
"ZoneOffset",
"std",
"=",
"(",
"stdByte",
"==",
"255",
"?",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"in",
".",
"readInt",
"(",
")",
")",
":",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"(",
"stdByte",
"-",
"128",
")",
"*",
"900",
")",
")",
";",
"ZoneOffset",
"before",
"=",
"(",
"beforeByte",
"==",
"3",
"?",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"in",
".",
"readInt",
"(",
")",
")",
":",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"std",
".",
"getTotalSeconds",
"(",
")",
"+",
"beforeByte",
"*",
"1800",
")",
")",
";",
"ZoneOffset",
"after",
"=",
"(",
"afterByte",
"==",
"3",
"?",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"in",
".",
"readInt",
"(",
")",
")",
":",
"ZoneOffset",
".",
"ofTotalSeconds",
"(",
"std",
".",
"getTotalSeconds",
"(",
")",
"+",
"afterByte",
"*",
"1800",
")",
")",
";",
"// only bit of validation that we need to copy from public of() method",
"if",
"(",
"dom",
"<",
"-",
"28",
"||",
"dom",
">",
"31",
"||",
"dom",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Day of month indicator must be between -28 and 31 inclusive excluding zero\"",
")",
";",
"}",
"LocalTime",
"time",
"=",
"LocalTime",
".",
"ofSecondOfDay",
"(",
"Jdk8Methods",
".",
"floorMod",
"(",
"timeOfDaysSecs",
",",
"SECS_PER_DAY",
")",
")",
";",
"int",
"adjustDays",
"=",
"Jdk8Methods",
".",
"floorDiv",
"(",
"timeOfDaysSecs",
",",
"SECS_PER_DAY",
")",
";",
"return",
"new",
"ZoneOffsetTransitionRule",
"(",
"month",
",",
"dom",
",",
"dow",
",",
"time",
",",
"adjustDays",
",",
"defn",
",",
"std",
",",
"before",
",",
"after",
")",
";",
"}"
] |
Reads the state from the stream.
@param in the input stream, not null
@return the created object, not null
@throws IOException if an error occurs
|
[
"Reads",
"the",
"state",
"from",
"the",
"stream",
"."
] |
train
|
https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java#L262-L284
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
|
ResourceGroovyMethods.withDataInputStream
|
public static <T> T withDataInputStream(File file, @ClosureParams(value = SimpleType.class, options = "java.io.DataInputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newDataInputStream(file), closure);
}
|
java
|
public static <T> T withDataInputStream(File file, @ClosureParams(value = SimpleType.class, options = "java.io.DataInputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newDataInputStream(file), closure);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"withDataInputStream",
"(",
"File",
"file",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.DataInputStream\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"withStream",
"(",
"newDataInputStream",
"(",
"file",
")",
",",
"closure",
")",
";",
"}"
] |
Create a new DataInputStream for this file and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param file a File
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@see IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure)
@since 1.5.2
|
[
"Create",
"a",
"new",
"DataInputStream",
"for",
"this",
"file",
"and",
"passes",
"it",
"into",
"the",
"closure",
".",
"This",
"method",
"ensures",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1887-L1889
|
ThreeTen/threetenbp
|
src/main/java/org/threeten/bp/format/DateTimeFormatter.java
|
DateTimeFormatter.withResolverStyle
|
public DateTimeFormatter withResolverStyle(ResolverStyle resolverStyle) {
Jdk8Methods.requireNonNull(resolverStyle, "resolverStyle");
if (Jdk8Methods.equals(this.resolverStyle, resolverStyle)) {
return this;
}
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}
|
java
|
public DateTimeFormatter withResolverStyle(ResolverStyle resolverStyle) {
Jdk8Methods.requireNonNull(resolverStyle, "resolverStyle");
if (Jdk8Methods.equals(this.resolverStyle, resolverStyle)) {
return this;
}
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}
|
[
"public",
"DateTimeFormatter",
"withResolverStyle",
"(",
"ResolverStyle",
"resolverStyle",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"resolverStyle",
",",
"\"resolverStyle\"",
")",
";",
"if",
"(",
"Jdk8Methods",
".",
"equals",
"(",
"this",
".",
"resolverStyle",
",",
"resolverStyle",
")",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"DateTimeFormatter",
"(",
"printerParser",
",",
"locale",
",",
"decimalStyle",
",",
"resolverStyle",
",",
"resolverFields",
",",
"chrono",
",",
"zone",
")",
";",
"}"
] |
Returns a copy of this formatter with a new resolver style.
<p>
This returns a formatter with similar state to this formatter but
with the resolver style set. By default, a formatter has the
{@link ResolverStyle#SMART SMART} resolver style.
<p>
Changing the resolver style only has an effect during parsing.
Parsing a text string occurs in two phases.
Phase 1 is a basic text parse according to the fields added to the builder.
Phase 2 resolves the parsed field-value pairs into date and/or time objects.
The resolver style is used to control how phase 2, resolving, happens.
See {@code ResolverStyle} for more information on the options available.
<p>
This instance is immutable and unaffected by this method call.
@param resolverStyle the new resolver style, not null
@return a formatter based on this formatter with the requested resolver style, not null
|
[
"Returns",
"a",
"copy",
"of",
"this",
"formatter",
"with",
"a",
"new",
"resolver",
"style",
".",
"<p",
">",
"This",
"returns",
"a",
"formatter",
"with",
"similar",
"state",
"to",
"this",
"formatter",
"but",
"with",
"the",
"resolver",
"style",
"set",
".",
"By",
"default",
"a",
"formatter",
"has",
"the",
"{",
"@link",
"ResolverStyle#SMART",
"SMART",
"}",
"resolver",
"style",
".",
"<p",
">",
"Changing",
"the",
"resolver",
"style",
"only",
"has",
"an",
"effect",
"during",
"parsing",
".",
"Parsing",
"a",
"text",
"string",
"occurs",
"in",
"two",
"phases",
".",
"Phase",
"1",
"is",
"a",
"basic",
"text",
"parse",
"according",
"to",
"the",
"fields",
"added",
"to",
"the",
"builder",
".",
"Phase",
"2",
"resolves",
"the",
"parsed",
"field",
"-",
"value",
"pairs",
"into",
"date",
"and",
"/",
"or",
"time",
"objects",
".",
"The",
"resolver",
"style",
"is",
"used",
"to",
"control",
"how",
"phase",
"2",
"resolving",
"happens",
".",
"See",
"{",
"@code",
"ResolverStyle",
"}",
"for",
"more",
"information",
"on",
"the",
"options",
"available",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"call",
"."
] |
train
|
https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/format/DateTimeFormatter.java#L1223-L1229
|
aws/aws-sdk-java
|
aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/TableInput.java
|
TableInput.withParameters
|
public TableInput withParameters(java.util.Map<String, String> parameters) {
setParameters(parameters);
return this;
}
|
java
|
public TableInput withParameters(java.util.Map<String, String> parameters) {
setParameters(parameters);
return this;
}
|
[
"public",
"TableInput",
"withParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"setParameters",
"(",
"parameters",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
These key-value pairs define properties associated with the table.
</p>
@param parameters
These key-value pairs define properties associated with the table.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"These",
"key",
"-",
"value",
"pairs",
"define",
"properties",
"associated",
"with",
"the",
"table",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/TableInput.java#L672-L675
|
jbundle/jbundle
|
base/message/core/src/main/java/org/jbundle/base/message/core/tree/TreeMessageFilterList.java
|
TreeMessageFilterList.setNewFilterTree
|
public void setNewFilterTree(BaseMessageFilter messageFilter, Object[][] propKeys)
{
if (propKeys != null)
if (!propKeys.equals(messageFilter.getNameValueTree()))
{ // This moves the filter to the new leaf
this.getRegistry().removeMessageFilter(messageFilter);
super.setNewFilterTree(messageFilter, propKeys);
this.getRegistry().addMessageFilter(messageFilter);
}
}
|
java
|
public void setNewFilterTree(BaseMessageFilter messageFilter, Object[][] propKeys)
{
if (propKeys != null)
if (!propKeys.equals(messageFilter.getNameValueTree()))
{ // This moves the filter to the new leaf
this.getRegistry().removeMessageFilter(messageFilter);
super.setNewFilterTree(messageFilter, propKeys);
this.getRegistry().addMessageFilter(messageFilter);
}
}
|
[
"public",
"void",
"setNewFilterTree",
"(",
"BaseMessageFilter",
"messageFilter",
",",
"Object",
"[",
"]",
"[",
"]",
"propKeys",
")",
"{",
"if",
"(",
"propKeys",
"!=",
"null",
")",
"if",
"(",
"!",
"propKeys",
".",
"equals",
"(",
"messageFilter",
".",
"getNameValueTree",
"(",
")",
")",
")",
"{",
"// This moves the filter to the new leaf",
"this",
".",
"getRegistry",
"(",
")",
".",
"removeMessageFilter",
"(",
"messageFilter",
")",
";",
"super",
".",
"setNewFilterTree",
"(",
"messageFilter",
",",
"propKeys",
")",
";",
"this",
".",
"getRegistry",
"(",
")",
".",
"addMessageFilter",
"(",
"messageFilter",
")",
";",
"}",
"}"
] |
Update this filter with this new information.
@param messageFilter The message filter I am updating.
@param propKeys New tree key filter information (ie, bookmark=345).
|
[
"Update",
"this",
"filter",
"with",
"this",
"new",
"information",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/core/src/main/java/org/jbundle/base/message/core/tree/TreeMessageFilterList.java#L90-L99
|
Azure/azure-sdk-for-java
|
privatedns/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/privatedns/v2018_09_01/implementation/RecordSetsInner.java
|
RecordSetsInner.getAsync
|
public Observable<RecordSetInner> getAsync(String resourceGroupName, String privateZoneName, RecordType recordType, String relativeRecordSetName) {
return getWithServiceResponseAsync(resourceGroupName, privateZoneName, recordType, relativeRecordSetName).map(new Func1<ServiceResponse<RecordSetInner>, RecordSetInner>() {
@Override
public RecordSetInner call(ServiceResponse<RecordSetInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<RecordSetInner> getAsync(String resourceGroupName, String privateZoneName, RecordType recordType, String relativeRecordSetName) {
return getWithServiceResponseAsync(resourceGroupName, privateZoneName, recordType, relativeRecordSetName).map(new Func1<ServiceResponse<RecordSetInner>, RecordSetInner>() {
@Override
public RecordSetInner call(ServiceResponse<RecordSetInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"RecordSetInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"privateZoneName",
",",
"RecordType",
"recordType",
",",
"String",
"relativeRecordSetName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"privateZoneName",
",",
"recordType",
",",
"relativeRecordSetName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"RecordSetInner",
">",
",",
"RecordSetInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RecordSetInner",
"call",
"(",
"ServiceResponse",
"<",
"RecordSetInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a record set.
@param resourceGroupName The name of the resource group.
@param privateZoneName The name of the Private DNS zone (without a terminating dot).
@param recordType The type of DNS record in this record set. Possible values include: 'A', 'AAAA', 'CNAME', 'MX', 'PTR', 'SOA', 'SRV', 'TXT'
@param relativeRecordSetName The name of the record set, relative to the name of the zone.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RecordSetInner object
|
[
"Gets",
"a",
"record",
"set",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/privatedns/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/privatedns/v2018_09_01/implementation/RecordSetsInner.java#L772-L779
|
google/flogger
|
api/src/main/java/com/google/common/flogger/parser/ParseException.java
|
ParseException.atPosition
|
public static ParseException atPosition(String errorMessage, String logMessage, int position) {
return new ParseException(msg(errorMessage, logMessage, position, position + 1), logMessage);
}
|
java
|
public static ParseException atPosition(String errorMessage, String logMessage, int position) {
return new ParseException(msg(errorMessage, logMessage, position, position + 1), logMessage);
}
|
[
"public",
"static",
"ParseException",
"atPosition",
"(",
"String",
"errorMessage",
",",
"String",
"logMessage",
",",
"int",
"position",
")",
"{",
"return",
"new",
"ParseException",
"(",
"msg",
"(",
"errorMessage",
",",
"logMessage",
",",
"position",
",",
"position",
"+",
"1",
")",
",",
"logMessage",
")",
";",
"}"
] |
Creates a new parse exception for situations in which the position of the error is known.
@param errorMessage the user error message.
@param logMessage the original log message.
@param position the index of the invalid character in the log message.
@return the parser exception.
|
[
"Creates",
"a",
"new",
"parse",
"exception",
"for",
"situations",
"in",
"which",
"the",
"position",
"of",
"the",
"error",
"is",
"known",
"."
] |
train
|
https://github.com/google/flogger/blob/a164967a93a9f4ce92f34319fc0cc7c91a57321c/api/src/main/java/com/google/common/flogger/parser/ParseException.java#L56-L58
|
hibernate/hibernate-ogm
|
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/LocalCacheManager.java
|
LocalCacheManager.enableClusteringHashGroups
|
private static Configuration enableClusteringHashGroups(String cacheName, Configuration configuration) {
if ( configuration.clustering().hash().groups().enabled() ) {
return configuration;
}
LOG.clusteringHashGroupsMustBeEnabled( cacheName );
ConfigurationBuilder builder = new ConfigurationBuilder().read( configuration );
builder.clustering().hash().groups().enabled();
return builder.build();
}
|
java
|
private static Configuration enableClusteringHashGroups(String cacheName, Configuration configuration) {
if ( configuration.clustering().hash().groups().enabled() ) {
return configuration;
}
LOG.clusteringHashGroupsMustBeEnabled( cacheName );
ConfigurationBuilder builder = new ConfigurationBuilder().read( configuration );
builder.clustering().hash().groups().enabled();
return builder.build();
}
|
[
"private",
"static",
"Configuration",
"enableClusteringHashGroups",
"(",
"String",
"cacheName",
",",
"Configuration",
"configuration",
")",
"{",
"if",
"(",
"configuration",
".",
"clustering",
"(",
")",
".",
"hash",
"(",
")",
".",
"groups",
"(",
")",
".",
"enabled",
"(",
")",
")",
"{",
"return",
"configuration",
";",
"}",
"LOG",
".",
"clusteringHashGroupsMustBeEnabled",
"(",
"cacheName",
")",
";",
"ConfigurationBuilder",
"builder",
"=",
"new",
"ConfigurationBuilder",
"(",
")",
".",
"read",
"(",
"configuration",
")",
";",
"builder",
".",
"clustering",
"(",
")",
".",
"hash",
"(",
")",
".",
"groups",
"(",
")",
".",
"enabled",
"(",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Enable the clustering.hash.groups configuration if it's not already enabled.
<p>
Infinispan requires this option enabled because we are using fine grained maps.
The function will log a warning if the property is disabled.
@return the updated configuration
|
[
"Enable",
"the",
"clustering",
".",
"hash",
".",
"groups",
"configuration",
"if",
"it",
"s",
"not",
"already",
"enabled",
".",
"<p",
">",
"Infinispan",
"requires",
"this",
"option",
"enabled",
"because",
"we",
"are",
"using",
"fine",
"grained",
"maps",
".",
"The",
"function",
"will",
"log",
"a",
"warning",
"if",
"the",
"property",
"is",
"disabled",
"."
] |
train
|
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/LocalCacheManager.java#L155-L163
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.asBoolean
|
protected Boolean asBoolean(String name, Map<String, Value> params) {
return coerceToBoolean(params.get(name));
}
|
java
|
protected Boolean asBoolean(String name, Map<String, Value> params) {
return coerceToBoolean(params.get(name));
}
|
[
"protected",
"Boolean",
"asBoolean",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
")",
"{",
"return",
"coerceToBoolean",
"(",
"params",
".",
"get",
"(",
"name",
")",
")",
";",
"}"
] |
Gets a parameter value as a Java Boolean.
@param name The parameter name
@param params The parameters
@return The boolean
|
[
"Gets",
"a",
"parameter",
"value",
"as",
"a",
"Java",
"Boolean",
"."
] |
train
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L174-L176
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/odmg/TransactionImpl.java
|
TransactionImpl.lockAndRegister
|
public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
{
lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
}
|
java
|
public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
{
lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
}
|
[
"public",
"void",
"lockAndRegister",
"(",
"RuntimeObject",
"rtObject",
",",
"int",
"lockMode",
",",
"List",
"registeredObjects",
")",
"{",
"lockAndRegister",
"(",
"rtObject",
",",
"lockMode",
",",
"isImplicitLocking",
"(",
")",
",",
"registeredObjects",
")",
";",
"}"
] |
Lock and register the specified object, make sure that when cascading locking and register
is enabled to specify a List to register the already processed object Identiy.
|
[
"Lock",
"and",
"register",
"the",
"specified",
"object",
"make",
"sure",
"that",
"when",
"cascading",
"locking",
"and",
"register",
"is",
"enabled",
"to",
"specify",
"a",
"List",
"to",
"register",
"the",
"already",
"processed",
"object",
"Identiy",
"."
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L254-L257
|
googleapis/google-cloud-java
|
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriptionAdminClientSnippets.java
|
SubscriptionAdminClientSnippets.replacePushConfig
|
public void replacePushConfig(String subscriptionId, String endpoint) throws Exception {
// [START pubsub_update_push_configuration]
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
subscriptionAdminClient.modifyPushConfig(subscriptionName, pushConfig);
}
// [END pubsub_update_push_configuration]
}
|
java
|
public void replacePushConfig(String subscriptionId, String endpoint) throws Exception {
// [START pubsub_update_push_configuration]
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
subscriptionAdminClient.modifyPushConfig(subscriptionName, pushConfig);
}
// [END pubsub_update_push_configuration]
}
|
[
"public",
"void",
"replacePushConfig",
"(",
"String",
"subscriptionId",
",",
"String",
"endpoint",
")",
"throws",
"Exception",
"{",
"// [START pubsub_update_push_configuration]",
"try",
"(",
"SubscriptionAdminClient",
"subscriptionAdminClient",
"=",
"SubscriptionAdminClient",
".",
"create",
"(",
")",
")",
"{",
"ProjectSubscriptionName",
"subscriptionName",
"=",
"ProjectSubscriptionName",
".",
"of",
"(",
"projectId",
",",
"subscriptionId",
")",
";",
"PushConfig",
"pushConfig",
"=",
"PushConfig",
".",
"newBuilder",
"(",
")",
".",
"setPushEndpoint",
"(",
"endpoint",
")",
".",
"build",
"(",
")",
";",
"subscriptionAdminClient",
".",
"modifyPushConfig",
"(",
"subscriptionName",
",",
"pushConfig",
")",
";",
"}",
"// [END pubsub_update_push_configuration]",
"}"
] |
Example of replacing the push configuration of a subscription, setting the push endpoint.
|
[
"Example",
"of",
"replacing",
"the",
"push",
"configuration",
"of",
"a",
"subscription",
"setting",
"the",
"push",
"endpoint",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriptionAdminClientSnippets.java#L93-L102
|
VoltDB/voltdb
|
src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java
|
JDBCResultSet.updateLong
|
public void updateLong(int columnIndex, long x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setLongParameter(columnIndex, x);
}
|
java
|
public void updateLong(int columnIndex, long x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setLongParameter(columnIndex, x);
}
|
[
"public",
"void",
"updateLong",
"(",
"int",
"columnIndex",
",",
"long",
"x",
")",
"throws",
"SQLException",
"{",
"startUpdate",
"(",
"columnIndex",
")",
";",
"preparedStatement",
".",
"setLongParameter",
"(",
"columnIndex",
",",
"x",
")",
";",
"}"
] |
<!-- start generic documentation -->
Updates the designated column with a <code>long</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet)
|
[
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"Updates",
"the",
"designated",
"column",
"with",
"a",
"<code",
">",
"long<",
"/",
"code",
">",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<!",
"--",
"end",
"generic",
"documentation",
"--",
">"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L2781-L2784
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java
|
CPInstancePersistenceImpl.fetchByC_C
|
@Override
public CPInstance fetchByC_C(long CPDefinitionId, String CPInstanceUuid) {
return fetchByC_C(CPDefinitionId, CPInstanceUuid, true);
}
|
java
|
@Override
public CPInstance fetchByC_C(long CPDefinitionId, String CPInstanceUuid) {
return fetchByC_C(CPDefinitionId, CPInstanceUuid, true);
}
|
[
"@",
"Override",
"public",
"CPInstance",
"fetchByC_C",
"(",
"long",
"CPDefinitionId",
",",
"String",
"CPInstanceUuid",
")",
"{",
"return",
"fetchByC_C",
"(",
"CPDefinitionId",
",",
"CPInstanceUuid",
",",
"true",
")",
";",
"}"
] |
Returns the cp instance where CPDefinitionId = ? and CPInstanceUuid = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param CPDefinitionId the cp definition ID
@param CPInstanceUuid the cp instance uuid
@return the matching cp instance, or <code>null</code> if a matching cp instance could not be found
|
[
"Returns",
"the",
"cp",
"instance",
"where",
"CPDefinitionId",
"=",
"?",
";",
"and",
"CPInstanceUuid",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
"finder",
"cache",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java#L4121-L4124
|
virgo47/javasimon
|
jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java
|
SimonConnection.createStatement
|
@Override
public Statement createStatement(int rsType, int rsConcurrency) throws SQLException {
return new SimonStatement(this, conn.createStatement(rsType, rsConcurrency), prefix);
}
|
java
|
@Override
public Statement createStatement(int rsType, int rsConcurrency) throws SQLException {
return new SimonStatement(this, conn.createStatement(rsType, rsConcurrency), prefix);
}
|
[
"@",
"Override",
"public",
"Statement",
"createStatement",
"(",
"int",
"rsType",
",",
"int",
"rsConcurrency",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"SimonStatement",
"(",
"this",
",",
"conn",
".",
"createStatement",
"(",
"rsType",
",",
"rsConcurrency",
")",
",",
"prefix",
")",
";",
"}"
] |
Calls real createStatement and wraps returned statement by Simon's statement.
@param rsType result set type
@param rsConcurrency result set concurrency
@return Simon's statement with wrapped real statement
@throws java.sql.SQLException if real operation fails
|
[
"Calls",
"real",
"createStatement",
"and",
"wraps",
"returned",
"statement",
"by",
"Simon",
"s",
"statement",
"."
] |
train
|
https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java#L144-L147
|
xcesco/kripton
|
kripton-shared-preferences/src/main/java/com/abubusoft/kripton/common/PrefsTypeAdapterUtils.java
|
PrefsTypeAdapterUtils.toData
|
@SuppressWarnings("unchecked")
public static <D, J> D toData(Class<? extends PreferenceTypeAdapter<J, D>> clazz, J javaValue) {
PreferenceTypeAdapter<J, D> adapter = cache.get(clazz);
if (adapter == null) {
try {
lock.lock();
adapter = clazz.newInstance();
cache.put(clazz, adapter);
} catch (Throwable e) {
throw (new KriptonRuntimeException(e));
} finally {
lock.unlock();
}
}
return adapter.toData(javaValue);
}
|
java
|
@SuppressWarnings("unchecked")
public static <D, J> D toData(Class<? extends PreferenceTypeAdapter<J, D>> clazz, J javaValue) {
PreferenceTypeAdapter<J, D> adapter = cache.get(clazz);
if (adapter == null) {
try {
lock.lock();
adapter = clazz.newInstance();
cache.put(clazz, adapter);
} catch (Throwable e) {
throw (new KriptonRuntimeException(e));
} finally {
lock.unlock();
}
}
return adapter.toData(javaValue);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"D",
",",
"J",
">",
"D",
"toData",
"(",
"Class",
"<",
"?",
"extends",
"PreferenceTypeAdapter",
"<",
"J",
",",
"D",
">",
">",
"clazz",
",",
"J",
"javaValue",
")",
"{",
"PreferenceTypeAdapter",
"<",
"J",
",",
"D",
">",
"adapter",
"=",
"cache",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"adapter",
"==",
"null",
")",
"{",
"try",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"adapter",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"cache",
".",
"put",
"(",
"clazz",
",",
"adapter",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"(",
"new",
"KriptonRuntimeException",
"(",
"e",
")",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}",
"return",
"adapter",
".",
"toData",
"(",
"javaValue",
")",
";",
"}"
] |
To data.
@param <D> the generic type
@param <J> the generic type
@param clazz the clazz
@param javaValue the java value
@return the d
|
[
"To",
"data",
"."
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-shared-preferences/src/main/java/com/abubusoft/kripton/common/PrefsTypeAdapterUtils.java#L105-L122
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/helpers/MBeanRoutedNotificationHelper.java
|
MBeanRoutedNotificationHelper.postRoutedServerNotificationListenerRegistrationEvent
|
private void postRoutedServerNotificationListenerRegistrationEvent(String operation, NotificationTargetInformation nti, ObjectName listener,
NotificationFilter filter, Object handback) {
Map<String, Object> props = createServerListenerRegistrationEvent(operation, nti, listener, filter, handback);
safePostEvent(new Event(REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC, props));
}
|
java
|
private void postRoutedServerNotificationListenerRegistrationEvent(String operation, NotificationTargetInformation nti, ObjectName listener,
NotificationFilter filter, Object handback) {
Map<String, Object> props = createServerListenerRegistrationEvent(operation, nti, listener, filter, handback);
safePostEvent(new Event(REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC, props));
}
|
[
"private",
"void",
"postRoutedServerNotificationListenerRegistrationEvent",
"(",
"String",
"operation",
",",
"NotificationTargetInformation",
"nti",
",",
"ObjectName",
"listener",
",",
"NotificationFilter",
"filter",
",",
"Object",
"handback",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
"=",
"createServerListenerRegistrationEvent",
"(",
"operation",
",",
"nti",
",",
"listener",
",",
"filter",
",",
"handback",
")",
";",
"safePostEvent",
"(",
"new",
"Event",
"(",
"REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC",
",",
"props",
")",
")",
";",
"}"
] |
Post an event to EventAdmin, instructing the Target-Client Manager to register or unregister a listener MBean on a given target.
|
[
"Post",
"an",
"event",
"to",
"EventAdmin",
"instructing",
"the",
"Target",
"-",
"Client",
"Manager",
"to",
"register",
"or",
"unregister",
"a",
"listener",
"MBean",
"on",
"a",
"given",
"target",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/helpers/MBeanRoutedNotificationHelper.java#L257-L261
|
frostwire/frostwire-jlibtorrent
|
src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java
|
TorrentBuilder.addNode
|
public TorrentBuilder addNode(Pair<String, Integer> value) {
if (value != null) {
this.nodes.add(value);
}
return this;
}
|
java
|
public TorrentBuilder addNode(Pair<String, Integer> value) {
if (value != null) {
this.nodes.add(value);
}
return this;
}
|
[
"public",
"TorrentBuilder",
"addNode",
"(",
"Pair",
"<",
"String",
",",
"Integer",
">",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"this",
".",
"nodes",
".",
"add",
"(",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
This adds a DHT node to the torrent. This especially useful if you're creating a
tracker less torrent. It can be used by clients to bootstrap their DHT node from.
The node is a hostname and a port number where there is a DHT node running.
You can have any number of DHT nodes in a torrent.
@param value
@return
|
[
"This",
"adds",
"a",
"DHT",
"node",
"to",
"the",
"torrent",
".",
"This",
"especially",
"useful",
"if",
"you",
"re",
"creating",
"a",
"tracker",
"less",
"torrent",
".",
"It",
"can",
"be",
"used",
"by",
"clients",
"to",
"bootstrap",
"their",
"DHT",
"node",
"from",
".",
"The",
"node",
"is",
"a",
"hostname",
"and",
"a",
"port",
"number",
"where",
"there",
"is",
"a",
"DHT",
"node",
"running",
".",
"You",
"can",
"have",
"any",
"number",
"of",
"DHT",
"nodes",
"in",
"a",
"torrent",
"."
] |
train
|
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java#L290-L295
|
undertow-io/undertow
|
core/src/main/java/io/undertow/websockets/core/WebSockets.java
|
WebSockets.sendPong
|
public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) {
sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis);
}
|
java
|
public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) {
sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis);
}
|
[
"public",
"static",
"void",
"sendPong",
"(",
"final",
"ByteBuffer",
"[",
"]",
"data",
",",
"final",
"WebSocketChannel",
"wsChannel",
",",
"final",
"WebSocketCallback",
"<",
"Void",
">",
"callback",
",",
"long",
"timeoutmillis",
")",
"{",
"sendInternal",
"(",
"mergeBuffers",
"(",
"data",
")",
",",
"WebSocketFrameType",
".",
"PONG",
",",
"wsChannel",
",",
"callback",
",",
"null",
",",
"timeoutmillis",
")",
";",
"}"
] |
Sends a complete pong message, invoking the callback when complete
@param data The data to send
@param wsChannel The web socket channel
@param callback The callback to invoke on completion
@param timeoutmillis the timeout in milliseconds
|
[
"Sends",
"a",
"complete",
"pong",
"message",
"invoking",
"the",
"callback",
"when",
"complete"
] |
train
|
https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/websockets/core/WebSockets.java#L482-L484
|
TheHortonMachine/hortonmachine
|
gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoMetadata.java
|
DaoMetadata.fillProjectMetadata
|
public static void fillProjectMetadata(Connection connection, String name, String description, String notes, String creationUser) throws Exception {
Date creationDate = new Date();
if (name == null) {
name = "project-" + ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(creationDate);
}
if (description == null) {
description = EMPTY_VALUE;
}
if (notes == null) {
notes = EMPTY_VALUE;
}
if (creationUser == null) {
creationUser = "dummy user";
}
insertPair(connection, MetadataTableFields.KEY_NAME.getFieldName(), name);
insertPair(connection, MetadataTableFields.KEY_DESCRIPTION.getFieldName(), description);
insertPair(connection, MetadataTableFields.KEY_NOTES.getFieldName(), notes);
insertPair(connection, MetadataTableFields.KEY_CREATIONTS.getFieldName(), String.valueOf(creationDate.getTime()));
insertPair(connection, MetadataTableFields.KEY_LASTTS.getFieldName(), EMPTY_VALUE);
insertPair(connection, MetadataTableFields.KEY_CREATIONUSER.getFieldName(), creationUser);
insertPair(connection, MetadataTableFields.KEY_LASTUSER.getFieldName(), EMPTY_VALUE);
}
|
java
|
public static void fillProjectMetadata(Connection connection, String name, String description, String notes, String creationUser) throws Exception {
Date creationDate = new Date();
if (name == null) {
name = "project-" + ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(creationDate);
}
if (description == null) {
description = EMPTY_VALUE;
}
if (notes == null) {
notes = EMPTY_VALUE;
}
if (creationUser == null) {
creationUser = "dummy user";
}
insertPair(connection, MetadataTableFields.KEY_NAME.getFieldName(), name);
insertPair(connection, MetadataTableFields.KEY_DESCRIPTION.getFieldName(), description);
insertPair(connection, MetadataTableFields.KEY_NOTES.getFieldName(), notes);
insertPair(connection, MetadataTableFields.KEY_CREATIONTS.getFieldName(), String.valueOf(creationDate.getTime()));
insertPair(connection, MetadataTableFields.KEY_LASTTS.getFieldName(), EMPTY_VALUE);
insertPair(connection, MetadataTableFields.KEY_CREATIONUSER.getFieldName(), creationUser);
insertPair(connection, MetadataTableFields.KEY_LASTUSER.getFieldName(), EMPTY_VALUE);
}
|
[
"public",
"static",
"void",
"fillProjectMetadata",
"(",
"Connection",
"connection",
",",
"String",
"name",
",",
"String",
"description",
",",
"String",
"notes",
",",
"String",
"creationUser",
")",
"throws",
"Exception",
"{",
"Date",
"creationDate",
"=",
"new",
"Date",
"(",
")",
";",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"name",
"=",
"\"project-\"",
"+",
"ETimeUtilities",
".",
"INSTANCE",
".",
"TIME_FORMATTER_LOCAL",
".",
"format",
"(",
"creationDate",
")",
";",
"}",
"if",
"(",
"description",
"==",
"null",
")",
"{",
"description",
"=",
"EMPTY_VALUE",
";",
"}",
"if",
"(",
"notes",
"==",
"null",
")",
"{",
"notes",
"=",
"EMPTY_VALUE",
";",
"}",
"if",
"(",
"creationUser",
"==",
"null",
")",
"{",
"creationUser",
"=",
"\"dummy user\"",
";",
"}",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_NAME",
".",
"getFieldName",
"(",
")",
",",
"name",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_DESCRIPTION",
".",
"getFieldName",
"(",
")",
",",
"description",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_NOTES",
".",
"getFieldName",
"(",
")",
",",
"notes",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_CREATIONTS",
".",
"getFieldName",
"(",
")",
",",
"String",
".",
"valueOf",
"(",
"creationDate",
".",
"getTime",
"(",
")",
")",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_LASTTS",
".",
"getFieldName",
"(",
")",
",",
"EMPTY_VALUE",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_CREATIONUSER",
".",
"getFieldName",
"(",
")",
",",
"creationUser",
")",
";",
"insertPair",
"(",
"connection",
",",
"MetadataTableFields",
".",
"KEY_LASTUSER",
".",
"getFieldName",
"(",
")",
",",
"EMPTY_VALUE",
")",
";",
"}"
] |
Populate the project metadata table.
@param name the project name
@param description an optional description.
@param notes optional notes.
@param creationUser the user creating the project.
@throws java.io.IOException if something goes wrong.
|
[
"Populate",
"the",
"project",
"metadata",
"table",
"."
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoMetadata.java#L74-L97
|
m-m-m/util
|
datatype/src/main/java/net/sf/mmm/util/datatype/api/color/GenericColor.java
|
GenericColor.valueOf
|
public static GenericColor valueOf(Color color) {
Objects.requireNonNull(color, "color");
Red red = new Red(color.getRed());
Green green = new Green(color.getGreen());
Blue blue = new Blue(color.getBlue());
Alpha alpha = new Alpha(color.getAlpha());
return valueOf(red, green, blue, alpha);
}
|
java
|
public static GenericColor valueOf(Color color) {
Objects.requireNonNull(color, "color");
Red red = new Red(color.getRed());
Green green = new Green(color.getGreen());
Blue blue = new Blue(color.getBlue());
Alpha alpha = new Alpha(color.getAlpha());
return valueOf(red, green, blue, alpha);
}
|
[
"public",
"static",
"GenericColor",
"valueOf",
"(",
"Color",
"color",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"color",
",",
"\"color\"",
")",
";",
"Red",
"red",
"=",
"new",
"Red",
"(",
"color",
".",
"getRed",
"(",
")",
")",
";",
"Green",
"green",
"=",
"new",
"Green",
"(",
"color",
".",
"getGreen",
"(",
")",
")",
";",
"Blue",
"blue",
"=",
"new",
"Blue",
"(",
"color",
".",
"getBlue",
"(",
")",
")",
";",
"Alpha",
"alpha",
"=",
"new",
"Alpha",
"(",
"color",
".",
"getAlpha",
"(",
")",
")",
";",
"return",
"valueOf",
"(",
"red",
",",
"green",
",",
"blue",
",",
"alpha",
")",
";",
"}"
] |
Converts the given {@link Color} to a {@link GenericColor}.
@param color is the discrete RGBA {@link Color}.
@return the corresponding {@link GenericColor}.
|
[
"Converts",
"the",
"given",
"{",
"@link",
"Color",
"}",
"to",
"a",
"{",
"@link",
"GenericColor",
"}",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/datatype/src/main/java/net/sf/mmm/util/datatype/api/color/GenericColor.java#L140-L148
|
codegist/crest
|
core/src/main/java/org/codegist/crest/CRestBuilder.java
|
CRestBuilder.bindDeserializer
|
public CRestBuilder bindDeserializer(Class<? extends Deserializer> deserializer, Class<?>[] classes, Map<String, Object> config) {
this.classDeserializerBuilder.register(deserializer, classes, config);
return this;
}
|
java
|
public CRestBuilder bindDeserializer(Class<? extends Deserializer> deserializer, Class<?>[] classes, Map<String, Object> config) {
this.classDeserializerBuilder.register(deserializer, classes, config);
return this;
}
|
[
"public",
"CRestBuilder",
"bindDeserializer",
"(",
"Class",
"<",
"?",
"extends",
"Deserializer",
">",
"deserializer",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"config",
")",
"{",
"this",
".",
"classDeserializerBuilder",
".",
"register",
"(",
"deserializer",
",",
"classes",
",",
"config",
")",
";",
"return",
"this",
";",
"}"
] |
<p>Binds a deserializer to a list of interface method's return types.</p>
<p>By default, <b>CRest</b> handle the following types:</p>
<ul>
<li>all primitives and wrapper types</li>
<li>java.io.InputStream</li>
<li>java.io.Reader</li>
</ul>
<p>Meaning that any interface method return type can be by default one of these types.</p>
@param deserializer Deserializer class to use for the given interface method's return types
@param classes Interface method's return types to bind deserializer to
@param config State that will be passed to the deserializer along with the CRestConfig object if the deserializer has declared a single argument constructor with CRestConfig parameter type
@return current builder
@see org.codegist.crest.CRestConfig
|
[
"<p",
">",
"Binds",
"a",
"deserializer",
"to",
"a",
"list",
"of",
"interface",
"method",
"s",
"return",
"types",
".",
"<",
"/",
"p",
">",
"<p",
">",
"By",
"default",
"<b",
">",
"CRest<",
"/",
"b",
">",
"handle",
"the",
"following",
"types",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"all",
"primitives",
"and",
"wrapper",
"types<",
"/",
"li",
">",
"<li",
">",
"java",
".",
"io",
".",
"InputStream<",
"/",
"li",
">",
"<li",
">",
"java",
".",
"io",
".",
"Reader<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"Meaning",
"that",
"any",
"interface",
"method",
"return",
"type",
"can",
"be",
"by",
"default",
"one",
"of",
"these",
"types",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/codegist/crest/blob/e99ba7728b27d2ddb2c247261350f1b6fa7a6698/core/src/main/java/org/codegist/crest/CRestBuilder.java#L565-L568
|
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
|
KeyDecoder.decodeByteDesc
|
public static byte decodeByteDesc(byte[] src, int srcOffset)
throws CorruptEncodingException
{
try {
return (byte)(src[srcOffset] ^ 0x7f);
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
}
|
java
|
public static byte decodeByteDesc(byte[] src, int srcOffset)
throws CorruptEncodingException
{
try {
return (byte)(src[srcOffset] ^ 0x7f);
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
}
|
[
"public",
"static",
"byte",
"decodeByteDesc",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"throws",
"CorruptEncodingException",
"{",
"try",
"{",
"return",
"(",
"byte",
")",
"(",
"src",
"[",
"srcOffset",
"]",
"^",
"0x7f",
")",
";",
"}",
"catch",
"(",
"IndexOutOfBoundsException",
"e",
")",
"{",
"throw",
"new",
"CorruptEncodingException",
"(",
"null",
",",
"e",
")",
";",
"}",
"}"
] |
Decodes a signed byte from exactly 1 byte, as encoded for descending
order.
@param src source of encoded bytes
@param srcOffset offset into source array
@return signed byte value
|
[
"Decodes",
"a",
"signed",
"byte",
"from",
"exactly",
"1",
"byte",
"as",
"encoded",
"for",
"descending",
"order",
"."
] |
train
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L116-L124
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/random/RandomInteger.java
|
RandomInteger.updateInteger
|
public static int updateInteger(int value, int range) {
range = range == 0 ? (int) (0.1 * value) : range;
int min = value - range;
int max = value + range;
return nextInteger(min, max);
}
|
java
|
public static int updateInteger(int value, int range) {
range = range == 0 ? (int) (0.1 * value) : range;
int min = value - range;
int max = value + range;
return nextInteger(min, max);
}
|
[
"public",
"static",
"int",
"updateInteger",
"(",
"int",
"value",
",",
"int",
"range",
")",
"{",
"range",
"=",
"range",
"==",
"0",
"?",
"(",
"int",
")",
"(",
"0.1",
"*",
"value",
")",
":",
"range",
";",
"int",
"min",
"=",
"value",
"-",
"range",
";",
"int",
"max",
"=",
"value",
"+",
"range",
";",
"return",
"nextInteger",
"(",
"min",
",",
"max",
")",
";",
"}"
] |
Updates (drifts) a integer value within specified range defined
@param value a integer value to drift.
@param range (optional) a range. Default: 10% of the value
@return updated random integer value.
|
[
"Updates",
"(",
"drifts",
")",
"a",
"integer",
"value",
"within",
"specified",
"range",
"defined"
] |
train
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomInteger.java#L65-L70
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ClassContext.java
|
ClassContext.putMethodAnalysis
|
public void putMethodAnalysis(Class<?> analysisClass, MethodDescriptor methodDescriptor, Object object) {
if (object == null) {
throw new IllegalArgumentException();
}
Map<MethodDescriptor, Object> objectMap = getObjectMap(analysisClass);
objectMap.put(methodDescriptor, object);
}
|
java
|
public void putMethodAnalysis(Class<?> analysisClass, MethodDescriptor methodDescriptor, Object object) {
if (object == null) {
throw new IllegalArgumentException();
}
Map<MethodDescriptor, Object> objectMap = getObjectMap(analysisClass);
objectMap.put(methodDescriptor, object);
}
|
[
"public",
"void",
"putMethodAnalysis",
"(",
"Class",
"<",
"?",
">",
"analysisClass",
",",
"MethodDescriptor",
"methodDescriptor",
",",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"Map",
"<",
"MethodDescriptor",
",",
"Object",
">",
"objectMap",
"=",
"getObjectMap",
"(",
"analysisClass",
")",
";",
"objectMap",
".",
"put",
"(",
"methodDescriptor",
",",
"object",
")",
";",
"}"
] |
Store a method analysis object. Note that the cached analysis object
could be a special value (indicating null or an exception).
@param analysisClass
class the method analysis object belongs to
@param methodDescriptor
method descriptor identifying the analyzed method
@param object
the analysis object to cache
|
[
"Store",
"a",
"method",
"analysis",
"object",
".",
"Note",
"that",
"the",
"cached",
"analysis",
"object",
"could",
"be",
"a",
"special",
"value",
"(",
"indicating",
"null",
"or",
"an",
"exception",
")",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ClassContext.java#L152-L158
|
alkacon/opencms-core
|
src/org/opencms/main/CmsSessionManager.java
|
CmsSessionManager.killSession
|
public void killSession(CmsObject cms, CmsUUID sessionid) throws CmsException {
OpenCms.getRoleManager().checkRole(cms, CmsRole.ACCOUNT_MANAGER);
m_sessionStorageProvider.remove(sessionid);
}
|
java
|
public void killSession(CmsObject cms, CmsUUID sessionid) throws CmsException {
OpenCms.getRoleManager().checkRole(cms, CmsRole.ACCOUNT_MANAGER);
m_sessionStorageProvider.remove(sessionid);
}
|
[
"public",
"void",
"killSession",
"(",
"CmsObject",
"cms",
",",
"CmsUUID",
"sessionid",
")",
"throws",
"CmsException",
"{",
"OpenCms",
".",
"getRoleManager",
"(",
")",
".",
"checkRole",
"(",
"cms",
",",
"CmsRole",
".",
"ACCOUNT_MANAGER",
")",
";",
"m_sessionStorageProvider",
".",
"remove",
"(",
"sessionid",
")",
";",
"}"
] |
Destroys a session given the session id. Only allowed for users which have the "account manager" role.<p>
@param cms the current CMS context
@param sessionid the session id
@throws CmsException if something goes wrong
|
[
"Destroys",
"a",
"session",
"given",
"the",
"session",
"id",
".",
"Only",
"allowed",
"for",
"users",
"which",
"have",
"the",
"account",
"manager",
"role",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsSessionManager.java#L322-L327
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferFastAggregation.java
|
BufferFastAggregation.priorityqueue_xor
|
public static MutableRoaringBitmap priorityqueue_xor(ImmutableRoaringBitmap... bitmaps) {
// code could be faster, see priorityqueue_or
if (bitmaps.length < 2) {
throw new IllegalArgumentException("Expecting at least 2 bitmaps");
}
final PriorityQueue<ImmutableRoaringBitmap> pq =
new PriorityQueue<>(bitmaps.length, new Comparator<ImmutableRoaringBitmap>() {
@Override
public int compare(ImmutableRoaringBitmap a, ImmutableRoaringBitmap b) {
return (int)(a.getLongSizeInBytes() - b.getLongSizeInBytes());
}
});
Collections.addAll(pq, bitmaps);
while (pq.size() > 1) {
final ImmutableRoaringBitmap x1 = pq.poll();
final ImmutableRoaringBitmap x2 = pq.poll();
pq.add(ImmutableRoaringBitmap.xor(x1, x2));
}
return (MutableRoaringBitmap) pq.poll();
}
|
java
|
public static MutableRoaringBitmap priorityqueue_xor(ImmutableRoaringBitmap... bitmaps) {
// code could be faster, see priorityqueue_or
if (bitmaps.length < 2) {
throw new IllegalArgumentException("Expecting at least 2 bitmaps");
}
final PriorityQueue<ImmutableRoaringBitmap> pq =
new PriorityQueue<>(bitmaps.length, new Comparator<ImmutableRoaringBitmap>() {
@Override
public int compare(ImmutableRoaringBitmap a, ImmutableRoaringBitmap b) {
return (int)(a.getLongSizeInBytes() - b.getLongSizeInBytes());
}
});
Collections.addAll(pq, bitmaps);
while (pq.size() > 1) {
final ImmutableRoaringBitmap x1 = pq.poll();
final ImmutableRoaringBitmap x2 = pq.poll();
pq.add(ImmutableRoaringBitmap.xor(x1, x2));
}
return (MutableRoaringBitmap) pq.poll();
}
|
[
"public",
"static",
"MutableRoaringBitmap",
"priorityqueue_xor",
"(",
"ImmutableRoaringBitmap",
"...",
"bitmaps",
")",
"{",
"// code could be faster, see priorityqueue_or",
"if",
"(",
"bitmaps",
".",
"length",
"<",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expecting at least 2 bitmaps\"",
")",
";",
"}",
"final",
"PriorityQueue",
"<",
"ImmutableRoaringBitmap",
">",
"pq",
"=",
"new",
"PriorityQueue",
"<>",
"(",
"bitmaps",
".",
"length",
",",
"new",
"Comparator",
"<",
"ImmutableRoaringBitmap",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"ImmutableRoaringBitmap",
"a",
",",
"ImmutableRoaringBitmap",
"b",
")",
"{",
"return",
"(",
"int",
")",
"(",
"a",
".",
"getLongSizeInBytes",
"(",
")",
"-",
"b",
".",
"getLongSizeInBytes",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"Collections",
".",
"addAll",
"(",
"pq",
",",
"bitmaps",
")",
";",
"while",
"(",
"pq",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"final",
"ImmutableRoaringBitmap",
"x1",
"=",
"pq",
".",
"poll",
"(",
")",
";",
"final",
"ImmutableRoaringBitmap",
"x2",
"=",
"pq",
".",
"poll",
"(",
")",
";",
"pq",
".",
"add",
"(",
"ImmutableRoaringBitmap",
".",
"xor",
"(",
"x1",
",",
"x2",
")",
")",
";",
"}",
"return",
"(",
"MutableRoaringBitmap",
")",
"pq",
".",
"poll",
"(",
")",
";",
"}"
] |
Uses a priority queue to compute the xor aggregate.
This function runs in linearithmic (O(n log n)) time with respect to the number of bitmaps.
@param bitmaps input bitmaps
@return aggregated bitmap
@see #horizontal_xor(ImmutableRoaringBitmap...)
|
[
"Uses",
"a",
"priority",
"queue",
"to",
"compute",
"the",
"xor",
"aggregate",
"."
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferFastAggregation.java#L583-L602
|
Metatavu/edelphi
|
smvcj/src/main/java/fi/metatavu/edelphi/smvcj/dispatcher/Servlet.java
|
Servlet.service
|
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
if (sessionSynchronization) {
String syncKey = getSyncKey(request);
synchronized (getSyncObject(syncKey)) {
try {
doService(request, response);
}
finally {
removeSyncObject(syncKey);
}
}
}
else {
doService(request, response);
}
}
|
java
|
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
if (sessionSynchronization) {
String syncKey = getSyncKey(request);
synchronized (getSyncObject(syncKey)) {
try {
doService(request, response);
}
finally {
removeSyncObject(syncKey);
}
}
}
else {
doService(request, response);
}
}
|
[
"@",
"Override",
"protected",
"void",
"service",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"java",
".",
"io",
".",
"IOException",
"{",
"if",
"(",
"sessionSynchronization",
")",
"{",
"String",
"syncKey",
"=",
"getSyncKey",
"(",
"request",
")",
";",
"synchronized",
"(",
"getSyncObject",
"(",
"syncKey",
")",
")",
"{",
"try",
"{",
"doService",
"(",
"request",
",",
"response",
")",
";",
"}",
"finally",
"{",
"removeSyncObject",
"(",
"syncKey",
")",
";",
"}",
"}",
"}",
"else",
"{",
"doService",
"(",
"request",
",",
"response",
")",
";",
"}",
"}"
] |
Processes all application requests, delegating them to their corresponding page, binary and JSON controllers.
|
[
"Processes",
"all",
"application",
"requests",
"delegating",
"them",
"to",
"their",
"corresponding",
"page",
"binary",
"and",
"JSON",
"controllers",
"."
] |
train
|
https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/smvcj/src/main/java/fi/metatavu/edelphi/smvcj/dispatcher/Servlet.java#L81-L97
|
jayantk/jklol
|
src/com/jayantkrish/jklol/ccg/lambda2/Expression2.java
|
Expression2.substitute
|
public Expression2 substitute(String value, String replacement) {
return substitute(Expression2.constant(value), Expression2.constant(replacement));
}
|
java
|
public Expression2 substitute(String value, String replacement) {
return substitute(Expression2.constant(value), Expression2.constant(replacement));
}
|
[
"public",
"Expression2",
"substitute",
"(",
"String",
"value",
",",
"String",
"replacement",
")",
"{",
"return",
"substitute",
"(",
"Expression2",
".",
"constant",
"(",
"value",
")",
",",
"Expression2",
".",
"constant",
"(",
"replacement",
")",
")",
";",
"}"
] |
Replaces all occurrences of {@code value} in this
expression with {@code replacement}.
@param value
@param replacement
@return
|
[
"Replaces",
"all",
"occurrences",
"of",
"{",
"@code",
"value",
"}",
"in",
"this",
"expression",
"with",
"{",
"@code",
"replacement",
"}",
"."
] |
train
|
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/lambda2/Expression2.java#L251-L253
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/common/logging/LoggingDecoratorBuilder.java
|
LoggingDecoratorBuilder.responseCauseSanitizer
|
public T responseCauseSanitizer(Function<? super Throwable, ? extends Throwable> responseCauseSanitizer) {
this.responseCauseSanitizer = requireNonNull(responseCauseSanitizer, "responseCauseSanitizer");
return self();
}
|
java
|
public T responseCauseSanitizer(Function<? super Throwable, ? extends Throwable> responseCauseSanitizer) {
this.responseCauseSanitizer = requireNonNull(responseCauseSanitizer, "responseCauseSanitizer");
return self();
}
|
[
"public",
"T",
"responseCauseSanitizer",
"(",
"Function",
"<",
"?",
"super",
"Throwable",
",",
"?",
"extends",
"Throwable",
">",
"responseCauseSanitizer",
")",
"{",
"this",
".",
"responseCauseSanitizer",
"=",
"requireNonNull",
"(",
"responseCauseSanitizer",
",",
"\"responseCauseSanitizer\"",
")",
";",
"return",
"self",
"(",
")",
";",
"}"
] |
Sets the {@link Function} to use to sanitize a response cause before logging. You can
sanitize the stack trace of the exception to remove sensitive information, or prevent from logging
the stack trace completely by returning {@code null} in the {@link Function}. If unset, will use
{@link Function#identity()}.
|
[
"Sets",
"the",
"{"
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/common/logging/LoggingDecoratorBuilder.java#L256-L259
|
stickfigure/batchfb
|
src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java
|
MultiqueryRequest.getParams
|
@Override
@JsonIgnore
protected Param[] getParams() {
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
}
|
java
|
@Override
@JsonIgnore
protected Param[] getParams() {
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
}
|
[
"@",
"Override",
"@",
"JsonIgnore",
"protected",
"Param",
"[",
"]",
"getParams",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"queries",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"QueryRequest",
"<",
"?",
">",
"req",
":",
"this",
".",
"queryRequests",
")",
"queries",
".",
"put",
"(",
"req",
".",
"getName",
"(",
")",
",",
"req",
".",
"getFQL",
"(",
")",
")",
";",
"String",
"json",
"=",
"JSONUtils",
".",
"toJSON",
"(",
"queries",
",",
"this",
".",
"mapper",
")",
";",
"return",
"new",
"Param",
"[",
"]",
"{",
"new",
"Param",
"(",
"\"queries\"",
",",
"json",
")",
"}",
";",
"}"
] |
Generate the parameters approprate to a multiquery from the registered queries
|
[
"Generate",
"the",
"parameters",
"approprate",
"to",
"a",
"multiquery",
"from",
"the",
"registered",
"queries"
] |
train
|
https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java#L38-L48
|
aws/aws-sdk-java
|
aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/ReceiveQueueBuffer.java
|
ReceiveQueueBuffer.issueFuture
|
private ReceiveMessageFuture issueFuture(int size,
QueueBufferCallback<ReceiveMessageRequest, ReceiveMessageResult> callback) {
synchronized (futures) {
ReceiveMessageFuture theFuture = new ReceiveMessageFuture(callback, size);
futures.addLast(theFuture);
return theFuture;
}
}
|
java
|
private ReceiveMessageFuture issueFuture(int size,
QueueBufferCallback<ReceiveMessageRequest, ReceiveMessageResult> callback) {
synchronized (futures) {
ReceiveMessageFuture theFuture = new ReceiveMessageFuture(callback, size);
futures.addLast(theFuture);
return theFuture;
}
}
|
[
"private",
"ReceiveMessageFuture",
"issueFuture",
"(",
"int",
"size",
",",
"QueueBufferCallback",
"<",
"ReceiveMessageRequest",
",",
"ReceiveMessageResult",
">",
"callback",
")",
"{",
"synchronized",
"(",
"futures",
")",
"{",
"ReceiveMessageFuture",
"theFuture",
"=",
"new",
"ReceiveMessageFuture",
"(",
"callback",
",",
"size",
")",
";",
"futures",
".",
"addLast",
"(",
"theFuture",
")",
";",
"return",
"theFuture",
";",
"}",
"}"
] |
Creates and returns a new future object. Sleeps if the list of already-issued but as yet
unsatisfied futures is over a throttle limit.
@return never null
|
[
"Creates",
"and",
"returns",
"a",
"new",
"future",
"object",
".",
"Sleeps",
"if",
"the",
"list",
"of",
"already",
"-",
"issued",
"but",
"as",
"yet",
"unsatisfied",
"futures",
"is",
"over",
"a",
"throttle",
"limit",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/ReceiveQueueBuffer.java#L161-L168
|
j256/ormlite-core
|
src/main/java/com/j256/ormlite/stmt/QueryBuilder.java
|
QueryBuilder.leftJoin
|
public QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
addJoinInfo(JoinType.LEFT, null, null, joinedQueryBuilder, JoinWhereOperation.AND);
return this;
}
|
java
|
public QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
addJoinInfo(JoinType.LEFT, null, null, joinedQueryBuilder, JoinWhereOperation.AND);
return this;
}
|
[
"public",
"QueryBuilder",
"<",
"T",
",",
"ID",
">",
"leftJoin",
"(",
"QueryBuilder",
"<",
"?",
",",
"?",
">",
"joinedQueryBuilder",
")",
"throws",
"SQLException",
"{",
"addJoinInfo",
"(",
"JoinType",
".",
"LEFT",
",",
"null",
",",
"null",
",",
"joinedQueryBuilder",
",",
"JoinWhereOperation",
".",
"AND",
")",
";",
"return",
"this",
";",
"}"
] |
Similar to {@link #join(QueryBuilder)} but it will use "LEFT JOIN" instead.
See: <a href="http://www.w3schools.com/sql/sql_join_left.asp" >LEFT JOIN SQL docs</a>
<p>
<b>NOTE:</b> RIGHT and FULL JOIN SQL commands are not supported because we are only returning objects from the
"left" table.
</p>
<p>
<b>NOTE:</b> This will do combine the WHERE statement of the two query builders with a SQL "AND". See
{@link #leftJoinOr(QueryBuilder)}.
</p>
|
[
"Similar",
"to",
"{",
"@link",
"#join",
"(",
"QueryBuilder",
")",
"}",
"but",
"it",
"will",
"use",
"LEFT",
"JOIN",
"instead",
"."
] |
train
|
https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/QueryBuilder.java#L327-L330
|
wildfly/wildfly-core
|
controller/src/main/java/org/jboss/as/controller/access/AuthorizationResult.java
|
AuthorizationResult.failIfDenied
|
public void failIfDenied(ModelNode operation, PathAddress targetAddress) throws OperationFailedException {
if (decision == AuthorizationResult.Decision.DENY) {
throw ControllerLogger.ACCESS_LOGGER.unauthorized(operation.get(OP).asString(),
targetAddress, explanation);
}
}
|
java
|
public void failIfDenied(ModelNode operation, PathAddress targetAddress) throws OperationFailedException {
if (decision == AuthorizationResult.Decision.DENY) {
throw ControllerLogger.ACCESS_LOGGER.unauthorized(operation.get(OP).asString(),
targetAddress, explanation);
}
}
|
[
"public",
"void",
"failIfDenied",
"(",
"ModelNode",
"operation",
",",
"PathAddress",
"targetAddress",
")",
"throws",
"OperationFailedException",
"{",
"if",
"(",
"decision",
"==",
"AuthorizationResult",
".",
"Decision",
".",
"DENY",
")",
"{",
"throw",
"ControllerLogger",
".",
"ACCESS_LOGGER",
".",
"unauthorized",
"(",
"operation",
".",
"get",
"(",
"OP",
")",
".",
"asString",
"(",
")",
",",
"targetAddress",
",",
"explanation",
")",
";",
"}",
"}"
] |
Utility method to throw a standard failure if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY}.
@param operation the operation the triggered this authorization result. Cannot be {@code null}
@param targetAddress the target address of the request that triggered this authorization result. Cannot be {@code null}
@throws OperationFailedException if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY}
|
[
"Utility",
"method",
"to",
"throw",
"a",
"standard",
"failure",
"if",
"{",
"@link",
"#getDecision",
"()",
"}",
"is",
"{",
"@link",
"org",
".",
"jboss",
".",
"as",
".",
"controller",
".",
"access",
".",
"AuthorizationResult",
".",
"Decision#DENY",
"}",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/access/AuthorizationResult.java#L119-L125
|
krummas/DrizzleJDBC
|
src/main/java/org/drizzle/jdbc/DrizzleDataSource.java
|
DrizzleDataSource.getConnection
|
public Connection getConnection() throws SQLException {
try {
return new DrizzleConnection(new MySQLProtocol(hostname, port, database, null, null, new Properties()),
new DrizzleQueryFactory());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
}
|
java
|
public Connection getConnection() throws SQLException {
try {
return new DrizzleConnection(new MySQLProtocol(hostname, port, database, null, null, new Properties()),
new DrizzleQueryFactory());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
}
|
[
"public",
"Connection",
"getConnection",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"return",
"new",
"DrizzleConnection",
"(",
"new",
"MySQLProtocol",
"(",
"hostname",
",",
"port",
",",
"database",
",",
"null",
",",
"null",
",",
"new",
"Properties",
"(",
")",
")",
",",
"new",
"DrizzleQueryFactory",
"(",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"e",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"get",
"(",
"e",
")",
";",
"}",
"}"
] |
<p>Attempts to establish a connection with the data source that this <code>DataSource</code> object represents.
@return a connection to the data source
@throws java.sql.SQLException if a database access error occurs
|
[
"<p",
">",
"Attempts",
"to",
"establish",
"a",
"connection",
"with",
"the",
"data",
"source",
"that",
"this",
"<code",
">",
"DataSource<",
"/",
"code",
">",
"object",
"represents",
"."
] |
train
|
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleDataSource.java#L60-L67
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/X509CertPath.java
|
X509CertPath.encodePKCS7
|
private byte[] encodePKCS7() throws CertificateEncodingException {
PKCS7 p7 = new PKCS7(new AlgorithmId[0],
new ContentInfo(ContentInfo.DATA_OID, null),
certs.toArray(new X509Certificate[certs.size()]),
new SignerInfo[0]);
DerOutputStream derout = new DerOutputStream();
try {
p7.encodeSignedData(derout);
} catch (IOException ioe) {
throw new CertificateEncodingException(ioe.getMessage());
}
return derout.toByteArray();
}
|
java
|
private byte[] encodePKCS7() throws CertificateEncodingException {
PKCS7 p7 = new PKCS7(new AlgorithmId[0],
new ContentInfo(ContentInfo.DATA_OID, null),
certs.toArray(new X509Certificate[certs.size()]),
new SignerInfo[0]);
DerOutputStream derout = new DerOutputStream();
try {
p7.encodeSignedData(derout);
} catch (IOException ioe) {
throw new CertificateEncodingException(ioe.getMessage());
}
return derout.toByteArray();
}
|
[
"private",
"byte",
"[",
"]",
"encodePKCS7",
"(",
")",
"throws",
"CertificateEncodingException",
"{",
"PKCS7",
"p7",
"=",
"new",
"PKCS7",
"(",
"new",
"AlgorithmId",
"[",
"0",
"]",
",",
"new",
"ContentInfo",
"(",
"ContentInfo",
".",
"DATA_OID",
",",
"null",
")",
",",
"certs",
".",
"toArray",
"(",
"new",
"X509Certificate",
"[",
"certs",
".",
"size",
"(",
")",
"]",
")",
",",
"new",
"SignerInfo",
"[",
"0",
"]",
")",
";",
"DerOutputStream",
"derout",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"try",
"{",
"p7",
".",
"encodeSignedData",
"(",
"derout",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"CertificateEncodingException",
"(",
"ioe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"derout",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Encode the CertPath using PKCS#7 format.
@return a byte array containing the binary encoding of the PKCS#7 object
@exception CertificateEncodingException if an exception occurs
|
[
"Encode",
"the",
"CertPath",
"using",
"PKCS#7",
"format",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/X509CertPath.java#L323-L335
|
alkacon/opencms-core
|
src/org/opencms/staticexport/CmsAdvancedLinkSubstitutionHandler.java
|
CmsAdvancedLinkSubstitutionHandler.isExcluded
|
protected boolean isExcluded(CmsObject cms, String path) {
List<String> excludes = getExcludes(cms);
// now check if the current link start with one of the exclude links
for (int i = 0; i < excludes.size(); i++) {
if (path.startsWith(excludes.get(i))) {
return true;
}
}
return false;
}
|
java
|
protected boolean isExcluded(CmsObject cms, String path) {
List<String> excludes = getExcludes(cms);
// now check if the current link start with one of the exclude links
for (int i = 0; i < excludes.size(); i++) {
if (path.startsWith(excludes.get(i))) {
return true;
}
}
return false;
}
|
[
"protected",
"boolean",
"isExcluded",
"(",
"CmsObject",
"cms",
",",
"String",
"path",
")",
"{",
"List",
"<",
"String",
">",
"excludes",
"=",
"getExcludes",
"(",
"cms",
")",
";",
"// now check if the current link start with one of the exclude links",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"excludes",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"path",
".",
"startsWith",
"(",
"excludes",
".",
"get",
"(",
"i",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns if the given path starts with an exclude prefix.<p>
@param cms the cms context
@param path the path to check
@return <code>true</code> if the given path starts with an exclude prefix
|
[
"Returns",
"if",
"the",
"given",
"path",
"starts",
"with",
"an",
"exclude",
"prefix",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsAdvancedLinkSubstitutionHandler.java#L128-L138
|
graknlabs/grakn
|
server/src/graql/analytics/KCoreVertexProgram.java
|
KCoreVertexProgram.getMessageCountExcludeSelf
|
private static int getMessageCountExcludeSelf(Messenger<String> messenger, String id) {
Set<String> messageSet = newHashSet(messenger.receiveMessages());
messageSet.remove(id);
return messageSet.size();
}
|
java
|
private static int getMessageCountExcludeSelf(Messenger<String> messenger, String id) {
Set<String> messageSet = newHashSet(messenger.receiveMessages());
messageSet.remove(id);
return messageSet.size();
}
|
[
"private",
"static",
"int",
"getMessageCountExcludeSelf",
"(",
"Messenger",
"<",
"String",
">",
"messenger",
",",
"String",
"id",
")",
"{",
"Set",
"<",
"String",
">",
"messageSet",
"=",
"newHashSet",
"(",
"messenger",
".",
"receiveMessages",
"(",
")",
")",
";",
"messageSet",
".",
"remove",
"(",
"id",
")",
";",
"return",
"messageSet",
".",
"size",
"(",
")",
";",
"}"
] |
count the messages from relations, so need to filter its own msg
|
[
"count",
"the",
"messages",
"from",
"relations",
"so",
"need",
"to",
"filter",
"its",
"own",
"msg"
] |
train
|
https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/graql/analytics/KCoreVertexProgram.java#L215-L219
|
alkacon/opencms-core
|
src-modules/org/opencms/workplace/tools/searchindex/CmsHookListSearchCategory.java
|
CmsHookListSearchCategory.onGetCall
|
@Override
protected void onGetCall(Object peer, int index) {
// zero categories are all (first condition)
if (((m_backupCategories.size() == 0) && (size() != 0)) || !(containsAll(m_backupCategories))) {
((CmsSearchParameters)peer).setSearchPage(1);
}
}
|
java
|
@Override
protected void onGetCall(Object peer, int index) {
// zero categories are all (first condition)
if (((m_backupCategories.size() == 0) && (size() != 0)) || !(containsAll(m_backupCategories))) {
((CmsSearchParameters)peer).setSearchPage(1);
}
}
|
[
"@",
"Override",
"protected",
"void",
"onGetCall",
"(",
"Object",
"peer",
",",
"int",
"index",
")",
"{",
"// zero categories are all (first condition)",
"if",
"(",
"(",
"(",
"m_backupCategories",
".",
"size",
"(",
")",
"==",
"0",
")",
"&&",
"(",
"size",
"(",
")",
"!=",
"0",
")",
")",
"||",
"!",
"(",
"containsAll",
"(",
"m_backupCategories",
")",
")",
")",
"{",
"(",
"(",
"CmsSearchParameters",
")",
"peer",
")",
".",
"setSearchPage",
"(",
"1",
")",
";",
"}",
"}"
] |
Set the search page of the peer Object
(<code>{@link org.opencms.search.CmsSearch#setSearchPage(int)}</code>)
to zero if the internal backup list of categories (taken at clear time which
is triggered by <code>{@link org.opencms.workplace.CmsWidgetDialog#ACTION_SAVE}</code>)
was empty (no restriction) and now categories are contained or if the new
backup list of categories is no subset of the current categories any
more (more restrictive search than before). <p>
@see org.opencms.workplace.tools.searchindex.CmsHookList#onGetCall(java.lang.Object, int)
|
[
"Set",
"the",
"search",
"page",
"of",
"the",
"peer",
"Object",
"(",
"<code",
">",
"{",
"@link",
"org",
".",
"opencms",
".",
"search",
".",
"CmsSearch#setSearchPage",
"(",
"int",
")",
"}",
"<",
"/",
"code",
">",
")",
"to",
"zero",
"if",
"the",
"internal",
"backup",
"list",
"of",
"categories",
"(",
"taken",
"at",
"clear",
"time",
"which",
"is",
"triggered",
"by",
"<code",
">",
"{",
"@link",
"org",
".",
"opencms",
".",
"workplace",
".",
"CmsWidgetDialog#ACTION_SAVE",
"}",
"<",
"/",
"code",
">",
")",
"was",
"empty",
"(",
"no",
"restriction",
")",
"and",
"now",
"categories",
"are",
"contained",
"or",
"if",
"the",
"new",
"backup",
"list",
"of",
"categories",
"is",
"no",
"subset",
"of",
"the",
"current",
"categories",
"any",
"more",
"(",
"more",
"restrictive",
"search",
"than",
"before",
")",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsHookListSearchCategory.java#L155-L162
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerValue.java
|
DerValue.getUTCTime
|
public Date getUTCTime() throws IOException {
if (tag != tag_UtcTime) {
throw new IOException("DerValue.getUTCTime, not a UtcTime: " + tag);
}
return buffer.getUTCTime(data.available());
}
|
java
|
public Date getUTCTime() throws IOException {
if (tag != tag_UtcTime) {
throw new IOException("DerValue.getUTCTime, not a UtcTime: " + tag);
}
return buffer.getUTCTime(data.available());
}
|
[
"public",
"Date",
"getUTCTime",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"tag",
"!=",
"tag_UtcTime",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"DerValue.getUTCTime, not a UtcTime: \"",
"+",
"tag",
")",
";",
"}",
"return",
"buffer",
".",
"getUTCTime",
"(",
"data",
".",
"available",
"(",
")",
")",
";",
"}"
] |
Returns a Date if the DerValue is UtcTime.
@return the Date held in this DER value
|
[
"Returns",
"a",
"Date",
"if",
"the",
"DerValue",
"is",
"UtcTime",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/DerValue.java#L741-L746
|
EdwardRaff/JSAT
|
JSAT/src/jsat/regression/RANSAC.java
|
RANSAC.setMaxPointError
|
public void setMaxPointError(double maxPointError)
{
if(maxPointError < 0 || Double.isInfinite(maxPointError) || Double.isNaN(maxPointError))
throw new ArithmeticException("The error must be a positive value, not " + maxPointError );
this.maxPointError = maxPointError;
}
|
java
|
public void setMaxPointError(double maxPointError)
{
if(maxPointError < 0 || Double.isInfinite(maxPointError) || Double.isNaN(maxPointError))
throw new ArithmeticException("The error must be a positive value, not " + maxPointError );
this.maxPointError = maxPointError;
}
|
[
"public",
"void",
"setMaxPointError",
"(",
"double",
"maxPointError",
")",
"{",
"if",
"(",
"maxPointError",
"<",
"0",
"||",
"Double",
".",
"isInfinite",
"(",
"maxPointError",
")",
"||",
"Double",
".",
"isNaN",
"(",
"maxPointError",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"\"The error must be a positive value, not \"",
"+",
"maxPointError",
")",
";",
"this",
".",
"maxPointError",
"=",
"maxPointError",
";",
"}"
] |
Each data point not in the initial training set will be tested against.
If a data points error is sufficiently small, it will be added to the set
of inliers.
@param maxPointError the new maximum error a data point may have to be
considered an inlier.
|
[
"Each",
"data",
"point",
"not",
"in",
"the",
"initial",
"training",
"set",
"will",
"be",
"tested",
"against",
".",
"If",
"a",
"data",
"points",
"error",
"is",
"sufficiently",
"small",
"it",
"will",
"be",
"added",
"to",
"the",
"set",
"of",
"inliers",
"."
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/regression/RANSAC.java#L258-L263
|
alkacon/opencms-core
|
src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelMonthlyController.java
|
CmsPatternPanelMonthlyController.setPatternScheme
|
public void setPatternScheme(final boolean isByWeekDay, final boolean fireChange) {
if (isByWeekDay ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isByWeekDay) {
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
} else {
m_model.clearWeekDays();
m_model.clearWeeksOfMonth();
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
}
m_model.setInterval(getPatternDefaultValues().getInterval());
if (fireChange) {
onValueChange();
}
}
});
}
}
|
java
|
public void setPatternScheme(final boolean isByWeekDay, final boolean fireChange) {
if (isByWeekDay ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isByWeekDay) {
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
} else {
m_model.clearWeekDays();
m_model.clearWeeksOfMonth();
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
}
m_model.setInterval(getPatternDefaultValues().getInterval());
if (fireChange) {
onValueChange();
}
}
});
}
}
|
[
"public",
"void",
"setPatternScheme",
"(",
"final",
"boolean",
"isByWeekDay",
",",
"final",
"boolean",
"fireChange",
")",
"{",
"if",
"(",
"isByWeekDay",
"^",
"(",
"null",
"!=",
"m_model",
".",
"getWeekDay",
"(",
")",
")",
")",
"{",
"removeExceptionsOnChange",
"(",
"new",
"Command",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
")",
"{",
"if",
"(",
"isByWeekDay",
")",
"{",
"m_model",
".",
"setWeekOfMonth",
"(",
"getPatternDefaultValues",
"(",
")",
".",
"getWeekOfMonth",
"(",
")",
")",
";",
"m_model",
".",
"setWeekDay",
"(",
"getPatternDefaultValues",
"(",
")",
".",
"getWeekDay",
"(",
")",
")",
";",
"}",
"else",
"{",
"m_model",
".",
"clearWeekDays",
"(",
")",
";",
"m_model",
".",
"clearWeeksOfMonth",
"(",
")",
";",
"m_model",
".",
"setDayOfMonth",
"(",
"getPatternDefaultValues",
"(",
")",
".",
"getDayOfMonth",
"(",
")",
")",
";",
"}",
"m_model",
".",
"setInterval",
"(",
"getPatternDefaultValues",
"(",
")",
".",
"getInterval",
"(",
")",
")",
";",
"if",
"(",
"fireChange",
")",
"{",
"onValueChange",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"}"
] |
Set the pattern scheme to either "by weekday" or "by day of month".
@param isByWeekDay flag, indicating if the pattern "by weekday" should be set.
@param fireChange flag, indicating if a value change event should be fired.
|
[
"Set",
"the",
"pattern",
"scheme",
"to",
"either",
"by",
"weekday",
"or",
"by",
"day",
"of",
"month",
"."
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelMonthlyController.java#L65-L88
|
threerings/narya
|
core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java
|
ChatProvider.createTellMessage
|
protected UserMessage createTellMessage (BodyObject source, String message)
{
return UserMessage.create(source.getVisibleName(), message);
}
|
java
|
protected UserMessage createTellMessage (BodyObject source, String message)
{
return UserMessage.create(source.getVisibleName(), message);
}
|
[
"protected",
"UserMessage",
"createTellMessage",
"(",
"BodyObject",
"source",
",",
"String",
"message",
")",
"{",
"return",
"UserMessage",
".",
"create",
"(",
"source",
".",
"getVisibleName",
"(",
")",
",",
"message",
")",
";",
"}"
] |
Used to create a {@link UserMessage} for the supplied sender.
|
[
"Used",
"to",
"create",
"a",
"{"
] |
train
|
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L272-L275
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
|
InvokerHelper.setProperty2
|
public static void setProperty2(Object newValue, Object object, String property) {
setProperty(object, property, newValue);
}
|
java
|
public static void setProperty2(Object newValue, Object object, String property) {
setProperty(object, property, newValue);
}
|
[
"public",
"static",
"void",
"setProperty2",
"(",
"Object",
"newValue",
",",
"Object",
"object",
",",
"String",
"property",
")",
"{",
"setProperty",
"(",
"object",
",",
"property",
",",
"newValue",
")",
";",
"}"
] |
This is so we don't have to reorder the stack when we call this method.
At some point a better name might be in order.
|
[
"This",
"is",
"so",
"we",
"don",
"t",
"have",
"to",
"reorder",
"the",
"stack",
"when",
"we",
"call",
"this",
"method",
".",
"At",
"some",
"point",
"a",
"better",
"name",
"might",
"be",
"in",
"order",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java#L227-L229
|
mbenson/therian
|
core/src/main/java/therian/TherianContext.java
|
TherianContext.evalSuccess
|
public final synchronized boolean evalSuccess(Operation<?> operation, Hint... hints) {
final boolean dummyRoot = stack.isEmpty();
if (dummyRoot) {
// add a root frame to preserve our cache "around" the supports/eval lifecycle, bypassing #push():
stack.push(Frame.ROOT);
}
try {
if (supports(operation, hints)) {
eval(operation, hints);
return operation.isSuccessful();
}
} finally {
if (dummyRoot) {
pop(Frame.ROOT);
}
}
return false;
}
|
java
|
public final synchronized boolean evalSuccess(Operation<?> operation, Hint... hints) {
final boolean dummyRoot = stack.isEmpty();
if (dummyRoot) {
// add a root frame to preserve our cache "around" the supports/eval lifecycle, bypassing #push():
stack.push(Frame.ROOT);
}
try {
if (supports(operation, hints)) {
eval(operation, hints);
return operation.isSuccessful();
}
} finally {
if (dummyRoot) {
pop(Frame.ROOT);
}
}
return false;
}
|
[
"public",
"final",
"synchronized",
"boolean",
"evalSuccess",
"(",
"Operation",
"<",
"?",
">",
"operation",
",",
"Hint",
"...",
"hints",
")",
"{",
"final",
"boolean",
"dummyRoot",
"=",
"stack",
".",
"isEmpty",
"(",
")",
";",
"if",
"(",
"dummyRoot",
")",
"{",
"// add a root frame to preserve our cache \"around\" the supports/eval lifecycle, bypassing #push():",
"stack",
".",
"push",
"(",
"Frame",
".",
"ROOT",
")",
";",
"}",
"try",
"{",
"if",
"(",
"supports",
"(",
"operation",
",",
"hints",
")",
")",
"{",
"eval",
"(",
"operation",
",",
"hints",
")",
";",
"return",
"operation",
".",
"isSuccessful",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"dummyRoot",
")",
"{",
"pop",
"(",
"Frame",
".",
"ROOT",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Convenience method to perform an operation, discarding its result, and report whether it succeeded.
@param operation
@param hints
@return whether {@code operation} was supported and successful
@throws NullPointerException on {@code null} input
@throws OperationException potentially, via {@link Operation#getResult()}
|
[
"Convenience",
"method",
"to",
"perform",
"an",
"operation",
"discarding",
"its",
"result",
"and",
"report",
"whether",
"it",
"succeeded",
"."
] |
train
|
https://github.com/mbenson/therian/blob/0653505f73e2a6f5b0abc394ea6d83af03408254/core/src/main/java/therian/TherianContext.java#L429-L446
|
fhoeben/hsac-fitnesse-fixtures
|
src/main/java/nl/hsac/fitnesse/fixture/slim/MapFixture.java
|
MapFixture.copyValuesFromTo
|
public void copyValuesFromTo(Map<String, Object> otherMap, Map<String, Object> map) {
getMapHelper().copyValuesFromTo(otherMap, map);
}
|
java
|
public void copyValuesFromTo(Map<String, Object> otherMap, Map<String, Object> map) {
getMapHelper().copyValuesFromTo(otherMap, map);
}
|
[
"public",
"void",
"copyValuesFromTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"otherMap",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"getMapHelper",
"(",
")",
".",
"copyValuesFromTo",
"(",
"otherMap",
",",
"map",
")",
";",
"}"
] |
Adds all values in the supplied map to the current values.
@param otherMap to obtain values from.
@param map map to store value in.
|
[
"Adds",
"all",
"values",
"in",
"the",
"supplied",
"map",
"to",
"the",
"current",
"values",
"."
] |
train
|
https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/slim/MapFixture.java#L104-L106
|
Whiley/WhileyCompiler
|
src/main/java/wyil/util/AbstractTypedVisitor.java
|
AbstractTypedVisitor.selectLambda
|
public Type.Callable selectLambda(Type target, Expr expr, Environment environment) {
Type.Callable type = asType(expr.getType(), Type.Callable.class);
// Construct the default case for matching against any
Type.Callable anyType = new Type.Function(type.getParameters(), TUPLE_ANY);
// Create the filter itself
AbstractTypeFilter<Type.Callable> filter = new AbstractTypeFilter<>(Type.Callable.class, anyType);
//
return selectCandidate(filter.apply(target), type, environment);
}
|
java
|
public Type.Callable selectLambda(Type target, Expr expr, Environment environment) {
Type.Callable type = asType(expr.getType(), Type.Callable.class);
// Construct the default case for matching against any
Type.Callable anyType = new Type.Function(type.getParameters(), TUPLE_ANY);
// Create the filter itself
AbstractTypeFilter<Type.Callable> filter = new AbstractTypeFilter<>(Type.Callable.class, anyType);
//
return selectCandidate(filter.apply(target), type, environment);
}
|
[
"public",
"Type",
".",
"Callable",
"selectLambda",
"(",
"Type",
"target",
",",
"Expr",
"expr",
",",
"Environment",
"environment",
")",
"{",
"Type",
".",
"Callable",
"type",
"=",
"asType",
"(",
"expr",
".",
"getType",
"(",
")",
",",
"Type",
".",
"Callable",
".",
"class",
")",
";",
"// Construct the default case for matching against any",
"Type",
".",
"Callable",
"anyType",
"=",
"new",
"Type",
".",
"Function",
"(",
"type",
".",
"getParameters",
"(",
")",
",",
"TUPLE_ANY",
")",
";",
"// Create the filter itself",
"AbstractTypeFilter",
"<",
"Type",
".",
"Callable",
">",
"filter",
"=",
"new",
"AbstractTypeFilter",
"<>",
"(",
"Type",
".",
"Callable",
".",
"class",
",",
"anyType",
")",
";",
"//",
"return",
"selectCandidate",
"(",
"filter",
".",
"apply",
"(",
"target",
")",
",",
"type",
",",
"environment",
")",
";",
"}"
] |
<p>
Given an arbitrary target type, filter out the target lambda types. For
example, consider the following method:
</p>
<pre>
type fun_t is function(int)->(int)
method f(int x):
fun_t|null xs = &(int y -> y+1)
...
</pre>
<p>
When type checking the expression <code>&(int y -> y+1)</code> the flow type
checker will attempt to determine an <i>expected</i> lambda type. In order to
then determine the appropriate expected type for the lambda body
<code>y+1</code> it filters <code>fun_t|null</code> down to just
<code>fun_t</code>.
</p>
@param target
Target type for this value
@param expr
Source expression for this value
@author David J. Pearce
|
[
"<p",
">",
"Given",
"an",
"arbitrary",
"target",
"type",
"filter",
"out",
"the",
"target",
"lambda",
"types",
".",
"For",
"example",
"consider",
"the",
"following",
"method",
":",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/util/AbstractTypedVisitor.java#L1208-L1216
|
ksclarke/freelib-utils
|
src/main/java/info/freelibrary/util/FileUtils.java
|
FileUtils.toDocument
|
public static Document toDocument(final String aFilePath, final String aPattern, final boolean aDeepConversion)
throws FileNotFoundException, ParserConfigurationException {
final Element element = toElement(aFilePath, aPattern, aDeepConversion);
final Document document = element.getOwnerDocument();
document.appendChild(element);
return document;
}
|
java
|
public static Document toDocument(final String aFilePath, final String aPattern, final boolean aDeepConversion)
throws FileNotFoundException, ParserConfigurationException {
final Element element = toElement(aFilePath, aPattern, aDeepConversion);
final Document document = element.getOwnerDocument();
document.appendChild(element);
return document;
}
|
[
"public",
"static",
"Document",
"toDocument",
"(",
"final",
"String",
"aFilePath",
",",
"final",
"String",
"aPattern",
",",
"final",
"boolean",
"aDeepConversion",
")",
"throws",
"FileNotFoundException",
",",
"ParserConfigurationException",
"{",
"final",
"Element",
"element",
"=",
"toElement",
"(",
"aFilePath",
",",
"aPattern",
",",
"aDeepConversion",
")",
";",
"final",
"Document",
"document",
"=",
"element",
".",
"getOwnerDocument",
"(",
")",
";",
"document",
".",
"appendChild",
"(",
"element",
")",
";",
"return",
"document",
";",
"}"
] |
Returns an XML Document representing the file structure found at the supplied file system path. Files included
in the representation will match the supplied regular expression pattern. This method doesn't descend through
the directory structure.
@param aFilePath The directory from which the structural representation should be built
@param aPattern A regular expression pattern which files included in the Document should match
@param aDeepConversion Whether the conversion should descend through subdirectories
@return An XML Document representation of the directory structure
@throws FileNotFoundException If the supplied directory isn't found
@throws ParserConfigurationException If the default XML parser for the JRE isn't configured correctly
|
[
"Returns",
"an",
"XML",
"Document",
"representing",
"the",
"file",
"structure",
"found",
"at",
"the",
"supplied",
"file",
"system",
"path",
".",
"Files",
"included",
"in",
"the",
"representation",
"will",
"match",
"the",
"supplied",
"regular",
"expression",
"pattern",
".",
"This",
"method",
"doesn",
"t",
"descend",
"through",
"the",
"directory",
"structure",
"."
] |
train
|
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L310-L317
|
lessthanoptimal/BoofCV
|
integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java
|
UtilOpenKinect.bufferDepthToU16
|
public static void bufferDepthToU16( ByteBuffer input , GrayU16 output ) {
int indexIn = 0;
for( int y = 0; y < output.height; y++ ) {
int indexOut = output.startIndex + y*output.stride;
for( int x = 0; x < output.width; x++ , indexOut++ ) {
output.data[indexOut] = (short)((input.get(indexIn++) & 0xFF) | ((input.get(indexIn++) & 0xFF) << 8 ));
}
}
}
|
java
|
public static void bufferDepthToU16( ByteBuffer input , GrayU16 output ) {
int indexIn = 0;
for( int y = 0; y < output.height; y++ ) {
int indexOut = output.startIndex + y*output.stride;
for( int x = 0; x < output.width; x++ , indexOut++ ) {
output.data[indexOut] = (short)((input.get(indexIn++) & 0xFF) | ((input.get(indexIn++) & 0xFF) << 8 ));
}
}
}
|
[
"public",
"static",
"void",
"bufferDepthToU16",
"(",
"ByteBuffer",
"input",
",",
"GrayU16",
"output",
")",
"{",
"int",
"indexIn",
"=",
"0",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"output",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"indexOut",
"=",
"output",
".",
"startIndex",
"+",
"y",
"*",
"output",
".",
"stride",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"output",
".",
"width",
";",
"x",
"++",
",",
"indexOut",
"++",
")",
"{",
"output",
".",
"data",
"[",
"indexOut",
"]",
"=",
"(",
"short",
")",
"(",
"(",
"input",
".",
"get",
"(",
"indexIn",
"++",
")",
"&",
"0xFF",
")",
"|",
"(",
"(",
"input",
".",
"get",
"(",
"indexIn",
"++",
")",
"&",
"0xFF",
")",
"<<",
"8",
")",
")",
";",
"}",
"}",
"}"
] |
Converts data in a ByteBuffer into a 16bit depth image
@param input Input buffer
@param output Output depth image
|
[
"Converts",
"data",
"in",
"a",
"ByteBuffer",
"into",
"a",
"16bit",
"depth",
"image"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java#L65-L73
|
dwdyer/watchmaker
|
examples/src/java/main/org/uncommons/watchmaker/examples/geneticprogramming/TreeFactory.java
|
TreeFactory.makeNode
|
private Node makeNode(Random rng, int maxDepth)
{
if (functionProbability.nextEvent(rng) && maxDepth > 1)
{
// Max depth for sub-trees is one less than max depth for this node.
int depth = maxDepth - 1;
switch (rng.nextInt(5))
{
case 0: return new Addition(makeNode(rng, depth), makeNode(rng, depth));
case 1: return new Subtraction(makeNode(rng, depth), makeNode(rng, depth));
case 2: return new Multiplication(makeNode(rng, depth), makeNode(rng, depth));
case 3: return new IfThenElse(makeNode(rng, depth), makeNode(rng, depth), makeNode(rng, depth));
default: return new IsGreater(makeNode(rng, depth), makeNode(rng, depth));
}
}
else if (parameterProbability.nextEvent(rng))
{
return new Parameter(rng.nextInt(parameterCount));
}
else
{
return new Constant(rng.nextInt(11));
}
}
|
java
|
private Node makeNode(Random rng, int maxDepth)
{
if (functionProbability.nextEvent(rng) && maxDepth > 1)
{
// Max depth for sub-trees is one less than max depth for this node.
int depth = maxDepth - 1;
switch (rng.nextInt(5))
{
case 0: return new Addition(makeNode(rng, depth), makeNode(rng, depth));
case 1: return new Subtraction(makeNode(rng, depth), makeNode(rng, depth));
case 2: return new Multiplication(makeNode(rng, depth), makeNode(rng, depth));
case 3: return new IfThenElse(makeNode(rng, depth), makeNode(rng, depth), makeNode(rng, depth));
default: return new IsGreater(makeNode(rng, depth), makeNode(rng, depth));
}
}
else if (parameterProbability.nextEvent(rng))
{
return new Parameter(rng.nextInt(parameterCount));
}
else
{
return new Constant(rng.nextInt(11));
}
}
|
[
"private",
"Node",
"makeNode",
"(",
"Random",
"rng",
",",
"int",
"maxDepth",
")",
"{",
"if",
"(",
"functionProbability",
".",
"nextEvent",
"(",
"rng",
")",
"&&",
"maxDepth",
">",
"1",
")",
"{",
"// Max depth for sub-trees is one less than max depth for this node.",
"int",
"depth",
"=",
"maxDepth",
"-",
"1",
";",
"switch",
"(",
"rng",
".",
"nextInt",
"(",
"5",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"Addition",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"1",
":",
"return",
"new",
"Subtraction",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"Multiplication",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"IfThenElse",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"default",
":",
"return",
"new",
"IsGreater",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"parameterProbability",
".",
"nextEvent",
"(",
"rng",
")",
")",
"{",
"return",
"new",
"Parameter",
"(",
"rng",
".",
"nextInt",
"(",
"parameterCount",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Constant",
"(",
"rng",
".",
"nextInt",
"(",
"11",
")",
")",
";",
"}",
"}"
] |
Recursively constructs a tree of Nodes, up to the specified maximum depth.
@param rng The RNG used to random create nodes.
@param maxDepth The maximum depth of the generated tree.
@return A tree of nodes.
|
[
"Recursively",
"constructs",
"a",
"tree",
"of",
"Nodes",
"up",
"to",
"the",
"specified",
"maximum",
"depth",
"."
] |
train
|
https://github.com/dwdyer/watchmaker/blob/33d942350e6bf7d9a17b9262a4f898158530247e/examples/src/java/main/org/uncommons/watchmaker/examples/geneticprogramming/TreeFactory.java#L91-L114
|
BioPAX/Paxtools
|
pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java
|
PatternBox.neighborOf
|
public static Pattern neighborOf()
{
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(peToInter(), "PE1", "Inter");
p.add(interToPE(), "Inter", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(equal(false), "SPE1", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
}
|
java
|
public static Pattern neighborOf()
{
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(peToInter(), "PE1", "Inter");
p.add(interToPE(), "Inter", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(equal(false), "SPE1", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
}
|
[
"public",
"static",
"Pattern",
"neighborOf",
"(",
")",
"{",
"Pattern",
"p",
"=",
"new",
"Pattern",
"(",
"SequenceEntityReference",
".",
"class",
",",
"\"Protein 1\"",
")",
";",
"p",
".",
"add",
"(",
"linkedER",
"(",
"true",
")",
",",
"\"Protein 1\"",
",",
"\"generic Protein 1\"",
")",
";",
"p",
".",
"add",
"(",
"erToPE",
"(",
")",
",",
"\"generic Protein 1\"",
",",
"\"SPE1\"",
")",
";",
"p",
".",
"add",
"(",
"linkToComplex",
"(",
")",
",",
"\"SPE1\"",
",",
"\"PE1\"",
")",
";",
"p",
".",
"add",
"(",
"peToInter",
"(",
")",
",",
"\"PE1\"",
",",
"\"Inter\"",
")",
";",
"p",
".",
"add",
"(",
"interToPE",
"(",
")",
",",
"\"Inter\"",
",",
"\"PE2\"",
")",
";",
"p",
".",
"add",
"(",
"linkToSpecific",
"(",
")",
",",
"\"PE2\"",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"equal",
"(",
"false",
")",
",",
"\"SPE1\"",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"type",
"(",
"SequenceEntity",
".",
"class",
")",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"peToER",
"(",
")",
",",
"\"SPE2\"",
",",
"\"generic Protein 2\"",
")",
";",
"p",
".",
"add",
"(",
"linkedER",
"(",
"false",
")",
",",
"\"generic Protein 2\"",
",",
"\"Protein 2\"",
")",
";",
"p",
".",
"add",
"(",
"equal",
"(",
"false",
")",
",",
"\"Protein 1\"",
",",
"\"Protein 2\"",
")",
";",
"return",
"p",
";",
"}"
] |
Constructs a pattern where first and last proteins are related through an interaction. They
can be participants or controllers. No limitation.
@return the pattern
|
[
"Constructs",
"a",
"pattern",
"where",
"first",
"and",
"last",
"proteins",
"are",
"related",
"through",
"an",
"interaction",
".",
"They",
"can",
"be",
"participants",
"or",
"controllers",
".",
"No",
"limitation",
"."
] |
train
|
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java#L570-L585
|
rometools/rome
|
rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedCollection.java
|
FileBasedCollection.addEntry
|
public Entry addEntry(final Entry entry) throws Exception {
synchronized (FileStore.getFileStore()) {
final Feed f = getFeedDocument();
final String fsid = FileStore.getFileStore().getNextId();
updateTimestamps(entry);
// Save entry to file
final String entryPath = getEntryPath(fsid);
final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
updateEntryAppLinks(entry, fsid, true);
Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
os.flush();
os.close();
// Update feed file
updateEntryAppLinks(entry, fsid, false);
updateFeedDocumentWithNewEntry(f, entry);
return entry;
}
}
|
java
|
public Entry addEntry(final Entry entry) throws Exception {
synchronized (FileStore.getFileStore()) {
final Feed f = getFeedDocument();
final String fsid = FileStore.getFileStore().getNextId();
updateTimestamps(entry);
// Save entry to file
final String entryPath = getEntryPath(fsid);
final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
updateEntryAppLinks(entry, fsid, true);
Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
os.flush();
os.close();
// Update feed file
updateEntryAppLinks(entry, fsid, false);
updateFeedDocumentWithNewEntry(f, entry);
return entry;
}
}
|
[
"public",
"Entry",
"addEntry",
"(",
"final",
"Entry",
"entry",
")",
"throws",
"Exception",
"{",
"synchronized",
"(",
"FileStore",
".",
"getFileStore",
"(",
")",
")",
"{",
"final",
"Feed",
"f",
"=",
"getFeedDocument",
"(",
")",
";",
"final",
"String",
"fsid",
"=",
"FileStore",
".",
"getFileStore",
"(",
")",
".",
"getNextId",
"(",
")",
";",
"updateTimestamps",
"(",
"entry",
")",
";",
"// Save entry to file",
"final",
"String",
"entryPath",
"=",
"getEntryPath",
"(",
"fsid",
")",
";",
"final",
"OutputStream",
"os",
"=",
"FileStore",
".",
"getFileStore",
"(",
")",
".",
"getFileOutputStream",
"(",
"entryPath",
")",
";",
"updateEntryAppLinks",
"(",
"entry",
",",
"fsid",
",",
"true",
")",
";",
"Atom10Generator",
".",
"serializeEntry",
"(",
"entry",
",",
"new",
"OutputStreamWriter",
"(",
"os",
",",
"\"UTF-8\"",
")",
")",
";",
"os",
".",
"flush",
"(",
")",
";",
"os",
".",
"close",
"(",
")",
";",
"// Update feed file",
"updateEntryAppLinks",
"(",
"entry",
",",
"fsid",
",",
"false",
")",
";",
"updateFeedDocumentWithNewEntry",
"(",
"f",
",",
"entry",
")",
";",
"return",
"entry",
";",
"}",
"}"
] |
Add entry to collection.
@param entry Entry to be added to collection. Entry will be saved to disk in a directory
under the collection's directory and the path will follow the pattern
[collection-plural]/[entryid]/entry.xml. The entry will be added to the
collection's feed in [collection-plural]/feed.xml.
@throws java.lang.Exception On error.
@return Entry as it exists on the server.
|
[
"Add",
"entry",
"to",
"collection",
"."
] |
train
|
https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedCollection.java#L188-L210
|
datacleaner/DataCleaner
|
desktop/ui/src/main/java/org/datacleaner/widgets/tabs/CloseableTabbedPaneUI.java
|
CloseableTabbedPaneUI.calculateTabWidth
|
@Override
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
if (_pane.getSeparators().contains(tabIndex)) {
return SEPARATOR_WIDTH;
}
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
if (!_pane.getUnclosables().contains(tabIndex)) {
width += CLOSE_ICON_WIDTH;
}
return width;
}
|
java
|
@Override
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
if (_pane.getSeparators().contains(tabIndex)) {
return SEPARATOR_WIDTH;
}
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
if (!_pane.getUnclosables().contains(tabIndex)) {
width += CLOSE_ICON_WIDTH;
}
return width;
}
|
[
"@",
"Override",
"protected",
"int",
"calculateTabWidth",
"(",
"final",
"int",
"tabPlacement",
",",
"final",
"int",
"tabIndex",
",",
"final",
"FontMetrics",
"metrics",
")",
"{",
"if",
"(",
"_pane",
".",
"getSeparators",
"(",
")",
".",
"contains",
"(",
"tabIndex",
")",
")",
"{",
"return",
"SEPARATOR_WIDTH",
";",
"}",
"int",
"width",
"=",
"super",
".",
"calculateTabWidth",
"(",
"tabPlacement",
",",
"tabIndex",
",",
"metrics",
")",
";",
"if",
"(",
"!",
"_pane",
".",
"getUnclosables",
"(",
")",
".",
"contains",
"(",
"tabIndex",
")",
")",
"{",
"width",
"+=",
"CLOSE_ICON_WIDTH",
";",
"}",
"return",
"width",
";",
"}"
] |
Override this to provide extra space on right for close button
|
[
"Override",
"this",
"to",
"provide",
"extra",
"space",
"on",
"right",
"for",
"close",
"button"
] |
train
|
https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/desktop/ui/src/main/java/org/datacleaner/widgets/tabs/CloseableTabbedPaneUI.java#L131-L141
|
wmdietl/jsr308-langtools
|
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java
|
ProfileSummaryBuilder.buildContent
|
public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
}
|
java
|
public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
}
|
[
"public",
"void",
"buildContent",
"(",
"XMLNode",
"node",
",",
"Content",
"contentTree",
")",
"{",
"Content",
"profileContentTree",
"=",
"profileWriter",
".",
"getContentHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"profileContentTree",
")",
";",
"contentTree",
".",
"addContent",
"(",
"profileContentTree",
")",
";",
"}"
] |
Build the content for the profile doc.
@param node the XML element that specifies which components to document
@param contentTree the content tree to which the profile contents
will be added
|
[
"Build",
"the",
"content",
"for",
"the",
"profile",
"doc",
"."
] |
train
|
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L141-L145
|
realtime-framework/RealtimeStorage-Android
|
library/src/main/java/co/realtime/storage/StorageRef.java
|
StorageRef.getTables
|
public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
}
|
java
|
public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
}
|
[
"public",
"StorageRef",
"getTables",
"(",
"OnTableSnapshot",
"onTableSnapshot",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"LISTTABLES",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableSnapshot",
"=",
"onTableSnapshot",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] |
Retrieves a list of the names of all tables created by the user's subscription.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
storage.getTables(new OnTableSnapshot() {
@Override
public void run(TableSnapshot tableSnapshot) {
if(tableSnapshot != null) {
Log.d("StorageRef", "Table Name: " + tableSnapshot.val());
}
}
},new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("StorageRef","Error retrieving tables: " + errorMessage);
}
});
</pre>
@param onTableSnapshot
The callback to call once the values are available. The function will be called with a table snapshot as argument, as many times as the number of tables existent. In the end, when all calls are done, the success function will be called with null as argument to signal that there are no more tables.
@param onError
The callback to call if an exception occurred
@return Current storage reference
|
[
"Retrieves",
"a",
"list",
"of",
"the",
"names",
"of",
"all",
"tables",
"created",
"by",
"the",
"user",
"s",
"subscription",
"."
] |
train
|
https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/StorageRef.java#L372-L379
|
carewebframework/carewebframework-core
|
org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/TreeUtil.java
|
TreeUtil.compare
|
private static int compare(Treenode item1, Treenode item2) {
String label1 = item1.getLabel();
String label2 = item2.getLabel();
return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
}
|
java
|
private static int compare(Treenode item1, Treenode item2) {
String label1 = item1.getLabel();
String label2 = item2.getLabel();
return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
}
|
[
"private",
"static",
"int",
"compare",
"(",
"Treenode",
"item1",
",",
"Treenode",
"item2",
")",
"{",
"String",
"label1",
"=",
"item1",
".",
"getLabel",
"(",
")",
";",
"String",
"label2",
"=",
"item2",
".",
"getLabel",
"(",
")",
";",
"return",
"label1",
"==",
"label2",
"?",
"0",
":",
"label1",
"==",
"null",
"?",
"-",
"1",
":",
"label2",
"==",
"null",
"?",
"-",
"1",
":",
"label1",
".",
"compareToIgnoreCase",
"(",
"label2",
")",
";",
"}"
] |
Case insensitive comparison of labels of two tree items.
@param item1 First tree item.
@param item2 Second tree item.
@return Result of the comparison.
|
[
"Case",
"insensitive",
"comparison",
"of",
"labels",
"of",
"two",
"tree",
"items",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/TreeUtil.java#L258-L262
|
twitter/cloudhopper-commons
|
ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java
|
PropertiesReplacementUtil.replaceProperties
|
static public InputStream replaceProperties(InputStream source, Properties props, String startStr, String endStr) throws IOException, SubstitutionException {
String template = streamToString(source);
String replaced = StringUtil.substituteWithProperties(template, startStr, endStr, props);
System.err.println(template);
System.err.println(replaced);
return new ByteArrayInputStream(replaced.getBytes());
}
|
java
|
static public InputStream replaceProperties(InputStream source, Properties props, String startStr, String endStr) throws IOException, SubstitutionException {
String template = streamToString(source);
String replaced = StringUtil.substituteWithProperties(template, startStr, endStr, props);
System.err.println(template);
System.err.println(replaced);
return new ByteArrayInputStream(replaced.getBytes());
}
|
[
"static",
"public",
"InputStream",
"replaceProperties",
"(",
"InputStream",
"source",
",",
"Properties",
"props",
",",
"String",
"startStr",
",",
"String",
"endStr",
")",
"throws",
"IOException",
",",
"SubstitutionException",
"{",
"String",
"template",
"=",
"streamToString",
"(",
"source",
")",
";",
"String",
"replaced",
"=",
"StringUtil",
".",
"substituteWithProperties",
"(",
"template",
",",
"startStr",
",",
"endStr",
",",
"props",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"template",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"replaced",
")",
";",
"return",
"new",
"ByteArrayInputStream",
"(",
"replaced",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] |
Creates an InputStream containing the document resulting from replacing template
parameters in the given InputStream source.
@param source The source stream
@param props The properties
@param startStr The String that marks the start of a replacement key such as "${"
@param endStr The String that marks the end of a replacement key such as "}"
@return An InputStream containing the resulting document.
|
[
"Creates",
"an",
"InputStream",
"containing",
"the",
"document",
"resulting",
"from",
"replacing",
"template",
"parameters",
"in",
"the",
"given",
"InputStream",
"source",
"."
] |
train
|
https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java#L123-L129
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java
|
TrainingsImpl.createImagesFromUrlsAsync
|
public Observable<ImageCreateSummary> createImagesFromUrlsAsync(UUID projectId, ImageUrlCreateBatch batch) {
return createImagesFromUrlsWithServiceResponseAsync(projectId, batch).map(new Func1<ServiceResponse<ImageCreateSummary>, ImageCreateSummary>() {
@Override
public ImageCreateSummary call(ServiceResponse<ImageCreateSummary> response) {
return response.body();
}
});
}
|
java
|
public Observable<ImageCreateSummary> createImagesFromUrlsAsync(UUID projectId, ImageUrlCreateBatch batch) {
return createImagesFromUrlsWithServiceResponseAsync(projectId, batch).map(new Func1<ServiceResponse<ImageCreateSummary>, ImageCreateSummary>() {
@Override
public ImageCreateSummary call(ServiceResponse<ImageCreateSummary> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"ImageCreateSummary",
">",
"createImagesFromUrlsAsync",
"(",
"UUID",
"projectId",
",",
"ImageUrlCreateBatch",
"batch",
")",
"{",
"return",
"createImagesFromUrlsWithServiceResponseAsync",
"(",
"projectId",
",",
"batch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ImageCreateSummary",
">",
",",
"ImageCreateSummary",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ImageCreateSummary",
"call",
"(",
"ServiceResponse",
"<",
"ImageCreateSummary",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Add the provided images urls to the set of training images.
This API accepts a batch of urls, and optionally tags, to create images. There is a limit of 64 images and 20 tags.
@param projectId The project id
@param batch Image urls and tag ids. Limited to 64 images and 20 tags per batch
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImageCreateSummary object
|
[
"Add",
"the",
"provided",
"images",
"urls",
"to",
"the",
"set",
"of",
"training",
"images",
".",
"This",
"API",
"accepts",
"a",
"batch",
"of",
"urls",
"and",
"optionally",
"tags",
"to",
"create",
"images",
".",
"There",
"is",
"a",
"limit",
"of",
"64",
"images",
"and",
"20",
"tags",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L3867-L3874
|
windup/windup
|
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ArchiveCoordinateService.java
|
ArchiveCoordinateService.getSingleOrCreate
|
public ArchiveCoordinateModel getSingleOrCreate(String groupId, String artifactId, String version)
{
ArchiveCoordinateModel archive = findSingle(groupId, artifactId, version);
if (archive != null)
return archive;
else
return create().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
}
|
java
|
public ArchiveCoordinateModel getSingleOrCreate(String groupId, String artifactId, String version)
{
ArchiveCoordinateModel archive = findSingle(groupId, artifactId, version);
if (archive != null)
return archive;
else
return create().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
}
|
[
"public",
"ArchiveCoordinateModel",
"getSingleOrCreate",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
")",
"{",
"ArchiveCoordinateModel",
"archive",
"=",
"findSingle",
"(",
"groupId",
",",
"artifactId",
",",
"version",
")",
";",
"if",
"(",
"archive",
"!=",
"null",
")",
"return",
"archive",
";",
"else",
"return",
"create",
"(",
")",
".",
"setGroupId",
"(",
"groupId",
")",
".",
"setArtifactId",
"(",
"artifactId",
")",
".",
"setVersion",
"(",
"version",
")",
";",
"}"
] |
Returns a single ArchiveCoordinateModel with given G:A:V. Creates it if it does not already exist.
|
[
"Returns",
"a",
"single",
"ArchiveCoordinateModel",
"with",
"given",
"G",
":",
"A",
":",
"V",
".",
"Creates",
"it",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] |
train
|
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ArchiveCoordinateService.java#L29-L36
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/markup/AnnotatedTextBuilder.java
|
AnnotatedTextBuilder.addGlobalMetaData
|
public AnnotatedTextBuilder addGlobalMetaData(String key, String value) {
customMetaData.put(key, value);
return this;
}
|
java
|
public AnnotatedTextBuilder addGlobalMetaData(String key, String value) {
customMetaData.put(key, value);
return this;
}
|
[
"public",
"AnnotatedTextBuilder",
"addGlobalMetaData",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"customMetaData",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Add any global meta data about the document to be checked. Some rules may use this information.
Unless you're using your own rules for which you know useful keys, you probably want to
use {@link #addGlobalMetaData(AnnotatedText.MetaDataKey, String)}.
@since 3.9
|
[
"Add",
"any",
"global",
"meta",
"data",
"about",
"the",
"document",
"to",
"be",
"checked",
".",
"Some",
"rules",
"may",
"use",
"this",
"information",
".",
"Unless",
"you",
"re",
"using",
"your",
"own",
"rules",
"for",
"which",
"you",
"know",
"useful",
"keys",
"you",
"probably",
"want",
"to",
"use",
"{"
] |
train
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/markup/AnnotatedTextBuilder.java#L75-L78
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Scanner.java
|
Scanner.hasNextBigInteger
|
public boolean hasNextBigInteger(int radix) {
setRadix(radix);
boolean result = hasNext(integerPattern());
if (result) { // Cache it
try {
String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ?
processIntegerToken(hasNextResult) :
hasNextResult;
typeCache = new BigInteger(s, radix);
} catch (NumberFormatException nfe) {
result = false;
}
}
return result;
}
|
java
|
public boolean hasNextBigInteger(int radix) {
setRadix(radix);
boolean result = hasNext(integerPattern());
if (result) { // Cache it
try {
String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ?
processIntegerToken(hasNextResult) :
hasNextResult;
typeCache = new BigInteger(s, radix);
} catch (NumberFormatException nfe) {
result = false;
}
}
return result;
}
|
[
"public",
"boolean",
"hasNextBigInteger",
"(",
"int",
"radix",
")",
"{",
"setRadix",
"(",
"radix",
")",
";",
"boolean",
"result",
"=",
"hasNext",
"(",
"integerPattern",
"(",
")",
")",
";",
"if",
"(",
"result",
")",
"{",
"// Cache it",
"try",
"{",
"String",
"s",
"=",
"(",
"matcher",
".",
"group",
"(",
"SIMPLE_GROUP_INDEX",
")",
"==",
"null",
")",
"?",
"processIntegerToken",
"(",
"hasNextResult",
")",
":",
"hasNextResult",
";",
"typeCache",
"=",
"new",
"BigInteger",
"(",
"s",
",",
"radix",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"result",
"=",
"false",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns true if the next token in this scanner's input can be
interpreted as a <code>BigInteger</code> in the specified radix using
the {@link #nextBigInteger} method. The scanner does not advance past
any input.
@param radix the radix used to interpret the token as an integer
@return true if and only if this scanner's next token is a valid
<code>BigInteger</code>
@throws IllegalStateException if this scanner is closed
|
[
"Returns",
"true",
"if",
"the",
"next",
"token",
"in",
"this",
"scanner",
"s",
"input",
"can",
"be",
"interpreted",
"as",
"a",
"<code",
">",
"BigInteger<",
"/",
"code",
">",
"in",
"the",
"specified",
"radix",
"using",
"the",
"{",
"@link",
"#nextBigInteger",
"}",
"method",
".",
"The",
"scanner",
"does",
"not",
"advance",
"past",
"any",
"input",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Scanner.java#L2422-L2436
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.downgradeEdgeToInode
|
public void downgradeEdgeToInode(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
EdgeEntry last = (EdgeEntry) mEntries.get(mEntries.size() - 1);
LockResource inodeLock = mInodeLockManager.lockInode(inode, mode);
LockResource edgeLock = mInodeLockManager.lockEdge(last.mEdge, LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new EdgeEntry(edgeLock, last.getEdge()));
mEntries.add(new InodeEntry(inodeLock, inode));
mLockedInodes.add(inode);
mLockMode = mode;
}
|
java
|
public void downgradeEdgeToInode(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
EdgeEntry last = (EdgeEntry) mEntries.get(mEntries.size() - 1);
LockResource inodeLock = mInodeLockManager.lockInode(inode, mode);
LockResource edgeLock = mInodeLockManager.lockEdge(last.mEdge, LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new EdgeEntry(edgeLock, last.getEdge()));
mEntries.add(new InodeEntry(inodeLock, inode));
mLockedInodes.add(inode);
mLockMode = mode;
}
|
[
"public",
"void",
"downgradeEdgeToInode",
"(",
"Inode",
"inode",
",",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"WRITE",
")",
";",
"EdgeEntry",
"last",
"=",
"(",
"EdgeEntry",
")",
"mEntries",
".",
"get",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"LockResource",
"inodeLock",
"=",
"mInodeLockManager",
".",
"lockInode",
"(",
"inode",
",",
"mode",
")",
";",
"LockResource",
"edgeLock",
"=",
"mInodeLockManager",
".",
"lockEdge",
"(",
"last",
".",
"mEdge",
",",
"LockMode",
".",
"READ",
")",
";",
"last",
".",
"getLock",
"(",
")",
".",
"close",
"(",
")",
";",
"mEntries",
".",
"set",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
",",
"new",
"EdgeEntry",
"(",
"edgeLock",
",",
"last",
".",
"getEdge",
"(",
")",
")",
")",
";",
"mEntries",
".",
"add",
"(",
"new",
"InodeEntry",
"(",
"inodeLock",
",",
"inode",
")",
")",
";",
"mLockedInodes",
".",
"add",
"(",
"inode",
")",
";",
"mLockMode",
"=",
"mode",
";",
"}"
] |
Downgrades from edge write-locking to inode write-locking. This reduces the scope of the write
lock by pushing it forward one entry.
For example, if the lock list is in write mode with entries [a, a->b, b, b->c],
downgradeEdgeToInode(c, mode) will change the list to [a, a->b, b, b->c, c], with b->c
downgraded to a read lock. c will be locked according to the mode.
The read lock on the final edge is taken before releasing the write lock.
@param inode the next inode in the lock list
@param mode the mode to downgrade to
|
[
"Downgrades",
"from",
"edge",
"write",
"-",
"locking",
"to",
"inode",
"write",
"-",
"locking",
".",
"This",
"reduces",
"the",
"scope",
"of",
"the",
"write",
"lock",
"by",
"pushing",
"it",
"forward",
"one",
"entry",
"."
] |
train
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L244-L257
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jaxws.clientcontainer/src/com/ibm/ws/jaxws/utils/JaxWsUtils.java
|
JaxWsUtils.matchesQName
|
public static boolean matchesQName(QName regQName, QName targetQName, boolean ignorePrefix) {
if (regQName == null || targetQName == null) {
return false;
}
if ("*".equals(getQNameString(regQName))) {
return true;
}
// if the name space or the prefix is not equal, just return false;
if (!(regQName.getNamespaceURI().equals(targetQName.getNamespaceURI())) ||
!(ignorePrefix || regQName.getPrefix().equals(targetQName.getPrefix()))) {
return false;
}
if (regQName.getLocalPart().contains("*")) {
return Pattern.matches(mapPattern(regQName.getLocalPart()), targetQName.getLocalPart());
} else if (regQName.getLocalPart().equals(targetQName.getLocalPart())) {
return true;
}
return false;
}
|
java
|
public static boolean matchesQName(QName regQName, QName targetQName, boolean ignorePrefix) {
if (regQName == null || targetQName == null) {
return false;
}
if ("*".equals(getQNameString(regQName))) {
return true;
}
// if the name space or the prefix is not equal, just return false;
if (!(regQName.getNamespaceURI().equals(targetQName.getNamespaceURI())) ||
!(ignorePrefix || regQName.getPrefix().equals(targetQName.getPrefix()))) {
return false;
}
if (regQName.getLocalPart().contains("*")) {
return Pattern.matches(mapPattern(regQName.getLocalPart()), targetQName.getLocalPart());
} else if (regQName.getLocalPart().equals(targetQName.getLocalPart())) {
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"matchesQName",
"(",
"QName",
"regQName",
",",
"QName",
"targetQName",
",",
"boolean",
"ignorePrefix",
")",
"{",
"if",
"(",
"regQName",
"==",
"null",
"||",
"targetQName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\"*\"",
".",
"equals",
"(",
"getQNameString",
"(",
"regQName",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// if the name space or the prefix is not equal, just return false;",
"if",
"(",
"!",
"(",
"regQName",
".",
"getNamespaceURI",
"(",
")",
".",
"equals",
"(",
"targetQName",
".",
"getNamespaceURI",
"(",
")",
")",
")",
"||",
"!",
"(",
"ignorePrefix",
"||",
"regQName",
".",
"getPrefix",
"(",
")",
".",
"equals",
"(",
"targetQName",
".",
"getPrefix",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"regQName",
".",
"getLocalPart",
"(",
")",
".",
"contains",
"(",
"\"*\"",
")",
")",
"{",
"return",
"Pattern",
".",
"matches",
"(",
"mapPattern",
"(",
"regQName",
".",
"getLocalPart",
"(",
")",
")",
",",
"targetQName",
".",
"getLocalPart",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"regQName",
".",
"getLocalPart",
"(",
")",
".",
"equals",
"(",
"targetQName",
".",
"getLocalPart",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether the regQName matches the targetQName
Only the localPart of the regQName supports the * match, it means only the name space and prefix is all matched, then
the localPart will be compared considering the *
When the ignorePrefix is true, the prefix will be ignored.
@param regQName
@param targetQName
@param ignorePrefix
@return
|
[
"Check",
"whether",
"the",
"regQName",
"matches",
"the",
"targetQName"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jaxws.clientcontainer/src/com/ibm/ws/jaxws/utils/JaxWsUtils.java#L490-L509
|
cdapio/netty-http
|
src/main/java/io/cdap/http/NettyHttpService.java
|
NettyHttpService.createEventExecutorGroup
|
@Nullable
private EventExecutorGroup createEventExecutorGroup(int size) {
if (size <= 0) {
return null;
}
ThreadFactory threadFactory = new ThreadFactory() {
private final ThreadGroup threadGroup = new ThreadGroup(serviceName + "-executor-thread");
private final AtomicLong count = new AtomicLong(0);
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(threadGroup, r, String.format("%s-executor-%d", serviceName, count.getAndIncrement()));
t.setDaemon(true);
return t;
}
};
UnorderedThreadPoolEventExecutor executor = new UnorderedThreadPoolEventExecutor(size, threadFactory,
rejectedExecutionHandler);
if (execThreadKeepAliveSecs > 0) {
executor.setKeepAliveTime(execThreadKeepAliveSecs, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
}
return new NonStickyEventExecutorGroup(executor);
}
|
java
|
@Nullable
private EventExecutorGroup createEventExecutorGroup(int size) {
if (size <= 0) {
return null;
}
ThreadFactory threadFactory = new ThreadFactory() {
private final ThreadGroup threadGroup = new ThreadGroup(serviceName + "-executor-thread");
private final AtomicLong count = new AtomicLong(0);
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(threadGroup, r, String.format("%s-executor-%d", serviceName, count.getAndIncrement()));
t.setDaemon(true);
return t;
}
};
UnorderedThreadPoolEventExecutor executor = new UnorderedThreadPoolEventExecutor(size, threadFactory,
rejectedExecutionHandler);
if (execThreadKeepAliveSecs > 0) {
executor.setKeepAliveTime(execThreadKeepAliveSecs, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
}
return new NonStickyEventExecutorGroup(executor);
}
|
[
"@",
"Nullable",
"private",
"EventExecutorGroup",
"createEventExecutorGroup",
"(",
"int",
"size",
")",
"{",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"ThreadFactory",
"threadFactory",
"=",
"new",
"ThreadFactory",
"(",
")",
"{",
"private",
"final",
"ThreadGroup",
"threadGroup",
"=",
"new",
"ThreadGroup",
"(",
"serviceName",
"+",
"\"-executor-thread\"",
")",
";",
"private",
"final",
"AtomicLong",
"count",
"=",
"new",
"AtomicLong",
"(",
"0",
")",
";",
"@",
"Override",
"public",
"Thread",
"newThread",
"(",
"Runnable",
"r",
")",
"{",
"Thread",
"t",
"=",
"new",
"Thread",
"(",
"threadGroup",
",",
"r",
",",
"String",
".",
"format",
"(",
"\"%s-executor-%d\"",
",",
"serviceName",
",",
"count",
".",
"getAndIncrement",
"(",
")",
")",
")",
";",
"t",
".",
"setDaemon",
"(",
"true",
")",
";",
"return",
"t",
";",
"}",
"}",
";",
"UnorderedThreadPoolEventExecutor",
"executor",
"=",
"new",
"UnorderedThreadPoolEventExecutor",
"(",
"size",
",",
"threadFactory",
",",
"rejectedExecutionHandler",
")",
";",
"if",
"(",
"execThreadKeepAliveSecs",
">",
"0",
")",
"{",
"executor",
".",
"setKeepAliveTime",
"(",
"execThreadKeepAliveSecs",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"executor",
".",
"allowCoreThreadTimeOut",
"(",
"true",
")",
";",
"}",
"return",
"new",
"NonStickyEventExecutorGroup",
"(",
"executor",
")",
";",
"}"
] |
Create {@link EventExecutorGroup} for executing handle methods.
@param size size of threadPool
@return instance of {@link EventExecutorGroup} or {@code null} if {@code size} is {@code <= 0}.
|
[
"Create",
"{",
"@link",
"EventExecutorGroup",
"}",
"for",
"executing",
"handle",
"methods",
"."
] |
train
|
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L270-L295
|
alkacon/opencms-core
|
src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java
|
CmsJSONSearchConfigurationParser.parseOptionalIntValue
|
protected static Integer parseOptionalIntValue(JSONObject json, String key) {
try {
return Integer.valueOf(json.getInt(key));
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_INTEGER_MISSING_1, key), e);
return null;
}
}
|
java
|
protected static Integer parseOptionalIntValue(JSONObject json, String key) {
try {
return Integer.valueOf(json.getInt(key));
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_INTEGER_MISSING_1, key), e);
return null;
}
}
|
[
"protected",
"static",
"Integer",
"parseOptionalIntValue",
"(",
"JSONObject",
"json",
",",
"String",
"key",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"valueOf",
"(",
"json",
".",
"getInt",
"(",
"key",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_OPTIONAL_INTEGER_MISSING_1",
",",
"key",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Helper for reading an optional Integer value - returning <code>null</code> if parsing fails.
@param json The JSON object where the value should be read from.
@param key The key of the value to read.
@return The value from the JSON, or <code>null</code> if the value does not exist, or is no Integer.
|
[
"Helper",
"for",
"reading",
"an",
"optional",
"Integer",
"value",
"-",
"returning",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"parsing",
"fails",
"."
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L284-L292
|
wmdietl/jsr308-langtools
|
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
|
AnnotationTypeBuilder.buildAnnotationTypeSignature
|
public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
StringBuilder modifiers = new StringBuilder(
annotationTypeDoc.modifiers() + " ");
writer.addAnnotationTypeSignature(Util.replaceText(
modifiers.toString(), "interface", "@interface"), annotationInfoTree);
}
|
java
|
public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
StringBuilder modifiers = new StringBuilder(
annotationTypeDoc.modifiers() + " ");
writer.addAnnotationTypeSignature(Util.replaceText(
modifiers.toString(), "interface", "@interface"), annotationInfoTree);
}
|
[
"public",
"void",
"buildAnnotationTypeSignature",
"(",
"XMLNode",
"node",
",",
"Content",
"annotationInfoTree",
")",
"{",
"StringBuilder",
"modifiers",
"=",
"new",
"StringBuilder",
"(",
"annotationTypeDoc",
".",
"modifiers",
"(",
")",
"+",
"\" \"",
")",
";",
"writer",
".",
"addAnnotationTypeSignature",
"(",
"Util",
".",
"replaceText",
"(",
"modifiers",
".",
"toString",
"(",
")",
",",
"\"interface\"",
",",
"\"@interface\"",
")",
",",
"annotationInfoTree",
")",
";",
"}"
] |
Build the signature of the current annotation type.
@param node the XML element that specifies which components to document
@param annotationInfoTree the content tree to which the documentation will be added
|
[
"Build",
"the",
"signature",
"of",
"the",
"current",
"annotation",
"type",
"."
] |
train
|
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java#L175-L180
|
sebastiangraf/jSCSI
|
bundles/commons/src/main/java/org/jscsi/parser/ProtocolDataUnit.java
|
ProtocolDataUnit.serializeDataSegment
|
public final int serializeDataSegment (final ByteBuffer dst, final int offset) throws InternetSCSIException {
dataSegment.rewind();
dst.position(offset);
dst.put(dataSegment);
return dataSegment.limit();
}
|
java
|
public final int serializeDataSegment (final ByteBuffer dst, final int offset) throws InternetSCSIException {
dataSegment.rewind();
dst.position(offset);
dst.put(dataSegment);
return dataSegment.limit();
}
|
[
"public",
"final",
"int",
"serializeDataSegment",
"(",
"final",
"ByteBuffer",
"dst",
",",
"final",
"int",
"offset",
")",
"throws",
"InternetSCSIException",
"{",
"dataSegment",
".",
"rewind",
"(",
")",
";",
"dst",
".",
"position",
"(",
"offset",
")",
";",
"dst",
".",
"put",
"(",
"dataSegment",
")",
";",
"return",
"dataSegment",
".",
"limit",
"(",
")",
";",
"}"
] |
Serializes the data segment (binary or key-value pairs) to a destination array, staring from offset to write.
@param dst The array to write in.
@param offset The start offset to start from in <code>dst</code>.
@return The written length.
@throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
|
[
"Serializes",
"the",
"data",
"segment",
"(",
"binary",
"or",
"key",
"-",
"value",
"pairs",
")",
"to",
"a",
"destination",
"array",
"staring",
"from",
"offset",
"to",
"write",
"."
] |
train
|
https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/commons/src/main/java/org/jscsi/parser/ProtocolDataUnit.java#L268-L275
|
groupon/robo-remote
|
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/Utils.java
|
Utils.getEnv
|
public static String getEnv(String name, String defaultValue) {
Map<String, String> env = System.getenv();
// try to get value from environment variables
if (env.get(name) != null) {
return env.get(name);
}
// fall back to system properties
return System.getProperty(name, defaultValue);
}
|
java
|
public static String getEnv(String name, String defaultValue) {
Map<String, String> env = System.getenv();
// try to get value from environment variables
if (env.get(name) != null) {
return env.get(name);
}
// fall back to system properties
return System.getProperty(name, defaultValue);
}
|
[
"public",
"static",
"String",
"getEnv",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"env",
"=",
"System",
".",
"getenv",
"(",
")",
";",
"// try to get value from environment variables",
"if",
"(",
"env",
".",
"get",
"(",
"name",
")",
"!=",
"null",
")",
"{",
"return",
"env",
".",
"get",
"(",
"name",
")",
";",
"}",
"// fall back to system properties",
"return",
"System",
".",
"getProperty",
"(",
"name",
",",
"defaultValue",
")",
";",
"}"
] |
returns values for a key in the following order:
1. First checks environment variables
2. Falls back to system properties
@param name
@param defaultValue
@return
|
[
"returns",
"values",
"for",
"a",
"key",
"in",
"the",
"following",
"order",
":",
"1",
".",
"First",
"checks",
"environment",
"variables",
"2",
".",
"Falls",
"back",
"to",
"system",
"properties"
] |
train
|
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/Utils.java#L69-L79
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.setUserPassword
|
public void setUserPassword(String userName, String password) {
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetUserPassword);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
SetUserPasswordProtocol p = new SetUserPasswordProtocol(userName, secret);
connection.submitRequest(header, p, null);
}
|
java
|
public void setUserPassword(String userName, String password) {
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetUserPassword);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
SetUserPasswordProtocol p = new SetUserPasswordProtocol(userName, secret);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"setUserPassword",
"(",
"String",
"userName",
",",
"String",
"password",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"SetUserPassword",
")",
";",
"byte",
"[",
"]",
"secret",
"=",
"null",
";",
"if",
"(",
"password",
"!=",
"null",
"&&",
"!",
"password",
".",
"isEmpty",
"(",
")",
")",
"{",
"secret",
"=",
"ObfuscatUtil",
".",
"base64Encode",
"(",
"password",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"SetUserPasswordProtocol",
"p",
"=",
"new",
"SetUserPasswordProtocol",
"(",
"userName",
",",
"secret",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Set user password.
@param userName
the user name.
@param password
the user password.
|
[
"Set",
"user",
"password",
"."
] |
train
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L232-L244
|
roboconf/roboconf-platform
|
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
|
ApplicationWsDelegate.removeInstance
|
public void removeInstance( String applicationName, String instancePath ) {
this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...",
instancePath, applicationName ) );
WebResource path = this.resource
.path( UrlConstants.APP )
.path( applicationName )
.path( "instances" )
.queryParam( "instance-path", instancePath );
this.wsClient.createBuilder( path ).delete();
this.logger.finer( String.format( "Instance \"%s\" has been removed from application \"%s\"",
instancePath, applicationName ) );
}
|
java
|
public void removeInstance( String applicationName, String instancePath ) {
this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...",
instancePath, applicationName ) );
WebResource path = this.resource
.path( UrlConstants.APP )
.path( applicationName )
.path( "instances" )
.queryParam( "instance-path", instancePath );
this.wsClient.createBuilder( path ).delete();
this.logger.finer( String.format( "Instance \"%s\" has been removed from application \"%s\"",
instancePath, applicationName ) );
}
|
[
"public",
"void",
"removeInstance",
"(",
"String",
"applicationName",
",",
"String",
"instancePath",
")",
"{",
"this",
".",
"logger",
".",
"finer",
"(",
"String",
".",
"format",
"(",
"\"Removing instance \\\"%s\\\" from application \\\"%s\\\"...\"",
",",
"instancePath",
",",
"applicationName",
")",
")",
";",
"WebResource",
"path",
"=",
"this",
".",
"resource",
".",
"path",
"(",
"UrlConstants",
".",
"APP",
")",
".",
"path",
"(",
"applicationName",
")",
".",
"path",
"(",
"\"instances\"",
")",
".",
"queryParam",
"(",
"\"instance-path\"",
",",
"instancePath",
")",
";",
"this",
".",
"wsClient",
".",
"createBuilder",
"(",
"path",
")",
".",
"delete",
"(",
")",
";",
"this",
".",
"logger",
".",
"finer",
"(",
"String",
".",
"format",
"(",
"\"Instance \\\"%s\\\" has been removed from application \\\"%s\\\"\"",
",",
"instancePath",
",",
"applicationName",
")",
")",
";",
"}"
] |
Removes an instance.
@param applicationName the application name
@param instancePath the path of the instance to remove
|
[
"Removes",
"an",
"instance",
"."
] |
train
|
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L258-L271
|
lessthanoptimal/BoofCV
|
main/boofcv-ip/src/main/java/boofcv/alg/filter/stat/ImageLocalNormalization.java
|
ImageLocalNormalization.zeroMeanStdOne
|
public void zeroMeanStdOne(Kernel1D kernel, T input , double maxPixelValue , double delta , T output ) {
// check preconditions and initialize data structures
initialize(input, output);
// avoid overflow issues by ensuring that the max pixel value is 1
T adjusted = ensureMaxValueOfOne(input, maxPixelValue);
// take advantage of 2D gaussian kernels being separable
if( border == null ) {
GConvolveImageOps.horizontalNormalized(kernel, adjusted, output);
GConvolveImageOps.verticalNormalized(kernel, output, localMean);
GPixelMath.pow2(adjusted, pow2);
GConvolveImageOps.horizontalNormalized(kernel, pow2, output);
GConvolveImageOps.verticalNormalized(kernel, output, localPow2);
} else {
GConvolveImageOps.horizontal(kernel, adjusted, output, border);
GConvolveImageOps.vertical(kernel, output, localMean, border);
GPixelMath.pow2(adjusted, pow2);
GConvolveImageOps.horizontal(kernel, pow2, output, border);
GConvolveImageOps.vertical(kernel, output, localPow2, border);
}
// Compute the final output
if( imageType == GrayF32.class )
computeOutput((GrayF32)input, (float)delta, (GrayF32)output, (GrayF32)adjusted);
else
computeOutput((GrayF64)input, delta, (GrayF64)output, (GrayF64)adjusted);
}
|
java
|
public void zeroMeanStdOne(Kernel1D kernel, T input , double maxPixelValue , double delta , T output ) {
// check preconditions and initialize data structures
initialize(input, output);
// avoid overflow issues by ensuring that the max pixel value is 1
T adjusted = ensureMaxValueOfOne(input, maxPixelValue);
// take advantage of 2D gaussian kernels being separable
if( border == null ) {
GConvolveImageOps.horizontalNormalized(kernel, adjusted, output);
GConvolveImageOps.verticalNormalized(kernel, output, localMean);
GPixelMath.pow2(adjusted, pow2);
GConvolveImageOps.horizontalNormalized(kernel, pow2, output);
GConvolveImageOps.verticalNormalized(kernel, output, localPow2);
} else {
GConvolveImageOps.horizontal(kernel, adjusted, output, border);
GConvolveImageOps.vertical(kernel, output, localMean, border);
GPixelMath.pow2(adjusted, pow2);
GConvolveImageOps.horizontal(kernel, pow2, output, border);
GConvolveImageOps.vertical(kernel, output, localPow2, border);
}
// Compute the final output
if( imageType == GrayF32.class )
computeOutput((GrayF32)input, (float)delta, (GrayF32)output, (GrayF32)adjusted);
else
computeOutput((GrayF64)input, delta, (GrayF64)output, (GrayF64)adjusted);
}
|
[
"public",
"void",
"zeroMeanStdOne",
"(",
"Kernel1D",
"kernel",
",",
"T",
"input",
",",
"double",
"maxPixelValue",
",",
"double",
"delta",
",",
"T",
"output",
")",
"{",
"// check preconditions and initialize data structures",
"initialize",
"(",
"input",
",",
"output",
")",
";",
"// avoid overflow issues by ensuring that the max pixel value is 1",
"T",
"adjusted",
"=",
"ensureMaxValueOfOne",
"(",
"input",
",",
"maxPixelValue",
")",
";",
"// take advantage of 2D gaussian kernels being separable",
"if",
"(",
"border",
"==",
"null",
")",
"{",
"GConvolveImageOps",
".",
"horizontalNormalized",
"(",
"kernel",
",",
"adjusted",
",",
"output",
")",
";",
"GConvolveImageOps",
".",
"verticalNormalized",
"(",
"kernel",
",",
"output",
",",
"localMean",
")",
";",
"GPixelMath",
".",
"pow2",
"(",
"adjusted",
",",
"pow2",
")",
";",
"GConvolveImageOps",
".",
"horizontalNormalized",
"(",
"kernel",
",",
"pow2",
",",
"output",
")",
";",
"GConvolveImageOps",
".",
"verticalNormalized",
"(",
"kernel",
",",
"output",
",",
"localPow2",
")",
";",
"}",
"else",
"{",
"GConvolveImageOps",
".",
"horizontal",
"(",
"kernel",
",",
"adjusted",
",",
"output",
",",
"border",
")",
";",
"GConvolveImageOps",
".",
"vertical",
"(",
"kernel",
",",
"output",
",",
"localMean",
",",
"border",
")",
";",
"GPixelMath",
".",
"pow2",
"(",
"adjusted",
",",
"pow2",
")",
";",
"GConvolveImageOps",
".",
"horizontal",
"(",
"kernel",
",",
"pow2",
",",
"output",
",",
"border",
")",
";",
"GConvolveImageOps",
".",
"vertical",
"(",
"kernel",
",",
"output",
",",
"localPow2",
",",
"border",
")",
";",
"}",
"// Compute the final output",
"if",
"(",
"imageType",
"==",
"GrayF32",
".",
"class",
")",
"computeOutput",
"(",
"(",
"GrayF32",
")",
"input",
",",
"(",
"float",
")",
"delta",
",",
"(",
"GrayF32",
")",
"output",
",",
"(",
"GrayF32",
")",
"adjusted",
")",
";",
"else",
"computeOutput",
"(",
"(",
"GrayF64",
")",
"input",
",",
"delta",
",",
"(",
"GrayF64",
")",
"output",
",",
"(",
"GrayF64",
")",
"adjusted",
")",
";",
"}"
] |
/*
<p>Normalizes the input image such that local weighted statics are a zero mean and with standard deviation
of 1. The image border is handled by truncating the kernel and renormalizing it so that it's sum is
still one.</p>
<p>output[x,y] = (input[x,y]-mean[x,y])/(stdev[x,y] + delta)</p>
@param kernel Separable kernel. Typically Gaussian
@param input Input image
@param maxPixelValue maximum value of a pixel element in the input image. -1 = compute max value.
Typically this is 255 or 1.
@param delta A small value used to avoid divide by zero errors. Typical 1e-4f for 32 bit and 1e-8 for 64bit
@param output Storage for output
|
[
"/",
"*",
"<p",
">",
"Normalizes",
"the",
"input",
"image",
"such",
"that",
"local",
"weighted",
"statics",
"are",
"a",
"zero",
"mean",
"and",
"with",
"standard",
"deviation",
"of",
"1",
".",
"The",
"image",
"border",
"is",
"handled",
"by",
"truncating",
"the",
"kernel",
"and",
"renormalizing",
"it",
"so",
"that",
"it",
"s",
"sum",
"is",
"still",
"one",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/stat/ImageLocalNormalization.java#L90-L117
|
jayantk/jklol
|
src/com/jayantkrish/jklol/tensor/AbstractTensorBase.java
|
AbstractTensorBase.mergeDimensions
|
public static final DimensionSpec mergeDimensions(int[] firstDimensionNums, int[] firstDimensionSizes,
int[] secondDimensionNums, int[] secondDimensionSizes) {
SortedSet<Integer> first = Sets.newTreeSet(Ints.asList(firstDimensionNums));
SortedSet<Integer> second = Sets.newTreeSet(Ints.asList(secondDimensionNums));
SortedSet<Integer> all = Sets.newTreeSet(first);
all.addAll(second);
int[] resultDims = Ints.toArray(all);
int[] resultSizes = new int[resultDims.length];
for (int i = 0; i < resultDims.length; i++) {
int dim = resultDims[i];
if (first.contains(dim) && second.contains(dim)) {
int firstIndex = Ints.indexOf(firstDimensionNums, dim);
int secondIndex = Ints.indexOf(secondDimensionNums, dim);
int firstSize = firstDimensionSizes[firstIndex];
int secondSize = secondDimensionSizes[secondIndex];
Preconditions.checkArgument(firstSize == secondSize,
"Dimension sizes do not match: dim %s, sizes %s and %s.", dim, firstSize, secondSize);
resultSizes[i] = firstSize;
} else if (first.contains(dim)) {
int firstIndex = Ints.indexOf(firstDimensionNums, dim);
int firstSize = firstDimensionSizes[firstIndex];
resultSizes[i] = firstSize;
} else {
int secondIndex = Ints.indexOf(secondDimensionNums, dim);
int secondSize = secondDimensionSizes[secondIndex];
resultSizes[i] = secondSize;
}
}
return new DimensionSpec(resultDims, resultSizes);
}
|
java
|
public static final DimensionSpec mergeDimensions(int[] firstDimensionNums, int[] firstDimensionSizes,
int[] secondDimensionNums, int[] secondDimensionSizes) {
SortedSet<Integer> first = Sets.newTreeSet(Ints.asList(firstDimensionNums));
SortedSet<Integer> second = Sets.newTreeSet(Ints.asList(secondDimensionNums));
SortedSet<Integer> all = Sets.newTreeSet(first);
all.addAll(second);
int[] resultDims = Ints.toArray(all);
int[] resultSizes = new int[resultDims.length];
for (int i = 0; i < resultDims.length; i++) {
int dim = resultDims[i];
if (first.contains(dim) && second.contains(dim)) {
int firstIndex = Ints.indexOf(firstDimensionNums, dim);
int secondIndex = Ints.indexOf(secondDimensionNums, dim);
int firstSize = firstDimensionSizes[firstIndex];
int secondSize = secondDimensionSizes[secondIndex];
Preconditions.checkArgument(firstSize == secondSize,
"Dimension sizes do not match: dim %s, sizes %s and %s.", dim, firstSize, secondSize);
resultSizes[i] = firstSize;
} else if (first.contains(dim)) {
int firstIndex = Ints.indexOf(firstDimensionNums, dim);
int firstSize = firstDimensionSizes[firstIndex];
resultSizes[i] = firstSize;
} else {
int secondIndex = Ints.indexOf(secondDimensionNums, dim);
int secondSize = secondDimensionSizes[secondIndex];
resultSizes[i] = secondSize;
}
}
return new DimensionSpec(resultDims, resultSizes);
}
|
[
"public",
"static",
"final",
"DimensionSpec",
"mergeDimensions",
"(",
"int",
"[",
"]",
"firstDimensionNums",
",",
"int",
"[",
"]",
"firstDimensionSizes",
",",
"int",
"[",
"]",
"secondDimensionNums",
",",
"int",
"[",
"]",
"secondDimensionSizes",
")",
"{",
"SortedSet",
"<",
"Integer",
">",
"first",
"=",
"Sets",
".",
"newTreeSet",
"(",
"Ints",
".",
"asList",
"(",
"firstDimensionNums",
")",
")",
";",
"SortedSet",
"<",
"Integer",
">",
"second",
"=",
"Sets",
".",
"newTreeSet",
"(",
"Ints",
".",
"asList",
"(",
"secondDimensionNums",
")",
")",
";",
"SortedSet",
"<",
"Integer",
">",
"all",
"=",
"Sets",
".",
"newTreeSet",
"(",
"first",
")",
";",
"all",
".",
"addAll",
"(",
"second",
")",
";",
"int",
"[",
"]",
"resultDims",
"=",
"Ints",
".",
"toArray",
"(",
"all",
")",
";",
"int",
"[",
"]",
"resultSizes",
"=",
"new",
"int",
"[",
"resultDims",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"resultDims",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"dim",
"=",
"resultDims",
"[",
"i",
"]",
";",
"if",
"(",
"first",
".",
"contains",
"(",
"dim",
")",
"&&",
"second",
".",
"contains",
"(",
"dim",
")",
")",
"{",
"int",
"firstIndex",
"=",
"Ints",
".",
"indexOf",
"(",
"firstDimensionNums",
",",
"dim",
")",
";",
"int",
"secondIndex",
"=",
"Ints",
".",
"indexOf",
"(",
"secondDimensionNums",
",",
"dim",
")",
";",
"int",
"firstSize",
"=",
"firstDimensionSizes",
"[",
"firstIndex",
"]",
";",
"int",
"secondSize",
"=",
"secondDimensionSizes",
"[",
"secondIndex",
"]",
";",
"Preconditions",
".",
"checkArgument",
"(",
"firstSize",
"==",
"secondSize",
",",
"\"Dimension sizes do not match: dim %s, sizes %s and %s.\"",
",",
"dim",
",",
"firstSize",
",",
"secondSize",
")",
";",
"resultSizes",
"[",
"i",
"]",
"=",
"firstSize",
";",
"}",
"else",
"if",
"(",
"first",
".",
"contains",
"(",
"dim",
")",
")",
"{",
"int",
"firstIndex",
"=",
"Ints",
".",
"indexOf",
"(",
"firstDimensionNums",
",",
"dim",
")",
";",
"int",
"firstSize",
"=",
"firstDimensionSizes",
"[",
"firstIndex",
"]",
";",
"resultSizes",
"[",
"i",
"]",
"=",
"firstSize",
";",
"}",
"else",
"{",
"int",
"secondIndex",
"=",
"Ints",
".",
"indexOf",
"(",
"secondDimensionNums",
",",
"dim",
")",
";",
"int",
"secondSize",
"=",
"secondDimensionSizes",
"[",
"secondIndex",
"]",
";",
"resultSizes",
"[",
"i",
"]",
"=",
"secondSize",
";",
"}",
"}",
"return",
"new",
"DimensionSpec",
"(",
"resultDims",
",",
"resultSizes",
")",
";",
"}"
] |
Merges the given sets of dimensions, verifying that any dimensions in
both sets have the same size.
@param firstDimensionNums
@param firstDimensionSizes
@param secondDimensionNums
@param secondDimensionSizes
@return
|
[
"Merges",
"the",
"given",
"sets",
"of",
"dimensions",
"verifying",
"that",
"any",
"dimensions",
"in",
"both",
"sets",
"have",
"the",
"same",
"size",
"."
] |
train
|
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/tensor/AbstractTensorBase.java#L94-L125
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java
|
LocalMapStatsProvider.getReplicaAddress
|
private Address getReplicaAddress(int partitionId, int replicaNumber, int backupCount) {
IPartition partition = partitionService.getPartition(partitionId);
Address replicaAddress = partition.getReplicaAddress(replicaNumber);
if (replicaAddress == null) {
replicaAddress = waitForReplicaAddress(replicaNumber, partition, backupCount);
}
return replicaAddress;
}
|
java
|
private Address getReplicaAddress(int partitionId, int replicaNumber, int backupCount) {
IPartition partition = partitionService.getPartition(partitionId);
Address replicaAddress = partition.getReplicaAddress(replicaNumber);
if (replicaAddress == null) {
replicaAddress = waitForReplicaAddress(replicaNumber, partition, backupCount);
}
return replicaAddress;
}
|
[
"private",
"Address",
"getReplicaAddress",
"(",
"int",
"partitionId",
",",
"int",
"replicaNumber",
",",
"int",
"backupCount",
")",
"{",
"IPartition",
"partition",
"=",
"partitionService",
".",
"getPartition",
"(",
"partitionId",
")",
";",
"Address",
"replicaAddress",
"=",
"partition",
".",
"getReplicaAddress",
"(",
"replicaNumber",
")",
";",
"if",
"(",
"replicaAddress",
"==",
"null",
")",
"{",
"replicaAddress",
"=",
"waitForReplicaAddress",
"(",
"replicaNumber",
",",
"partition",
",",
"backupCount",
")",
";",
"}",
"return",
"replicaAddress",
";",
"}"
] |
Gets replica address. Waits if necessary.
@see #waitForReplicaAddress
|
[
"Gets",
"replica",
"address",
".",
"Waits",
"if",
"necessary",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/LocalMapStatsProvider.java#L275-L282
|
ckpoint/CheckPoint
|
src/main/java/hsim/checkpoint/core/msg/MsgChecker.java
|
MsgChecker.checkDataInnerRules
|
public void checkDataInnerRules(ValidationData data, Object bodyObj) {
data.getValidationRules().stream().filter(vr -> vr.isUse()).forEach(rule -> {
if (data.isListChild()) {
this.checkPointListChild(data, rule, bodyObj, rule.getStandardValue());
} else {
this.checkPoint(data, rule, bodyObj, rule.getStandardValue());
}
});
}
|
java
|
public void checkDataInnerRules(ValidationData data, Object bodyObj) {
data.getValidationRules().stream().filter(vr -> vr.isUse()).forEach(rule -> {
if (data.isListChild()) {
this.checkPointListChild(data, rule, bodyObj, rule.getStandardValue());
} else {
this.checkPoint(data, rule, bodyObj, rule.getStandardValue());
}
});
}
|
[
"public",
"void",
"checkDataInnerRules",
"(",
"ValidationData",
"data",
",",
"Object",
"bodyObj",
")",
"{",
"data",
".",
"getValidationRules",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"vr",
"->",
"vr",
".",
"isUse",
"(",
")",
")",
".",
"forEach",
"(",
"rule",
"->",
"{",
"if",
"(",
"data",
".",
"isListChild",
"(",
")",
")",
"{",
"this",
".",
"checkPointListChild",
"(",
"data",
",",
"rule",
",",
"bodyObj",
",",
"rule",
".",
"getStandardValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"checkPoint",
"(",
"data",
",",
"rule",
",",
"bodyObj",
",",
"rule",
".",
"getStandardValue",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Check data inner rules.
@param data the data
@param bodyObj the body obj
|
[
"Check",
"data",
"inner",
"rules",
"."
] |
train
|
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L105-L113
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/web/action/VfsTreeAction.java
|
VfsTreeAction.populateTreeNodeData
|
protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException {
boolean noChild = true;
FileType type = file.getType();
if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){
noChild = file.getChildren().length == 0;
}
String relativePath = root.getName().getRelativeName(file.getName());
return populateTreeNodeData(file, noChild, relativePath);
}
|
java
|
protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException {
boolean noChild = true;
FileType type = file.getType();
if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){
noChild = file.getChildren().length == 0;
}
String relativePath = root.getName().getRelativeName(file.getName());
return populateTreeNodeData(file, noChild, relativePath);
}
|
[
"protected",
"JsTreeNodeData",
"populateTreeNodeData",
"(",
"FileObject",
"root",
",",
"FileObject",
"file",
")",
"throws",
"FileSystemException",
"{",
"boolean",
"noChild",
"=",
"true",
";",
"FileType",
"type",
"=",
"file",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
".",
"equals",
"(",
"FileType",
".",
"FOLDER",
")",
"||",
"type",
".",
"equals",
"(",
"FileType",
".",
"FILE_OR_FOLDER",
")",
")",
"{",
"noChild",
"=",
"file",
".",
"getChildren",
"(",
")",
".",
"length",
"==",
"0",
";",
"}",
"String",
"relativePath",
"=",
"root",
".",
"getName",
"(",
")",
".",
"getRelativeName",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"return",
"populateTreeNodeData",
"(",
"file",
",",
"noChild",
",",
"relativePath",
")",
";",
"}"
] |
Populate a node.
@param root Relative root directory.
@param file The file object.
@return The node data structure which presents the file.
@throws FileSystemException
|
[
"Populate",
"a",
"node",
"."
] |
train
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/web/action/VfsTreeAction.java#L137-L145
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/internal/protocol/MasterProtocol.java
|
MasterProtocol.resetHostList
|
private static void resetHostList(Listener listener, Deque<HostAddress> loopAddresses) {
//if all servers have been connected without result
//add back all servers
List<HostAddress> servers = new ArrayList<>();
servers.addAll(listener.getUrlParser().getHostAddresses());
Collections.shuffle(servers);
loopAddresses.clear();
loopAddresses.addAll(servers);
}
|
java
|
private static void resetHostList(Listener listener, Deque<HostAddress> loopAddresses) {
//if all servers have been connected without result
//add back all servers
List<HostAddress> servers = new ArrayList<>();
servers.addAll(listener.getUrlParser().getHostAddresses());
Collections.shuffle(servers);
loopAddresses.clear();
loopAddresses.addAll(servers);
}
|
[
"private",
"static",
"void",
"resetHostList",
"(",
"Listener",
"listener",
",",
"Deque",
"<",
"HostAddress",
">",
"loopAddresses",
")",
"{",
"//if all servers have been connected without result",
"//add back all servers",
"List",
"<",
"HostAddress",
">",
"servers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"servers",
".",
"addAll",
"(",
"listener",
".",
"getUrlParser",
"(",
")",
".",
"getHostAddresses",
"(",
")",
")",
";",
"Collections",
".",
"shuffle",
"(",
"servers",
")",
";",
"loopAddresses",
".",
"clear",
"(",
")",
";",
"loopAddresses",
".",
"addAll",
"(",
"servers",
")",
";",
"}"
] |
Reinitialize loopAddresses with all hosts : all servers in randomize order without connected
host.
@param listener current listener
@param loopAddresses the list to reinitialize
|
[
"Reinitialize",
"loopAddresses",
"with",
"all",
"hosts",
":",
"all",
"servers",
"in",
"randomize",
"order",
"without",
"connected",
"host",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/MasterProtocol.java#L184-L193
|
structurizr/java
|
structurizr-core/src/com/structurizr/model/Model.java
|
Model.addPerson
|
@Nonnull
public Person addPerson(@Nonnull String name, @Nullable String description) {
return addPerson(Location.Unspecified, name, description);
}
|
java
|
@Nonnull
public Person addPerson(@Nonnull String name, @Nullable String description) {
return addPerson(Location.Unspecified, name, description);
}
|
[
"@",
"Nonnull",
"public",
"Person",
"addPerson",
"(",
"@",
"Nonnull",
"String",
"name",
",",
"@",
"Nullable",
"String",
"description",
")",
"{",
"return",
"addPerson",
"(",
"Location",
".",
"Unspecified",
",",
"name",
",",
"description",
")",
";",
"}"
] |
Creates a person (with an unspecified location) and adds it to the model.
@param name the name of the person (e.g. "Admin User" or "Bob the Business User")
@param description a short description of the person
@return the Person instance created and added to the model (or null)
@throws IllegalArgumentException if a person with the same name already exists
|
[
"Creates",
"a",
"person",
"(",
"with",
"an",
"unspecified",
"location",
")",
"and",
"adds",
"it",
"to",
"the",
"model",
"."
] |
train
|
https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/Model.java#L95-L98
|
chrisjenx/Calligraphy
|
calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyUtils.java
|
CalligraphyUtils.pullFontPathFromTheme
|
static String pullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId) {
if (styleAttrId == -1 || attributeId == null)
return null;
final Resources.Theme theme = context.getTheme();
final TypedValue value = new TypedValue();
theme.resolveAttribute(styleAttrId, value, true);
final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, attributeId);
try {
String font = typedArray.getString(0);
return font;
} catch (Exception ignore) {
// Failed for some reason.
return null;
} finally {
typedArray.recycle();
}
}
|
java
|
static String pullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId) {
if (styleAttrId == -1 || attributeId == null)
return null;
final Resources.Theme theme = context.getTheme();
final TypedValue value = new TypedValue();
theme.resolveAttribute(styleAttrId, value, true);
final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, attributeId);
try {
String font = typedArray.getString(0);
return font;
} catch (Exception ignore) {
// Failed for some reason.
return null;
} finally {
typedArray.recycle();
}
}
|
[
"static",
"String",
"pullFontPathFromTheme",
"(",
"Context",
"context",
",",
"int",
"styleAttrId",
",",
"int",
"[",
"]",
"attributeId",
")",
"{",
"if",
"(",
"styleAttrId",
"==",
"-",
"1",
"||",
"attributeId",
"==",
"null",
")",
"return",
"null",
";",
"final",
"Resources",
".",
"Theme",
"theme",
"=",
"context",
".",
"getTheme",
"(",
")",
";",
"final",
"TypedValue",
"value",
"=",
"new",
"TypedValue",
"(",
")",
";",
"theme",
".",
"resolveAttribute",
"(",
"styleAttrId",
",",
"value",
",",
"true",
")",
";",
"final",
"TypedArray",
"typedArray",
"=",
"theme",
".",
"obtainStyledAttributes",
"(",
"value",
".",
"resourceId",
",",
"attributeId",
")",
";",
"try",
"{",
"String",
"font",
"=",
"typedArray",
".",
"getString",
"(",
"0",
")",
";",
"return",
"font",
";",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"// Failed for some reason.",
"return",
"null",
";",
"}",
"finally",
"{",
"typedArray",
".",
"recycle",
"(",
")",
";",
"}",
"}"
] |
Last but not least, try to pull the Font Path from the Theme, which is defined.
@param context Activity Context
@param styleAttrId Theme style id
@param attributeId if -1 returns null.
@return null if no theme or attribute defined.
|
[
"Last",
"but",
"not",
"least",
"try",
"to",
"pull",
"the",
"Font",
"Path",
"from",
"the",
"Theme",
"which",
"is",
"defined",
"."
] |
train
|
https://github.com/chrisjenx/Calligraphy/blob/085e441954d787bd4ef31f245afe5f2f2a311ea5/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyUtils.java#L252-L270
|
couchbase/couchbase-jvm-core
|
src/main/java/com/couchbase/client/core/ResponseHandler.java
|
ResponseHandler.bucketHasFastForwardMap
|
private static boolean bucketHasFastForwardMap(String bucketName, ClusterConfig clusterConfig) {
if (bucketName == null) {
return false;
}
BucketConfig bucketConfig = clusterConfig.bucketConfig(bucketName);
return bucketConfig != null && bucketConfig.hasFastForwardMap();
}
|
java
|
private static boolean bucketHasFastForwardMap(String bucketName, ClusterConfig clusterConfig) {
if (bucketName == null) {
return false;
}
BucketConfig bucketConfig = clusterConfig.bucketConfig(bucketName);
return bucketConfig != null && bucketConfig.hasFastForwardMap();
}
|
[
"private",
"static",
"boolean",
"bucketHasFastForwardMap",
"(",
"String",
"bucketName",
",",
"ClusterConfig",
"clusterConfig",
")",
"{",
"if",
"(",
"bucketName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"BucketConfig",
"bucketConfig",
"=",
"clusterConfig",
".",
"bucketConfig",
"(",
"bucketName",
")",
";",
"return",
"bucketConfig",
"!=",
"null",
"&&",
"bucketConfig",
".",
"hasFastForwardMap",
"(",
")",
";",
"}"
] |
Helper method to check if the current given bucket contains a fast forward map.
@param bucketName the name of the bucket.
@param clusterConfig the current cluster configuration.
@return true if it has a ffwd-map, false otherwise.
|
[
"Helper",
"method",
"to",
"check",
"if",
"the",
"current",
"given",
"bucket",
"contains",
"a",
"fast",
"forward",
"map",
"."
] |
train
|
https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/ResponseHandler.java#L230-L236
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.