repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.registerListener | private boolean registerListener(String newPath, ArtifactListenerSelector newListener) {
"""
Register a listener to a specified path.
Registration has two effects: The listener is put into a table
which maps the listener to specified path. The path of the
listener are added to the covering paths collection, possibly
causing newly covered paths to be removed from the collection.
If the new path is already covered, the covering paths
collection is not changed.
@param newPath The path to which to register the listener.
@param newListener The listener which is to be registered.
@return True or false telling if the uncovered paths collection
was updated.
"""
boolean updatedCoveringPaths = addCoveringPath(newPath);
Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath);
if ( listenersForPath == null ) {
// Each listeners collection is expected to be small.
listenersForPath = new LinkedList<ArtifactListenerSelector>();
listeners.put(newPath, listenersForPath);
}
listenersForPath.add(newListener);
return ( updatedCoveringPaths );
} | java | private boolean registerListener(String newPath, ArtifactListenerSelector newListener) {
boolean updatedCoveringPaths = addCoveringPath(newPath);
Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath);
if ( listenersForPath == null ) {
// Each listeners collection is expected to be small.
listenersForPath = new LinkedList<ArtifactListenerSelector>();
listeners.put(newPath, listenersForPath);
}
listenersForPath.add(newListener);
return ( updatedCoveringPaths );
} | [
"private",
"boolean",
"registerListener",
"(",
"String",
"newPath",
",",
"ArtifactListenerSelector",
"newListener",
")",
"{",
"boolean",
"updatedCoveringPaths",
"=",
"addCoveringPath",
"(",
"newPath",
")",
";",
"Collection",
"<",
"ArtifactListenerSelector",
">",
"listenersForPath",
"=",
"listeners",
".",
"get",
"(",
"newPath",
")",
";",
"if",
"(",
"listenersForPath",
"==",
"null",
")",
"{",
"// Each listeners collection is expected to be small.",
"listenersForPath",
"=",
"new",
"LinkedList",
"<",
"ArtifactListenerSelector",
">",
"(",
")",
";",
"listeners",
".",
"put",
"(",
"newPath",
",",
"listenersForPath",
")",
";",
"}",
"listenersForPath",
".",
"add",
"(",
"newListener",
")",
";",
"return",
"(",
"updatedCoveringPaths",
")",
";",
"}"
] | Register a listener to a specified path.
Registration has two effects: The listener is put into a table
which maps the listener to specified path. The path of the
listener are added to the covering paths collection, possibly
causing newly covered paths to be removed from the collection.
If the new path is already covered, the covering paths
collection is not changed.
@param newPath The path to which to register the listener.
@param newListener The listener which is to be registered.
@return True or false telling if the uncovered paths collection
was updated. | [
"Register",
"a",
"listener",
"to",
"a",
"specified",
"path",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L465-L477 |
52inc/android-52Kit | library-winds/src/main/java/com/ftinc/kit/winds/Winds.java | Winds.checkChangelogActivity | public static void checkChangelogActivity(Context ctx, @XmlRes int configId) {
"""
Check to see if we should show the changelog activity if there are any new changes
to the configuration file.
@param ctx the context to launch the activity with
@param configId the changelog configuration xml resource id
"""
// Parse configuration
ChangeLog changeLog = Parser.parse(ctx, configId);
if(changeLog != null){
// Validate that there is a new version code
if(validateVersion(ctx, changeLog)) {
openChangelogActivity(ctx, configId);
}
}else{
throw new NullPointerException("Unable to find a 'Winds' configuration @ " + configId);
}
} | java | public static void checkChangelogActivity(Context ctx, @XmlRes int configId){
// Parse configuration
ChangeLog changeLog = Parser.parse(ctx, configId);
if(changeLog != null){
// Validate that there is a new version code
if(validateVersion(ctx, changeLog)) {
openChangelogActivity(ctx, configId);
}
}else{
throw new NullPointerException("Unable to find a 'Winds' configuration @ " + configId);
}
} | [
"public",
"static",
"void",
"checkChangelogActivity",
"(",
"Context",
"ctx",
",",
"@",
"XmlRes",
"int",
"configId",
")",
"{",
"// Parse configuration",
"ChangeLog",
"changeLog",
"=",
"Parser",
".",
"parse",
"(",
"ctx",
",",
"configId",
")",
";",
"if",
"(",
"changeLog",
"!=",
"null",
")",
"{",
"// Validate that there is a new version code",
"if",
"(",
"validateVersion",
"(",
"ctx",
",",
"changeLog",
")",
")",
"{",
"openChangelogActivity",
"(",
"ctx",
",",
"configId",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Unable to find a 'Winds' configuration @ \"",
"+",
"configId",
")",
";",
"}",
"}"
] | Check to see if we should show the changelog activity if there are any new changes
to the configuration file.
@param ctx the context to launch the activity with
@param configId the changelog configuration xml resource id | [
"Check",
"to",
"see",
"if",
"we",
"should",
"show",
"the",
"changelog",
"activity",
"if",
"there",
"are",
"any",
"new",
"changes",
"to",
"the",
"configuration",
"file",
"."
] | train | https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-winds/src/main/java/com/ftinc/kit/winds/Winds.java#L120-L135 |
bugsnag/bugsnag-java | bugsnag/src/main/java/com/bugsnag/Report.java | Report.addToTab | public Report addToTab(String tabName, String key, Object value) {
"""
Add a key value pair to a metadata tab.
@param tabName the name of the tab to add the key value pair to
@param key the key of the metadata to add
@param value the metadata value to add
@return the modified report
"""
diagnostics.metaData.addToTab(tabName, key, value);
return this;
} | java | public Report addToTab(String tabName, String key, Object value) {
diagnostics.metaData.addToTab(tabName, key, value);
return this;
} | [
"public",
"Report",
"addToTab",
"(",
"String",
"tabName",
",",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"diagnostics",
".",
"metaData",
".",
"addToTab",
"(",
"tabName",
",",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Add a key value pair to a metadata tab.
@param tabName the name of the tab to add the key value pair to
@param key the key of the metadata to add
@param value the metadata value to add
@return the modified report | [
"Add",
"a",
"key",
"value",
"pair",
"to",
"a",
"metadata",
"tab",
"."
] | train | https://github.com/bugsnag/bugsnag-java/blob/11817d63949bcf2b2b6b765a1d37305cdec356f2/bugsnag/src/main/java/com/bugsnag/Report.java#L190-L193 |
guardtime/ksi-java-sdk | ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java | TLVElement.getDecodedString | public final String getDecodedString() throws TLVParserException {
"""
Converts the TLV element content data to UTF-8 string.
@return Decoded instance of string.
@throws TLVParserException
when content string isn't null terminated or is malformed UTF-8 data.
"""
byte[] data = getContent();
if (!(data.length > 0 && data[data.length - 1] == '\0')) {
throw new TLVParserException("String must be null terminated");
}
try {
return Util.decodeString(data, 0, data.length - 1);
} catch (CharacterCodingException e) {
throw new TLVParserException("Malformed UTF-8 data", e);
}
} | java | public final String getDecodedString() throws TLVParserException {
byte[] data = getContent();
if (!(data.length > 0 && data[data.length - 1] == '\0')) {
throw new TLVParserException("String must be null terminated");
}
try {
return Util.decodeString(data, 0, data.length - 1);
} catch (CharacterCodingException e) {
throw new TLVParserException("Malformed UTF-8 data", e);
}
} | [
"public",
"final",
"String",
"getDecodedString",
"(",
")",
"throws",
"TLVParserException",
"{",
"byte",
"[",
"]",
"data",
"=",
"getContent",
"(",
")",
";",
"if",
"(",
"!",
"(",
"data",
".",
"length",
">",
"0",
"&&",
"data",
"[",
"data",
".",
"length",
"-",
"1",
"]",
"==",
"'",
"'",
")",
")",
"{",
"throw",
"new",
"TLVParserException",
"(",
"\"String must be null terminated\"",
")",
";",
"}",
"try",
"{",
"return",
"Util",
".",
"decodeString",
"(",
"data",
",",
"0",
",",
"data",
".",
"length",
"-",
"1",
")",
";",
"}",
"catch",
"(",
"CharacterCodingException",
"e",
")",
"{",
"throw",
"new",
"TLVParserException",
"(",
"\"Malformed UTF-8 data\"",
",",
"e",
")",
";",
"}",
"}"
] | Converts the TLV element content data to UTF-8 string.
@return Decoded instance of string.
@throws TLVParserException
when content string isn't null terminated or is malformed UTF-8 data. | [
"Converts",
"the",
"TLV",
"element",
"content",
"data",
"to",
"UTF",
"-",
"8",
"string",
"."
] | train | https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L257-L267 |
apache/flink | flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonStreamExecutionEnvironment.java | PythonStreamExecutionEnvironment.socket_text_stream | public PythonDataStream socket_text_stream(String host, int port) {
"""
A thin wrapper layer over {@link StreamExecutionEnvironment#socketTextStream(java.lang.String, int)}.
@param host The host name which a server socket binds
@param port The port number which a server socket binds. A port number of 0 means that the port number is automatically
allocated.
@return A python data stream containing the strings received from the socket
"""
return new PythonDataStream<>(env.socketTextStream(host, port).map(new AdapterMap<String>()));
} | java | public PythonDataStream socket_text_stream(String host, int port) {
return new PythonDataStream<>(env.socketTextStream(host, port).map(new AdapterMap<String>()));
} | [
"public",
"PythonDataStream",
"socket_text_stream",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"return",
"new",
"PythonDataStream",
"<>",
"(",
"env",
".",
"socketTextStream",
"(",
"host",
",",
"port",
")",
".",
"map",
"(",
"new",
"AdapterMap",
"<",
"String",
">",
"(",
")",
")",
")",
";",
"}"
] | A thin wrapper layer over {@link StreamExecutionEnvironment#socketTextStream(java.lang.String, int)}.
@param host The host name which a server socket binds
@param port The port number which a server socket binds. A port number of 0 means that the port number is automatically
allocated.
@return A python data stream containing the strings received from the socket | [
"A",
"thin",
"wrapper",
"layer",
"over",
"{",
"@link",
"StreamExecutionEnvironment#socketTextStream",
"(",
"java",
".",
"lang",
".",
"String",
"int",
")",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonStreamExecutionEnvironment.java#L200-L202 |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/img/ImageExtensions.java | ImageExtensions.newPdfPTable | public static PdfPTable newPdfPTable(int numColumns, List<String> headerNames) {
"""
Factory method for create a new {@link PdfPTable} with the given count of columns and the
column header names
@param numColumns
the count of columns of the table
@param headerNames
the column header names
@return the new {@link PdfPTable}
"""
PdfPTable table = new PdfPTable(numColumns);
headerNames.stream().forEach(columnHeaderName -> {
PdfPCell header = new PdfPCell();
header.setBackgroundColor(BaseColor.LIGHT_GRAY);
header.setBorderWidth(2);
header.setPhrase(new Phrase(columnHeaderName));
table.addCell(header);
});
return table;
} | java | public static PdfPTable newPdfPTable(int numColumns, List<String> headerNames)
{
PdfPTable table = new PdfPTable(numColumns);
headerNames.stream().forEach(columnHeaderName -> {
PdfPCell header = new PdfPCell();
header.setBackgroundColor(BaseColor.LIGHT_GRAY);
header.setBorderWidth(2);
header.setPhrase(new Phrase(columnHeaderName));
table.addCell(header);
});
return table;
} | [
"public",
"static",
"PdfPTable",
"newPdfPTable",
"(",
"int",
"numColumns",
",",
"List",
"<",
"String",
">",
"headerNames",
")",
"{",
"PdfPTable",
"table",
"=",
"new",
"PdfPTable",
"(",
"numColumns",
")",
";",
"headerNames",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"columnHeaderName",
"->",
"{",
"PdfPCell",
"header",
"=",
"new",
"PdfPCell",
"(",
")",
";",
"header",
".",
"setBackgroundColor",
"(",
"BaseColor",
".",
"LIGHT_GRAY",
")",
";",
"header",
".",
"setBorderWidth",
"(",
"2",
")",
";",
"header",
".",
"setPhrase",
"(",
"new",
"Phrase",
"(",
"columnHeaderName",
")",
")",
";",
"table",
".",
"addCell",
"(",
"header",
")",
";",
"}",
")",
";",
"return",
"table",
";",
"}"
] | Factory method for create a new {@link PdfPTable} with the given count of columns and the
column header names
@param numColumns
the count of columns of the table
@param headerNames
the column header names
@return the new {@link PdfPTable} | [
"Factory",
"method",
"for",
"create",
"a",
"new",
"{",
"@link",
"PdfPTable",
"}",
"with",
"the",
"given",
"count",
"of",
"columns",
"and",
"the",
"column",
"header",
"names"
] | train | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/img/ImageExtensions.java#L217-L228 |
structurizr/java | structurizr-core/src/com/structurizr/model/DeploymentNode.java | DeploymentNode.addDeploymentNode | public DeploymentNode addDeploymentNode(String name, String description, String technology, int instances) {
"""
Adds a child deployment node.
@param name the name of the deployment node
@param description a short description
@param technology the technology
@param instances the number of instances
@return a DeploymentNode object
"""
return addDeploymentNode(name, description, technology, instances, null);
} | java | public DeploymentNode addDeploymentNode(String name, String description, String technology, int instances) {
return addDeploymentNode(name, description, technology, instances, null);
} | [
"public",
"DeploymentNode",
"addDeploymentNode",
"(",
"String",
"name",
",",
"String",
"description",
",",
"String",
"technology",
",",
"int",
"instances",
")",
"{",
"return",
"addDeploymentNode",
"(",
"name",
",",
"description",
",",
"technology",
",",
"instances",
",",
"null",
")",
";",
"}"
] | Adds a child deployment node.
@param name the name of the deployment node
@param description a short description
@param technology the technology
@param instances the number of instances
@return a DeploymentNode object | [
"Adds",
"a",
"child",
"deployment",
"node",
"."
] | train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/DeploymentNode.java#L78-L80 |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/FilterUtils.java | FilterUtils.checkRuleMapping | private void checkRuleMapping(final QName attName, final List<String> attValue) {
"""
Check if attribute value has mapping in filter configuration and throw messages.
@param attName attribute name
@param attValue attribute value
"""
if (attValue == null || attValue.isEmpty()) {
return;
}
for (final String attSubValue: attValue) {
final FilterKey filterKey = new FilterKey(attName, attSubValue);
final Action filterAction = filterMap.get(filterKey);
if (filterAction == null && logMissingAction) {
if (!alreadyShowed(filterKey)) {
logger.info(MessageUtils.getMessage("DOTJ031I", filterKey.toString()).toString());
}
}
}
} | java | private void checkRuleMapping(final QName attName, final List<String> attValue) {
if (attValue == null || attValue.isEmpty()) {
return;
}
for (final String attSubValue: attValue) {
final FilterKey filterKey = new FilterKey(attName, attSubValue);
final Action filterAction = filterMap.get(filterKey);
if (filterAction == null && logMissingAction) {
if (!alreadyShowed(filterKey)) {
logger.info(MessageUtils.getMessage("DOTJ031I", filterKey.toString()).toString());
}
}
}
} | [
"private",
"void",
"checkRuleMapping",
"(",
"final",
"QName",
"attName",
",",
"final",
"List",
"<",
"String",
">",
"attValue",
")",
"{",
"if",
"(",
"attValue",
"==",
"null",
"||",
"attValue",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"final",
"String",
"attSubValue",
":",
"attValue",
")",
"{",
"final",
"FilterKey",
"filterKey",
"=",
"new",
"FilterKey",
"(",
"attName",
",",
"attSubValue",
")",
";",
"final",
"Action",
"filterAction",
"=",
"filterMap",
".",
"get",
"(",
"filterKey",
")",
";",
"if",
"(",
"filterAction",
"==",
"null",
"&&",
"logMissingAction",
")",
"{",
"if",
"(",
"!",
"alreadyShowed",
"(",
"filterKey",
")",
")",
"{",
"logger",
".",
"info",
"(",
"MessageUtils",
".",
"getMessage",
"(",
"\"DOTJ031I\"",
",",
"filterKey",
".",
"toString",
"(",
")",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Check if attribute value has mapping in filter configuration and throw messages.
@param attName attribute name
@param attValue attribute value | [
"Check",
"if",
"attribute",
"value",
"has",
"mapping",
"in",
"filter",
"configuration",
"and",
"throw",
"messages",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L467-L480 |
KyoriPowered/lunar | src/main/java/net/kyori/lunar/PrimitiveOptionals.java | PrimitiveOptionals.mapToInt | public static @NonNull OptionalInt mapToInt(final @NonNull OptionalDouble optional, final @NonNull DoubleToIntFunction function) {
"""
Apply the provided mapping function to the {@code optional} if a value is present,
and return an {@code OptionalInt} describing the result.
@param optional the optional
@param function the function
@return an optional
"""
requireNonNull(function, "function");
return optional.isPresent() ? OptionalInt.of(function.applyAsInt(optional.getAsDouble())) : OptionalInt.empty();
} | java | public static @NonNull OptionalInt mapToInt(final @NonNull OptionalDouble optional, final @NonNull DoubleToIntFunction function) {
requireNonNull(function, "function");
return optional.isPresent() ? OptionalInt.of(function.applyAsInt(optional.getAsDouble())) : OptionalInt.empty();
} | [
"public",
"static",
"@",
"NonNull",
"OptionalInt",
"mapToInt",
"(",
"final",
"@",
"NonNull",
"OptionalDouble",
"optional",
",",
"final",
"@",
"NonNull",
"DoubleToIntFunction",
"function",
")",
"{",
"requireNonNull",
"(",
"function",
",",
"\"function\"",
")",
";",
"return",
"optional",
".",
"isPresent",
"(",
")",
"?",
"OptionalInt",
".",
"of",
"(",
"function",
".",
"applyAsInt",
"(",
"optional",
".",
"getAsDouble",
"(",
")",
")",
")",
":",
"OptionalInt",
".",
"empty",
"(",
")",
";",
"}"
] | Apply the provided mapping function to the {@code optional} if a value is present,
and return an {@code OptionalInt} describing the result.
@param optional the optional
@param function the function
@return an optional | [
"Apply",
"the",
"provided",
"mapping",
"function",
"to",
"the",
"{",
"@code",
"optional",
"}",
"if",
"a",
"value",
"is",
"present",
"and",
"return",
"an",
"{",
"@code",
"OptionalInt",
"}",
"describing",
"the",
"result",
"."
] | train | https://github.com/KyoriPowered/lunar/blob/6856747d9034a2fe0c8d0a8a0150986797732b5c/src/main/java/net/kyori/lunar/PrimitiveOptionals.java#L63-L66 |
scribejava/scribejava | scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java | OAuth10aService.getAccessTokenAsync | public Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier,
OAuthAsyncRequestCallback<OAuth1AccessToken> callback) {
"""
Start the request to retrieve the access token. The optionally provided callback will be called with the Token
when it is available.
@param requestToken request token (obtained previously or null)
@param oauthVerifier oauth_verifier
@param callback optional callback
@return Future
"""
log("async obtaining access token from %s", api.getAccessTokenEndpoint());
final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier);
return execute(request, callback, new OAuthRequest.ResponseConverter<OAuth1AccessToken>() {
@Override
public OAuth1AccessToken convert(Response response) throws IOException {
return getApi().getAccessTokenExtractor().extract(response);
}
});
} | java | public Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier,
OAuthAsyncRequestCallback<OAuth1AccessToken> callback) {
log("async obtaining access token from %s", api.getAccessTokenEndpoint());
final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier);
return execute(request, callback, new OAuthRequest.ResponseConverter<OAuth1AccessToken>() {
@Override
public OAuth1AccessToken convert(Response response) throws IOException {
return getApi().getAccessTokenExtractor().extract(response);
}
});
} | [
"public",
"Future",
"<",
"OAuth1AccessToken",
">",
"getAccessTokenAsync",
"(",
"OAuth1RequestToken",
"requestToken",
",",
"String",
"oauthVerifier",
",",
"OAuthAsyncRequestCallback",
"<",
"OAuth1AccessToken",
">",
"callback",
")",
"{",
"log",
"(",
"\"async obtaining access token from %s\"",
",",
"api",
".",
"getAccessTokenEndpoint",
"(",
")",
")",
";",
"final",
"OAuthRequest",
"request",
"=",
"prepareAccessTokenRequest",
"(",
"requestToken",
",",
"oauthVerifier",
")",
";",
"return",
"execute",
"(",
"request",
",",
"callback",
",",
"new",
"OAuthRequest",
".",
"ResponseConverter",
"<",
"OAuth1AccessToken",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OAuth1AccessToken",
"convert",
"(",
"Response",
"response",
")",
"throws",
"IOException",
"{",
"return",
"getApi",
"(",
")",
".",
"getAccessTokenExtractor",
"(",
")",
".",
"extract",
"(",
"response",
")",
";",
"}",
"}",
")",
";",
"}"
] | Start the request to retrieve the access token. The optionally provided callback will be called with the Token
when it is available.
@param requestToken request token (obtained previously or null)
@param oauthVerifier oauth_verifier
@param callback optional callback
@return Future | [
"Start",
"the",
"request",
"to",
"retrieve",
"the",
"access",
"token",
".",
"The",
"optionally",
"provided",
"callback",
"will",
"be",
"called",
"with",
"the",
"Token",
"when",
"it",
"is",
"available",
"."
] | train | https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java#L113-L123 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java | NetworkConfig.createAllPeers | private void createAllPeers() throws NetworkConfigurationException {
"""
Creates Node instances representing all the peers defined in the config file
"""
// Sanity checks
if (peers != null) {
throw new NetworkConfigurationException("INTERNAL ERROR: peers has already been initialized!");
}
peers = new HashMap<>();
// peers is a JSON object containing a nested object for each peer
JsonObject jsonPeers = getJsonObject(jsonConfig, "peers");
//out("Peers: " + (jsonPeers == null ? "null" : jsonPeers.toString()));
if (jsonPeers != null) {
for (Entry<String, JsonValue> entry : jsonPeers.entrySet()) {
String peerName = entry.getKey();
JsonObject jsonPeer = getJsonValueAsObject(entry.getValue());
if (jsonPeer == null) {
throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName));
}
Node peer = createNode(peerName, jsonPeer, "url");
if (peer == null) {
throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName));
}
peers.put(peerName, peer);
}
}
} | java | private void createAllPeers() throws NetworkConfigurationException {
// Sanity checks
if (peers != null) {
throw new NetworkConfigurationException("INTERNAL ERROR: peers has already been initialized!");
}
peers = new HashMap<>();
// peers is a JSON object containing a nested object for each peer
JsonObject jsonPeers = getJsonObject(jsonConfig, "peers");
//out("Peers: " + (jsonPeers == null ? "null" : jsonPeers.toString()));
if (jsonPeers != null) {
for (Entry<String, JsonValue> entry : jsonPeers.entrySet()) {
String peerName = entry.getKey();
JsonObject jsonPeer = getJsonValueAsObject(entry.getValue());
if (jsonPeer == null) {
throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName));
}
Node peer = createNode(peerName, jsonPeer, "url");
if (peer == null) {
throw new NetworkConfigurationException(format("Error loading config. Invalid peer entry: %s", peerName));
}
peers.put(peerName, peer);
}
}
} | [
"private",
"void",
"createAllPeers",
"(",
")",
"throws",
"NetworkConfigurationException",
"{",
"// Sanity checks",
"if",
"(",
"peers",
"!=",
"null",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"\"INTERNAL ERROR: peers has already been initialized!\"",
")",
";",
"}",
"peers",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"// peers is a JSON object containing a nested object for each peer",
"JsonObject",
"jsonPeers",
"=",
"getJsonObject",
"(",
"jsonConfig",
",",
"\"peers\"",
")",
";",
"//out(\"Peers: \" + (jsonPeers == null ? \"null\" : jsonPeers.toString()));",
"if",
"(",
"jsonPeers",
"!=",
"null",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"JsonValue",
">",
"entry",
":",
"jsonPeers",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"peerName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"JsonObject",
"jsonPeer",
"=",
"getJsonValueAsObject",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"jsonPeer",
"==",
"null",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"format",
"(",
"\"Error loading config. Invalid peer entry: %s\"",
",",
"peerName",
")",
")",
";",
"}",
"Node",
"peer",
"=",
"createNode",
"(",
"peerName",
",",
"jsonPeer",
",",
"\"url\"",
")",
";",
"if",
"(",
"peer",
"==",
"null",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"format",
"(",
"\"Error loading config. Invalid peer entry: %s\"",
",",
"peerName",
")",
")",
";",
"}",
"peers",
".",
"put",
"(",
"peerName",
",",
"peer",
")",
";",
"}",
"}",
"}"
] | Creates Node instances representing all the peers defined in the config file | [
"Creates",
"Node",
"instances",
"representing",
"all",
"the",
"peers",
"defined",
"in",
"the",
"config",
"file"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java#L534-L566 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/ManagedPropertyPersistenceHelper.java | ManagedPropertyPersistenceHelper.generateParamSerializer | public static void generateParamSerializer(BindTypeContext context, String propertyName, TypeName parameterTypeName, PersistType persistType) {
"""
Generate param serializer.
@param context the context
@param propertyName the property name
@param parameterTypeName the parameter type name
@param persistType the persist type
"""
propertyName = SQLiteDaoDefinition.PARAM_SERIALIZER_PREFIX + propertyName;
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(propertyName).addJavadoc("for param $L serialization\n", propertyName).addParameter(ParameterSpec.builder(parameterTypeName, "value").build());
methodBuilder.addModifiers(context.modifiers);
switch (persistType) {
case STRING:
methodBuilder.returns(className(String.class));
break;
case BYTE:
methodBuilder.returns(TypeUtility.arrayTypeName(Byte.TYPE));
break;
}
methodBuilder.beginControlFlow("if (value==null)");
methodBuilder.addStatement("return null");
methodBuilder.endControlFlow();
methodBuilder.addStatement("$T context=$T.jsonBind()", KriptonJsonContext.class, KriptonBinder.class);
methodBuilder.beginControlFlow("try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))", KriptonByteArrayOutputStream.class, KriptonByteArrayOutputStream.class,
JacksonWrapperSerializer.class);
methodBuilder.addStatement("$T jacksonSerializer=wrapper.jacksonGenerator", JsonGenerator.class);
methodBuilder.addStatement("int fieldCount=0");
BindTransform bindTransform = BindTransformer.lookup(parameterTypeName);
String serializerName = "jacksonSerializer";
boolean isInCollection = true;
if (!BindTransformer.isBindedObject(parameterTypeName)) {
methodBuilder.addStatement("$L.writeStartObject()", serializerName);
isInCollection = false;
}
BindProperty property = BindProperty.builder(parameterTypeName).inCollection(isInCollection).elementName(DEFAULT_FIELD_NAME).build();
bindTransform.generateSerializeOnJackson(context, methodBuilder, serializerName, null, "value", property);
if (!BindTransformer.isBindedObject(parameterTypeName)) {
methodBuilder.addStatement("$L.writeEndObject()", serializerName);
}
methodBuilder.addStatement("$L.flush()", serializerName);
switch (persistType) {
case STRING:
methodBuilder.addStatement("return stream.toString()");
break;
case BYTE:
methodBuilder.addStatement("return stream.toByteArray()");
break;
}
methodBuilder.nextControlFlow("catch($T e)", Exception.class);
methodBuilder.addStatement("throw(new $T(e.getMessage()))", KriptonRuntimeException.class);
methodBuilder.endControlFlow();
context.builder.addMethod(methodBuilder.build());
} | java | public static void generateParamSerializer(BindTypeContext context, String propertyName, TypeName parameterTypeName, PersistType persistType) {
propertyName = SQLiteDaoDefinition.PARAM_SERIALIZER_PREFIX + propertyName;
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(propertyName).addJavadoc("for param $L serialization\n", propertyName).addParameter(ParameterSpec.builder(parameterTypeName, "value").build());
methodBuilder.addModifiers(context.modifiers);
switch (persistType) {
case STRING:
methodBuilder.returns(className(String.class));
break;
case BYTE:
methodBuilder.returns(TypeUtility.arrayTypeName(Byte.TYPE));
break;
}
methodBuilder.beginControlFlow("if (value==null)");
methodBuilder.addStatement("return null");
methodBuilder.endControlFlow();
methodBuilder.addStatement("$T context=$T.jsonBind()", KriptonJsonContext.class, KriptonBinder.class);
methodBuilder.beginControlFlow("try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))", KriptonByteArrayOutputStream.class, KriptonByteArrayOutputStream.class,
JacksonWrapperSerializer.class);
methodBuilder.addStatement("$T jacksonSerializer=wrapper.jacksonGenerator", JsonGenerator.class);
methodBuilder.addStatement("int fieldCount=0");
BindTransform bindTransform = BindTransformer.lookup(parameterTypeName);
String serializerName = "jacksonSerializer";
boolean isInCollection = true;
if (!BindTransformer.isBindedObject(parameterTypeName)) {
methodBuilder.addStatement("$L.writeStartObject()", serializerName);
isInCollection = false;
}
BindProperty property = BindProperty.builder(parameterTypeName).inCollection(isInCollection).elementName(DEFAULT_FIELD_NAME).build();
bindTransform.generateSerializeOnJackson(context, methodBuilder, serializerName, null, "value", property);
if (!BindTransformer.isBindedObject(parameterTypeName)) {
methodBuilder.addStatement("$L.writeEndObject()", serializerName);
}
methodBuilder.addStatement("$L.flush()", serializerName);
switch (persistType) {
case STRING:
methodBuilder.addStatement("return stream.toString()");
break;
case BYTE:
methodBuilder.addStatement("return stream.toByteArray()");
break;
}
methodBuilder.nextControlFlow("catch($T e)", Exception.class);
methodBuilder.addStatement("throw(new $T(e.getMessage()))", KriptonRuntimeException.class);
methodBuilder.endControlFlow();
context.builder.addMethod(methodBuilder.build());
} | [
"public",
"static",
"void",
"generateParamSerializer",
"(",
"BindTypeContext",
"context",
",",
"String",
"propertyName",
",",
"TypeName",
"parameterTypeName",
",",
"PersistType",
"persistType",
")",
"{",
"propertyName",
"=",
"SQLiteDaoDefinition",
".",
"PARAM_SERIALIZER_PREFIX",
"+",
"propertyName",
";",
"MethodSpec",
".",
"Builder",
"methodBuilder",
"=",
"MethodSpec",
".",
"methodBuilder",
"(",
"propertyName",
")",
".",
"addJavadoc",
"(",
"\"for param $L serialization\\n\"",
",",
"propertyName",
")",
".",
"addParameter",
"(",
"ParameterSpec",
".",
"builder",
"(",
"parameterTypeName",
",",
"\"value\"",
")",
".",
"build",
"(",
")",
")",
";",
"methodBuilder",
".",
"addModifiers",
"(",
"context",
".",
"modifiers",
")",
";",
"switch",
"(",
"persistType",
")",
"{",
"case",
"STRING",
":",
"methodBuilder",
".",
"returns",
"(",
"className",
"(",
"String",
".",
"class",
")",
")",
";",
"break",
";",
"case",
"BYTE",
":",
"methodBuilder",
".",
"returns",
"(",
"TypeUtility",
".",
"arrayTypeName",
"(",
"Byte",
".",
"TYPE",
")",
")",
";",
"break",
";",
"}",
"methodBuilder",
".",
"beginControlFlow",
"(",
"\"if (value==null)\"",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"return null\"",
")",
";",
"methodBuilder",
".",
"endControlFlow",
"(",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"$T context=$T.jsonBind()\"",
",",
"KriptonJsonContext",
".",
"class",
",",
"KriptonBinder",
".",
"class",
")",
";",
"methodBuilder",
".",
"beginControlFlow",
"(",
"\"try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))\"",
",",
"KriptonByteArrayOutputStream",
".",
"class",
",",
"KriptonByteArrayOutputStream",
".",
"class",
",",
"JacksonWrapperSerializer",
".",
"class",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"$T jacksonSerializer=wrapper.jacksonGenerator\"",
",",
"JsonGenerator",
".",
"class",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"int fieldCount=0\"",
")",
";",
"BindTransform",
"bindTransform",
"=",
"BindTransformer",
".",
"lookup",
"(",
"parameterTypeName",
")",
";",
"String",
"serializerName",
"=",
"\"jacksonSerializer\"",
";",
"boolean",
"isInCollection",
"=",
"true",
";",
"if",
"(",
"!",
"BindTransformer",
".",
"isBindedObject",
"(",
"parameterTypeName",
")",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"\"$L.writeStartObject()\"",
",",
"serializerName",
")",
";",
"isInCollection",
"=",
"false",
";",
"}",
"BindProperty",
"property",
"=",
"BindProperty",
".",
"builder",
"(",
"parameterTypeName",
")",
".",
"inCollection",
"(",
"isInCollection",
")",
".",
"elementName",
"(",
"DEFAULT_FIELD_NAME",
")",
".",
"build",
"(",
")",
";",
"bindTransform",
".",
"generateSerializeOnJackson",
"(",
"context",
",",
"methodBuilder",
",",
"serializerName",
",",
"null",
",",
"\"value\"",
",",
"property",
")",
";",
"if",
"(",
"!",
"BindTransformer",
".",
"isBindedObject",
"(",
"parameterTypeName",
")",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"\"$L.writeEndObject()\"",
",",
"serializerName",
")",
";",
"}",
"methodBuilder",
".",
"addStatement",
"(",
"\"$L.flush()\"",
",",
"serializerName",
")",
";",
"switch",
"(",
"persistType",
")",
"{",
"case",
"STRING",
":",
"methodBuilder",
".",
"addStatement",
"(",
"\"return stream.toString()\"",
")",
";",
"break",
";",
"case",
"BYTE",
":",
"methodBuilder",
".",
"addStatement",
"(",
"\"return stream.toByteArray()\"",
")",
";",
"break",
";",
"}",
"methodBuilder",
".",
"nextControlFlow",
"(",
"\"catch($T e)\"",
",",
"Exception",
".",
"class",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"throw(new $T(e.getMessage()))\"",
",",
"KriptonRuntimeException",
".",
"class",
")",
";",
"methodBuilder",
".",
"endControlFlow",
"(",
")",
";",
"context",
".",
"builder",
".",
"addMethod",
"(",
"methodBuilder",
".",
"build",
"(",
")",
")",
";",
"}"
] | Generate param serializer.
@param context the context
@param propertyName the property name
@param parameterTypeName the parameter type name
@param persistType the persist type | [
"Generate",
"param",
"serializer",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/ManagedPropertyPersistenceHelper.java#L244-L303 |
tvesalainen/lpg | src/main/java/org/vesalainen/grammar/state/NFAState.java | NFAState.epsilonClosure | public Set<NFAState<T>> epsilonClosure(Scope<DFAState<T>> scope) {
"""
Creates a dfa state from all nfa states that can be reached from this state
with epsilon move.
@param scope
@return
"""
Set<NFAState<T>> set = new HashSet<>();
set.add(this);
return epsilonClosure(scope, set);
} | java | public Set<NFAState<T>> epsilonClosure(Scope<DFAState<T>> scope)
{
Set<NFAState<T>> set = new HashSet<>();
set.add(this);
return epsilonClosure(scope, set);
} | [
"public",
"Set",
"<",
"NFAState",
"<",
"T",
">",
">",
"epsilonClosure",
"(",
"Scope",
"<",
"DFAState",
"<",
"T",
">",
">",
"scope",
")",
"{",
"Set",
"<",
"NFAState",
"<",
"T",
">>",
"set",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"set",
".",
"add",
"(",
"this",
")",
";",
"return",
"epsilonClosure",
"(",
"scope",
",",
"set",
")",
";",
"}"
] | Creates a dfa state from all nfa states that can be reached from this state
with epsilon move.
@param scope
@return | [
"Creates",
"a",
"dfa",
"state",
"from",
"all",
"nfa",
"states",
"that",
"can",
"be",
"reached",
"from",
"this",
"state",
"with",
"epsilon",
"move",
"."
] | train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/grammar/state/NFAState.java#L431-L436 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java | Line.set | public void set(Vector2f start, Vector2f end) {
"""
Configure the line
@param start
The start point of the line
@param end
The end point of the line
"""
super.pointsDirty = true;
if (this.start == null) {
this.start = new Vector2f();
}
this.start.set(start);
if (this.end == null) {
this.end = new Vector2f();
}
this.end.set(end);
vec = new Vector2f(end);
vec.sub(start);
lenSquared = vec.lengthSquared();
} | java | public void set(Vector2f start, Vector2f end) {
super.pointsDirty = true;
if (this.start == null) {
this.start = new Vector2f();
}
this.start.set(start);
if (this.end == null) {
this.end = new Vector2f();
}
this.end.set(end);
vec = new Vector2f(end);
vec.sub(start);
lenSquared = vec.lengthSquared();
} | [
"public",
"void",
"set",
"(",
"Vector2f",
"start",
",",
"Vector2f",
"end",
")",
"{",
"super",
".",
"pointsDirty",
"=",
"true",
";",
"if",
"(",
"this",
".",
"start",
"==",
"null",
")",
"{",
"this",
".",
"start",
"=",
"new",
"Vector2f",
"(",
")",
";",
"}",
"this",
".",
"start",
".",
"set",
"(",
"start",
")",
";",
"if",
"(",
"this",
".",
"end",
"==",
"null",
")",
"{",
"this",
".",
"end",
"=",
"new",
"Vector2f",
"(",
")",
";",
"}",
"this",
".",
"end",
".",
"set",
"(",
"end",
")",
";",
"vec",
"=",
"new",
"Vector2f",
"(",
"end",
")",
";",
"vec",
".",
"sub",
"(",
"start",
")",
";",
"lenSquared",
"=",
"vec",
".",
"lengthSquared",
"(",
")",
";",
"}"
] | Configure the line
@param start
The start point of the line
@param end
The end point of the line | [
"Configure",
"the",
"line"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java#L185-L201 |
cvut/JCOP | src/main/java/cz/cvut/felk/cig/jcop/problem/sat/SAT.java | SAT.initCommons | protected void initCommons() {
"""
Initializes common attributes such as operations and default fitness.
<p/>
Requires {@link #formula}/{@link #variables} to be already fully loaded.
"""
this.setTrueOperations = new ArrayList<SetTrueOperation>(this.dimension);
this.setFalseOperations = new ArrayList<SetFalseOperation>(this.dimension);
SetTrueOperation setTrueOperation;
SetFalseOperation setFalseOperation;
for (int i = 0; i < this.dimension; ++i) {
setTrueOperation = new SetTrueOperation(this.variables.get(i));
setFalseOperation = new SetFalseOperation(this.variables.get(i));
setTrueOperation.setReverse(setFalseOperation);
setFalseOperation.setReverse(setTrueOperation);
this.setTrueOperations.add(setTrueOperation);
this.setFalseOperations.add(setFalseOperation);
}
// create starting configuration
List<Integer> tmp = new ArrayList<Integer>(this.dimension);
for (int i = 0; i < this.dimension; ++i) tmp.add(0);
this.startingConfiguration = new Configuration(tmp, "Empty SAT created");
} | java | protected void initCommons() {
this.setTrueOperations = new ArrayList<SetTrueOperation>(this.dimension);
this.setFalseOperations = new ArrayList<SetFalseOperation>(this.dimension);
SetTrueOperation setTrueOperation;
SetFalseOperation setFalseOperation;
for (int i = 0; i < this.dimension; ++i) {
setTrueOperation = new SetTrueOperation(this.variables.get(i));
setFalseOperation = new SetFalseOperation(this.variables.get(i));
setTrueOperation.setReverse(setFalseOperation);
setFalseOperation.setReverse(setTrueOperation);
this.setTrueOperations.add(setTrueOperation);
this.setFalseOperations.add(setFalseOperation);
}
// create starting configuration
List<Integer> tmp = new ArrayList<Integer>(this.dimension);
for (int i = 0; i < this.dimension; ++i) tmp.add(0);
this.startingConfiguration = new Configuration(tmp, "Empty SAT created");
} | [
"protected",
"void",
"initCommons",
"(",
")",
"{",
"this",
".",
"setTrueOperations",
"=",
"new",
"ArrayList",
"<",
"SetTrueOperation",
">",
"(",
"this",
".",
"dimension",
")",
";",
"this",
".",
"setFalseOperations",
"=",
"new",
"ArrayList",
"<",
"SetFalseOperation",
">",
"(",
"this",
".",
"dimension",
")",
";",
"SetTrueOperation",
"setTrueOperation",
";",
"SetFalseOperation",
"setFalseOperation",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"dimension",
";",
"++",
"i",
")",
"{",
"setTrueOperation",
"=",
"new",
"SetTrueOperation",
"(",
"this",
".",
"variables",
".",
"get",
"(",
"i",
")",
")",
";",
"setFalseOperation",
"=",
"new",
"SetFalseOperation",
"(",
"this",
".",
"variables",
".",
"get",
"(",
"i",
")",
")",
";",
"setTrueOperation",
".",
"setReverse",
"(",
"setFalseOperation",
")",
";",
"setFalseOperation",
".",
"setReverse",
"(",
"setTrueOperation",
")",
";",
"this",
".",
"setTrueOperations",
".",
"add",
"(",
"setTrueOperation",
")",
";",
"this",
".",
"setFalseOperations",
".",
"add",
"(",
"setFalseOperation",
")",
";",
"}",
"// create starting configuration",
"List",
"<",
"Integer",
">",
"tmp",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
"this",
".",
"dimension",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"dimension",
";",
"++",
"i",
")",
"tmp",
".",
"(",
"0",
")",
";",
"this",
".",
"startingConfiguration",
"=",
"new",
"Configuration",
"(",
"tmp",
",",
"\"Empty SAT created\"",
")",
";",
"}"
] | Initializes common attributes such as operations and default fitness.
<p/>
Requires {@link #formula}/{@link #variables} to be already fully loaded. | [
"Initializes",
"common",
"attributes",
"such",
"as",
"operations",
"and",
"default",
"fitness",
".",
"<p",
"/",
">",
"Requires",
"{"
] | train | https://github.com/cvut/JCOP/blob/2ec18315a9a452e5f4e3d07cccfde0310adc465a/src/main/java/cz/cvut/felk/cig/jcop/problem/sat/SAT.java#L180-L197 |
GoogleCloudPlatform/bigdata-interop | gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/auth/AbstractDelegationTokenBinding.java | AbstractDelegationTokenBinding.bindToFileSystem | public void bindToFileSystem(GoogleHadoopFileSystemBase fs, Text service) {
"""
Bind to the filesystem. Subclasses can use this to perform their own binding operations - but
they must always call their superclass implementation. This <i>Must</i> be called before
calling {@code init()}.
<p><b>Important:</b> This binding will happen during FileSystem.initialize(); the FS is not
live for actual use and will not yet have interacted with GCS services.
@param fs owning FS.
@param service name of the service (i.e. bucket name) for the FS.
"""
this.fileSystem = requireNonNull(fs);
this.service = requireNonNull(service);
} | java | public void bindToFileSystem(GoogleHadoopFileSystemBase fs, Text service) {
this.fileSystem = requireNonNull(fs);
this.service = requireNonNull(service);
} | [
"public",
"void",
"bindToFileSystem",
"(",
"GoogleHadoopFileSystemBase",
"fs",
",",
"Text",
"service",
")",
"{",
"this",
".",
"fileSystem",
"=",
"requireNonNull",
"(",
"fs",
")",
";",
"this",
".",
"service",
"=",
"requireNonNull",
"(",
"service",
")",
";",
"}"
] | Bind to the filesystem. Subclasses can use this to perform their own binding operations - but
they must always call their superclass implementation. This <i>Must</i> be called before
calling {@code init()}.
<p><b>Important:</b> This binding will happen during FileSystem.initialize(); the FS is not
live for actual use and will not yet have interacted with GCS services.
@param fs owning FS.
@param service name of the service (i.e. bucket name) for the FS. | [
"Bind",
"to",
"the",
"filesystem",
".",
"Subclasses",
"can",
"use",
"this",
"to",
"perform",
"their",
"own",
"binding",
"operations",
"-",
"but",
"they",
"must",
"always",
"call",
"their",
"superclass",
"implementation",
".",
"This",
"<i",
">",
"Must<",
"/",
"i",
">",
"be",
"called",
"before",
"calling",
"{",
"@code",
"init",
"()",
"}",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/auth/AbstractDelegationTokenBinding.java#L94-L97 |
Samsung/GearVRf | GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/TimeSensor.java | TimeSensor.setEnabled | public void setEnabled(boolean enable, GVRContext gvrContext) {
"""
setEnabled will set the TimeSensor enable variable.
if true, then it will started the animation
if fase, then it changes repeat mode to ONCE so the animation will conclude.
There is no simple stop() animation
@param enable
@param gvrContext
"""
if (this.enabled != enabled ) {
// a change in the animation stopping / starting
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
if (enable) gvrKeyFrameAnimation.start(gvrContext.getAnimationEngine());
else {
gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.ONCE);
}
}
this.enabled = enable;
}
} | java | public void setEnabled(boolean enable, GVRContext gvrContext) {
if (this.enabled != enabled ) {
// a change in the animation stopping / starting
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
if (enable) gvrKeyFrameAnimation.start(gvrContext.getAnimationEngine());
else {
gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.ONCE);
}
}
this.enabled = enable;
}
} | [
"public",
"void",
"setEnabled",
"(",
"boolean",
"enable",
",",
"GVRContext",
"gvrContext",
")",
"{",
"if",
"(",
"this",
".",
"enabled",
"!=",
"enabled",
")",
"{",
"// a change in the animation stopping / starting",
"for",
"(",
"GVRNodeAnimation",
"gvrKeyFrameAnimation",
":",
"gvrKeyFrameAnimations",
")",
"{",
"if",
"(",
"enable",
")",
"gvrKeyFrameAnimation",
".",
"start",
"(",
"gvrContext",
".",
"getAnimationEngine",
"(",
")",
")",
";",
"else",
"{",
"gvrKeyFrameAnimation",
".",
"setRepeatMode",
"(",
"GVRRepeatMode",
".",
"ONCE",
")",
";",
"}",
"}",
"this",
".",
"enabled",
"=",
"enable",
";",
"}",
"}"
] | setEnabled will set the TimeSensor enable variable.
if true, then it will started the animation
if fase, then it changes repeat mode to ONCE so the animation will conclude.
There is no simple stop() animation
@param enable
@param gvrContext | [
"setEnabled",
"will",
"set",
"the",
"TimeSensor",
"enable",
"variable",
".",
"if",
"true",
"then",
"it",
"will",
"started",
"the",
"animation",
"if",
"fase",
"then",
"it",
"changes",
"repeat",
"mode",
"to",
"ONCE",
"so",
"the",
"animation",
"will",
"conclude",
".",
"There",
"is",
"no",
"simple",
"stop",
"()",
"animation"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/TimeSensor.java#L76-L87 |
MenoData/Time4J | base/src/main/java/net/time4j/engine/Chronology.java | Chronology.getRule | <V> ElementRule<T, V> getRule(ChronoElement<V> element) {
"""
<p>Bestimmt eine chronologische Regel zum angegebenen Element. </p>
@param <V> Elementwerttyp
@param element chronologisches Element
@return Regelobjekt
@throws RuleNotFoundException if given element is not registered in
this chronology and there is also no element rule which can
be derived from element
"""
if (element == null) {
throw new NullPointerException("Missing chronological element.");
}
ElementRule<?, ?> rule = this.ruleMap.get(element);
if (rule == null) {
rule = this.getDerivedRule(element, true);
if (rule == null) {
throw new RuleNotFoundException(this, element);
}
}
return cast(rule); // type-safe
} | java | <V> ElementRule<T, V> getRule(ChronoElement<V> element) {
if (element == null) {
throw new NullPointerException("Missing chronological element.");
}
ElementRule<?, ?> rule = this.ruleMap.get(element);
if (rule == null) {
rule = this.getDerivedRule(element, true);
if (rule == null) {
throw new RuleNotFoundException(this, element);
}
}
return cast(rule); // type-safe
} | [
"<",
"V",
">",
"ElementRule",
"<",
"T",
",",
"V",
">",
"getRule",
"(",
"ChronoElement",
"<",
"V",
">",
"element",
")",
"{",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Missing chronological element.\"",
")",
";",
"}",
"ElementRule",
"<",
"?",
",",
"?",
">",
"rule",
"=",
"this",
".",
"ruleMap",
".",
"get",
"(",
"element",
")",
";",
"if",
"(",
"rule",
"==",
"null",
")",
"{",
"rule",
"=",
"this",
".",
"getDerivedRule",
"(",
"element",
",",
"true",
")",
";",
"if",
"(",
"rule",
"==",
"null",
")",
"{",
"throw",
"new",
"RuleNotFoundException",
"(",
"this",
",",
"element",
")",
";",
"}",
"}",
"return",
"cast",
"(",
"rule",
")",
";",
"// type-safe",
"}"
] | <p>Bestimmt eine chronologische Regel zum angegebenen Element. </p>
@param <V> Elementwerttyp
@param element chronologisches Element
@return Regelobjekt
@throws RuleNotFoundException if given element is not registered in
this chronology and there is also no element rule which can
be derived from element | [
"<p",
">",
"Bestimmt",
"eine",
"chronologische",
"Regel",
"zum",
"angegebenen",
"Element",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/engine/Chronology.java#L471-L489 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-core/src/main/java/com/ibm/cloud/objectstorage/util/ComparableUtils.java | ComparableUtils.safeCompare | public static <T> int safeCompare(Comparable<T> d1, T d2) {
"""
Does a safe comparison of two {@link Comparable} objects accounting for nulls
@param d1
First object
@param d2
Second object
@return A positive number if the object double is larger, a negative number if the second
object is larger, or 0 if they are equal. Null is considered less than any non-null
value
"""
if (d1 != null && d2 != null) {
return d1.compareTo(d2);
} else if (d1 == null && d2 != null) {
return -1;
} else if (d1 != null && d2 == null) {
return 1;
} else {
return 0;
}
} | java | public static <T> int safeCompare(Comparable<T> d1, T d2) {
if (d1 != null && d2 != null) {
return d1.compareTo(d2);
} else if (d1 == null && d2 != null) {
return -1;
} else if (d1 != null && d2 == null) {
return 1;
} else {
return 0;
}
} | [
"public",
"static",
"<",
"T",
">",
"int",
"safeCompare",
"(",
"Comparable",
"<",
"T",
">",
"d1",
",",
"T",
"d2",
")",
"{",
"if",
"(",
"d1",
"!=",
"null",
"&&",
"d2",
"!=",
"null",
")",
"{",
"return",
"d1",
".",
"compareTo",
"(",
"d2",
")",
";",
"}",
"else",
"if",
"(",
"d1",
"==",
"null",
"&&",
"d2",
"!=",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"d1",
"!=",
"null",
"&&",
"d2",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | Does a safe comparison of two {@link Comparable} objects accounting for nulls
@param d1
First object
@param d2
Second object
@return A positive number if the object double is larger, a negative number if the second
object is larger, or 0 if they are equal. Null is considered less than any non-null
value | [
"Does",
"a",
"safe",
"comparison",
"of",
"two",
"{",
"@link",
"Comparable",
"}",
"objects",
"accounting",
"for",
"nulls"
] | train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-core/src/main/java/com/ibm/cloud/objectstorage/util/ComparableUtils.java#L30-L40 |
eurekaclinical/protempa | protempa-framework/src/main/java/org/protempa/proposition/interval/Relation.java | Relation.hasRelation | public boolean hasRelation(Interval interval1, Interval interval2) {
"""
Determines whether the given intervals have this relation.
@param interval1
the left-hand-side {@link Interval}.
@param interval2
the right-hand-side {@link Interval}.
@return <code>true</code> if the intervals have this relation,
<code>false</code> otherwise. Returns <code>false</code> if any
<code>null</code> arguments are given.
"""
if (interval1 == null || interval2 == null) {
return false;
}
Long minStart1 = interval1.getMinimumStart();
Long maxStart1 = interval1.getMaximumStart();
Long minFinish1 = interval1.getMinimumFinish();
Long maxFinish1 = interval1.getMaximumFinish();
Long minStart2 = interval2.getMinimumStart();
Long maxStart2 = interval2.getMaximumStart();
Long minFinish2 = interval2.getMinimumFinish();
Long maxFinish2 = interval2.getMaximumFinish();
return evenHasRelationCheck(0, minStart1, minStart2)
&& oddHasRelationCheck(1, maxStart1, maxStart2)
&& evenHasRelationCheck(2, minStart1, minFinish2)
&& oddHasRelationCheck(3, maxStart1, maxFinish2)
&& evenHasRelationCheck(4, minFinish1, minStart2)
&& oddHasRelationCheck(5, maxFinish1, maxStart2)
&& evenHasRelationCheck(6, minFinish1, minFinish2)
&& oddHasRelationCheck(7, maxFinish1, maxFinish2);
} | java | public boolean hasRelation(Interval interval1, Interval interval2) {
if (interval1 == null || interval2 == null) {
return false;
}
Long minStart1 = interval1.getMinimumStart();
Long maxStart1 = interval1.getMaximumStart();
Long minFinish1 = interval1.getMinimumFinish();
Long maxFinish1 = interval1.getMaximumFinish();
Long minStart2 = interval2.getMinimumStart();
Long maxStart2 = interval2.getMaximumStart();
Long minFinish2 = interval2.getMinimumFinish();
Long maxFinish2 = interval2.getMaximumFinish();
return evenHasRelationCheck(0, minStart1, minStart2)
&& oddHasRelationCheck(1, maxStart1, maxStart2)
&& evenHasRelationCheck(2, minStart1, minFinish2)
&& oddHasRelationCheck(3, maxStart1, maxFinish2)
&& evenHasRelationCheck(4, minFinish1, minStart2)
&& oddHasRelationCheck(5, maxFinish1, maxStart2)
&& evenHasRelationCheck(6, minFinish1, minFinish2)
&& oddHasRelationCheck(7, maxFinish1, maxFinish2);
} | [
"public",
"boolean",
"hasRelation",
"(",
"Interval",
"interval1",
",",
"Interval",
"interval2",
")",
"{",
"if",
"(",
"interval1",
"==",
"null",
"||",
"interval2",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"Long",
"minStart1",
"=",
"interval1",
".",
"getMinimumStart",
"(",
")",
";",
"Long",
"maxStart1",
"=",
"interval1",
".",
"getMaximumStart",
"(",
")",
";",
"Long",
"minFinish1",
"=",
"interval1",
".",
"getMinimumFinish",
"(",
")",
";",
"Long",
"maxFinish1",
"=",
"interval1",
".",
"getMaximumFinish",
"(",
")",
";",
"Long",
"minStart2",
"=",
"interval2",
".",
"getMinimumStart",
"(",
")",
";",
"Long",
"maxStart2",
"=",
"interval2",
".",
"getMaximumStart",
"(",
")",
";",
"Long",
"minFinish2",
"=",
"interval2",
".",
"getMinimumFinish",
"(",
")",
";",
"Long",
"maxFinish2",
"=",
"interval2",
".",
"getMaximumFinish",
"(",
")",
";",
"return",
"evenHasRelationCheck",
"(",
"0",
",",
"minStart1",
",",
"minStart2",
")",
"&&",
"oddHasRelationCheck",
"(",
"1",
",",
"maxStart1",
",",
"maxStart2",
")",
"&&",
"evenHasRelationCheck",
"(",
"2",
",",
"minStart1",
",",
"minFinish2",
")",
"&&",
"oddHasRelationCheck",
"(",
"3",
",",
"maxStart1",
",",
"maxFinish2",
")",
"&&",
"evenHasRelationCheck",
"(",
"4",
",",
"minFinish1",
",",
"minStart2",
")",
"&&",
"oddHasRelationCheck",
"(",
"5",
",",
"maxFinish1",
",",
"maxStart2",
")",
"&&",
"evenHasRelationCheck",
"(",
"6",
",",
"minFinish1",
",",
"minFinish2",
")",
"&&",
"oddHasRelationCheck",
"(",
"7",
",",
"maxFinish1",
",",
"maxFinish2",
")",
";",
"}"
] | Determines whether the given intervals have this relation.
@param interval1
the left-hand-side {@link Interval}.
@param interval2
the right-hand-side {@link Interval}.
@return <code>true</code> if the intervals have this relation,
<code>false</code> otherwise. Returns <code>false</code> if any
<code>null</code> arguments are given. | [
"Determines",
"whether",
"the",
"given",
"intervals",
"have",
"this",
"relation",
"."
] | train | https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/interval/Relation.java#L288-L308 |
openengsb/openengsb | connector/userprojectsldap/src/main/java/org/openengsb/connector/userprojects/ldap/internal/ldap/Utils.java | Utils.extractAttributeValueNoEmptyCheck | public static String extractAttributeValueNoEmptyCheck(Entry entry, String attributeType) {
"""
Returns the value of the attribute of attributeType from entry.
"""
Attribute attribute = entry.get(attributeType);
if (attribute == null) {
return null;
}
try {
return attribute.getString();
} catch (LdapInvalidAttributeValueException e) {
throw new LdapRuntimeException(e);
}
} | java | public static String extractAttributeValueNoEmptyCheck(Entry entry, String attributeType) {
Attribute attribute = entry.get(attributeType);
if (attribute == null) {
return null;
}
try {
return attribute.getString();
} catch (LdapInvalidAttributeValueException e) {
throw new LdapRuntimeException(e);
}
} | [
"public",
"static",
"String",
"extractAttributeValueNoEmptyCheck",
"(",
"Entry",
"entry",
",",
"String",
"attributeType",
")",
"{",
"Attribute",
"attribute",
"=",
"entry",
".",
"get",
"(",
"attributeType",
")",
";",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"attribute",
".",
"getString",
"(",
")",
";",
"}",
"catch",
"(",
"LdapInvalidAttributeValueException",
"e",
")",
"{",
"throw",
"new",
"LdapRuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Returns the value of the attribute of attributeType from entry. | [
"Returns",
"the",
"value",
"of",
"the",
"attribute",
"of",
"attributeType",
"from",
"entry",
"."
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/connector/userprojectsldap/src/main/java/org/openengsb/connector/userprojects/ldap/internal/ldap/Utils.java#L55-L65 |
LearnLib/learnlib | oracles/membership-oracles/src/main/java/de/learnlib/oracle/membership/SimulatorOmegaOracle.java | SimulatorOmegaOracle.isSameState | @Override
public boolean isSameState(Word<I> input1, S s1, Word<I> input2, S s2) {
"""
Test for state equivalence by simply invoking {@link Object#equals(Object)}.
@see OmegaMembershipOracle#isSameState(Word, Object, Word, Object)
"""
return s1.equals(s2);
} | java | @Override
public boolean isSameState(Word<I> input1, S s1, Word<I> input2, S s2) {
return s1.equals(s2);
} | [
"@",
"Override",
"public",
"boolean",
"isSameState",
"(",
"Word",
"<",
"I",
">",
"input1",
",",
"S",
"s1",
",",
"Word",
"<",
"I",
">",
"input2",
",",
"S",
"s2",
")",
"{",
"return",
"s1",
".",
"equals",
"(",
"s2",
")",
";",
"}"
] | Test for state equivalence by simply invoking {@link Object#equals(Object)}.
@see OmegaMembershipOracle#isSameState(Word, Object, Word, Object) | [
"Test",
"for",
"state",
"equivalence",
"by",
"simply",
"invoking",
"{",
"@link",
"Object#equals",
"(",
"Object",
")",
"}",
"."
] | train | https://github.com/LearnLib/learnlib/blob/fa38a14adcc0664099f180d671ffa42480318d7b/oracles/membership-oracles/src/main/java/de/learnlib/oracle/membership/SimulatorOmegaOracle.java#L92-L95 |
bbottema/outlook-message-parser | src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java | OutlookMessageParser.analyzeDocumentEntry | private OutlookFieldInformation analyzeDocumentEntry(final DocumentEntry de) {
"""
Analyzes the {@link DocumentEntry} and returns
a {@link OutlookFieldInformation} object containing the
class (the field name, so to say) and type of
the entry.
@param de The {@link DocumentEntry} that should be examined.
@return A {@link OutlookFieldInformation} object containing class and type of the document entry or, if the entry is not an interesting field, an empty
{@link OutlookFieldInformation} object containing {@link OutlookFieldInformation#UNKNOWN} class and type.
"""
final String name = de.getName();
// we are only interested in document entries
// with names starting with __substg1.
LOGGER.trace("Document entry: {}", name);
if (name.startsWith(PROPERTY_STREAM_PREFIX)) {
final String clazz;
final String type;
final int mapiType;
try {
final String val = name.substring(PROPERTY_STREAM_PREFIX.length()).toLowerCase();
// the first 4 digits of the remainder
// defines the field class (or field name)
// and the last 4 digits indicate the
// data type.
clazz = val.substring(0, 4);
type = val.substring(4);
LOGGER.trace(" Found document entry: class={}, type={}", clazz, type);
mapiType = Integer.parseInt(type, 16);
} catch (final RuntimeException re) {
LOGGER.error("Could not parse directory entry {}", name, re);
return new OutlookFieldInformation();
}
return new OutlookFieldInformation(clazz, mapiType);
} else {
LOGGER.trace("Ignoring entry with name {}", name);
}
// we are not interested in the field
// and return an empty OutlookFieldInformation object
return new OutlookFieldInformation();
} | java | private OutlookFieldInformation analyzeDocumentEntry(final DocumentEntry de) {
final String name = de.getName();
// we are only interested in document entries
// with names starting with __substg1.
LOGGER.trace("Document entry: {}", name);
if (name.startsWith(PROPERTY_STREAM_PREFIX)) {
final String clazz;
final String type;
final int mapiType;
try {
final String val = name.substring(PROPERTY_STREAM_PREFIX.length()).toLowerCase();
// the first 4 digits of the remainder
// defines the field class (or field name)
// and the last 4 digits indicate the
// data type.
clazz = val.substring(0, 4);
type = val.substring(4);
LOGGER.trace(" Found document entry: class={}, type={}", clazz, type);
mapiType = Integer.parseInt(type, 16);
} catch (final RuntimeException re) {
LOGGER.error("Could not parse directory entry {}", name, re);
return new OutlookFieldInformation();
}
return new OutlookFieldInformation(clazz, mapiType);
} else {
LOGGER.trace("Ignoring entry with name {}", name);
}
// we are not interested in the field
// and return an empty OutlookFieldInformation object
return new OutlookFieldInformation();
} | [
"private",
"OutlookFieldInformation",
"analyzeDocumentEntry",
"(",
"final",
"DocumentEntry",
"de",
")",
"{",
"final",
"String",
"name",
"=",
"de",
".",
"getName",
"(",
")",
";",
"// we are only interested in document entries",
"// with names starting with __substg1.",
"LOGGER",
".",
"trace",
"(",
"\"Document entry: {}\"",
",",
"name",
")",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"PROPERTY_STREAM_PREFIX",
")",
")",
"{",
"final",
"String",
"clazz",
";",
"final",
"String",
"type",
";",
"final",
"int",
"mapiType",
";",
"try",
"{",
"final",
"String",
"val",
"=",
"name",
".",
"substring",
"(",
"PROPERTY_STREAM_PREFIX",
".",
"length",
"(",
")",
")",
".",
"toLowerCase",
"(",
")",
";",
"// the first 4 digits of the remainder",
"// defines the field class (or field name)",
"// and the last 4 digits indicate the",
"// data type.",
"clazz",
"=",
"val",
".",
"substring",
"(",
"0",
",",
"4",
")",
";",
"type",
"=",
"val",
".",
"substring",
"(",
"4",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\" Found document entry: class={}, type={}\"",
",",
"clazz",
",",
"type",
")",
";",
"mapiType",
"=",
"Integer",
".",
"parseInt",
"(",
"type",
",",
"16",
")",
";",
"}",
"catch",
"(",
"final",
"RuntimeException",
"re",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Could not parse directory entry {}\"",
",",
"name",
",",
"re",
")",
";",
"return",
"new",
"OutlookFieldInformation",
"(",
")",
";",
"}",
"return",
"new",
"OutlookFieldInformation",
"(",
"clazz",
",",
"mapiType",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"trace",
"(",
"\"Ignoring entry with name {}\"",
",",
"name",
")",
";",
"}",
"// we are not interested in the field",
"// and return an empty OutlookFieldInformation object",
"return",
"new",
"OutlookFieldInformation",
"(",
")",
";",
"}"
] | Analyzes the {@link DocumentEntry} and returns
a {@link OutlookFieldInformation} object containing the
class (the field name, so to say) and type of
the entry.
@param de The {@link DocumentEntry} that should be examined.
@return A {@link OutlookFieldInformation} object containing class and type of the document entry or, if the entry is not an interesting field, an empty
{@link OutlookFieldInformation} object containing {@link OutlookFieldInformation#UNKNOWN} class and type. | [
"Analyzes",
"the",
"{",
"@link",
"DocumentEntry",
"}",
"and",
"returns",
"a",
"{",
"@link",
"OutlookFieldInformation",
"}",
"object",
"containing",
"the",
"class",
"(",
"the",
"field",
"name",
"so",
"to",
"say",
")",
"and",
"type",
"of",
"the",
"entry",
"."
] | train | https://github.com/bbottema/outlook-message-parser/blob/ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java#L520-L550 |
j256/ormlite-core | src/main/java/com/j256/ormlite/dao/DaoManager.java | DaoManager.unregisterDao | public static synchronized void unregisterDao(ConnectionSource connectionSource, Dao<?, ?> dao) {
"""
Remove a DAO from the cache. This is necessary if we've registered it already but it throws an exception during
configuration.
"""
if (connectionSource == null) {
throw new IllegalArgumentException("connectionSource argument cannot be null");
}
removeDaoToClassMap(new ClassConnectionSource(connectionSource, dao.getDataClass()));
} | java | public static synchronized void unregisterDao(ConnectionSource connectionSource, Dao<?, ?> dao) {
if (connectionSource == null) {
throw new IllegalArgumentException("connectionSource argument cannot be null");
}
removeDaoToClassMap(new ClassConnectionSource(connectionSource, dao.getDataClass()));
} | [
"public",
"static",
"synchronized",
"void",
"unregisterDao",
"(",
"ConnectionSource",
"connectionSource",
",",
"Dao",
"<",
"?",
",",
"?",
">",
"dao",
")",
"{",
"if",
"(",
"connectionSource",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"connectionSource argument cannot be null\"",
")",
";",
"}",
"removeDaoToClassMap",
"(",
"new",
"ClassConnectionSource",
"(",
"connectionSource",
",",
"dao",
".",
"getDataClass",
"(",
")",
")",
")",
";",
"}"
] | Remove a DAO from the cache. This is necessary if we've registered it already but it throws an exception during
configuration. | [
"Remove",
"a",
"DAO",
"from",
"the",
"cache",
".",
"This",
"is",
"necessary",
"if",
"we",
"ve",
"registered",
"it",
"already",
"but",
"it",
"throws",
"an",
"exception",
"during",
"configuration",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/dao/DaoManager.java#L179-L184 |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java | PersistentPageFile.readPage | @Override
public P readPage(int pageID) {
"""
Reads the page with the given id from this file.
@param pageID the id of the page to be returned
@return the page with the given pageId
"""
try {
countRead();
long offset = ((long) (header.getReservedPages() + pageID)) * (long) pageSize;
byte[] buffer = new byte[pageSize];
file.seek(offset);
file.read(buffer);
return byteArrayToPage(buffer);
}
catch(IOException e) {
throw new RuntimeException("IOException occurred during reading of page " + pageID + "\n", e);
}
} | java | @Override
public P readPage(int pageID) {
try {
countRead();
long offset = ((long) (header.getReservedPages() + pageID)) * (long) pageSize;
byte[] buffer = new byte[pageSize];
file.seek(offset);
file.read(buffer);
return byteArrayToPage(buffer);
}
catch(IOException e) {
throw new RuntimeException("IOException occurred during reading of page " + pageID + "\n", e);
}
} | [
"@",
"Override",
"public",
"P",
"readPage",
"(",
"int",
"pageID",
")",
"{",
"try",
"{",
"countRead",
"(",
")",
";",
"long",
"offset",
"=",
"(",
"(",
"long",
")",
"(",
"header",
".",
"getReservedPages",
"(",
")",
"+",
"pageID",
")",
")",
"*",
"(",
"long",
")",
"pageSize",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"pageSize",
"]",
";",
"file",
".",
"seek",
"(",
"offset",
")",
";",
"file",
".",
"read",
"(",
"buffer",
")",
";",
"return",
"byteArrayToPage",
"(",
"buffer",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"IOException occurred during reading of page \"",
"+",
"pageID",
"+",
"\"\\n\"",
",",
"e",
")",
";",
"}",
"}"
] | Reads the page with the given id from this file.
@param pageID the id of the page to be returned
@return the page with the given pageId | [
"Reads",
"the",
"page",
"with",
"the",
"given",
"id",
"from",
"this",
"file",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java#L112-L125 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/util/EventListenerListHelper.java | EventListenerListHelper.fire | public void fire(String methodName, Object arg) {
"""
Invokes the method with the given name and a single parameter on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg the single argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and a single formal
parameter exists on the listener class managed by this list helper.
"""
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg });
}
} | java | public void fire(String methodName, Object arg) {
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg });
}
} | [
"public",
"void",
"fire",
"(",
"String",
"methodName",
",",
"Object",
"arg",
")",
"{",
"if",
"(",
"listeners",
"!=",
"EMPTY_OBJECT_ARRAY",
")",
"{",
"fireEventByReflection",
"(",
"methodName",
",",
"new",
"Object",
"[",
"]",
"{",
"arg",
"}",
")",
";",
"}",
"}"
] | Invokes the method with the given name and a single parameter on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg the single argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and a single formal
parameter exists on the listener class managed by this list helper. | [
"Invokes",
"the",
"method",
"with",
"the",
"given",
"name",
"and",
"a",
"single",
"parameter",
"on",
"each",
"of",
"the",
"listeners",
"registered",
"with",
"this",
"list",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/EventListenerListHelper.java#L233-L237 |
mguymon/naether | src/main/java/com/tobedevoured/naether/maven/Project.java | Project.toXml | public String toXml() throws ProjectException {
"""
Convert Project to POM XML
@return String
@throws ProjectException exception
"""
log.debug("Writing xml");
Project copy = this;
copy.removeProperty( "project.basedir" );
StringWriter writer = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(writer, copy.mavenModel);
} catch (IOException e) {
throw new ProjectException("Failed to create pom xml", e);
}
writer.flush();
return writer.toString();
} | java | public String toXml() throws ProjectException {
log.debug("Writing xml");
Project copy = this;
copy.removeProperty( "project.basedir" );
StringWriter writer = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(writer, copy.mavenModel);
} catch (IOException e) {
throw new ProjectException("Failed to create pom xml", e);
}
writer.flush();
return writer.toString();
} | [
"public",
"String",
"toXml",
"(",
")",
"throws",
"ProjectException",
"{",
"log",
".",
"debug",
"(",
"\"Writing xml\"",
")",
";",
"Project",
"copy",
"=",
"this",
";",
"copy",
".",
"removeProperty",
"(",
"\"project.basedir\"",
")",
";",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"MavenXpp3Writer",
"pomWriter",
"=",
"new",
"MavenXpp3Writer",
"(",
")",
";",
"try",
"{",
"pomWriter",
".",
"write",
"(",
"writer",
",",
"copy",
".",
"mavenModel",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ProjectException",
"(",
"\"Failed to create pom xml\"",
",",
"e",
")",
";",
"}",
"writer",
".",
"flush",
"(",
")",
";",
"return",
"writer",
".",
"toString",
"(",
")",
";",
"}"
] | Convert Project to POM XML
@return String
@throws ProjectException exception | [
"Convert",
"Project",
"to",
"POM",
"XML"
] | train | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/java/com/tobedevoured/naether/maven/Project.java#L543-L560 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java | MarshallUtil.marshallMap | public static <K, V, T extends Map<K, V>> void marshallMap(T map, ElementWriter<K> keyWriter, ElementWriter<V> valueWrite, ObjectOutput out) throws IOException {
"""
Marshall the {@code map} to the {@code ObjectOutput}.
<p>
{@code null} maps are supported.
@param map {@link Map} to marshall.
@param out {@link ObjectOutput} to write. It must be non-null.
@param <K> Key type of the map.
@param <V> Value type of the map.
@param <T> Type of the {@link Map}.
@throws IOException If any of the usual Input/Output related exceptions occur.
"""
final int mapSize = map == null ? NULL_VALUE : map.size();
marshallSize(out, mapSize);
if (mapSize <= 0) return;
for (Map.Entry<K, V> me : map.entrySet()) {
keyWriter.writeTo(out, me.getKey());
valueWrite.writeTo(out, me.getValue());
}
} | java | public static <K, V, T extends Map<K, V>> void marshallMap(T map, ElementWriter<K> keyWriter, ElementWriter<V> valueWrite, ObjectOutput out) throws IOException {
final int mapSize = map == null ? NULL_VALUE : map.size();
marshallSize(out, mapSize);
if (mapSize <= 0) return;
for (Map.Entry<K, V> me : map.entrySet()) {
keyWriter.writeTo(out, me.getKey());
valueWrite.writeTo(out, me.getValue());
}
} | [
"public",
"static",
"<",
"K",
",",
"V",
",",
"T",
"extends",
"Map",
"<",
"K",
",",
"V",
">",
">",
"void",
"marshallMap",
"(",
"T",
"map",
",",
"ElementWriter",
"<",
"K",
">",
"keyWriter",
",",
"ElementWriter",
"<",
"V",
">",
"valueWrite",
",",
"ObjectOutput",
"out",
")",
"throws",
"IOException",
"{",
"final",
"int",
"mapSize",
"=",
"map",
"==",
"null",
"?",
"NULL_VALUE",
":",
"map",
".",
"size",
"(",
")",
";",
"marshallSize",
"(",
"out",
",",
"mapSize",
")",
";",
"if",
"(",
"mapSize",
"<=",
"0",
")",
"return",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"me",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"keyWriter",
".",
"writeTo",
"(",
"out",
",",
"me",
".",
"getKey",
"(",
")",
")",
";",
"valueWrite",
".",
"writeTo",
"(",
"out",
",",
"me",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Marshall the {@code map} to the {@code ObjectOutput}.
<p>
{@code null} maps are supported.
@param map {@link Map} to marshall.
@param out {@link ObjectOutput} to write. It must be non-null.
@param <K> Key type of the map.
@param <V> Value type of the map.
@param <T> Type of the {@link Map}.
@throws IOException If any of the usual Input/Output related exceptions occur. | [
"Marshall",
"the",
"{",
"@code",
"map",
"}",
"to",
"the",
"{",
"@code",
"ObjectOutput",
"}",
".",
"<p",
">",
"{",
"@code",
"null",
"}",
"maps",
"are",
"supported",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L102-L111 |
eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/nodemodel/impl/InvariantChecker.java | InvariantChecker.checkInvariant | public void checkInvariant(INode node) throws InconsistentNodeModelException {
"""
Assert the invariant of completely build node model.
Checks that every pointer is correct, e.g.
<ul>
<li>a parent points to its first child,</li>
<li>siblings point to the very same parent,</li>
<li>the offset and length data is in sync, and</li>
<li>no null fields are present (besides some empty first child pointers).</li>
</ul>
@param node an arbitrary node of the complete node model that should be checked.
@throws InconsistentNodeModelException if the node is part of an inconsistent node tree.
"""
try {
doCheckInvariant(node.getRootNode());
} catch(ClassCastException e) {
throw new InconsistentNodeModelException("node has no root node", e);
} catch(NullPointerException e) {
throw new InconsistentNodeModelException("node's pointer is null", e);
}
} | java | public void checkInvariant(INode node) throws InconsistentNodeModelException {
try {
doCheckInvariant(node.getRootNode());
} catch(ClassCastException e) {
throw new InconsistentNodeModelException("node has no root node", e);
} catch(NullPointerException e) {
throw new InconsistentNodeModelException("node's pointer is null", e);
}
} | [
"public",
"void",
"checkInvariant",
"(",
"INode",
"node",
")",
"throws",
"InconsistentNodeModelException",
"{",
"try",
"{",
"doCheckInvariant",
"(",
"node",
".",
"getRootNode",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"throw",
"new",
"InconsistentNodeModelException",
"(",
"\"node has no root node\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"throw",
"new",
"InconsistentNodeModelException",
"(",
"\"node's pointer is null\"",
",",
"e",
")",
";",
"}",
"}"
] | Assert the invariant of completely build node model.
Checks that every pointer is correct, e.g.
<ul>
<li>a parent points to its first child,</li>
<li>siblings point to the very same parent,</li>
<li>the offset and length data is in sync, and</li>
<li>no null fields are present (besides some empty first child pointers).</li>
</ul>
@param node an arbitrary node of the complete node model that should be checked.
@throws InconsistentNodeModelException if the node is part of an inconsistent node tree. | [
"Assert",
"the",
"invariant",
"of",
"completely",
"build",
"node",
"model",
".",
"Checks",
"that",
"every",
"pointer",
"is",
"correct",
"e",
".",
"g",
".",
"<ul",
">",
"<li",
">",
"a",
"parent",
"points",
"to",
"its",
"first",
"child",
"<",
"/",
"li",
">",
"<li",
">",
"siblings",
"point",
"to",
"the",
"very",
"same",
"parent",
"<",
"/",
"li",
">",
"<li",
">",
"the",
"offset",
"and",
"length",
"data",
"is",
"in",
"sync",
"and<",
"/",
"li",
">",
"<li",
">",
"no",
"null",
"fields",
"are",
"present",
"(",
"besides",
"some",
"empty",
"first",
"child",
"pointers",
")",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/nodemodel/impl/InvariantChecker.java#L53-L61 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/FeaturableModel.java | FeaturableModel.setField | private void setField(Field field, Object object, Class<?> type) {
"""
Set the field service only if currently <code>null</code>.
@param field The field to set.
@param object The object to update.
@param type The service type.
@throws LionEngineException If error on setting service.
"""
try
{
if (field.get(object) == null)
{
final Class<? extends Feature> clazz;
// CHECKSTYLE IGNORE LINE: InnerAssignment
if (Feature.class.isAssignableFrom(type) && hasFeature(clazz = type.asSubclass(Feature.class)))
{
field.set(object, getFeature(clazz));
}
else if (media != null)
{
throw new LionEngineException(media, ERROR_CLASS_PRESENCE + String.valueOf(type) + IN + object);
}
else
{
throw new LionEngineException(ERROR_CLASS_PRESENCE + String.valueOf(type) + IN + object);
}
}
}
catch (final IllegalAccessException exception)
{
throw new LionEngineException(exception,
ERROR_INJECT + type.getSimpleName() + Constant.SLASH + field.getName());
}
} | java | private void setField(Field field, Object object, Class<?> type)
{
try
{
if (field.get(object) == null)
{
final Class<? extends Feature> clazz;
// CHECKSTYLE IGNORE LINE: InnerAssignment
if (Feature.class.isAssignableFrom(type) && hasFeature(clazz = type.asSubclass(Feature.class)))
{
field.set(object, getFeature(clazz));
}
else if (media != null)
{
throw new LionEngineException(media, ERROR_CLASS_PRESENCE + String.valueOf(type) + IN + object);
}
else
{
throw new LionEngineException(ERROR_CLASS_PRESENCE + String.valueOf(type) + IN + object);
}
}
}
catch (final IllegalAccessException exception)
{
throw new LionEngineException(exception,
ERROR_INJECT + type.getSimpleName() + Constant.SLASH + field.getName());
}
} | [
"private",
"void",
"setField",
"(",
"Field",
"field",
",",
"Object",
"object",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"try",
"{",
"if",
"(",
"field",
".",
"get",
"(",
"object",
")",
"==",
"null",
")",
"{",
"final",
"Class",
"<",
"?",
"extends",
"Feature",
">",
"clazz",
";",
"// CHECKSTYLE IGNORE LINE: InnerAssignment\r",
"if",
"(",
"Feature",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
")",
"&&",
"hasFeature",
"(",
"clazz",
"=",
"type",
".",
"asSubclass",
"(",
"Feature",
".",
"class",
")",
")",
")",
"{",
"field",
".",
"set",
"(",
"object",
",",
"getFeature",
"(",
"clazz",
")",
")",
";",
"}",
"else",
"if",
"(",
"media",
"!=",
"null",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"media",
",",
"ERROR_CLASS_PRESENCE",
"+",
"String",
".",
"valueOf",
"(",
"type",
")",
"+",
"IN",
"+",
"object",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"LionEngineException",
"(",
"ERROR_CLASS_PRESENCE",
"+",
"String",
".",
"valueOf",
"(",
"type",
")",
"+",
"IN",
"+",
"object",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"IllegalAccessException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_INJECT",
"+",
"type",
".",
"getSimpleName",
"(",
")",
"+",
"Constant",
".",
"SLASH",
"+",
"field",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Set the field service only if currently <code>null</code>.
@param field The field to set.
@param object The object to update.
@param type The service type.
@throws LionEngineException If error on setting service. | [
"Set",
"the",
"field",
"service",
"only",
"if",
"currently",
"<code",
">",
"null<",
"/",
"code",
">",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/FeaturableModel.java#L127-L154 |
hortonworks/dstream | dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java | DStreamExecutionGraphBuilder.doBuild | @SuppressWarnings("rawtypes")
private DStreamExecutionGraph doBuild(boolean isDependent) {
"""
The 'dependentStream' attribute implies that the DStreamOperations the methid is about to build
is a dependency of another DStreamOperations (e.g., for cases such as Join, union etc.)
Basically, each process should have at least two operations - 'read -> write' with shuffle in between.
For cases where we are building a dependent operations the second operation is actually
implicit (the operation that does the join, union etc.).
"""
this.invocationPipeline.getInvocations().forEach(this::addInvocation);
if (this.requiresInitialSetOfOperations()){
this.createDefaultExtractOperation();
}
if (this.requiresPostShuffleOperation(isDependent)){
SerFunction loadFunc = this.determineUnmapFunction(this.currentStreamOperation.getLastOperationName());
this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++, this.currentStreamOperation);
this.currentStreamOperation.addStreamOperationFunction(Ops.load.name(), loadFunc);
}
DStreamOperation parent = this.currentStreamOperation;
List<DStreamOperation> operationList = new ArrayList<>();
do {
operationList.add(parent);
parent = parent.getParent();
} while (parent != null);
Collections.reverse(operationList);
//
DStreamExecutionGraph operations = new DStreamExecutionGraph(
this.invocationPipeline.getSourceElementType(),
this.invocationPipeline.getSourceIdentifier(),
Collections.unmodifiableList(operationList));
return operations;
} | java | @SuppressWarnings("rawtypes")
private DStreamExecutionGraph doBuild(boolean isDependent){
this.invocationPipeline.getInvocations().forEach(this::addInvocation);
if (this.requiresInitialSetOfOperations()){
this.createDefaultExtractOperation();
}
if (this.requiresPostShuffleOperation(isDependent)){
SerFunction loadFunc = this.determineUnmapFunction(this.currentStreamOperation.getLastOperationName());
this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++, this.currentStreamOperation);
this.currentStreamOperation.addStreamOperationFunction(Ops.load.name(), loadFunc);
}
DStreamOperation parent = this.currentStreamOperation;
List<DStreamOperation> operationList = new ArrayList<>();
do {
operationList.add(parent);
parent = parent.getParent();
} while (parent != null);
Collections.reverse(operationList);
//
DStreamExecutionGraph operations = new DStreamExecutionGraph(
this.invocationPipeline.getSourceElementType(),
this.invocationPipeline.getSourceIdentifier(),
Collections.unmodifiableList(operationList));
return operations;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"DStreamExecutionGraph",
"doBuild",
"(",
"boolean",
"isDependent",
")",
"{",
"this",
".",
"invocationPipeline",
".",
"getInvocations",
"(",
")",
".",
"forEach",
"(",
"this",
"::",
"addInvocation",
")",
";",
"if",
"(",
"this",
".",
"requiresInitialSetOfOperations",
"(",
")",
")",
"{",
"this",
".",
"createDefaultExtractOperation",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"requiresPostShuffleOperation",
"(",
"isDependent",
")",
")",
"{",
"SerFunction",
"loadFunc",
"=",
"this",
".",
"determineUnmapFunction",
"(",
"this",
".",
"currentStreamOperation",
".",
"getLastOperationName",
"(",
")",
")",
";",
"this",
".",
"currentStreamOperation",
"=",
"new",
"DStreamOperation",
"(",
"this",
".",
"operationIdCounter",
"++",
",",
"this",
".",
"currentStreamOperation",
")",
";",
"this",
".",
"currentStreamOperation",
".",
"addStreamOperationFunction",
"(",
"Ops",
".",
"load",
".",
"name",
"(",
")",
",",
"loadFunc",
")",
";",
"}",
"DStreamOperation",
"parent",
"=",
"this",
".",
"currentStreamOperation",
";",
"List",
"<",
"DStreamOperation",
">",
"operationList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"do",
"{",
"operationList",
".",
"add",
"(",
"parent",
")",
";",
"parent",
"=",
"parent",
".",
"getParent",
"(",
")",
";",
"}",
"while",
"(",
"parent",
"!=",
"null",
")",
";",
"Collections",
".",
"reverse",
"(",
"operationList",
")",
";",
"//\t",
"DStreamExecutionGraph",
"operations",
"=",
"new",
"DStreamExecutionGraph",
"(",
"this",
".",
"invocationPipeline",
".",
"getSourceElementType",
"(",
")",
",",
"this",
".",
"invocationPipeline",
".",
"getSourceIdentifier",
"(",
")",
",",
"Collections",
".",
"unmodifiableList",
"(",
"operationList",
")",
")",
";",
"return",
"operations",
";",
"}"
] | The 'dependentStream' attribute implies that the DStreamOperations the methid is about to build
is a dependency of another DStreamOperations (e.g., for cases such as Join, union etc.)
Basically, each process should have at least two operations - 'read -> write' with shuffle in between.
For cases where we are building a dependent operations the second operation is actually
implicit (the operation that does the join, union etc.). | [
"The",
"dependentStream",
"attribute",
"implies",
"that",
"the",
"DStreamOperations",
"the",
"methid",
"is",
"about",
"to",
"build",
"is",
"a",
"dependency",
"of",
"another",
"DStreamOperations",
"(",
"e",
".",
"g",
".",
"for",
"cases",
"such",
"as",
"Join",
"union",
"etc",
".",
")",
"Basically",
"each",
"process",
"should",
"have",
"at",
"least",
"two",
"operations",
"-",
"read",
"-",
">",
"write",
"with",
"shuffle",
"in",
"between",
".",
"For",
"cases",
"where",
"we",
"are",
"building",
"a",
"dependent",
"operations",
"the",
"second",
"operation",
"is",
"actually",
"implicit",
"(",
"the",
"operation",
"that",
"does",
"the",
"join",
"union",
"etc",
".",
")",
"."
] | train | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java#L89-L117 |
awslabs/jsii | packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiClient.java | JsiiClient.setStaticPropertyValue | public void setStaticPropertyValue(final String fqn, final String property, final JsonNode value) {
"""
Sets the value of a mutable static property.
@param fqn The FQN of the class
@param property The property name
@param value The new value
"""
ObjectNode req = makeRequest("sset");
req.put("fqn", fqn);
req.put("property", property);
req.set("value", value);
this.runtime.requestResponse(req);
} | java | public void setStaticPropertyValue(final String fqn, final String property, final JsonNode value) {
ObjectNode req = makeRequest("sset");
req.put("fqn", fqn);
req.put("property", property);
req.set("value", value);
this.runtime.requestResponse(req);
} | [
"public",
"void",
"setStaticPropertyValue",
"(",
"final",
"String",
"fqn",
",",
"final",
"String",
"property",
",",
"final",
"JsonNode",
"value",
")",
"{",
"ObjectNode",
"req",
"=",
"makeRequest",
"(",
"\"sset\"",
")",
";",
"req",
".",
"put",
"(",
"\"fqn\"",
",",
"fqn",
")",
";",
"req",
".",
"put",
"(",
"\"property\"",
",",
"property",
")",
";",
"req",
".",
"set",
"(",
"\"value\"",
",",
"value",
")",
";",
"this",
".",
"runtime",
".",
"requestResponse",
"(",
"req",
")",
";",
"}"
] | Sets the value of a mutable static property.
@param fqn The FQN of the class
@param property The property name
@param value The new value | [
"Sets",
"the",
"value",
"of",
"a",
"mutable",
"static",
"property",
"."
] | train | https://github.com/awslabs/jsii/blob/6bbf743f5f65e98e5199ad31c93961533ffc40e5/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiClient.java#L149-L155 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java | ObjectUtils.isCompatibleWithThrowsClause | public static boolean isCompatibleWithThrowsClause(Throwable ex, Class<?>... declaredExceptions) {
"""
Check whether the given exception is compatible with the specified
exception types, as declared in a throws clause.
@param ex the exception to check
@param declaredExceptions the exception types declared in the throws clause
@return whether the given exception is compatible
"""
if (!isCheckedException(ex)) {
return true;
}
if (declaredExceptions != null) {
for (Class<?> declaredException : declaredExceptions) {
if (declaredException.isInstance(ex)) {
return true;
}
}
}
return false;
} | java | public static boolean isCompatibleWithThrowsClause(Throwable ex, Class<?>... declaredExceptions) {
if (!isCheckedException(ex)) {
return true;
}
if (declaredExceptions != null) {
for (Class<?> declaredException : declaredExceptions) {
if (declaredException.isInstance(ex)) {
return true;
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"isCompatibleWithThrowsClause",
"(",
"Throwable",
"ex",
",",
"Class",
"<",
"?",
">",
"...",
"declaredExceptions",
")",
"{",
"if",
"(",
"!",
"isCheckedException",
"(",
"ex",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"declaredExceptions",
"!=",
"null",
")",
"{",
"for",
"(",
"Class",
"<",
"?",
">",
"declaredException",
":",
"declaredExceptions",
")",
"{",
"if",
"(",
"declaredException",
".",
"isInstance",
"(",
"ex",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Check whether the given exception is compatible with the specified
exception types, as declared in a throws clause.
@param ex the exception to check
@param declaredExceptions the exception types declared in the throws clause
@return whether the given exception is compatible | [
"Check",
"whether",
"the",
"given",
"exception",
"is",
"compatible",
"with",
"the",
"specified",
"exception",
"types",
"as",
"declared",
"in",
"a",
"throws",
"clause",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java#L48-L60 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/BoardsApi.java | BoardsApi.getBoard | public Board getBoard(Object projectIdOrPath, Integer boardId) throws GitLabApiException {
"""
Get a single issue board.
<pre><code>GitLab Endpoint: GET /projects/:id/boards/:board_id</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param boardId the ID of the board
@return a Board instance for the specified board ID
@throws GitLabApiException if any exception occurs
"""
Response response = get(Response.Status.OK, null,
"projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
return (response.readEntity(Board.class));
} | java | public Board getBoard(Object projectIdOrPath, Integer boardId) throws GitLabApiException {
Response response = get(Response.Status.OK, null,
"projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
return (response.readEntity(Board.class));
} | [
"public",
"Board",
"getBoard",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"boardId",
")",
"throws",
"GitLabApiException",
"{",
"Response",
"response",
"=",
"get",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"null",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"boards\"",
",",
"boardId",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"Board",
".",
"class",
")",
")",
";",
"}"
] | Get a single issue board.
<pre><code>GitLab Endpoint: GET /projects/:id/boards/:board_id</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param boardId the ID of the board
@return a Board instance for the specified board ID
@throws GitLabApiException if any exception occurs | [
"Get",
"a",
"single",
"issue",
"board",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/BoardsApi.java#L95-L99 |
weld/core | impl/src/main/java/org/jboss/weld/resolution/AbstractAssignabilityRules.java | AbstractAssignabilityRules.boundsMatch | protected boolean boundsMatch(Type[] upperBounds, Type[] stricterUpperBounds) {
"""
Returns <tt>true</tt> iff for each upper bound T, there is at least one bound from <tt>stricterUpperBounds</tt>
assignable to T. This reflects that <tt>stricterUpperBounds</tt> are at least as strict as <tt>upperBounds</tt> are.
<p>
Arguments passed to this method must be legal java bounds, i.e. bounds returned by {@link TypeVariable#getBounds()},
{@link WildcardType#getUpperBounds()} or {@link WildcardType#getLowerBounds()}.
"""
// getUppermostBounds to make sure that both arrays of bounds contain ONLY ACTUAL TYPES! otherwise, the CovariantTypes
// assignability rules do not reflect our needs
upperBounds = getUppermostBounds(upperBounds);
stricterUpperBounds = getUppermostBounds(stricterUpperBounds);
for (Type upperBound : upperBounds) {
if (!CovariantTypes.isAssignableFromAtLeastOne(upperBound, stricterUpperBounds)) {
return false;
}
}
return true;
} | java | protected boolean boundsMatch(Type[] upperBounds, Type[] stricterUpperBounds) {
// getUppermostBounds to make sure that both arrays of bounds contain ONLY ACTUAL TYPES! otherwise, the CovariantTypes
// assignability rules do not reflect our needs
upperBounds = getUppermostBounds(upperBounds);
stricterUpperBounds = getUppermostBounds(stricterUpperBounds);
for (Type upperBound : upperBounds) {
if (!CovariantTypes.isAssignableFromAtLeastOne(upperBound, stricterUpperBounds)) {
return false;
}
}
return true;
} | [
"protected",
"boolean",
"boundsMatch",
"(",
"Type",
"[",
"]",
"upperBounds",
",",
"Type",
"[",
"]",
"stricterUpperBounds",
")",
"{",
"// getUppermostBounds to make sure that both arrays of bounds contain ONLY ACTUAL TYPES! otherwise, the CovariantTypes",
"// assignability rules do not reflect our needs",
"upperBounds",
"=",
"getUppermostBounds",
"(",
"upperBounds",
")",
";",
"stricterUpperBounds",
"=",
"getUppermostBounds",
"(",
"stricterUpperBounds",
")",
";",
"for",
"(",
"Type",
"upperBound",
":",
"upperBounds",
")",
"{",
"if",
"(",
"!",
"CovariantTypes",
".",
"isAssignableFromAtLeastOne",
"(",
"upperBound",
",",
"stricterUpperBounds",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns <tt>true</tt> iff for each upper bound T, there is at least one bound from <tt>stricterUpperBounds</tt>
assignable to T. This reflects that <tt>stricterUpperBounds</tt> are at least as strict as <tt>upperBounds</tt> are.
<p>
Arguments passed to this method must be legal java bounds, i.e. bounds returned by {@link TypeVariable#getBounds()},
{@link WildcardType#getUpperBounds()} or {@link WildcardType#getLowerBounds()}. | [
"Returns",
"<tt",
">",
"true<",
"/",
"tt",
">",
"iff",
"for",
"each",
"upper",
"bound",
"T",
"there",
"is",
"at",
"least",
"one",
"bound",
"from",
"<tt",
">",
"stricterUpperBounds<",
"/",
"tt",
">",
"assignable",
"to",
"T",
".",
"This",
"reflects",
"that",
"<tt",
">",
"stricterUpperBounds<",
"/",
"tt",
">",
"are",
"at",
"least",
"as",
"strict",
"as",
"<tt",
">",
"upperBounds<",
"/",
"tt",
">",
"are",
".",
"<p",
">",
"Arguments",
"passed",
"to",
"this",
"method",
"must",
"be",
"legal",
"java",
"bounds",
"i",
".",
"e",
".",
"bounds",
"returned",
"by",
"{"
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/resolution/AbstractAssignabilityRules.java#L79-L90 |
rundeck/rundeck | core/src/main/java/com/dtolabs/utils/Mapper.java | Mapper.mapKeys | public static Map mapKeys(Mapper mapper, Map map, boolean allowNull) {
"""
Create a new Map by mapping all keys from the original map and maintaining the original value.
@param mapper a Mapper to map the keys
@param map a Map
@param allowNull allow null values
@return a new Map with keys mapped
"""
HashMap h = new HashMap();
for (Object e : map.entrySet()) {
Map.Entry entry = (Map.Entry) e;
Object o = mapper.map(entry.getKey());
if (allowNull || o != null) {
h.put(o, entry.getValue());
}
}
return h;
} | java | public static Map mapKeys(Mapper mapper, Map map, boolean allowNull) {
HashMap h = new HashMap();
for (Object e : map.entrySet()) {
Map.Entry entry = (Map.Entry) e;
Object o = mapper.map(entry.getKey());
if (allowNull || o != null) {
h.put(o, entry.getValue());
}
}
return h;
} | [
"public",
"static",
"Map",
"mapKeys",
"(",
"Mapper",
"mapper",
",",
"Map",
"map",
",",
"boolean",
"allowNull",
")",
"{",
"HashMap",
"h",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
"Object",
"e",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"e",
";",
"Object",
"o",
"=",
"mapper",
".",
"map",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"allowNull",
"||",
"o",
"!=",
"null",
")",
"{",
"h",
".",
"put",
"(",
"o",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"h",
";",
"}"
] | Create a new Map by mapping all keys from the original map and maintaining the original value.
@param mapper a Mapper to map the keys
@param map a Map
@param allowNull allow null values
@return a new Map with keys mapped | [
"Create",
"a",
"new",
"Map",
"by",
"mapping",
"all",
"keys",
"from",
"the",
"original",
"map",
"and",
"maintaining",
"the",
"original",
"value",
"."
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L390-L400 |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/BitemporalMapper.java | BitemporalMapper.readBitemporalDate | BitemporalDateTime readBitemporalDate(Columns columns, String field) {
"""
Returns a {@link BitemporalDateTime} read from the specified {@link Columns}.
@param columns the column where the data is
@param field the name of the field to be read from {@code columns}
@return a bitemporal date time
"""
return parseBitemporalDate(columns.valueForField(field));
} | java | BitemporalDateTime readBitemporalDate(Columns columns, String field) {
return parseBitemporalDate(columns.valueForField(field));
} | [
"BitemporalDateTime",
"readBitemporalDate",
"(",
"Columns",
"columns",
",",
"String",
"field",
")",
"{",
"return",
"parseBitemporalDate",
"(",
"columns",
".",
"valueForField",
"(",
"field",
")",
")",
";",
"}"
] | Returns a {@link BitemporalDateTime} read from the specified {@link Columns}.
@param columns the column where the data is
@param field the name of the field to be read from {@code columns}
@return a bitemporal date time | [
"Returns",
"a",
"{",
"@link",
"BitemporalDateTime",
"}",
"read",
"from",
"the",
"specified",
"{",
"@link",
"Columns",
"}",
"."
] | train | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/BitemporalMapper.java#L173-L175 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.jaspic/src/com/ibm/ws/security/jaspi/JaspiServiceImpl.java | JaspiServiceImpl.setRequestAuthType | protected void setRequestAuthType(MessageInfo msgInfo, JaspiRequest jaspiRequest) {
"""
/*
The runtime must also ensure that the value returned by calling
getAuthType on the HttpServletRequest is consistent in terms of being null
or non-null with the value returned by getUserPrincipal. When getAuthType
is to return a non-null value, the runtime must consult the Map of
the MessageInfo object used in the call to validateRequest to determine
if it contains an entry for the key "javax.servlet.http.authType".
If the Map contains an entry for the key, the runtime must obtain (from
the Map) the value corresponding to the key and establish it as the
getAuthType return value. If the Map does not contain an entry for the key,
and an auth-method is defined in the login-config element of the
deployment descriptor for the web application, the runtime must establish
the value from the auth-method as the value returned by getAuthType.
If the Map does not contain an entry for the key, and the deployment
descriptor does not define an auth-method, the runtime must establish a
non-null value of its choice as the value returned by getAuthType.
"""
String authType = null;
if (msgInfo.getMap().containsKey(AUTH_TYPE)) {
authType = (String) msgInfo.getMap().get(AUTH_TYPE);
} else {
authType = getDDAuthMethod(jaspiRequest);
if (authType == null) {
authType = "JASPI";
}
}
HttpServletRequest req = (HttpServletRequest) msgInfo.getRequestMessage();
setRequestAuthType(req, authType);
} | java | protected void setRequestAuthType(MessageInfo msgInfo, JaspiRequest jaspiRequest) {
String authType = null;
if (msgInfo.getMap().containsKey(AUTH_TYPE)) {
authType = (String) msgInfo.getMap().get(AUTH_TYPE);
} else {
authType = getDDAuthMethod(jaspiRequest);
if (authType == null) {
authType = "JASPI";
}
}
HttpServletRequest req = (HttpServletRequest) msgInfo.getRequestMessage();
setRequestAuthType(req, authType);
} | [
"protected",
"void",
"setRequestAuthType",
"(",
"MessageInfo",
"msgInfo",
",",
"JaspiRequest",
"jaspiRequest",
")",
"{",
"String",
"authType",
"=",
"null",
";",
"if",
"(",
"msgInfo",
".",
"getMap",
"(",
")",
".",
"containsKey",
"(",
"AUTH_TYPE",
")",
")",
"{",
"authType",
"=",
"(",
"String",
")",
"msgInfo",
".",
"getMap",
"(",
")",
".",
"get",
"(",
"AUTH_TYPE",
")",
";",
"}",
"else",
"{",
"authType",
"=",
"getDDAuthMethod",
"(",
"jaspiRequest",
")",
";",
"if",
"(",
"authType",
"==",
"null",
")",
"{",
"authType",
"=",
"\"JASPI\"",
";",
"}",
"}",
"HttpServletRequest",
"req",
"=",
"(",
"HttpServletRequest",
")",
"msgInfo",
".",
"getRequestMessage",
"(",
")",
";",
"setRequestAuthType",
"(",
"req",
",",
"authType",
")",
";",
"}"
] | /*
The runtime must also ensure that the value returned by calling
getAuthType on the HttpServletRequest is consistent in terms of being null
or non-null with the value returned by getUserPrincipal. When getAuthType
is to return a non-null value, the runtime must consult the Map of
the MessageInfo object used in the call to validateRequest to determine
if it contains an entry for the key "javax.servlet.http.authType".
If the Map contains an entry for the key, the runtime must obtain (from
the Map) the value corresponding to the key and establish it as the
getAuthType return value. If the Map does not contain an entry for the key,
and an auth-method is defined in the login-config element of the
deployment descriptor for the web application, the runtime must establish
the value from the auth-method as the value returned by getAuthType.
If the Map does not contain an entry for the key, and the deployment
descriptor does not define an auth-method, the runtime must establish a
non-null value of its choice as the value returned by getAuthType. | [
"/",
"*",
"The",
"runtime",
"must",
"also",
"ensure",
"that",
"the",
"value",
"returned",
"by",
"calling",
"getAuthType",
"on",
"the",
"HttpServletRequest",
"is",
"consistent",
"in",
"terms",
"of",
"being",
"null",
"or",
"non",
"-",
"null",
"with",
"the",
"value",
"returned",
"by",
"getUserPrincipal",
".",
"When",
"getAuthType",
"is",
"to",
"return",
"a",
"non",
"-",
"null",
"value",
"the",
"runtime",
"must",
"consult",
"the",
"Map",
"of",
"the",
"MessageInfo",
"object",
"used",
"in",
"the",
"call",
"to",
"validateRequest",
"to",
"determine",
"if",
"it",
"contains",
"an",
"entry",
"for",
"the",
"key",
"javax",
".",
"servlet",
".",
"http",
".",
"authType",
".",
"If",
"the",
"Map",
"contains",
"an",
"entry",
"for",
"the",
"key",
"the",
"runtime",
"must",
"obtain",
"(",
"from",
"the",
"Map",
")",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"establish",
"it",
"as",
"the",
"getAuthType",
"return",
"value",
".",
"If",
"the",
"Map",
"does",
"not",
"contain",
"an",
"entry",
"for",
"the",
"key",
"and",
"an",
"auth",
"-",
"method",
"is",
"defined",
"in",
"the",
"login",
"-",
"config",
"element",
"of",
"the",
"deployment",
"descriptor",
"for",
"the",
"web",
"application",
"the",
"runtime",
"must",
"establish",
"the",
"value",
"from",
"the",
"auth",
"-",
"method",
"as",
"the",
"value",
"returned",
"by",
"getAuthType",
".",
"If",
"the",
"Map",
"does",
"not",
"contain",
"an",
"entry",
"for",
"the",
"key",
"and",
"the",
"deployment",
"descriptor",
"does",
"not",
"define",
"an",
"auth",
"-",
"method",
"the",
"runtime",
"must",
"establish",
"a",
"non",
"-",
"null",
"value",
"of",
"its",
"choice",
"as",
"the",
"value",
"returned",
"by",
"getAuthType",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jaspic/src/com/ibm/ws/security/jaspi/JaspiServiceImpl.java#L635-L647 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java | GrailsDomainBinder.trackCustomCascadingSaves | protected void trackCustomCascadingSaves(Mapping mapping, Iterable<PersistentProperty> persistentProperties) {
"""
Checks for any custom cascading saves set up via the mapping DSL and records them within the persistent property.
@param mapping The Mapping.
@param persistentProperties The persistent properties of the domain class.
"""
for (PersistentProperty property : persistentProperties) {
PropertyConfig propConf = mapping.getPropertyConfig(property.getName());
if (propConf != null && propConf.getCascade() != null) {
propConf.setExplicitSaveUpdateCascade(isSaveUpdateCascade(propConf.getCascade()));
}
}
} | java | protected void trackCustomCascadingSaves(Mapping mapping, Iterable<PersistentProperty> persistentProperties) {
for (PersistentProperty property : persistentProperties) {
PropertyConfig propConf = mapping.getPropertyConfig(property.getName());
if (propConf != null && propConf.getCascade() != null) {
propConf.setExplicitSaveUpdateCascade(isSaveUpdateCascade(propConf.getCascade()));
}
}
} | [
"protected",
"void",
"trackCustomCascadingSaves",
"(",
"Mapping",
"mapping",
",",
"Iterable",
"<",
"PersistentProperty",
">",
"persistentProperties",
")",
"{",
"for",
"(",
"PersistentProperty",
"property",
":",
"persistentProperties",
")",
"{",
"PropertyConfig",
"propConf",
"=",
"mapping",
".",
"getPropertyConfig",
"(",
"property",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"propConf",
"!=",
"null",
"&&",
"propConf",
".",
"getCascade",
"(",
")",
"!=",
"null",
")",
"{",
"propConf",
".",
"setExplicitSaveUpdateCascade",
"(",
"isSaveUpdateCascade",
"(",
"propConf",
".",
"getCascade",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Checks for any custom cascading saves set up via the mapping DSL and records them within the persistent property.
@param mapping The Mapping.
@param persistentProperties The persistent properties of the domain class. | [
"Checks",
"for",
"any",
"custom",
"cascading",
"saves",
"set",
"up",
"via",
"the",
"mapping",
"DSL",
"and",
"records",
"them",
"within",
"the",
"persistent",
"property",
"."
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java#L1276-L1284 |
Swrve/rate-limited-logger | src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java | RateLimitedLog.get | public RateLimitedLogWithPattern get(final String message) {
"""
@return a RateLimitedLogWithPattern object for the supplied @param message. This can be cached and
reused by callers in performance-sensitive cases to avoid performing a ConcurrentHashMap lookup.
Note that the string is the sole key used, so the same string cannot be reused with differing period
settings; any periods which differ from the first one used are ignored.
@throws IllegalStateException if we exceed the limit on number of RateLimitedLogWithPattern objects
in any one period; if this happens, it's probable that an already-interpolated string is
accidentally being used as a log pattern.
"""
// fast path: hopefully we can do this without creating a Supplier object
RateLimitedLogWithPattern got = knownPatterns.get(message);
if (got != null) {
return got;
}
// before we create another one, check cache capacity first
if (knownPatterns.size() > MAX_PATTERNS_PER_LOG) {
outOfCacheCapacity();
}
// slow path: create a RateLimitedLogWithPattern
RateLimitedLogWithPattern newValue = new RateLimitedLogWithPattern(message, rateAndPeriod, registry, stats, stopwatch, logger);
RateLimitedLogWithPattern oldValue = knownPatterns.putIfAbsent(message, newValue);
if (oldValue != null) {
return oldValue;
} else {
return newValue;
}
} | java | public RateLimitedLogWithPattern get(final String message) {
// fast path: hopefully we can do this without creating a Supplier object
RateLimitedLogWithPattern got = knownPatterns.get(message);
if (got != null) {
return got;
}
// before we create another one, check cache capacity first
if (knownPatterns.size() > MAX_PATTERNS_PER_LOG) {
outOfCacheCapacity();
}
// slow path: create a RateLimitedLogWithPattern
RateLimitedLogWithPattern newValue = new RateLimitedLogWithPattern(message, rateAndPeriod, registry, stats, stopwatch, logger);
RateLimitedLogWithPattern oldValue = knownPatterns.putIfAbsent(message, newValue);
if (oldValue != null) {
return oldValue;
} else {
return newValue;
}
} | [
"public",
"RateLimitedLogWithPattern",
"get",
"(",
"final",
"String",
"message",
")",
"{",
"// fast path: hopefully we can do this without creating a Supplier object",
"RateLimitedLogWithPattern",
"got",
"=",
"knownPatterns",
".",
"get",
"(",
"message",
")",
";",
"if",
"(",
"got",
"!=",
"null",
")",
"{",
"return",
"got",
";",
"}",
"// before we create another one, check cache capacity first",
"if",
"(",
"knownPatterns",
".",
"size",
"(",
")",
">",
"MAX_PATTERNS_PER_LOG",
")",
"{",
"outOfCacheCapacity",
"(",
")",
";",
"}",
"// slow path: create a RateLimitedLogWithPattern",
"RateLimitedLogWithPattern",
"newValue",
"=",
"new",
"RateLimitedLogWithPattern",
"(",
"message",
",",
"rateAndPeriod",
",",
"registry",
",",
"stats",
",",
"stopwatch",
",",
"logger",
")",
";",
"RateLimitedLogWithPattern",
"oldValue",
"=",
"knownPatterns",
".",
"putIfAbsent",
"(",
"message",
",",
"newValue",
")",
";",
"if",
"(",
"oldValue",
"!=",
"null",
")",
"{",
"return",
"oldValue",
";",
"}",
"else",
"{",
"return",
"newValue",
";",
"}",
"}"
] | @return a RateLimitedLogWithPattern object for the supplied @param message. This can be cached and
reused by callers in performance-sensitive cases to avoid performing a ConcurrentHashMap lookup.
Note that the string is the sole key used, so the same string cannot be reused with differing period
settings; any periods which differ from the first one used are ignored.
@throws IllegalStateException if we exceed the limit on number of RateLimitedLogWithPattern objects
in any one period; if this happens, it's probable that an already-interpolated string is
accidentally being used as a log pattern. | [
"@return",
"a",
"RateLimitedLogWithPattern",
"object",
"for",
"the",
"supplied",
"@param",
"message",
".",
"This",
"can",
"be",
"cached",
"and",
"reused",
"by",
"callers",
"in",
"performance",
"-",
"sensitive",
"cases",
"to",
"avoid",
"performing",
"a",
"ConcurrentHashMap",
"lookup",
"."
] | train | https://github.com/Swrve/rate-limited-logger/blob/9094d3961f35dad0d6114aafade4a34b0b264b0b/src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java#L399-L419 |
foundation-runtime/service-directory | 2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java | Configurations.getBoolean | public static boolean getBoolean(String name, boolean defaultVal) {
"""
Get the property object as Boolean, or return defaultVal if property is not defined.
@param name
property name.
@param defaultVal
default property value.
@return
property value as boolean, return defaultVal if property is undefined.
"""
if(getConfiguration().containsKey(name)){
return getConfiguration().getBoolean(name);
} else {
return defaultVal;
}
} | java | public static boolean getBoolean(String name, boolean defaultVal){
if(getConfiguration().containsKey(name)){
return getConfiguration().getBoolean(name);
} else {
return defaultVal;
}
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"String",
"name",
",",
"boolean",
"defaultVal",
")",
"{",
"if",
"(",
"getConfiguration",
"(",
")",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"return",
"getConfiguration",
"(",
")",
".",
"getBoolean",
"(",
"name",
")",
";",
"}",
"else",
"{",
"return",
"defaultVal",
";",
"}",
"}"
] | Get the property object as Boolean, or return defaultVal if property is not defined.
@param name
property name.
@param defaultVal
default property value.
@return
property value as boolean, return defaultVal if property is undefined. | [
"Get",
"the",
"property",
"object",
"as",
"Boolean",
"or",
"return",
"defaultVal",
"if",
"property",
"is",
"not",
"defined",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L140-L146 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java | BootstrapConfig.getWorkareaFile | public File getWorkareaFile(String relativeServerWorkareaPath) {
"""
Allocate a file in the server directory, e.g.
usr/servers/serverName/workarea/relativeServerWorkareaPath
@param relativeServerWorkareaPath
relative path of file to create in the server's workarea
@return File object for relative path, or for the server workarea itself if
the relative path argument is null
"""
if (relativeServerWorkareaPath == null)
return workarea;
else
return new File(workarea, relativeServerWorkareaPath);
} | java | public File getWorkareaFile(String relativeServerWorkareaPath) {
if (relativeServerWorkareaPath == null)
return workarea;
else
return new File(workarea, relativeServerWorkareaPath);
} | [
"public",
"File",
"getWorkareaFile",
"(",
"String",
"relativeServerWorkareaPath",
")",
"{",
"if",
"(",
"relativeServerWorkareaPath",
"==",
"null",
")",
"return",
"workarea",
";",
"else",
"return",
"new",
"File",
"(",
"workarea",
",",
"relativeServerWorkareaPath",
")",
";",
"}"
] | Allocate a file in the server directory, e.g.
usr/servers/serverName/workarea/relativeServerWorkareaPath
@param relativeServerWorkareaPath
relative path of file to create in the server's workarea
@return File object for relative path, or for the server workarea itself if
the relative path argument is null | [
"Allocate",
"a",
"file",
"in",
"the",
"server",
"directory",
"e",
".",
"g",
".",
"usr",
"/",
"servers",
"/",
"serverName",
"/",
"workarea",
"/",
"relativeServerWorkareaPath"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java#L644-L649 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/util/AABBUtils.java | AABBUtils.writeToNBT | public static void writeToNBT(NBTTagCompound tag, AxisAlignedBB aabb, String prefix) {
"""
Writes a {@link AxisAlignedBB} to a {@link NBTTagCompound} with the specified prefix.
@param tag the tag
@param aabb the aabb
@param prefix the prefix
"""
if (tag == null || aabb == null)
return;
prefix = prefix == null ? "" : prefix + ".";
tag.setDouble(prefix + "minX", aabb.minX);
tag.setDouble(prefix + "minY", aabb.minY);
tag.setDouble(prefix + "minZ", aabb.minZ);
tag.setDouble(prefix + "maxX", aabb.maxX);
tag.setDouble(prefix + "maxY", aabb.maxY);
tag.setDouble(prefix + "maxZ", aabb.maxZ);
} | java | public static void writeToNBT(NBTTagCompound tag, AxisAlignedBB aabb, String prefix)
{
if (tag == null || aabb == null)
return;
prefix = prefix == null ? "" : prefix + ".";
tag.setDouble(prefix + "minX", aabb.minX);
tag.setDouble(prefix + "minY", aabb.minY);
tag.setDouble(prefix + "minZ", aabb.minZ);
tag.setDouble(prefix + "maxX", aabb.maxX);
tag.setDouble(prefix + "maxY", aabb.maxY);
tag.setDouble(prefix + "maxZ", aabb.maxZ);
} | [
"public",
"static",
"void",
"writeToNBT",
"(",
"NBTTagCompound",
"tag",
",",
"AxisAlignedBB",
"aabb",
",",
"String",
"prefix",
")",
"{",
"if",
"(",
"tag",
"==",
"null",
"||",
"aabb",
"==",
"null",
")",
"return",
";",
"prefix",
"=",
"prefix",
"==",
"null",
"?",
"\"\"",
":",
"prefix",
"+",
"\".\"",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"minX\"",
",",
"aabb",
".",
"minX",
")",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"minY\"",
",",
"aabb",
".",
"minY",
")",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"minZ\"",
",",
"aabb",
".",
"minZ",
")",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"maxX\"",
",",
"aabb",
".",
"maxX",
")",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"maxY\"",
",",
"aabb",
".",
"maxY",
")",
";",
"tag",
".",
"setDouble",
"(",
"prefix",
"+",
"\"maxZ\"",
",",
"aabb",
".",
"maxZ",
")",
";",
"}"
] | Writes a {@link AxisAlignedBB} to a {@link NBTTagCompound} with the specified prefix.
@param tag the tag
@param aabb the aabb
@param prefix the prefix | [
"Writes",
"a",
"{",
"@link",
"AxisAlignedBB",
"}",
"to",
"a",
"{",
"@link",
"NBTTagCompound",
"}",
"with",
"the",
"specified",
"prefix",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/AABBUtils.java#L266-L278 |
otto-de/edison-microservice | edison-jobs/src/main/java/de/otto/edison/jobs/definition/DefaultJobDefinition.java | DefaultJobDefinition.cronJobDefinition | public static JobDefinition cronJobDefinition(final String jobType,
final String jobName,
final String description,
final String cron,
final int restarts,
final Optional<Duration> maxAge) {
"""
Create a JobDefinition that is using a cron expression to specify, when and how often the job should be triggered.
@param jobType The type of the Job
@param jobName A human readable name of the Job
@param description A human readable description of the Job.
@param cron The cron expression. Must conform to {@link CronSequenceGenerator}s cron expressions.
@param restarts The number of restarts if the job failed because of errors or exceptions
@param maxAge Optional maximum age of a job. When the job is not run for longer than this duration,
a warning is displayed on the status page
@return JobDefinition
@throws IllegalArgumentException if cron expression is invalid.
"""
return new DefaultJobDefinition(jobType, jobName, description, maxAge, Optional.empty(), Optional.of(cron), restarts, 0, Optional.empty());
} | java | public static JobDefinition cronJobDefinition(final String jobType,
final String jobName,
final String description,
final String cron,
final int restarts,
final Optional<Duration> maxAge) {
return new DefaultJobDefinition(jobType, jobName, description, maxAge, Optional.empty(), Optional.of(cron), restarts, 0, Optional.empty());
} | [
"public",
"static",
"JobDefinition",
"cronJobDefinition",
"(",
"final",
"String",
"jobType",
",",
"final",
"String",
"jobName",
",",
"final",
"String",
"description",
",",
"final",
"String",
"cron",
",",
"final",
"int",
"restarts",
",",
"final",
"Optional",
"<",
"Duration",
">",
"maxAge",
")",
"{",
"return",
"new",
"DefaultJobDefinition",
"(",
"jobType",
",",
"jobName",
",",
"description",
",",
"maxAge",
",",
"Optional",
".",
"empty",
"(",
")",
",",
"Optional",
".",
"of",
"(",
"cron",
")",
",",
"restarts",
",",
"0",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}"
] | Create a JobDefinition that is using a cron expression to specify, when and how often the job should be triggered.
@param jobType The type of the Job
@param jobName A human readable name of the Job
@param description A human readable description of the Job.
@param cron The cron expression. Must conform to {@link CronSequenceGenerator}s cron expressions.
@param restarts The number of restarts if the job failed because of errors or exceptions
@param maxAge Optional maximum age of a job. When the job is not run for longer than this duration,
a warning is displayed on the status page
@return JobDefinition
@throws IllegalArgumentException if cron expression is invalid. | [
"Create",
"a",
"JobDefinition",
"that",
"is",
"using",
"a",
"cron",
"expression",
"to",
"specify",
"when",
"and",
"how",
"often",
"the",
"job",
"should",
"be",
"triggered",
"."
] | train | https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-jobs/src/main/java/de/otto/edison/jobs/definition/DefaultJobDefinition.java#L59-L66 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/CommonFunction.java | CommonFunction.getNLSMessage | public static final String getNLSMessage(String key, Object... args) {
"""
Retrieve a translated message from the J2C messages file.
If the message cannot be found, the key is returned.
@param key a valid message key from the J2C messages file.
@param args a list of parameters to include in the translatable message.
@return a translated message.
"""
return NLS.getFormattedMessage(key, args, key);
} | java | public static final String getNLSMessage(String key, Object... args) {
return NLS.getFormattedMessage(key, args, key);
} | [
"public",
"static",
"final",
"String",
"getNLSMessage",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"NLS",
".",
"getFormattedMessage",
"(",
"key",
",",
"args",
",",
"key",
")",
";",
"}"
] | Retrieve a translated message from the J2C messages file.
If the message cannot be found, the key is returned.
@param key a valid message key from the J2C messages file.
@param args a list of parameters to include in the translatable message.
@return a translated message. | [
"Retrieve",
"a",
"translated",
"message",
"from",
"the",
"J2C",
"messages",
"file",
".",
"If",
"the",
"message",
"cannot",
"be",
"found",
"the",
"key",
"is",
"returned",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/CommonFunction.java#L131-L133 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java | ConnectLinesGrid.connectTry | private boolean connectTry( LineSegment2D_F32 target , int x , int y ) {
"""
See if there is a line that matches in this adjacent region.
@param target Line being connected.
@param x x-coordinate of adjacent region.
@param y y-coordinate of adjacent region.
@return true if a connection was made.
"""
if( !grid.isInBounds(x,y) )
return false;
List<LineSegment2D_F32> lines = grid.get(x,y);
int index = findBestCompatible(target,lines,0);
if( index == -1 )
return false;
LineSegment2D_F32 b = lines.remove(index);
// join the two lines by connecting the farthest points from each other
Point2D_F32 pt0 = farthestIndex < 2 ? target.a : target.b;
Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b;
target.a.set(pt0);
target.b.set(pt1);
// adding the merged one back in allows it to be merged with other lines down
// the line. It will be compared against others in 'target's grid though
lines.add(target);
return true;
} | java | private boolean connectTry( LineSegment2D_F32 target , int x , int y ) {
if( !grid.isInBounds(x,y) )
return false;
List<LineSegment2D_F32> lines = grid.get(x,y);
int index = findBestCompatible(target,lines,0);
if( index == -1 )
return false;
LineSegment2D_F32 b = lines.remove(index);
// join the two lines by connecting the farthest points from each other
Point2D_F32 pt0 = farthestIndex < 2 ? target.a : target.b;
Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b;
target.a.set(pt0);
target.b.set(pt1);
// adding the merged one back in allows it to be merged with other lines down
// the line. It will be compared against others in 'target's grid though
lines.add(target);
return true;
} | [
"private",
"boolean",
"connectTry",
"(",
"LineSegment2D_F32",
"target",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"!",
"grid",
".",
"isInBounds",
"(",
"x",
",",
"y",
")",
")",
"return",
"false",
";",
"List",
"<",
"LineSegment2D_F32",
">",
"lines",
"=",
"grid",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"int",
"index",
"=",
"findBestCompatible",
"(",
"target",
",",
"lines",
",",
"0",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"return",
"false",
";",
"LineSegment2D_F32",
"b",
"=",
"lines",
".",
"remove",
"(",
"index",
")",
";",
"// join the two lines by connecting the farthest points from each other",
"Point2D_F32",
"pt0",
"=",
"farthestIndex",
"<",
"2",
"?",
"target",
".",
"a",
":",
"target",
".",
"b",
";",
"Point2D_F32",
"pt1",
"=",
"(",
"farthestIndex",
"%",
"2",
")",
"==",
"0",
"?",
"b",
".",
"a",
":",
"b",
".",
"b",
";",
"target",
".",
"a",
".",
"set",
"(",
"pt0",
")",
";",
"target",
".",
"b",
".",
"set",
"(",
"pt1",
")",
";",
"// adding the merged one back in allows it to be merged with other lines down",
"// the line. It will be compared against others in 'target's grid though",
"lines",
".",
"add",
"(",
"target",
")",
";",
"return",
"true",
";",
"}"
] | See if there is a line that matches in this adjacent region.
@param target Line being connected.
@param x x-coordinate of adjacent region.
@param y y-coordinate of adjacent region.
@return true if a connection was made. | [
"See",
"if",
"there",
"is",
"a",
"line",
"that",
"matches",
"in",
"this",
"adjacent",
"region",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L146-L171 |
aws/aws-sdk-java | aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/DocumentationUtils.java | DocumentationUtils.createLinkToServiceDocumentation | public static String createLinkToServiceDocumentation(Metadata metadata, String name) {
"""
Create the HTML for a link to the operation/shape core AWS docs site
@param metadata the UID for the service from that services metadata
@param name the name of the shape/request/operation
@return a '@see also' HTML link to the doc
"""
if (isCrossLinkingEnabledForService(metadata)) {
return String.format("@see <a href=\"http://%s/goto/WebAPI/%s/%s\" target=\"_top\">AWS API Documentation</a>",
AWS_DOCS_HOST,
metadata.getUid(),
name);
}
return "";
} | java | public static String createLinkToServiceDocumentation(Metadata metadata, String name) {
if (isCrossLinkingEnabledForService(metadata)) {
return String.format("@see <a href=\"http://%s/goto/WebAPI/%s/%s\" target=\"_top\">AWS API Documentation</a>",
AWS_DOCS_HOST,
metadata.getUid(),
name);
}
return "";
} | [
"public",
"static",
"String",
"createLinkToServiceDocumentation",
"(",
"Metadata",
"metadata",
",",
"String",
"name",
")",
"{",
"if",
"(",
"isCrossLinkingEnabledForService",
"(",
"metadata",
")",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"@see <a href=\\\"http://%s/goto/WebAPI/%s/%s\\\" target=\\\"_top\\\">AWS API Documentation</a>\"",
",",
"AWS_DOCS_HOST",
",",
"metadata",
".",
"getUid",
"(",
")",
",",
"name",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] | Create the HTML for a link to the operation/shape core AWS docs site
@param metadata the UID for the service from that services metadata
@param name the name of the shape/request/operation
@return a '@see also' HTML link to the doc | [
"Create",
"the",
"HTML",
"for",
"a",
"link",
"to",
"the",
"operation",
"/",
"shape",
"core",
"AWS",
"docs",
"site"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/DocumentationUtils.java#L130-L138 |
atomix/atomix | cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java | NettyMessagingService.bootstrapClient | private CompletableFuture<Channel> bootstrapClient(Address address) {
"""
Bootstraps a new channel to the given address.
@param address the address to which to connect
@return a future to be completed with the connected channel
"""
CompletableFuture<Channel> future = new OrderedFuture<>();
Bootstrap bootstrap = new Bootstrap();
bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK,
new WriteBufferWaterMark(10 * 32 * 1024, 10 * 64 * 1024));
bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024);
bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
bootstrap.option(ChannelOption.TCP_NODELAY, true);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000);
bootstrap.group(clientGroup);
// TODO: Make this faster:
// http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0
bootstrap.channel(clientChannelClass);
bootstrap.remoteAddress(address.address(true), address.port());
if (enableNettyTls) {
try {
bootstrap.handler(new SslClientChannelInitializer(future, address));
} catch (SSLException e) {
return Futures.exceptionalFuture(e);
}
} else {
bootstrap.handler(new BasicClientChannelInitializer(future));
}
bootstrap.connect().addListener(f -> {
if (!f.isSuccess()) {
future.completeExceptionally(f.cause());
}
});
return future;
} | java | private CompletableFuture<Channel> bootstrapClient(Address address) {
CompletableFuture<Channel> future = new OrderedFuture<>();
Bootstrap bootstrap = new Bootstrap();
bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK,
new WriteBufferWaterMark(10 * 32 * 1024, 10 * 64 * 1024));
bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024);
bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
bootstrap.option(ChannelOption.TCP_NODELAY, true);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000);
bootstrap.group(clientGroup);
// TODO: Make this faster:
// http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0
bootstrap.channel(clientChannelClass);
bootstrap.remoteAddress(address.address(true), address.port());
if (enableNettyTls) {
try {
bootstrap.handler(new SslClientChannelInitializer(future, address));
} catch (SSLException e) {
return Futures.exceptionalFuture(e);
}
} else {
bootstrap.handler(new BasicClientChannelInitializer(future));
}
bootstrap.connect().addListener(f -> {
if (!f.isSuccess()) {
future.completeExceptionally(f.cause());
}
});
return future;
} | [
"private",
"CompletableFuture",
"<",
"Channel",
">",
"bootstrapClient",
"(",
"Address",
"address",
")",
"{",
"CompletableFuture",
"<",
"Channel",
">",
"future",
"=",
"new",
"OrderedFuture",
"<>",
"(",
")",
";",
"Bootstrap",
"bootstrap",
"=",
"new",
"Bootstrap",
"(",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"ALLOCATOR",
",",
"PooledByteBufAllocator",
".",
"DEFAULT",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"WRITE_BUFFER_WATER_MARK",
",",
"new",
"WriteBufferWaterMark",
"(",
"10",
"*",
"32",
"*",
"1024",
",",
"10",
"*",
"64",
"*",
"1024",
")",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"SO_RCVBUF",
",",
"1024",
"*",
"1024",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"SO_SNDBUF",
",",
"1024",
"*",
"1024",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"SO_KEEPALIVE",
",",
"true",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"TCP_NODELAY",
",",
"true",
")",
";",
"bootstrap",
".",
"option",
"(",
"ChannelOption",
".",
"CONNECT_TIMEOUT_MILLIS",
",",
"1000",
")",
";",
"bootstrap",
".",
"group",
"(",
"clientGroup",
")",
";",
"// TODO: Make this faster:",
"// http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0",
"bootstrap",
".",
"channel",
"(",
"clientChannelClass",
")",
";",
"bootstrap",
".",
"remoteAddress",
"(",
"address",
".",
"address",
"(",
"true",
")",
",",
"address",
".",
"port",
"(",
")",
")",
";",
"if",
"(",
"enableNettyTls",
")",
"{",
"try",
"{",
"bootstrap",
".",
"handler",
"(",
"new",
"SslClientChannelInitializer",
"(",
"future",
",",
"address",
")",
")",
";",
"}",
"catch",
"(",
"SSLException",
"e",
")",
"{",
"return",
"Futures",
".",
"exceptionalFuture",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"bootstrap",
".",
"handler",
"(",
"new",
"BasicClientChannelInitializer",
"(",
"future",
")",
")",
";",
"}",
"bootstrap",
".",
"connect",
"(",
")",
".",
"addListener",
"(",
"f",
"->",
"{",
"if",
"(",
"!",
"f",
".",
"isSuccess",
"(",
")",
")",
"{",
"future",
".",
"completeExceptionally",
"(",
"f",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"future",
";",
"}"
] | Bootstraps a new channel to the given address.
@param address the address to which to connect
@return a future to be completed with the connected channel | [
"Bootstraps",
"a",
"new",
"channel",
"to",
"the",
"given",
"address",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/messaging/impl/NettyMessagingService.java#L471-L502 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/AnalyticsItemsInner.java | AnalyticsItemsInner.putAsync | public Observable<ApplicationInsightsComponentAnalyticsItemInner> putAsync(String resourceGroupName, String resourceName, ItemScopePath scopePath, ApplicationInsightsComponentAnalyticsItemInner itemProperties, Boolean overrideItem) {
"""
Adds or Updates a specific Analytics Item within an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param scopePath Enum indicating if this item definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'analyticsItems', 'myanalyticsItems'
@param itemProperties Properties that need to be specified to create a new item and add it to an Application Insights component.
@param overrideItem Flag indicating whether or not to force save an item. This allows overriding an item if it already exists.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentAnalyticsItemInner object
"""
return putWithServiceResponseAsync(resourceGroupName, resourceName, scopePath, itemProperties, overrideItem).map(new Func1<ServiceResponse<ApplicationInsightsComponentAnalyticsItemInner>, ApplicationInsightsComponentAnalyticsItemInner>() {
@Override
public ApplicationInsightsComponentAnalyticsItemInner call(ServiceResponse<ApplicationInsightsComponentAnalyticsItemInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentAnalyticsItemInner> putAsync(String resourceGroupName, String resourceName, ItemScopePath scopePath, ApplicationInsightsComponentAnalyticsItemInner itemProperties, Boolean overrideItem) {
return putWithServiceResponseAsync(resourceGroupName, resourceName, scopePath, itemProperties, overrideItem).map(new Func1<ServiceResponse<ApplicationInsightsComponentAnalyticsItemInner>, ApplicationInsightsComponentAnalyticsItemInner>() {
@Override
public ApplicationInsightsComponentAnalyticsItemInner call(ServiceResponse<ApplicationInsightsComponentAnalyticsItemInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentAnalyticsItemInner",
">",
"putAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"ItemScopePath",
"scopePath",
",",
"ApplicationInsightsComponentAnalyticsItemInner",
"itemProperties",
",",
"Boolean",
"overrideItem",
")",
"{",
"return",
"putWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"scopePath",
",",
"itemProperties",
",",
"overrideItem",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ApplicationInsightsComponentAnalyticsItemInner",
">",
",",
"ApplicationInsightsComponentAnalyticsItemInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ApplicationInsightsComponentAnalyticsItemInner",
"call",
"(",
"ServiceResponse",
"<",
"ApplicationInsightsComponentAnalyticsItemInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Adds or Updates a specific Analytics Item within an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param scopePath Enum indicating if this item definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'analyticsItems', 'myanalyticsItems'
@param itemProperties Properties that need to be specified to create a new item and add it to an Application Insights component.
@param overrideItem Flag indicating whether or not to force save an item. This allows overriding an item if it already exists.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentAnalyticsItemInner object | [
"Adds",
"or",
"Updates",
"a",
"specific",
"Analytics",
"Item",
"within",
"an",
"Application",
"Insights",
"component",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/AnalyticsItemsInner.java#L602-L609 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/JsonUtil.java | JsonUtil.parseJsonProperty | public static JsonProperty parseJsonProperty(JsonReader reader, String name)
throws RepositoryException, IOException {
"""
Parses a single property of the first element of an array and returns the result as a JSON POJO object.
@param reader the reader with the JSON stream
@param name the already parsed name of the property
@return a new JsonProperty object with the name, type, and value set
@throws RepositoryException
@throws IOException
"""
JsonToken token = reader.peek();
JsonProperty property = new JsonProperty();
property.name = name;
switch (token) {
case BOOLEAN:
// map boolean values directly if not a string
property.type = PropertyType.nameFromValue(PropertyType.BOOLEAN);
property.value = reader.nextBoolean();
break;
case NUMBER:
// map numver values to LONG directly if not a string
property.type = PropertyType.nameFromValue(PropertyType.LONG);
property.value = reader.nextLong();
break;
case STRING:
// parse the string with an option type hint within
parseJsonString(reader, property);
break;
case NULL:
reader.nextNull();
break;
}
return property;
} | java | public static JsonProperty parseJsonProperty(JsonReader reader, String name)
throws RepositoryException, IOException {
JsonToken token = reader.peek();
JsonProperty property = new JsonProperty();
property.name = name;
switch (token) {
case BOOLEAN:
// map boolean values directly if not a string
property.type = PropertyType.nameFromValue(PropertyType.BOOLEAN);
property.value = reader.nextBoolean();
break;
case NUMBER:
// map numver values to LONG directly if not a string
property.type = PropertyType.nameFromValue(PropertyType.LONG);
property.value = reader.nextLong();
break;
case STRING:
// parse the string with an option type hint within
parseJsonString(reader, property);
break;
case NULL:
reader.nextNull();
break;
}
return property;
} | [
"public",
"static",
"JsonProperty",
"parseJsonProperty",
"(",
"JsonReader",
"reader",
",",
"String",
"name",
")",
"throws",
"RepositoryException",
",",
"IOException",
"{",
"JsonToken",
"token",
"=",
"reader",
".",
"peek",
"(",
")",
";",
"JsonProperty",
"property",
"=",
"new",
"JsonProperty",
"(",
")",
";",
"property",
".",
"name",
"=",
"name",
";",
"switch",
"(",
"token",
")",
"{",
"case",
"BOOLEAN",
":",
"// map boolean values directly if not a string",
"property",
".",
"type",
"=",
"PropertyType",
".",
"nameFromValue",
"(",
"PropertyType",
".",
"BOOLEAN",
")",
";",
"property",
".",
"value",
"=",
"reader",
".",
"nextBoolean",
"(",
")",
";",
"break",
";",
"case",
"NUMBER",
":",
"// map numver values to LONG directly if not a string",
"property",
".",
"type",
"=",
"PropertyType",
".",
"nameFromValue",
"(",
"PropertyType",
".",
"LONG",
")",
";",
"property",
".",
"value",
"=",
"reader",
".",
"nextLong",
"(",
")",
";",
"break",
";",
"case",
"STRING",
":",
"// parse the string with an option type hint within",
"parseJsonString",
"(",
"reader",
",",
"property",
")",
";",
"break",
";",
"case",
"NULL",
":",
"reader",
".",
"nextNull",
"(",
")",
";",
"break",
";",
"}",
"return",
"property",
";",
"}"
] | Parses a single property of the first element of an array and returns the result as a JSON POJO object.
@param reader the reader with the JSON stream
@param name the already parsed name of the property
@return a new JsonProperty object with the name, type, and value set
@throws RepositoryException
@throws IOException | [
"Parses",
"a",
"single",
"property",
"of",
"the",
"first",
"element",
"of",
"an",
"array",
"and",
"returns",
"the",
"result",
"as",
"a",
"JSON",
"POJO",
"object",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/JsonUtil.java#L565-L590 |
Alluxio/alluxio | core/server/master/src/main/java/alluxio/master/file/meta/MountTable.java | MountTable.delete | public boolean delete(Supplier<JournalContext> journalContext, AlluxioURI uri) {
"""
Unmounts the given Alluxio path. The path should match an existing mount point.
@param journalContext journal context
@param uri an Alluxio path URI
@return whether the operation succeeded or not
"""
String path = uri.getPath();
LOG.info("Unmounting {}", path);
if (path.equals(ROOT)) {
LOG.warn("Cannot unmount the root mount point.");
return false;
}
try (LockResource r = new LockResource(mWriteLock)) {
if (mState.getMountTable().containsKey(path)) {
// check if the path contains another nested mount point
for (String mountPath : mState.getMountTable().keySet()) {
try {
if (PathUtils.hasPrefix(mountPath, path) && (!path.equals(mountPath))) {
LOG.warn("The path to unmount {} contains another nested mountpoint {}",
path, mountPath);
return false;
}
} catch (InvalidPathException e) {
LOG.warn("Invalid path {} encountered when checking for nested mount point", path);
}
}
mUfsManager.removeMount(mState.getMountTable().get(path).getMountId());
mState.applyAndJournal(journalContext,
DeleteMountPointEntry.newBuilder().setAlluxioPath(path).build());
return true;
}
LOG.warn("Mount point {} does not exist.", path);
return false;
}
} | java | public boolean delete(Supplier<JournalContext> journalContext, AlluxioURI uri) {
String path = uri.getPath();
LOG.info("Unmounting {}", path);
if (path.equals(ROOT)) {
LOG.warn("Cannot unmount the root mount point.");
return false;
}
try (LockResource r = new LockResource(mWriteLock)) {
if (mState.getMountTable().containsKey(path)) {
// check if the path contains another nested mount point
for (String mountPath : mState.getMountTable().keySet()) {
try {
if (PathUtils.hasPrefix(mountPath, path) && (!path.equals(mountPath))) {
LOG.warn("The path to unmount {} contains another nested mountpoint {}",
path, mountPath);
return false;
}
} catch (InvalidPathException e) {
LOG.warn("Invalid path {} encountered when checking for nested mount point", path);
}
}
mUfsManager.removeMount(mState.getMountTable().get(path).getMountId());
mState.applyAndJournal(journalContext,
DeleteMountPointEntry.newBuilder().setAlluxioPath(path).build());
return true;
}
LOG.warn("Mount point {} does not exist.", path);
return false;
}
} | [
"public",
"boolean",
"delete",
"(",
"Supplier",
"<",
"JournalContext",
">",
"journalContext",
",",
"AlluxioURI",
"uri",
")",
"{",
"String",
"path",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unmounting {}\"",
",",
"path",
")",
";",
"if",
"(",
"path",
".",
"equals",
"(",
"ROOT",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Cannot unmount the root mount point.\"",
")",
";",
"return",
"false",
";",
"}",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mWriteLock",
")",
")",
"{",
"if",
"(",
"mState",
".",
"getMountTable",
"(",
")",
".",
"containsKey",
"(",
"path",
")",
")",
"{",
"// check if the path contains another nested mount point",
"for",
"(",
"String",
"mountPath",
":",
"mState",
".",
"getMountTable",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"PathUtils",
".",
"hasPrefix",
"(",
"mountPath",
",",
"path",
")",
"&&",
"(",
"!",
"path",
".",
"equals",
"(",
"mountPath",
")",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"The path to unmount {} contains another nested mountpoint {}\"",
",",
"path",
",",
"mountPath",
")",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"InvalidPathException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Invalid path {} encountered when checking for nested mount point\"",
",",
"path",
")",
";",
"}",
"}",
"mUfsManager",
".",
"removeMount",
"(",
"mState",
".",
"getMountTable",
"(",
")",
".",
"get",
"(",
"path",
")",
".",
"getMountId",
"(",
")",
")",
";",
"mState",
".",
"applyAndJournal",
"(",
"journalContext",
",",
"DeleteMountPointEntry",
".",
"newBuilder",
"(",
")",
".",
"setAlluxioPath",
"(",
"path",
")",
".",
"build",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Mount point {} does not exist.\"",
",",
"path",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Unmounts the given Alluxio path. The path should match an existing mount point.
@param journalContext journal context
@param uri an Alluxio path URI
@return whether the operation succeeded or not | [
"Unmounts",
"the",
"given",
"Alluxio",
"path",
".",
"The",
"path",
"should",
"match",
"an",
"existing",
"mount",
"point",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MountTable.java#L157-L187 |
mgledi/DRUMS | src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java | GeneralStructure.addKeyPart | public boolean addKeyPart(String name, int size) throws IOException {
"""
Adds a new KeyPart
@param name
the name of the key part. With this name you can access this part
@param size
the size of the key part in bytes
@return true if adding the key part was successful
@throws IOException
"""
if (INSTANCE_EXISITS) {
throw new IOException("A GeneralStroable was already instantiated. You cant further add Key Parts");
}
int hash = Arrays.hashCode(name.getBytes());
int index = keyPartNames.size();
if (keyHash2Index.containsKey(hash)) {
logger.error("A keyPart with the name {} already exists", name);
return false;
}
keyPartNames.add(name);
keyHash2Index.put(hash, index);
keyIndex2Hash.add(hash);
keySizes.add(size);
keyByteOffsets.add(keySize);
keySize += size;
return true;
} | java | public boolean addKeyPart(String name, int size) throws IOException {
if (INSTANCE_EXISITS) {
throw new IOException("A GeneralStroable was already instantiated. You cant further add Key Parts");
}
int hash = Arrays.hashCode(name.getBytes());
int index = keyPartNames.size();
if (keyHash2Index.containsKey(hash)) {
logger.error("A keyPart with the name {} already exists", name);
return false;
}
keyPartNames.add(name);
keyHash2Index.put(hash, index);
keyIndex2Hash.add(hash);
keySizes.add(size);
keyByteOffsets.add(keySize);
keySize += size;
return true;
} | [
"public",
"boolean",
"addKeyPart",
"(",
"String",
"name",
",",
"int",
"size",
")",
"throws",
"IOException",
"{",
"if",
"(",
"INSTANCE_EXISITS",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A GeneralStroable was already instantiated. You cant further add Key Parts\"",
")",
";",
"}",
"int",
"hash",
"=",
"Arrays",
".",
"hashCode",
"(",
"name",
".",
"getBytes",
"(",
")",
")",
";",
"int",
"index",
"=",
"keyPartNames",
".",
"size",
"(",
")",
";",
"if",
"(",
"keyHash2Index",
".",
"containsKey",
"(",
"hash",
")",
")",
"{",
"logger",
".",
"error",
"(",
"\"A keyPart with the name {} already exists\"",
",",
"name",
")",
";",
"return",
"false",
";",
"}",
"keyPartNames",
".",
"add",
"(",
"name",
")",
";",
"keyHash2Index",
".",
"put",
"(",
"hash",
",",
"index",
")",
";",
"keyIndex2Hash",
".",
"add",
"(",
"hash",
")",
";",
"keySizes",
".",
"add",
"(",
"size",
")",
";",
"keyByteOffsets",
".",
"add",
"(",
"keySize",
")",
";",
"keySize",
"+=",
"size",
";",
"return",
"true",
";",
"}"
] | Adds a new KeyPart
@param name
the name of the key part. With this name you can access this part
@param size
the size of the key part in bytes
@return true if adding the key part was successful
@throws IOException | [
"Adds",
"a",
"new",
"KeyPart"
] | train | https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java#L125-L142 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/util/GosuStringUtil.java | GosuStringUtil.lastIndexOf | public static int lastIndexOf(String str, char searchChar, int startPos) {
"""
<p>Finds the last index within a String from a start position,
handling <code>null</code>.
This method uses {@link String#lastIndexOf(int, int)}.</p>
<p>A <code>null</code> or empty ("") String will return <code>-1</code>.
A negative start position returns <code>-1</code>.
A start position greater than the string length searches the whole string.</p>
<pre>
GosuStringUtil.lastIndexOf(null, *, *) = -1
GosuStringUtil.lastIndexOf("", *, *) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 8) = 5
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 4) = 2
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 0) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 9) = 5
GosuStringUtil.lastIndexOf("aabaabaa", 'b', -1) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'a', 0) = 0
</pre>
@param str the String to check, may be null
@param searchChar the character to find
@param startPos the start position
@return the last index of the search character,
-1 if no match or <code>null</code> string input
@since 2.0
"""
if (isEmpty(str)) {
return -1;
}
return str.lastIndexOf(searchChar, startPos);
} | java | public static int lastIndexOf(String str, char searchChar, int startPos) {
if (isEmpty(str)) {
return -1;
}
return str.lastIndexOf(searchChar, startPos);
} | [
"public",
"static",
"int",
"lastIndexOf",
"(",
"String",
"str",
",",
"char",
"searchChar",
",",
"int",
"startPos",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"str",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"str",
".",
"lastIndexOf",
"(",
"searchChar",
",",
"startPos",
")",
";",
"}"
] | <p>Finds the last index within a String from a start position,
handling <code>null</code>.
This method uses {@link String#lastIndexOf(int, int)}.</p>
<p>A <code>null</code> or empty ("") String will return <code>-1</code>.
A negative start position returns <code>-1</code>.
A start position greater than the string length searches the whole string.</p>
<pre>
GosuStringUtil.lastIndexOf(null, *, *) = -1
GosuStringUtil.lastIndexOf("", *, *) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 8) = 5
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 4) = 2
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 0) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'b', 9) = 5
GosuStringUtil.lastIndexOf("aabaabaa", 'b', -1) = -1
GosuStringUtil.lastIndexOf("aabaabaa", 'a', 0) = 0
</pre>
@param str the String to check, may be null
@param searchChar the character to find
@param startPos the start position
@return the last index of the search character,
-1 if no match or <code>null</code> string input
@since 2.0 | [
"<p",
">",
"Finds",
"the",
"last",
"index",
"within",
"a",
"String",
"from",
"a",
"start",
"position",
"handling",
"<code",
">",
"null<",
"/",
"code",
">",
".",
"This",
"method",
"uses",
"{",
"@link",
"String#lastIndexOf",
"(",
"int",
"int",
")",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/GosuStringUtil.java#L886-L891 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/HFClient.java | HFClient.newOrderer | public Orderer newOrderer(String name, String grpcURL) throws InvalidArgumentException {
"""
Create a new urlOrderer.
@param name name of the orderer.
@param grpcURL url location of orderer grpc or grpcs protocol.
@return a new Orderer.
@throws InvalidArgumentException
"""
clientCheck();
return newOrderer(name, grpcURL, null);
} | java | public Orderer newOrderer(String name, String grpcURL) throws InvalidArgumentException {
clientCheck();
return newOrderer(name, grpcURL, null);
} | [
"public",
"Orderer",
"newOrderer",
"(",
"String",
"name",
",",
"String",
"grpcURL",
")",
"throws",
"InvalidArgumentException",
"{",
"clientCheck",
"(",
")",
";",
"return",
"newOrderer",
"(",
"name",
",",
"grpcURL",
",",
"null",
")",
";",
"}"
] | Create a new urlOrderer.
@param name name of the orderer.
@param grpcURL url location of orderer grpc or grpcs protocol.
@return a new Orderer.
@throws InvalidArgumentException | [
"Create",
"a",
"new",
"urlOrderer",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/HFClient.java#L694-L697 |
sporniket/core | sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/WindowLocation.java | WindowLocation.snapWindowTo | public static void snapWindowTo(Window win, int location) {
"""
Snap the Window Position to a special location.
@param win
The Window to move
@param location
A value among the allowed predefined positions
"""
Dimension _screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension _window = win.getSize();
int _wx = 0;
int _wy = 0;
switch (location)
{
case TOP_LEFT:
break;
case TOP_CENTER:
_wx = (_screen.width - _window.width) / 2;
break;
case TOP_RIGHT:
_wx = _screen.width - _window.width;
break;
case MIDDLE_LEFT:
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_RIGHT:
_wx = _screen.width - _window.width;
_wy = (_screen.height - _window.height) / 2;
break;
case BOTTOM_LEFT:
_wy = _screen.height - _window.height;
break;
case BOTTOM_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = _screen.height - _window.height;
break;
case BOTTOM_RIGHT:
_wx = _screen.width - _window.width;
_wy = _screen.height - _window.height;
break;
}
win.setLocation(new Point(_wx, _wy));
} | java | public static void snapWindowTo(Window win, int location)
{
Dimension _screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension _window = win.getSize();
int _wx = 0;
int _wy = 0;
switch (location)
{
case TOP_LEFT:
break;
case TOP_CENTER:
_wx = (_screen.width - _window.width) / 2;
break;
case TOP_RIGHT:
_wx = _screen.width - _window.width;
break;
case MIDDLE_LEFT:
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_RIGHT:
_wx = _screen.width - _window.width;
_wy = (_screen.height - _window.height) / 2;
break;
case BOTTOM_LEFT:
_wy = _screen.height - _window.height;
break;
case BOTTOM_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = _screen.height - _window.height;
break;
case BOTTOM_RIGHT:
_wx = _screen.width - _window.width;
_wy = _screen.height - _window.height;
break;
}
win.setLocation(new Point(_wx, _wy));
} | [
"public",
"static",
"void",
"snapWindowTo",
"(",
"Window",
"win",
",",
"int",
"location",
")",
"{",
"Dimension",
"_screen",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getScreenSize",
"(",
")",
";",
"Dimension",
"_window",
"=",
"win",
".",
"getSize",
"(",
")",
";",
"int",
"_wx",
"=",
"0",
";",
"int",
"_wy",
"=",
"0",
";",
"switch",
"(",
"location",
")",
"{",
"case",
"TOP_LEFT",
":",
"break",
";",
"case",
"TOP_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"break",
";",
"case",
"TOP_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"break",
";",
"case",
"MIDDLE_LEFT",
":",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"MIDDLE_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"MIDDLE_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"BOTTOM_LEFT",
":",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"case",
"BOTTOM_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"case",
"BOTTOM_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"}",
"win",
".",
"setLocation",
"(",
"new",
"Point",
"(",
"_wx",
",",
"_wy",
")",
")",
";",
"}"
] | Snap the Window Position to a special location.
@param win
The Window to move
@param location
A value among the allowed predefined positions | [
"Snap",
"the",
"Window",
"Position",
"to",
"a",
"special",
"location",
"."
] | train | https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/WindowLocation.java#L76-L116 |
CODAIT/stocator | src/main/java/com/ibm/stocator/fs/common/Utils.java | Utils.getOption | public static String getOption(Properties props, String key) throws IOException {
"""
Get a mandatory configuration option
@param props property set
@param key key
@return value of the configuration
@throws IOException if there was no match for the key
"""
String val = props.getProperty(key);
if (val == null) {
throw new IOException("Undefined property: " + key);
}
return val;
} | java | public static String getOption(Properties props, String key) throws IOException {
String val = props.getProperty(key);
if (val == null) {
throw new IOException("Undefined property: " + key);
}
return val;
} | [
"public",
"static",
"String",
"getOption",
"(",
"Properties",
"props",
",",
"String",
"key",
")",
"throws",
"IOException",
"{",
"String",
"val",
"=",
"props",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Undefined property: \"",
"+",
"key",
")",
";",
"}",
"return",
"val",
";",
"}"
] | Get a mandatory configuration option
@param props property set
@param key key
@return value of the configuration
@throws IOException if there was no match for the key | [
"Get",
"a",
"mandatory",
"configuration",
"option"
] | train | https://github.com/CODAIT/stocator/blob/35969cadd2e8faa6fdac45e8bec1799fdd3d8299/src/main/java/com/ibm/stocator/fs/common/Utils.java#L198-L204 |
primefaces/primefaces | src/main/java/org/primefaces/expression/SearchExpressionFacade.java | SearchExpressionFacade.resolveComponent | public static UIComponent resolveComponent(FacesContext context, UIComponent source, String expression) {
"""
Resolves a {@link UIComponent} for the given expression.
@param context The {@link FacesContext}.
@param source The source component. E.g. a button.
@param expression The search expression.
@return A resolved {@link UIComponent} or <code>null</code>.
"""
return resolveComponent(context, source, expression, SearchExpressionHint.NONE);
} | java | public static UIComponent resolveComponent(FacesContext context, UIComponent source, String expression) {
return resolveComponent(context, source, expression, SearchExpressionHint.NONE);
} | [
"public",
"static",
"UIComponent",
"resolveComponent",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"source",
",",
"String",
"expression",
")",
"{",
"return",
"resolveComponent",
"(",
"context",
",",
"source",
",",
"expression",
",",
"SearchExpressionHint",
".",
"NONE",
")",
";",
"}"
] | Resolves a {@link UIComponent} for the given expression.
@param context The {@link FacesContext}.
@param source The source component. E.g. a button.
@param expression The search expression.
@return A resolved {@link UIComponent} or <code>null</code>. | [
"Resolves",
"a",
"{",
"@link",
"UIComponent",
"}",
"for",
"the",
"given",
"expression",
"."
] | train | https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/expression/SearchExpressionFacade.java#L419-L422 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/BackupShortTermRetentionPoliciesInner.java | BackupShortTermRetentionPoliciesInner.getAsync | public Observable<BackupShortTermRetentionPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
"""
Gets a database's short term retention policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BackupShortTermRetentionPolicyInner object
"""
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<BackupShortTermRetentionPolicyInner>, BackupShortTermRetentionPolicyInner>() {
@Override
public BackupShortTermRetentionPolicyInner call(ServiceResponse<BackupShortTermRetentionPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<BackupShortTermRetentionPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<BackupShortTermRetentionPolicyInner>, BackupShortTermRetentionPolicyInner>() {
@Override
public BackupShortTermRetentionPolicyInner call(ServiceResponse<BackupShortTermRetentionPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BackupShortTermRetentionPolicyInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BackupShortTermRetentionPolicyInner",
">",
",",
"BackupShortTermRetentionPolicyInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BackupShortTermRetentionPolicyInner",
"call",
"(",
"ServiceResponse",
"<",
"BackupShortTermRetentionPolicyInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a database's short term retention policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BackupShortTermRetentionPolicyInner object | [
"Gets",
"a",
"database",
"s",
"short",
"term",
"retention",
"policy",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/BackupShortTermRetentionPoliciesInner.java#L131-L138 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/Assert.java | Assert.isAssignableTo | public static void isAssignableTo(Class<?> from, Class<?> to, RuntimeException cause) {
"""
Asserts that the {@link Class 'from' class type} is assignable to the {@link Class 'to' class type}.
The assertion holds if and only if the {@link Class 'from' class type} is the same as or a subclass
of the {@link Class 'to' class type}.
@param from {@link Class class type} being evaluated for assignment compatibility
with the {@link Class 'to' class type}.
@param to {@link Class class type} used to determine if the {@link Class 'from' class type}
is assignment compatible.
@param cause {@link RuntimeException} thrown if the assertion fails.
@throws java.lang.RuntimeException if the {@link Class 'from' class type} is not assignment compatible
with the {@link Class 'to' class type}.
@see java.lang.Class#isAssignableFrom(Class)
"""
if (isNotAssignableTo(from, to)) {
throw cause;
}
} | java | public static void isAssignableTo(Class<?> from, Class<?> to, RuntimeException cause) {
if (isNotAssignableTo(from, to)) {
throw cause;
}
} | [
"public",
"static",
"void",
"isAssignableTo",
"(",
"Class",
"<",
"?",
">",
"from",
",",
"Class",
"<",
"?",
">",
"to",
",",
"RuntimeException",
"cause",
")",
"{",
"if",
"(",
"isNotAssignableTo",
"(",
"from",
",",
"to",
")",
")",
"{",
"throw",
"cause",
";",
"}",
"}"
] | Asserts that the {@link Class 'from' class type} is assignable to the {@link Class 'to' class type}.
The assertion holds if and only if the {@link Class 'from' class type} is the same as or a subclass
of the {@link Class 'to' class type}.
@param from {@link Class class type} being evaluated for assignment compatibility
with the {@link Class 'to' class type}.
@param to {@link Class class type} used to determine if the {@link Class 'from' class type}
is assignment compatible.
@param cause {@link RuntimeException} thrown if the assertion fails.
@throws java.lang.RuntimeException if the {@link Class 'from' class type} is not assignment compatible
with the {@link Class 'to' class type}.
@see java.lang.Class#isAssignableFrom(Class) | [
"Asserts",
"that",
"the",
"{",
"@link",
"Class",
"from",
"class",
"type",
"}",
"is",
"assignable",
"to",
"the",
"{",
"@link",
"Class",
"to",
"class",
"type",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/Assert.java#L584-L588 |
performancecopilot/parfait | parfait-core/src/main/java/io/pcp/parfait/MonitorableRegistry.java | MonitorableRegistry.registerOrReuse | @SuppressWarnings("unchecked")
public synchronized <T> T registerOrReuse(Monitorable<T> monitorable) {
"""
Registers the monitorable if it does not already exist, but otherwise returns an already registered
Monitorable with the same name, Semantics and UNnit definition. This method is useful when objects
appear and disappear, and then return, and the lifecycle of the application requires an attempt to recreate
the Monitorable without knowing if it has already been created.
If there exists a Monitorable with the same name, but with different Semantics or Unit then an IllegalArgumentException
is thrown.
"""
String name = monitorable.getName();
if (monitorables.containsKey(name)) {
Monitorable<?> existingMonitorableWithSameName = monitorables.get(name);
if (monitorable.getSemantics().equals(existingMonitorableWithSameName.getSemantics()) && monitorable.getUnit().equals(existingMonitorableWithSameName.getUnit())) {
return (T) existingMonitorableWithSameName;
} else {
throw new IllegalArgumentException(String.format("Cannot reuse the same name %s for a monitorable with different Semantics or Unit: requested=%s, existing=%s", name, monitorable, existingMonitorableWithSameName));
}
} else {
monitorables.put(name, monitorable);
notifyListenersOfNewMonitorable(monitorable);
return (T) monitorable;
}
} | java | @SuppressWarnings("unchecked")
public synchronized <T> T registerOrReuse(Monitorable<T> monitorable) {
String name = monitorable.getName();
if (monitorables.containsKey(name)) {
Monitorable<?> existingMonitorableWithSameName = monitorables.get(name);
if (monitorable.getSemantics().equals(existingMonitorableWithSameName.getSemantics()) && monitorable.getUnit().equals(existingMonitorableWithSameName.getUnit())) {
return (T) existingMonitorableWithSameName;
} else {
throw new IllegalArgumentException(String.format("Cannot reuse the same name %s for a monitorable with different Semantics or Unit: requested=%s, existing=%s", name, monitorable, existingMonitorableWithSameName));
}
} else {
monitorables.put(name, monitorable);
notifyListenersOfNewMonitorable(monitorable);
return (T) monitorable;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"synchronized",
"<",
"T",
">",
"T",
"registerOrReuse",
"(",
"Monitorable",
"<",
"T",
">",
"monitorable",
")",
"{",
"String",
"name",
"=",
"monitorable",
".",
"getName",
"(",
")",
";",
"if",
"(",
"monitorables",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"Monitorable",
"<",
"?",
">",
"existingMonitorableWithSameName",
"=",
"monitorables",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"monitorable",
".",
"getSemantics",
"(",
")",
".",
"equals",
"(",
"existingMonitorableWithSameName",
".",
"getSemantics",
"(",
")",
")",
"&&",
"monitorable",
".",
"getUnit",
"(",
")",
".",
"equals",
"(",
"existingMonitorableWithSameName",
".",
"getUnit",
"(",
")",
")",
")",
"{",
"return",
"(",
"T",
")",
"existingMonitorableWithSameName",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Cannot reuse the same name %s for a monitorable with different Semantics or Unit: requested=%s, existing=%s\"",
",",
"name",
",",
"monitorable",
",",
"existingMonitorableWithSameName",
")",
")",
";",
"}",
"}",
"else",
"{",
"monitorables",
".",
"put",
"(",
"name",
",",
"monitorable",
")",
";",
"notifyListenersOfNewMonitorable",
"(",
"monitorable",
")",
";",
"return",
"(",
"T",
")",
"monitorable",
";",
"}",
"}"
] | Registers the monitorable if it does not already exist, but otherwise returns an already registered
Monitorable with the same name, Semantics and UNnit definition. This method is useful when objects
appear and disappear, and then return, and the lifecycle of the application requires an attempt to recreate
the Monitorable without knowing if it has already been created.
If there exists a Monitorable with the same name, but with different Semantics or Unit then an IllegalArgumentException
is thrown. | [
"Registers",
"the",
"monitorable",
"if",
"it",
"does",
"not",
"already",
"exist",
"but",
"otherwise",
"returns",
"an",
"already",
"registered",
"Monitorable",
"with",
"the",
"same",
"name",
"Semantics",
"and",
"UNnit",
"definition",
".",
"This",
"method",
"is",
"useful",
"when",
"objects",
"appear",
"and",
"disappear",
"and",
"then",
"return",
"and",
"the",
"lifecycle",
"of",
"the",
"application",
"requires",
"an",
"attempt",
"to",
"recreate",
"the",
"Monitorable",
"without",
"knowing",
"if",
"it",
"has",
"already",
"been",
"created",
"."
] | train | https://github.com/performancecopilot/parfait/blob/33ed3aaa96ee3e0ab4c45791a7bd3e5cd443e94b/parfait-core/src/main/java/io/pcp/parfait/MonitorableRegistry.java#L86-L101 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java | JDBCUtilities.createEmptyTable | public static void createEmptyTable(Connection connection, String tableReference) throws SQLException {
"""
A method to create an empty table (no columns)
@param connection Connection
@param tableReference Table name
@throws java.sql.SQLException
"""
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE "+ tableReference+ " ()");
}
} | java | public static void createEmptyTable(Connection connection, String tableReference) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE "+ tableReference+ " ()");
}
} | [
"public",
"static",
"void",
"createEmptyTable",
"(",
"Connection",
"connection",
",",
"String",
"tableReference",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
")",
"{",
"statement",
".",
"execute",
"(",
"\"CREATE TABLE \"",
"+",
"tableReference",
"+",
"\" ()\"",
")",
";",
"}",
"}"
] | A method to create an empty table (no columns)
@param connection Connection
@param tableReference Table name
@throws java.sql.SQLException | [
"A",
"method",
"to",
"create",
"an",
"empty",
"table",
"(",
"no",
"columns",
")"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUtilities.java#L387-L391 |
opentelecoms-org/zrtp-java | src/zorg/ZRTP.java | ZRTP.setSdpHelloHash | public void setSdpHelloHash(String version, String helloHash) {
"""
Hash of the Hello message to be received. This hash is sent by the other
end as part of the SDP for further verification.
@param version
ZRTP version of the hash
@param helloHash
Hello hash received as part of SDP in SIP
"""
if (!version.startsWith(VERSION_PREFIX)) {
logWarning("Different version number: '" + version + "' Ours: '"
+ VERSION_PREFIX + "' (" + VERSION + ")");
}
sdpHelloHashReceived = helloHash;
} | java | public void setSdpHelloHash(String version, String helloHash) {
if (!version.startsWith(VERSION_PREFIX)) {
logWarning("Different version number: '" + version + "' Ours: '"
+ VERSION_PREFIX + "' (" + VERSION + ")");
}
sdpHelloHashReceived = helloHash;
} | [
"public",
"void",
"setSdpHelloHash",
"(",
"String",
"version",
",",
"String",
"helloHash",
")",
"{",
"if",
"(",
"!",
"version",
".",
"startsWith",
"(",
"VERSION_PREFIX",
")",
")",
"{",
"logWarning",
"(",
"\"Different version number: '\"",
"+",
"version",
"+",
"\"' Ours: '\"",
"+",
"VERSION_PREFIX",
"+",
"\"' (\"",
"+",
"VERSION",
"+",
"\")\"",
")",
";",
"}",
"sdpHelloHashReceived",
"=",
"helloHash",
";",
"}"
] | Hash of the Hello message to be received. This hash is sent by the other
end as part of the SDP for further verification.
@param version
ZRTP version of the hash
@param helloHash
Hello hash received as part of SDP in SIP | [
"Hash",
"of",
"the",
"Hello",
"message",
"to",
"be",
"received",
".",
"This",
"hash",
"is",
"sent",
"by",
"the",
"other",
"end",
"as",
"part",
"of",
"the",
"SDP",
"for",
"further",
"verification",
"."
] | train | https://github.com/opentelecoms-org/zrtp-java/blob/10a0c77866c5d1b1504df161db9a447f5069ed54/src/zorg/ZRTP.java#L2554-L2560 |
alkacon/opencms-core | src/org/opencms/ade/contenteditor/CmsContentTypeVisitor.java | CmsContentTypeVisitor.readDefaultValue | private String readDefaultValue(I_CmsXmlSchemaType schemaType, String path) {
"""
Reads the default value for the given type.<p>
@param schemaType the schema type
@param path the element path
@return the default value
"""
return m_contentHandler.getDefault(getCmsObject(), m_file, schemaType, path, m_locale);
} | java | private String readDefaultValue(I_CmsXmlSchemaType schemaType, String path) {
return m_contentHandler.getDefault(getCmsObject(), m_file, schemaType, path, m_locale);
} | [
"private",
"String",
"readDefaultValue",
"(",
"I_CmsXmlSchemaType",
"schemaType",
",",
"String",
"path",
")",
"{",
"return",
"m_contentHandler",
".",
"getDefault",
"(",
"getCmsObject",
"(",
")",
",",
"m_file",
",",
"schemaType",
",",
"path",
",",
"m_locale",
")",
";",
"}"
] | Reads the default value for the given type.<p>
@param schemaType the schema type
@param path the element path
@return the default value | [
"Reads",
"the",
"default",
"value",
"for",
"the",
"given",
"type",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/contenteditor/CmsContentTypeVisitor.java#L746-L749 |
CODAIT/stocator | src/main/java/com/ibm/stocator/fs/cos/COSAPIClient.java | COSAPIClient.pathToKey | private String pathToKey(Path path) {
"""
Turns a path (relative or otherwise) into an COS key
@param path object full path
"""
if (!path.isAbsolute()) {
path = new Path(workingDir, path);
}
if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
return "";
}
return path.toUri().getPath().substring(1);
} | java | private String pathToKey(Path path) {
if (!path.isAbsolute()) {
path = new Path(workingDir, path);
}
if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
return "";
}
return path.toUri().getPath().substring(1);
} | [
"private",
"String",
"pathToKey",
"(",
"Path",
"path",
")",
"{",
"if",
"(",
"!",
"path",
".",
"isAbsolute",
"(",
")",
")",
"{",
"path",
"=",
"new",
"Path",
"(",
"workingDir",
",",
"path",
")",
";",
"}",
"if",
"(",
"path",
".",
"toUri",
"(",
")",
".",
"getScheme",
"(",
")",
"!=",
"null",
"&&",
"path",
".",
"toUri",
"(",
")",
".",
"getPath",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"path",
".",
"toUri",
"(",
")",
".",
"getPath",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"}"
] | Turns a path (relative or otherwise) into an COS key
@param path object full path | [
"Turns",
"a",
"path",
"(",
"relative",
"or",
"otherwise",
")",
"into",
"an",
"COS",
"key"
] | train | https://github.com/CODAIT/stocator/blob/35969cadd2e8faa6fdac45e8bec1799fdd3d8299/src/main/java/com/ibm/stocator/fs/cos/COSAPIClient.java#L1035-L1045 |
whitesource/agents | wss-agent-api/src/main/java/org/whitesource/agent/api/dispatch/RequestFactory.java | RequestFactory.newDependencyDataRequest | @Deprecated
public GetDependencyDataRequest newDependencyDataRequest(String orgToken, Collection<AgentProjectInfo> projects, String userKey) {
"""
Create new Dependency Data request.
@param orgToken WhiteSource organization token.
@param projects Projects status statement to check.
@param userKey user key uniquely identifying the account at white source.
@return Newly created request to get Dependency Additional Data (Licenses, Description, homepageUrl and Vulnerabilities).
"""
return newDependencyDataRequest(orgToken, null, null, projects, userKey);
} | java | @Deprecated
public GetDependencyDataRequest newDependencyDataRequest(String orgToken, Collection<AgentProjectInfo> projects, String userKey) {
return newDependencyDataRequest(orgToken, null, null, projects, userKey);
} | [
"@",
"Deprecated",
"public",
"GetDependencyDataRequest",
"newDependencyDataRequest",
"(",
"String",
"orgToken",
",",
"Collection",
"<",
"AgentProjectInfo",
">",
"projects",
",",
"String",
"userKey",
")",
"{",
"return",
"newDependencyDataRequest",
"(",
"orgToken",
",",
"null",
",",
"null",
",",
"projects",
",",
"userKey",
")",
";",
"}"
] | Create new Dependency Data request.
@param orgToken WhiteSource organization token.
@param projects Projects status statement to check.
@param userKey user key uniquely identifying the account at white source.
@return Newly created request to get Dependency Additional Data (Licenses, Description, homepageUrl and Vulnerabilities). | [
"Create",
"new",
"Dependency",
"Data",
"request",
"."
] | train | https://github.com/whitesource/agents/blob/8a947a3dbad257aff70f23f79fb3a55ca90b765f/wss-agent-api/src/main/java/org/whitesource/agent/api/dispatch/RequestFactory.java#L483-L486 |
inmite/android-validation-komensky | library/src/main/java/eu/inmite/android/lib/validations/form/FormValidator.java | FormValidator.startLiveValidation | public static void startLiveValidation(final Object target, final View formContainer, final IValidationCallback callback) {
"""
Start live validation - whenever focus changes from view with validations upon itself, validators will run.<br/>
Don't forget to call {@link #stopLiveValidation(Object)} once you are done.
@param target target with views to validate, there can be only one continuous validation per target
@param formContainer view that contains our form (views to validate)
@param callback callback invoked whenever there is some validation fail, can be null
@throws IllegalArgumentException if formContainer or target is null
"""
if (formContainer == null) {
throw new IllegalArgumentException("form container view cannot be null");
}
if (target == null) {
throw new IllegalArgumentException("target cannot be null");
}
if (sLiveValidations == null) {
sLiveValidations = new HashMap<>();
} else if (sLiveValidations.containsKey(target)) {
// validation is already running
return;
}
final Map<View, FieldInfo> infoMap = FieldFinder.getFieldsForTarget(target);
final ViewGlobalFocusChangeListener listener = new ViewGlobalFocusChangeListener(infoMap, formContainer, target, callback);
final ViewTreeObserver observer = formContainer.getViewTreeObserver();
observer.addOnGlobalFocusChangeListener(listener);
sLiveValidations.put(target, listener);
} | java | public static void startLiveValidation(final Object target, final View formContainer, final IValidationCallback callback) {
if (formContainer == null) {
throw new IllegalArgumentException("form container view cannot be null");
}
if (target == null) {
throw new IllegalArgumentException("target cannot be null");
}
if (sLiveValidations == null) {
sLiveValidations = new HashMap<>();
} else if (sLiveValidations.containsKey(target)) {
// validation is already running
return;
}
final Map<View, FieldInfo> infoMap = FieldFinder.getFieldsForTarget(target);
final ViewGlobalFocusChangeListener listener = new ViewGlobalFocusChangeListener(infoMap, formContainer, target, callback);
final ViewTreeObserver observer = formContainer.getViewTreeObserver();
observer.addOnGlobalFocusChangeListener(listener);
sLiveValidations.put(target, listener);
} | [
"public",
"static",
"void",
"startLiveValidation",
"(",
"final",
"Object",
"target",
",",
"final",
"View",
"formContainer",
",",
"final",
"IValidationCallback",
"callback",
")",
"{",
"if",
"(",
"formContainer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"form container view cannot be null\"",
")",
";",
"}",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"target cannot be null\"",
")",
";",
"}",
"if",
"(",
"sLiveValidations",
"==",
"null",
")",
"{",
"sLiveValidations",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"else",
"if",
"(",
"sLiveValidations",
".",
"containsKey",
"(",
"target",
")",
")",
"{",
"// validation is already running",
"return",
";",
"}",
"final",
"Map",
"<",
"View",
",",
"FieldInfo",
">",
"infoMap",
"=",
"FieldFinder",
".",
"getFieldsForTarget",
"(",
"target",
")",
";",
"final",
"ViewGlobalFocusChangeListener",
"listener",
"=",
"new",
"ViewGlobalFocusChangeListener",
"(",
"infoMap",
",",
"formContainer",
",",
"target",
",",
"callback",
")",
";",
"final",
"ViewTreeObserver",
"observer",
"=",
"formContainer",
".",
"getViewTreeObserver",
"(",
")",
";",
"observer",
".",
"addOnGlobalFocusChangeListener",
"(",
"listener",
")",
";",
"sLiveValidations",
".",
"put",
"(",
"target",
",",
"listener",
")",
";",
"}"
] | Start live validation - whenever focus changes from view with validations upon itself, validators will run.<br/>
Don't forget to call {@link #stopLiveValidation(Object)} once you are done.
@param target target with views to validate, there can be only one continuous validation per target
@param formContainer view that contains our form (views to validate)
@param callback callback invoked whenever there is some validation fail, can be null
@throws IllegalArgumentException if formContainer or target is null | [
"Start",
"live",
"validation",
"-",
"whenever",
"focus",
"changes",
"from",
"view",
"with",
"validations",
"upon",
"itself",
"validators",
"will",
"run",
".",
"<br",
"/",
">",
"Don",
"t",
"forget",
"to",
"call",
"{",
"@link",
"#stopLiveValidation",
"(",
"Object",
")",
"}",
"once",
"you",
"are",
"done",
"."
] | train | https://github.com/inmite/android-validation-komensky/blob/7c544f2d9f104a9800fcf4757eecb3caa8e76451/library/src/main/java/eu/inmite/android/lib/validations/form/FormValidator.java#L139-L160 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/SigninPanel.java | SigninPanel.newPasswordTextField | protected LabeledPasswordTextFieldPanel<String, T> newPasswordTextField(final String id,
final IModel<T> model) {
"""
Factory method for creating the EmailTextField for the password. This method is invoked in
the constructor from the derived classes and can be overridden so users can provide their own
version of a EmailTextField for the password.
@param id
the id
@param model
the model
@return the text field LabeledPasswordTextFieldPanel
"""
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.password.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.password.label", this);
final LabeledPasswordTextFieldPanel<String, T> pwTextField = new LabeledPasswordTextFieldPanel<String, T>(
id, model, labelModel)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected PasswordTextField newPasswordTextField(final String id, final IModel<T> model)
{
final PasswordTextField pwTextField = new PasswordTextField(id,
new PropertyModel<>(model, "password"));
pwTextField.setOutputMarkupId(true);
if (placeholderModel != null)
{
pwTextField.add(new AttributeAppender("placeholder", placeholderModel));
}
return pwTextField;
}
};
return pwTextField;
} | java | protected LabeledPasswordTextFieldPanel<String, T> newPasswordTextField(final String id,
final IModel<T> model)
{
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.password.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.password.label", this);
final LabeledPasswordTextFieldPanel<String, T> pwTextField = new LabeledPasswordTextFieldPanel<String, T>(
id, model, labelModel)
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected PasswordTextField newPasswordTextField(final String id, final IModel<T> model)
{
final PasswordTextField pwTextField = new PasswordTextField(id,
new PropertyModel<>(model, "password"));
pwTextField.setOutputMarkupId(true);
if (placeholderModel != null)
{
pwTextField.add(new AttributeAppender("placeholder", placeholderModel));
}
return pwTextField;
}
};
return pwTextField;
} | [
"protected",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"newPasswordTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"IModel",
"<",
"String",
">",
"labelModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.password.label\"",
",",
"this",
")",
";",
"final",
"IModel",
"<",
"String",
">",
"placeholderModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.enter.your.password.label\"",
",",
"this",
")",
";",
"final",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"pwTextField",
"=",
"new",
"LabeledPasswordTextFieldPanel",
"<",
"String",
",",
"T",
">",
"(",
"id",
",",
"model",
",",
"labelModel",
")",
"{",
"/** The Constant serialVersionUID. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n\t\t\t * {@inheritDoc}\n\t\t\t */",
"@",
"Override",
"protected",
"PasswordTextField",
"newPasswordTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"PasswordTextField",
"pwTextField",
"=",
"new",
"PasswordTextField",
"(",
"id",
",",
"new",
"PropertyModel",
"<>",
"(",
"model",
",",
"\"password\"",
")",
")",
";",
"pwTextField",
".",
"setOutputMarkupId",
"(",
"true",
")",
";",
"if",
"(",
"placeholderModel",
"!=",
"null",
")",
"{",
"pwTextField",
".",
"add",
"(",
"new",
"AttributeAppender",
"(",
"\"placeholder\"",
",",
"placeholderModel",
")",
")",
";",
"}",
"return",
"pwTextField",
";",
"}",
"}",
";",
"return",
"pwTextField",
";",
"}"
] | Factory method for creating the EmailTextField for the password. This method is invoked in
the constructor from the derived classes and can be overridden so users can provide their own
version of a EmailTextField for the password.
@param id
the id
@param model
the model
@return the text field LabeledPasswordTextFieldPanel | [
"Factory",
"method",
"for",
"creating",
"the",
"EmailTextField",
"for",
"the",
"password",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"EmailTextField",
"for",
"the",
"password",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/SigninPanel.java#L121-L152 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java | ObjectArrayList.fillFromToWith | public void fillFromToWith(int from, int to, Object val) {
"""
Sets the specified range of elements in the specified array to the specified value.
@param from the index of the first element (inclusive) to be filled with the specified value.
@param to the index of the last element (inclusive) to be filled with the specified value.
@param val the value to be stored in the specified elements of the receiver.
"""
checkRangeFromTo(from,to,this.size);
for (int i=from; i<=to;) setQuick(i++,val);
} | java | public void fillFromToWith(int from, int to, Object val) {
checkRangeFromTo(from,to,this.size);
for (int i=from; i<=to;) setQuick(i++,val);
} | [
"public",
"void",
"fillFromToWith",
"(",
"int",
"from",
",",
"int",
"to",
",",
"Object",
"val",
")",
"{",
"checkRangeFromTo",
"(",
"from",
",",
"to",
",",
"this",
".",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"from",
";",
"i",
"<=",
"to",
";",
")",
"setQuick",
"(",
"i",
"++",
"",
",",
"val",
")",
";",
"}"
] | Sets the specified range of elements in the specified array to the specified value.
@param from the index of the first element (inclusive) to be filled with the specified value.
@param to the index of the last element (inclusive) to be filled with the specified value.
@param val the value to be stored in the specified elements of the receiver. | [
"Sets",
"the",
"specified",
"range",
"of",
"elements",
"in",
"the",
"specified",
"array",
"to",
"the",
"specified",
"value",
"."
] | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java#L376-L379 |
radkovo/SwingBox | src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java | TextBoxView.getTextEx | protected String getTextEx(int position, int len) {
"""
Gets the text.
@param position
the position, where to begin
@param len
the length of text portion
@return the text
"""
try {
return getDocument().getText(position, len);
} catch (BadLocationException e) {
e.printStackTrace();
return "";
}
} | java | protected String getTextEx(int position, int len)
{
try {
return getDocument().getText(position, len);
} catch (BadLocationException e) {
e.printStackTrace();
return "";
}
} | [
"protected",
"String",
"getTextEx",
"(",
"int",
"position",
",",
"int",
"len",
")",
"{",
"try",
"{",
"return",
"getDocument",
"(",
")",
".",
"getText",
"(",
"position",
",",
"len",
")",
";",
"}",
"catch",
"(",
"BadLocationException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"\"\"",
";",
"}",
"}"
] | Gets the text.
@param position
the position, where to begin
@param len
the length of text portion
@return the text | [
"Gets",
"the",
"text",
"."
] | train | https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L555-L563 |
leancloud/java-sdk-all | android-sdk/huawei-hmsagent/src/main/java/com/huawei/android/hms/agent/common/ActivityMgr.java | ActivityMgr.onActivityCreated | @Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
"""
activity onCreate 监听回调 | Activity OnCreate Listener Callback
@param activity 发生onCreate事件的activity | Activity that occurs OnCreate events
@param savedInstanceState 缓存状态数据 | Cached state data
"""
HMSAgentLog.d("onCreated:" + StrUtils.objDesc(activity));
setCurActivity(activity);
} | java | @Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
HMSAgentLog.d("onCreated:" + StrUtils.objDesc(activity));
setCurActivity(activity);
} | [
"@",
"Override",
"public",
"void",
"onActivityCreated",
"(",
"Activity",
"activity",
",",
"Bundle",
"savedInstanceState",
")",
"{",
"HMSAgentLog",
".",
"d",
"(",
"\"onCreated:\"",
"+",
"StrUtils",
".",
"objDesc",
"(",
"activity",
")",
")",
";",
"setCurActivity",
"(",
"activity",
")",
";",
"}"
] | activity onCreate 监听回调 | Activity OnCreate Listener Callback
@param activity 发生onCreate事件的activity | Activity that occurs OnCreate events
@param savedInstanceState 缓存状态数据 | Cached state data | [
"activity",
"onCreate",
"监听回调",
"|",
"Activity",
"OnCreate",
"Listener",
"Callback"
] | train | https://github.com/leancloud/java-sdk-all/blob/323f8e7ee38051b1350790e5192304768c5c9f5f/android-sdk/huawei-hmsagent/src/main/java/com/huawei/android/hms/agent/common/ActivityMgr.java#L168-L172 |
brunocvcunha/inutils4j | src/main/java/org/brunocvcunha/inutils4j/MyHTTPUtils.java | MyHTTPUtils.getContent | public static String getContent(String stringUrl, Map<String, String> parameters, Proxy proxy)
throws IOException {
"""
Get content for url/parameters/proxy
@param stringUrl the URL to get
@param parameters HTTP parameters to pass
@param proxy Proxy to use
@return content the response content
@throws IOException I/O error happened
"""
URL url = new URL(stringUrl);
URLConnection conn;
if (proxy != null) {
conn = url.openConnection(proxy);
} else {
conn = url.openConnection();
}
conn.setConnectTimeout(5000); // set connect timeout to 5 seconds
conn.setReadTimeout(60000); // set read timeout to 60 seconds
if (parameters != null) {
for (Entry<String, String> entry : parameters.entrySet()) {
conn.addRequestProperty(entry.getKey(), entry.getValue());
}
}
InputStream is = conn.getInputStream();
if ("gzip".equals(conn.getContentEncoding())) {
is = new GZIPInputStream(is);
}
return MyStreamUtils.readContent(is);
} | java | public static String getContent(String stringUrl, Map<String, String> parameters, Proxy proxy)
throws IOException {
URL url = new URL(stringUrl);
URLConnection conn;
if (proxy != null) {
conn = url.openConnection(proxy);
} else {
conn = url.openConnection();
}
conn.setConnectTimeout(5000); // set connect timeout to 5 seconds
conn.setReadTimeout(60000); // set read timeout to 60 seconds
if (parameters != null) {
for (Entry<String, String> entry : parameters.entrySet()) {
conn.addRequestProperty(entry.getKey(), entry.getValue());
}
}
InputStream is = conn.getInputStream();
if ("gzip".equals(conn.getContentEncoding())) {
is = new GZIPInputStream(is);
}
return MyStreamUtils.readContent(is);
} | [
"public",
"static",
"String",
"getContent",
"(",
"String",
"stringUrl",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"Proxy",
"proxy",
")",
"throws",
"IOException",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"stringUrl",
")",
";",
"URLConnection",
"conn",
";",
"if",
"(",
"proxy",
"!=",
"null",
")",
"{",
"conn",
"=",
"url",
".",
"openConnection",
"(",
"proxy",
")",
";",
"}",
"else",
"{",
"conn",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"}",
"conn",
".",
"setConnectTimeout",
"(",
"5000",
")",
";",
"// set connect timeout to 5 seconds",
"conn",
".",
"setReadTimeout",
"(",
"60000",
")",
";",
"// set read timeout to 60 seconds",
"if",
"(",
"parameters",
"!=",
"null",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"parameters",
".",
"entrySet",
"(",
")",
")",
"{",
"conn",
".",
"addRequestProperty",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"InputStream",
"is",
"=",
"conn",
".",
"getInputStream",
"(",
")",
";",
"if",
"(",
"\"gzip\"",
".",
"equals",
"(",
"conn",
".",
"getContentEncoding",
"(",
")",
")",
")",
"{",
"is",
"=",
"new",
"GZIPInputStream",
"(",
"is",
")",
";",
"}",
"return",
"MyStreamUtils",
".",
"readContent",
"(",
"is",
")",
";",
"}"
] | Get content for url/parameters/proxy
@param stringUrl the URL to get
@param parameters HTTP parameters to pass
@param proxy Proxy to use
@return content the response content
@throws IOException I/O error happened | [
"Get",
"content",
"for",
"url",
"/",
"parameters",
"/",
"proxy"
] | train | https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/MyHTTPUtils.java#L96-L122 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java | PoolsImpl.evaluateAutoScaleAsync | public ServiceFuture<AutoScaleRun> evaluateAutoScaleAsync(String poolId, String autoScaleFormula, final ServiceCallback<AutoScaleRun> serviceCallback) {
"""
Gets the result of evaluating an automatic scaling formula on the pool.
This API is primarily for validating an autoscale formula, as it simply returns the result without applying the formula to the pool. The pool must have auto scaling enabled in order to evaluate a formula.
@param poolId The ID of the pool on which to evaluate the automatic scaling formula.
@param autoScaleFormula The formula for the desired number of compute nodes in the pool. The formula is validated and its results calculated, but it is not applied to the pool. To apply the formula to the pool, 'Enable automatic scaling on a pool'. For more information about specifying this formula, see Automatically scale compute nodes in an Azure Batch pool (https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling).
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromHeaderResponse(evaluateAutoScaleWithServiceResponseAsync(poolId, autoScaleFormula), serviceCallback);
} | java | public ServiceFuture<AutoScaleRun> evaluateAutoScaleAsync(String poolId, String autoScaleFormula, final ServiceCallback<AutoScaleRun> serviceCallback) {
return ServiceFuture.fromHeaderResponse(evaluateAutoScaleWithServiceResponseAsync(poolId, autoScaleFormula), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"AutoScaleRun",
">",
"evaluateAutoScaleAsync",
"(",
"String",
"poolId",
",",
"String",
"autoScaleFormula",
",",
"final",
"ServiceCallback",
"<",
"AutoScaleRun",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromHeaderResponse",
"(",
"evaluateAutoScaleWithServiceResponseAsync",
"(",
"poolId",
",",
"autoScaleFormula",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Gets the result of evaluating an automatic scaling formula on the pool.
This API is primarily for validating an autoscale formula, as it simply returns the result without applying the formula to the pool. The pool must have auto scaling enabled in order to evaluate a formula.
@param poolId The ID of the pool on which to evaluate the automatic scaling formula.
@param autoScaleFormula The formula for the desired number of compute nodes in the pool. The formula is validated and its results calculated, but it is not applied to the pool. To apply the formula to the pool, 'Enable automatic scaling on a pool'. For more information about specifying this formula, see Automatically scale compute nodes in an Azure Batch pool (https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling).
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Gets",
"the",
"result",
"of",
"evaluating",
"an",
"automatic",
"scaling",
"formula",
"on",
"the",
"pool",
".",
"This",
"API",
"is",
"primarily",
"for",
"validating",
"an",
"autoscale",
"formula",
"as",
"it",
"simply",
"returns",
"the",
"result",
"without",
"applying",
"the",
"formula",
"to",
"the",
"pool",
".",
"The",
"pool",
"must",
"have",
"auto",
"scaling",
"enabled",
"in",
"order",
"to",
"evaluate",
"a",
"formula",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java#L2523-L2525 |
netty/netty | codec/src/main/java/io/netty/handler/codec/compression/Snappy.java | Snappy.findMatchingLength | private static int findMatchingLength(ByteBuf in, int minIndex, int inIndex, int maxIndex) {
"""
Iterates over the supplied input buffer between the supplied minIndex and
maxIndex to find how long our matched copy overlaps with an already-written
literal value.
@param in The input buffer to scan over
@param minIndex The index in the input buffer to start scanning from
@param inIndex The index of the start of our copy
@param maxIndex The length of our input buffer
@return The number of bytes for which our candidate copy is a repeat of
"""
int matched = 0;
while (inIndex <= maxIndex - 4 &&
in.getInt(inIndex) == in.getInt(minIndex + matched)) {
inIndex += 4;
matched += 4;
}
while (inIndex < maxIndex && in.getByte(minIndex + matched) == in.getByte(inIndex)) {
++inIndex;
++matched;
}
return matched;
} | java | private static int findMatchingLength(ByteBuf in, int minIndex, int inIndex, int maxIndex) {
int matched = 0;
while (inIndex <= maxIndex - 4 &&
in.getInt(inIndex) == in.getInt(minIndex + matched)) {
inIndex += 4;
matched += 4;
}
while (inIndex < maxIndex && in.getByte(minIndex + matched) == in.getByte(inIndex)) {
++inIndex;
++matched;
}
return matched;
} | [
"private",
"static",
"int",
"findMatchingLength",
"(",
"ByteBuf",
"in",
",",
"int",
"minIndex",
",",
"int",
"inIndex",
",",
"int",
"maxIndex",
")",
"{",
"int",
"matched",
"=",
"0",
";",
"while",
"(",
"inIndex",
"<=",
"maxIndex",
"-",
"4",
"&&",
"in",
".",
"getInt",
"(",
"inIndex",
")",
"==",
"in",
".",
"getInt",
"(",
"minIndex",
"+",
"matched",
")",
")",
"{",
"inIndex",
"+=",
"4",
";",
"matched",
"+=",
"4",
";",
"}",
"while",
"(",
"inIndex",
"<",
"maxIndex",
"&&",
"in",
".",
"getByte",
"(",
"minIndex",
"+",
"matched",
")",
"==",
"in",
".",
"getByte",
"(",
"inIndex",
")",
")",
"{",
"++",
"inIndex",
";",
"++",
"matched",
";",
"}",
"return",
"matched",
";",
"}"
] | Iterates over the supplied input buffer between the supplied minIndex and
maxIndex to find how long our matched copy overlaps with an already-written
literal value.
@param in The input buffer to scan over
@param minIndex The index in the input buffer to start scanning from
@param inIndex The index of the start of our copy
@param maxIndex The length of our input buffer
@return The number of bytes for which our candidate copy is a repeat of | [
"Iterates",
"over",
"the",
"supplied",
"input",
"buffer",
"between",
"the",
"supplied",
"minIndex",
"and",
"maxIndex",
"to",
"find",
"how",
"long",
"our",
"matched",
"copy",
"overlaps",
"with",
"an",
"already",
"-",
"written",
"literal",
"value",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java#L179-L194 |
RestComm/sipunit | src/main/java/org/cafesip/sipunit/SipStack.java | SipStack.createSipPhone | public SipPhone createSipPhone(String me) throws InvalidArgumentException, ParseException {
"""
This method is the equivalent to the other createSipPhone() methods but without a proxy server.
@param me "Address of Record" URI of the phone user. Each SipPhone is associated with one user.
This parameter is used in the "from" header field.
@return A new SipPhone object.
@throws InvalidArgumentException
@throws ParseException
"""
return createSipPhone(null, null, -1, me);
} | java | public SipPhone createSipPhone(String me) throws InvalidArgumentException, ParseException {
return createSipPhone(null, null, -1, me);
} | [
"public",
"SipPhone",
"createSipPhone",
"(",
"String",
"me",
")",
"throws",
"InvalidArgumentException",
",",
"ParseException",
"{",
"return",
"createSipPhone",
"(",
"null",
",",
"null",
",",
"-",
"1",
",",
"me",
")",
";",
"}"
] | This method is the equivalent to the other createSipPhone() methods but without a proxy server.
@param me "Address of Record" URI of the phone user. Each SipPhone is associated with one user.
This parameter is used in the "from" header field.
@return A new SipPhone object.
@throws InvalidArgumentException
@throws ParseException | [
"This",
"method",
"is",
"the",
"equivalent",
"to",
"the",
"other",
"createSipPhone",
"()",
"methods",
"but",
"without",
"a",
"proxy",
"server",
"."
] | train | https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipStack.java#L283-L285 |
OpenBEL/openbel-framework | org.openbel.framework.api/src/main/java/org/openbel/framework/api/BasicPathFinder.java | BasicPathFinder.runDepthFirstScan | private void runDepthFirstScan(final Kam kam,
final KamNode cnode,
final KamNode source,
int depth,
final SetStack<KamNode> nodeStack,
final SetStack<KamEdge> edgeStack,
final List<SimplePath> pathResults) {
"""
Runs a recursive depth-first scan from a {@link KamNode} source until a
max search depth ({@link BasicPathFinder#maxSearchDepth}) is reached.
When the max search depth is reached a {@link SimplePath} is added,
containing the {@link Stack} of {@link KamEdge}, and the algorithm continues.
@param kam {@link Kam}, the kam to traverse
@param cnode {@link KamNode}, the current node to evaluate
@param source {@link KamNode}, the node to search from
@param depth <tt>int</tt>, the current depth of this scan recursion
@param nodeStack {@link Stack} of {@link KamNode}, the nodes on the
current scan from the <tt>source</tt>
@param edgeStack {@link Stack} of {@link KamEdge}, the edges on the
current scan from the <tt>source</tt>
@param pathResults the resulting paths scanned from source
"""
depth += 1;
final Set<KamEdge> edges = kam.getAdjacentEdges(cnode, BOTH);
for (final KamEdge edge : edges) {
if (pushEdge(edge, nodeStack, edgeStack)) {
if (depth == maxSearchDepth) {
final SimplePath newPath =
new SimplePath(kam, source, nodeStack.peek(),
edgeStack.toStack());
pathResults.add(newPath);
} else {
// continue depth first scan
runDepthFirstScan(kam, nodeStack.peek(), source, depth,
nodeStack,
edgeStack, pathResults);
}
edgeStack.pop();
nodeStack.pop();
} else if (endOfBranch(edgeStack, edge, edges.size())) {
final SimplePath newPath =
new SimplePath(kam, source, nodeStack.peek(),
edgeStack.toStack());
pathResults.add(newPath);
}
}
} | java | private void runDepthFirstScan(final Kam kam,
final KamNode cnode,
final KamNode source,
int depth,
final SetStack<KamNode> nodeStack,
final SetStack<KamEdge> edgeStack,
final List<SimplePath> pathResults) {
depth += 1;
final Set<KamEdge> edges = kam.getAdjacentEdges(cnode, BOTH);
for (final KamEdge edge : edges) {
if (pushEdge(edge, nodeStack, edgeStack)) {
if (depth == maxSearchDepth) {
final SimplePath newPath =
new SimplePath(kam, source, nodeStack.peek(),
edgeStack.toStack());
pathResults.add(newPath);
} else {
// continue depth first scan
runDepthFirstScan(kam, nodeStack.peek(), source, depth,
nodeStack,
edgeStack, pathResults);
}
edgeStack.pop();
nodeStack.pop();
} else if (endOfBranch(edgeStack, edge, edges.size())) {
final SimplePath newPath =
new SimplePath(kam, source, nodeStack.peek(),
edgeStack.toStack());
pathResults.add(newPath);
}
}
} | [
"private",
"void",
"runDepthFirstScan",
"(",
"final",
"Kam",
"kam",
",",
"final",
"KamNode",
"cnode",
",",
"final",
"KamNode",
"source",
",",
"int",
"depth",
",",
"final",
"SetStack",
"<",
"KamNode",
">",
"nodeStack",
",",
"final",
"SetStack",
"<",
"KamEdge",
">",
"edgeStack",
",",
"final",
"List",
"<",
"SimplePath",
">",
"pathResults",
")",
"{",
"depth",
"+=",
"1",
";",
"final",
"Set",
"<",
"KamEdge",
">",
"edges",
"=",
"kam",
".",
"getAdjacentEdges",
"(",
"cnode",
",",
"BOTH",
")",
";",
"for",
"(",
"final",
"KamEdge",
"edge",
":",
"edges",
")",
"{",
"if",
"(",
"pushEdge",
"(",
"edge",
",",
"nodeStack",
",",
"edgeStack",
")",
")",
"{",
"if",
"(",
"depth",
"==",
"maxSearchDepth",
")",
"{",
"final",
"SimplePath",
"newPath",
"=",
"new",
"SimplePath",
"(",
"kam",
",",
"source",
",",
"nodeStack",
".",
"peek",
"(",
")",
",",
"edgeStack",
".",
"toStack",
"(",
")",
")",
";",
"pathResults",
".",
"add",
"(",
"newPath",
")",
";",
"}",
"else",
"{",
"// continue depth first scan",
"runDepthFirstScan",
"(",
"kam",
",",
"nodeStack",
".",
"peek",
"(",
")",
",",
"source",
",",
"depth",
",",
"nodeStack",
",",
"edgeStack",
",",
"pathResults",
")",
";",
"}",
"edgeStack",
".",
"pop",
"(",
")",
";",
"nodeStack",
".",
"pop",
"(",
")",
";",
"}",
"else",
"if",
"(",
"endOfBranch",
"(",
"edgeStack",
",",
"edge",
",",
"edges",
".",
"size",
"(",
")",
")",
")",
"{",
"final",
"SimplePath",
"newPath",
"=",
"new",
"SimplePath",
"(",
"kam",
",",
"source",
",",
"nodeStack",
".",
"peek",
"(",
")",
",",
"edgeStack",
".",
"toStack",
"(",
")",
")",
";",
"pathResults",
".",
"add",
"(",
"newPath",
")",
";",
"}",
"}",
"}"
] | Runs a recursive depth-first scan from a {@link KamNode} source until a
max search depth ({@link BasicPathFinder#maxSearchDepth}) is reached.
When the max search depth is reached a {@link SimplePath} is added,
containing the {@link Stack} of {@link KamEdge}, and the algorithm continues.
@param kam {@link Kam}, the kam to traverse
@param cnode {@link KamNode}, the current node to evaluate
@param source {@link KamNode}, the node to search from
@param depth <tt>int</tt>, the current depth of this scan recursion
@param nodeStack {@link Stack} of {@link KamNode}, the nodes on the
current scan from the <tt>source</tt>
@param edgeStack {@link Stack} of {@link KamEdge}, the edges on the
current scan from the <tt>source</tt>
@param pathResults the resulting paths scanned from source | [
"Runs",
"a",
"recursive",
"depth",
"-",
"first",
"scan",
"from",
"a",
"{",
"@link",
"KamNode",
"}",
"source",
"until",
"a",
"max",
"search",
"depth",
"(",
"{",
"@link",
"BasicPathFinder#maxSearchDepth",
"}",
")",
"is",
"reached",
".",
"When",
"the",
"max",
"search",
"depth",
"is",
"reached",
"a",
"{",
"@link",
"SimplePath",
"}",
"is",
"added",
"containing",
"the",
"{",
"@link",
"Stack",
"}",
"of",
"{",
"@link",
"KamEdge",
"}",
"and",
"the",
"algorithm",
"continues",
"."
] | train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.api/src/main/java/org/openbel/framework/api/BasicPathFinder.java#L374-L409 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/MurmurHashUtil.java | MurmurHashUtil.hashBytesByWords | public static int hashBytesByWords(MemorySegment segment, int offset, int lengthInBytes) {
"""
Hash bytes in MemorySegment, length must be aligned to 4 bytes.
@param segment segment.
@param offset offset for MemorySegment
@param lengthInBytes length in MemorySegment
@return hash code
"""
return hashBytesByWords(segment, offset, lengthInBytes, DEFAULT_SEED);
} | java | public static int hashBytesByWords(MemorySegment segment, int offset, int lengthInBytes) {
return hashBytesByWords(segment, offset, lengthInBytes, DEFAULT_SEED);
} | [
"public",
"static",
"int",
"hashBytesByWords",
"(",
"MemorySegment",
"segment",
",",
"int",
"offset",
",",
"int",
"lengthInBytes",
")",
"{",
"return",
"hashBytesByWords",
"(",
"segment",
",",
"offset",
",",
"lengthInBytes",
",",
"DEFAULT_SEED",
")",
";",
"}"
] | Hash bytes in MemorySegment, length must be aligned to 4 bytes.
@param segment segment.
@param offset offset for MemorySegment
@param lengthInBytes length in MemorySegment
@return hash code | [
"Hash",
"bytes",
"in",
"MemorySegment",
"length",
"must",
"be",
"aligned",
"to",
"4",
"bytes",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/MurmurHashUtil.java#L62-L64 |
ixa-ehu/ixa-pipe-ml | src/main/java/eus/ixa/ixa/pipe/ml/document/DocClassifierCrossValidator.java | DocClassifierCrossValidator.evaluate | public void evaluate(ObjectStream<DocSample> samples, int nFolds)
throws IOException {
"""
Starts the evaluation.
@param samples
the data to train and test
@param nFolds
number of folds
@throws IOException if io error
"""
CrossValidationPartitioner<DocSample> partitioner = new CrossValidationPartitioner<>(
samples, nFolds);
while (partitioner.hasNext()) {
CrossValidationPartitioner.TrainingSampleStream<DocSample> trainingSampleStream = partitioner
.next();
DocumentClassifierModel model = DocumentClassifierME.train(languageCode,
trainingSampleStream, params, factory);
DocumentClassifierEvaluator evaluator = new DocumentClassifierEvaluator(
new DocumentClassifierME(model), listeners);
evaluator.evaluate(trainingSampleStream.getTestSampleStream());
documentAccuracy.add(evaluator.getAccuracy(),
evaluator.getDocumentCount());
}
} | java | public void evaluate(ObjectStream<DocSample> samples, int nFolds)
throws IOException {
CrossValidationPartitioner<DocSample> partitioner = new CrossValidationPartitioner<>(
samples, nFolds);
while (partitioner.hasNext()) {
CrossValidationPartitioner.TrainingSampleStream<DocSample> trainingSampleStream = partitioner
.next();
DocumentClassifierModel model = DocumentClassifierME.train(languageCode,
trainingSampleStream, params, factory);
DocumentClassifierEvaluator evaluator = new DocumentClassifierEvaluator(
new DocumentClassifierME(model), listeners);
evaluator.evaluate(trainingSampleStream.getTestSampleStream());
documentAccuracy.add(evaluator.getAccuracy(),
evaluator.getDocumentCount());
}
} | [
"public",
"void",
"evaluate",
"(",
"ObjectStream",
"<",
"DocSample",
">",
"samples",
",",
"int",
"nFolds",
")",
"throws",
"IOException",
"{",
"CrossValidationPartitioner",
"<",
"DocSample",
">",
"partitioner",
"=",
"new",
"CrossValidationPartitioner",
"<>",
"(",
"samples",
",",
"nFolds",
")",
";",
"while",
"(",
"partitioner",
".",
"hasNext",
"(",
")",
")",
"{",
"CrossValidationPartitioner",
".",
"TrainingSampleStream",
"<",
"DocSample",
">",
"trainingSampleStream",
"=",
"partitioner",
".",
"next",
"(",
")",
";",
"DocumentClassifierModel",
"model",
"=",
"DocumentClassifierME",
".",
"train",
"(",
"languageCode",
",",
"trainingSampleStream",
",",
"params",
",",
"factory",
")",
";",
"DocumentClassifierEvaluator",
"evaluator",
"=",
"new",
"DocumentClassifierEvaluator",
"(",
"new",
"DocumentClassifierME",
"(",
"model",
")",
",",
"listeners",
")",
";",
"evaluator",
".",
"evaluate",
"(",
"trainingSampleStream",
".",
"getTestSampleStream",
"(",
")",
")",
";",
"documentAccuracy",
".",
"add",
"(",
"evaluator",
".",
"getAccuracy",
"(",
")",
",",
"evaluator",
".",
"getDocumentCount",
"(",
")",
")",
";",
"}",
"}"
] | Starts the evaluation.
@param samples
the data to train and test
@param nFolds
number of folds
@throws IOException if io error | [
"Starts",
"the",
"evaluation",
"."
] | train | https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/document/DocClassifierCrossValidator.java#L60-L83 |
keenon/loglinear | src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java | ConcatVectorNamespace.debugFeatureValue | private void debugFeatureValue(String feature, int index, ConcatVector vector, BufferedWriter bw) throws IOException {
"""
This writes a feature's individual value, using the human readable name if possible, to a StringBuilder
"""
bw.write("\t");
if (sparseFeatureIndex.containsKey(feature) && sparseFeatureIndex.get(feature).values().contains(index)) {
// we can map this index to an interpretable string, so we do
bw.write("SPARSE VALUE \"");
bw.write(reverseSparseFeatureIndex.get(feature).get(index));
bw.write("\"");
}
else {
// we can't map this to a useful string, so we default to the number
bw.write(Integer.toString(index));
}
bw.write(": ");
bw.write(Double.toString(vector.getValueAt(featureToIndex.getOrDefault(feature, -1), index)));
bw.write("\n");
} | java | private void debugFeatureValue(String feature, int index, ConcatVector vector, BufferedWriter bw) throws IOException {
bw.write("\t");
if (sparseFeatureIndex.containsKey(feature) && sparseFeatureIndex.get(feature).values().contains(index)) {
// we can map this index to an interpretable string, so we do
bw.write("SPARSE VALUE \"");
bw.write(reverseSparseFeatureIndex.get(feature).get(index));
bw.write("\"");
}
else {
// we can't map this to a useful string, so we default to the number
bw.write(Integer.toString(index));
}
bw.write(": ");
bw.write(Double.toString(vector.getValueAt(featureToIndex.getOrDefault(feature, -1), index)));
bw.write("\n");
} | [
"private",
"void",
"debugFeatureValue",
"(",
"String",
"feature",
",",
"int",
"index",
",",
"ConcatVector",
"vector",
",",
"BufferedWriter",
"bw",
")",
"throws",
"IOException",
"{",
"bw",
".",
"write",
"(",
"\"\\t\"",
")",
";",
"if",
"(",
"sparseFeatureIndex",
".",
"containsKey",
"(",
"feature",
")",
"&&",
"sparseFeatureIndex",
".",
"get",
"(",
"feature",
")",
".",
"values",
"(",
")",
".",
"contains",
"(",
"index",
")",
")",
"{",
"// we can map this index to an interpretable string, so we do",
"bw",
".",
"write",
"(",
"\"SPARSE VALUE \\\"\"",
")",
";",
"bw",
".",
"write",
"(",
"reverseSparseFeatureIndex",
".",
"get",
"(",
"feature",
")",
".",
"get",
"(",
"index",
")",
")",
";",
"bw",
".",
"write",
"(",
"\"\\\"\"",
")",
";",
"}",
"else",
"{",
"// we can't map this to a useful string, so we default to the number",
"bw",
".",
"write",
"(",
"Integer",
".",
"toString",
"(",
"index",
")",
")",
";",
"}",
"bw",
".",
"write",
"(",
"\": \"",
")",
";",
"bw",
".",
"write",
"(",
"Double",
".",
"toString",
"(",
"vector",
".",
"getValueAt",
"(",
"featureToIndex",
".",
"getOrDefault",
"(",
"feature",
",",
"-",
"1",
")",
",",
"index",
")",
")",
")",
";",
"bw",
".",
"write",
"(",
"\"\\n\"",
")",
";",
"}"
] | This writes a feature's individual value, using the human readable name if possible, to a StringBuilder | [
"This",
"writes",
"a",
"feature",
"s",
"individual",
"value",
"using",
"the",
"human",
"readable",
"name",
"if",
"possible",
"to",
"a",
"StringBuilder"
] | train | https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorNamespace.java#L371-L386 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/ByteArrayUtil.java | ByteArrayUtil.putFloatLE | public static void putFloatLE(final byte[] array, final int offset, final float value) {
"""
Put the source <i>float</i> into the destination byte array starting at the given offset
in little endian order.
There is no bounds checking.
@param array destination byte array
@param offset destination offset
@param value source <i>float</i>
"""
putIntLE(array, offset, Float.floatToRawIntBits(value));
} | java | public static void putFloatLE(final byte[] array, final int offset, final float value) {
putIntLE(array, offset, Float.floatToRawIntBits(value));
} | [
"public",
"static",
"void",
"putFloatLE",
"(",
"final",
"byte",
"[",
"]",
"array",
",",
"final",
"int",
"offset",
",",
"final",
"float",
"value",
")",
"{",
"putIntLE",
"(",
"array",
",",
"offset",
",",
"Float",
".",
"floatToRawIntBits",
"(",
"value",
")",
")",
";",
"}"
] | Put the source <i>float</i> into the destination byte array starting at the given offset
in little endian order.
There is no bounds checking.
@param array destination byte array
@param offset destination offset
@param value source <i>float</i> | [
"Put",
"the",
"source",
"<i",
">",
"float<",
"/",
"i",
">",
"into",
"the",
"destination",
"byte",
"array",
"starting",
"at",
"the",
"given",
"offset",
"in",
"little",
"endian",
"order",
".",
"There",
"is",
"no",
"bounds",
"checking",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/ByteArrayUtil.java#L213-L215 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ConfigUtils.java | ConfigUtils.resolveEncrypted | public static Config resolveEncrypted(Config config, Optional<String> encConfigPath) {
"""
Resolves encrypted config value(s) by considering on the path with "encConfigPath" as encrypted.
(If encConfigPath is absent or encConfigPath does not exist in config, config will be just returned untouched.)
It will use Password manager via given config. Thus, convention of PasswordManager need to be followed in order to be decrypted.
Note that "encConfigPath" path will be removed from the config key, leaving child path on the config key.
e.g:
encConfigPath = enc.conf
- Before : { enc.conf.secret_key : ENC(rOF43721f0pZqAXg#63a) }
- After : { secret_key : decrypted_val }
@param config
@param encConfigPath
@return
"""
if (!encConfigPath.isPresent() || !config.hasPath(encConfigPath.get())) {
return config;
}
Config encryptedConfig = config.getConfig(encConfigPath.get());
PasswordManager passwordManager = PasswordManager.getInstance(configToProperties(config));
Map<String, String> tmpMap = Maps.newHashMap();
for (Map.Entry<String, ConfigValue> entry : encryptedConfig.entrySet()) {
String val = entry.getValue().unwrapped().toString();
val = passwordManager.readPassword(val);
tmpMap.put(entry.getKey(), val);
}
return ConfigFactory.parseMap(tmpMap).withFallback(config);
} | java | public static Config resolveEncrypted(Config config, Optional<String> encConfigPath) {
if (!encConfigPath.isPresent() || !config.hasPath(encConfigPath.get())) {
return config;
}
Config encryptedConfig = config.getConfig(encConfigPath.get());
PasswordManager passwordManager = PasswordManager.getInstance(configToProperties(config));
Map<String, String> tmpMap = Maps.newHashMap();
for (Map.Entry<String, ConfigValue> entry : encryptedConfig.entrySet()) {
String val = entry.getValue().unwrapped().toString();
val = passwordManager.readPassword(val);
tmpMap.put(entry.getKey(), val);
}
return ConfigFactory.parseMap(tmpMap).withFallback(config);
} | [
"public",
"static",
"Config",
"resolveEncrypted",
"(",
"Config",
"config",
",",
"Optional",
"<",
"String",
">",
"encConfigPath",
")",
"{",
"if",
"(",
"!",
"encConfigPath",
".",
"isPresent",
"(",
")",
"||",
"!",
"config",
".",
"hasPath",
"(",
"encConfigPath",
".",
"get",
"(",
")",
")",
")",
"{",
"return",
"config",
";",
"}",
"Config",
"encryptedConfig",
"=",
"config",
".",
"getConfig",
"(",
"encConfigPath",
".",
"get",
"(",
")",
")",
";",
"PasswordManager",
"passwordManager",
"=",
"PasswordManager",
".",
"getInstance",
"(",
"configToProperties",
"(",
"config",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"tmpMap",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"ConfigValue",
">",
"entry",
":",
"encryptedConfig",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"val",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"unwrapped",
"(",
")",
".",
"toString",
"(",
")",
";",
"val",
"=",
"passwordManager",
".",
"readPassword",
"(",
"val",
")",
";",
"tmpMap",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"val",
")",
";",
"}",
"return",
"ConfigFactory",
".",
"parseMap",
"(",
"tmpMap",
")",
".",
"withFallback",
"(",
"config",
")",
";",
"}"
] | Resolves encrypted config value(s) by considering on the path with "encConfigPath" as encrypted.
(If encConfigPath is absent or encConfigPath does not exist in config, config will be just returned untouched.)
It will use Password manager via given config. Thus, convention of PasswordManager need to be followed in order to be decrypted.
Note that "encConfigPath" path will be removed from the config key, leaving child path on the config key.
e.g:
encConfigPath = enc.conf
- Before : { enc.conf.secret_key : ENC(rOF43721f0pZqAXg#63a) }
- After : { secret_key : decrypted_val }
@param config
@param encConfigPath
@return | [
"Resolves",
"encrypted",
"config",
"value",
"(",
"s",
")",
"by",
"considering",
"on",
"the",
"path",
"with",
"encConfigPath",
"as",
"encrypted",
".",
"(",
"If",
"encConfigPath",
"is",
"absent",
"or",
"encConfigPath",
"does",
"not",
"exist",
"in",
"config",
"config",
"will",
"be",
"just",
"returned",
"untouched",
".",
")",
"It",
"will",
"use",
"Password",
"manager",
"via",
"given",
"config",
".",
"Thus",
"convention",
"of",
"PasswordManager",
"need",
"to",
"be",
"followed",
"in",
"order",
"to",
"be",
"decrypted",
".",
"Note",
"that",
"encConfigPath",
"path",
"will",
"be",
"removed",
"from",
"the",
"config",
"key",
"leaving",
"child",
"path",
"on",
"the",
"config",
"key",
".",
"e",
".",
"g",
":",
"encConfigPath",
"=",
"enc",
".",
"conf",
"-",
"Before",
":",
"{",
"enc",
".",
"conf",
".",
"secret_key",
":",
"ENC",
"(",
"rOF43721f0pZqAXg#63a",
")",
"}",
"-",
"After",
":",
"{",
"secret_key",
":",
"decrypted_val",
"}"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ConfigUtils.java#L505-L520 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationRequest.java | CreateIntegrationRequest.withRequestTemplates | public CreateIntegrationRequest withRequestTemplates(java.util.Map<String, String> requestTemplates) {
"""
<p>
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template (as a
String) is the value.
</p>
@param requestTemplates
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template
(as a String) is the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setRequestTemplates(requestTemplates);
return this;
} | java | public CreateIntegrationRequest withRequestTemplates(java.util.Map<String, String> requestTemplates) {
setRequestTemplates(requestTemplates);
return this;
} | [
"public",
"CreateIntegrationRequest",
"withRequestTemplates",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"requestTemplates",
")",
"{",
"setRequestTemplates",
"(",
"requestTemplates",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template (as a
String) is the value.
</p>
@param requestTemplates
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template
(as a String) is the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Represents",
"a",
"map",
"of",
"Velocity",
"templates",
"that",
"are",
"applied",
"on",
"the",
"request",
"payload",
"based",
"on",
"the",
"value",
"of",
"the",
"Content",
"-",
"Type",
"header",
"sent",
"by",
"the",
"client",
".",
"The",
"content",
"type",
"value",
"is",
"the",
"key",
"in",
"this",
"map",
"and",
"the",
"template",
"(",
"as",
"a",
"String",
")",
"is",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationRequest.java#L1161-L1164 |
overview/mime-types | src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java | MimeTypeDetector.oneMatchletMagicEquals | private boolean oneMatchletMagicEquals(int offset, byte[] data) {
"""
Tests whether one matchlet (but not its children) matches data.
"""
int rangeStart = content.getInt(offset); // first byte of data for check to start at
int rangeLength = content.getInt(offset + 4); // last byte of data for check to start at
int dataLength = content.getInt(offset + 12); // number of bytes in match data/mask
int dataOffset = content.getInt(offset + 16); // contentBytes offset to the match data
int maskOffset = content.getInt(offset + 20); // contentBytes offset to the mask
boolean found = false;
for (int i = 0; !found && (i <= rangeLength) && (i + rangeStart + dataLength <= data.length); i++) {
if (maskOffset != 0) {
found = subArraysEqualWithMask(
contentBytes, dataOffset,
data, rangeStart + i,
contentBytes, maskOffset,
dataLength
);
} else {
found = subArraysEqual(
contentBytes, dataOffset,
data, rangeStart + i,
dataLength
);
}
}
return found;
} | java | private boolean oneMatchletMagicEquals(int offset, byte[] data) {
int rangeStart = content.getInt(offset); // first byte of data for check to start at
int rangeLength = content.getInt(offset + 4); // last byte of data for check to start at
int dataLength = content.getInt(offset + 12); // number of bytes in match data/mask
int dataOffset = content.getInt(offset + 16); // contentBytes offset to the match data
int maskOffset = content.getInt(offset + 20); // contentBytes offset to the mask
boolean found = false;
for (int i = 0; !found && (i <= rangeLength) && (i + rangeStart + dataLength <= data.length); i++) {
if (maskOffset != 0) {
found = subArraysEqualWithMask(
contentBytes, dataOffset,
data, rangeStart + i,
contentBytes, maskOffset,
dataLength
);
} else {
found = subArraysEqual(
contentBytes, dataOffset,
data, rangeStart + i,
dataLength
);
}
}
return found;
} | [
"private",
"boolean",
"oneMatchletMagicEquals",
"(",
"int",
"offset",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"int",
"rangeStart",
"=",
"content",
".",
"getInt",
"(",
"offset",
")",
";",
"// first byte of data for check to start at",
"int",
"rangeLength",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"4",
")",
";",
"// last byte of data for check to start at",
"int",
"dataLength",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"12",
")",
";",
"// number of bytes in match data/mask",
"int",
"dataOffset",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"16",
")",
";",
"// contentBytes offset to the match data",
"int",
"maskOffset",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"20",
")",
";",
"// contentBytes offset to the mask",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"!",
"found",
"&&",
"(",
"i",
"<=",
"rangeLength",
")",
"&&",
"(",
"i",
"+",
"rangeStart",
"+",
"dataLength",
"<=",
"data",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"maskOffset",
"!=",
"0",
")",
"{",
"found",
"=",
"subArraysEqualWithMask",
"(",
"contentBytes",
",",
"dataOffset",
",",
"data",
",",
"rangeStart",
"+",
"i",
",",
"contentBytes",
",",
"maskOffset",
",",
"dataLength",
")",
";",
"}",
"else",
"{",
"found",
"=",
"subArraysEqual",
"(",
"contentBytes",
",",
"dataOffset",
",",
"data",
",",
"rangeStart",
"+",
"i",
",",
"dataLength",
")",
";",
"}",
"}",
"return",
"found",
";",
"}"
] | Tests whether one matchlet (but not its children) matches data. | [
"Tests",
"whether",
"one",
"matchlet",
"(",
"but",
"not",
"its",
"children",
")",
"matches",
"data",
"."
] | train | https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L434-L461 |
vanilladb/vanillacore | src/main/java/org/vanilladb/core/server/VanillaDb.java | VanillaDb.newPlanner | public static Planner newPlanner() {
"""
Creates a planner for SQL commands. To change how the planner works,
modify this method.
@return the system's planner for SQL commands
"""
QueryPlanner qplanner;
UpdatePlanner uplanner;
try {
qplanner = (QueryPlanner) queryPlannerCls.newInstance();
uplanner = (UpdatePlanner) updatePlannerCls.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
return new Planner(qplanner, uplanner);
} | java | public static Planner newPlanner() {
QueryPlanner qplanner;
UpdatePlanner uplanner;
try {
qplanner = (QueryPlanner) queryPlannerCls.newInstance();
uplanner = (UpdatePlanner) updatePlannerCls.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
return new Planner(qplanner, uplanner);
} | [
"public",
"static",
"Planner",
"newPlanner",
"(",
")",
"{",
"QueryPlanner",
"qplanner",
";",
"UpdatePlanner",
"uplanner",
";",
"try",
"{",
"qplanner",
"=",
"(",
"QueryPlanner",
")",
"queryPlannerCls",
".",
"newInstance",
"(",
")",
";",
"uplanner",
"=",
"(",
"UpdatePlanner",
")",
"updatePlannerCls",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"return",
"new",
"Planner",
"(",
"qplanner",
",",
"uplanner",
")",
";",
"}"
] | Creates a planner for SQL commands. To change how the planner works,
modify this method.
@return the system's planner for SQL commands | [
"Creates",
"a",
"planner",
"for",
"SQL",
"commands",
".",
"To",
"change",
"how",
"the",
"planner",
"works",
"modify",
"this",
"method",
"."
] | train | https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/server/VanillaDb.java#L283-L296 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDConnectionDaoImpl.java | GeneratedDConnectionDaoImpl.queryByAppArg0 | public Iterable<DConnection> queryByAppArg0(java.lang.String appArg0) {
"""
query-by method for field appArg0
@param appArg0 the specified attribute
@return an Iterable of DConnections for the specified appArg0
"""
return queryByField(null, DConnectionMapper.Field.APPARG0.getFieldName(), appArg0);
} | java | public Iterable<DConnection> queryByAppArg0(java.lang.String appArg0) {
return queryByField(null, DConnectionMapper.Field.APPARG0.getFieldName(), appArg0);
} | [
"public",
"Iterable",
"<",
"DConnection",
">",
"queryByAppArg0",
"(",
"java",
".",
"lang",
".",
"String",
"appArg0",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DConnectionMapper",
".",
"Field",
".",
"APPARG0",
".",
"getFieldName",
"(",
")",
",",
"appArg0",
")",
";",
"}"
] | query-by method for field appArg0
@param appArg0 the specified attribute
@return an Iterable of DConnections for the specified appArg0 | [
"query",
"-",
"by",
"method",
"for",
"field",
"appArg0"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDConnectionDaoImpl.java#L52-L54 |
SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java | CharTrieIndex.addDocument | public int addDocument(String document) {
"""
Adds a document to be indexed. This can only be performed before splitting.
@param document the document
@return this int
"""
if (root().getNumberOfChildren() >= 0) {
throw new IllegalStateException("Tree sorting has begun");
}
final int index;
synchronized (this) {
index = documents.size();
documents.add(document);
}
cursors.addAll(
IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
nodes.update(0, node -> node.setCursorCount(cursors.length()));
return index;
} | java | public int addDocument(String document) {
if (root().getNumberOfChildren() >= 0) {
throw new IllegalStateException("Tree sorting has begun");
}
final int index;
synchronized (this) {
index = documents.size();
documents.add(document);
}
cursors.addAll(
IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
nodes.update(0, node -> node.setCursorCount(cursors.length()));
return index;
} | [
"public",
"int",
"addDocument",
"(",
"String",
"document",
")",
"{",
"if",
"(",
"root",
"(",
")",
".",
"getNumberOfChildren",
"(",
")",
">=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Tree sorting has begun\"",
")",
";",
"}",
"final",
"int",
"index",
";",
"synchronized",
"(",
"this",
")",
"{",
"index",
"=",
"documents",
".",
"size",
"(",
")",
";",
"documents",
".",
"add",
"(",
"document",
")",
";",
"}",
"cursors",
".",
"addAll",
"(",
"IntStream",
".",
"range",
"(",
"0",
",",
"document",
".",
"length",
"(",
")",
"+",
"1",
")",
".",
"mapToObj",
"(",
"i",
"->",
"new",
"CursorData",
"(",
"index",
",",
"i",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"nodes",
".",
"update",
"(",
"0",
",",
"node",
"->",
"node",
".",
"setCursorCount",
"(",
"cursors",
".",
"length",
"(",
")",
")",
")",
";",
"return",
"index",
";",
"}"
] | Adds a document to be indexed. This can only be performed before splitting.
@param document the document
@return this int | [
"Adds",
"a",
"document",
"to",
"be",
"indexed",
".",
"This",
"can",
"only",
"be",
"performed",
"before",
"splitting",
"."
] | train | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L220-L233 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPRuleUserSegmentRelPersistenceImpl.java | CPRuleUserSegmentRelPersistenceImpl.findByCPRuleId | @Override
public List<CPRuleUserSegmentRel> findByCPRuleId(long CPRuleId, int start,
int end, OrderByComparator<CPRuleUserSegmentRel> orderByComparator) {
"""
Returns an ordered range of all the cp rule user segment rels where CPRuleId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPRuleUserSegmentRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPRuleId the cp rule ID
@param start the lower bound of the range of cp rule user segment rels
@param end the upper bound of the range of cp rule user segment rels (not inclusive)
@param orderByComparator the comparator to order the results by (optionally <code>null</code>)
@return the ordered range of matching cp rule user segment rels
"""
return findByCPRuleId(CPRuleId, start, end, orderByComparator, true);
} | java | @Override
public List<CPRuleUserSegmentRel> findByCPRuleId(long CPRuleId, int start,
int end, OrderByComparator<CPRuleUserSegmentRel> orderByComparator) {
return findByCPRuleId(CPRuleId, start, end, orderByComparator, true);
} | [
"@",
"Override",
"public",
"List",
"<",
"CPRuleUserSegmentRel",
">",
"findByCPRuleId",
"(",
"long",
"CPRuleId",
",",
"int",
"start",
",",
"int",
"end",
",",
"OrderByComparator",
"<",
"CPRuleUserSegmentRel",
">",
"orderByComparator",
")",
"{",
"return",
"findByCPRuleId",
"(",
"CPRuleId",
",",
"start",
",",
"end",
",",
"orderByComparator",
",",
"true",
")",
";",
"}"
] | Returns an ordered range of all the cp rule user segment rels where CPRuleId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPRuleUserSegmentRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPRuleId the cp rule ID
@param start the lower bound of the range of cp rule user segment rels
@param end the upper bound of the range of cp rule user segment rels (not inclusive)
@param orderByComparator the comparator to order the results by (optionally <code>null</code>)
@return the ordered range of matching cp rule user segment rels | [
"Returns",
"an",
"ordered",
"range",
"of",
"all",
"the",
"cp",
"rule",
"user",
"segment",
"rels",
"where",
"CPRuleId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPRuleUserSegmentRelPersistenceImpl.java#L159-L163 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowUtils.java | PageFlowUtils.getRewrittenHrefURI | public static String getRewrittenHrefURI( ServletContext servletContext, HttpServletRequest request,
HttpServletResponse response, String path, Map params,
String fragment, boolean forXML )
throws URISyntaxException {
"""
Create a fully-rewritten URI given a path and parameters.
<p> Calls the rewriter service using a type of {@link URLType#ACTION}. </p>
@param servletContext the current ServletContext.
@param request the current HttpServletRequest.
@param response the current HttpServletResponse.
@param path the path to process into a fully-rewritten URI.
@param params the additional parameters to include in the URI query.
@param fragment the fragment (anchor or location) for this URI.
@param forXML flag indicating that the query of the uri should be written
using the "&amp;" entity, rather than the character, '&'.
@return a fully-rewritten URI for the given action.
@throws URISyntaxException if there's a problem converting the action URI (derived
from processing the given action name) into a MutableURI.
"""
return rewriteResourceOrHrefURL( servletContext, request, response, path, params, fragment, forXML, URLType.ACTION );
} | java | public static String getRewrittenHrefURI( ServletContext servletContext, HttpServletRequest request,
HttpServletResponse response, String path, Map params,
String fragment, boolean forXML )
throws URISyntaxException
{
return rewriteResourceOrHrefURL( servletContext, request, response, path, params, fragment, forXML, URLType.ACTION );
} | [
"public",
"static",
"String",
"getRewrittenHrefURI",
"(",
"ServletContext",
"servletContext",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"path",
",",
"Map",
"params",
",",
"String",
"fragment",
",",
"boolean",
"forXML",
")",
"throws",
"URISyntaxException",
"{",
"return",
"rewriteResourceOrHrefURL",
"(",
"servletContext",
",",
"request",
",",
"response",
",",
"path",
",",
"params",
",",
"fragment",
",",
"forXML",
",",
"URLType",
".",
"ACTION",
")",
";",
"}"
] | Create a fully-rewritten URI given a path and parameters.
<p> Calls the rewriter service using a type of {@link URLType#ACTION}. </p>
@param servletContext the current ServletContext.
@param request the current HttpServletRequest.
@param response the current HttpServletResponse.
@param path the path to process into a fully-rewritten URI.
@param params the additional parameters to include in the URI query.
@param fragment the fragment (anchor or location) for this URI.
@param forXML flag indicating that the query of the uri should be written
using the "&amp;" entity, rather than the character, '&'.
@return a fully-rewritten URI for the given action.
@throws URISyntaxException if there's a problem converting the action URI (derived
from processing the given action name) into a MutableURI. | [
"Create",
"a",
"fully",
"-",
"rewritten",
"URI",
"given",
"a",
"path",
"and",
"parameters",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowUtils.java#L1571-L1577 |
javamelody/javamelody | javamelody-swing/src/main/java/net/bull/javamelody/TransportFormatAdapter.java | TransportFormatAdapter.writeXml | public static void writeXml(Serializable serializable, OutputStream output) throws IOException {
"""
Export XML.
@param serializable Serializable
@param output OutputStream
@throws IOException e
"""
TransportFormat.XML.writeSerializableTo(serializable, output);
} | java | public static void writeXml(Serializable serializable, OutputStream output) throws IOException {
TransportFormat.XML.writeSerializableTo(serializable, output);
} | [
"public",
"static",
"void",
"writeXml",
"(",
"Serializable",
"serializable",
",",
"OutputStream",
"output",
")",
"throws",
"IOException",
"{",
"TransportFormat",
".",
"XML",
".",
"writeSerializableTo",
"(",
"serializable",
",",
"output",
")",
";",
"}"
] | Export XML.
@param serializable Serializable
@param output OutputStream
@throws IOException e | [
"Export",
"XML",
"."
] | train | https://github.com/javamelody/javamelody/blob/18ad583ddeb5dcadd797dfda295409c6983ffd71/javamelody-swing/src/main/java/net/bull/javamelody/TransportFormatAdapter.java#L41-L43 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextManager.java | ContextManager.commitContexts | private void commitContexts(boolean accept, boolean all) {
"""
Commit or cancel all pending context changes.
@param accept If true, pending changes are committed. If false, they are canceled.
@param all If false, only polled subscribers are notified.
"""
Stack<IManagedContext<?>> stack = commitStack;
commitStack = new Stack<>();
// First, commit or cancel all pending context changes.
for (IManagedContext<?> managedContext : stack) {
if (managedContext.isPending()) {
managedContext.commit(accept);
}
}
// Then notify subscribers of the changes.
while (!stack.isEmpty()) {
stack.pop().notifySubscribers(accept, all);
}
} | java | private void commitContexts(boolean accept, boolean all) {
Stack<IManagedContext<?>> stack = commitStack;
commitStack = new Stack<>();
// First, commit or cancel all pending context changes.
for (IManagedContext<?> managedContext : stack) {
if (managedContext.isPending()) {
managedContext.commit(accept);
}
}
// Then notify subscribers of the changes.
while (!stack.isEmpty()) {
stack.pop().notifySubscribers(accept, all);
}
} | [
"private",
"void",
"commitContexts",
"(",
"boolean",
"accept",
",",
"boolean",
"all",
")",
"{",
"Stack",
"<",
"IManagedContext",
"<",
"?",
">",
">",
"stack",
"=",
"commitStack",
";",
"commitStack",
"=",
"new",
"Stack",
"<>",
"(",
")",
";",
"// First, commit or cancel all pending context changes.",
"for",
"(",
"IManagedContext",
"<",
"?",
">",
"managedContext",
":",
"stack",
")",
"{",
"if",
"(",
"managedContext",
".",
"isPending",
"(",
")",
")",
"{",
"managedContext",
".",
"commit",
"(",
"accept",
")",
";",
"}",
"}",
"// Then notify subscribers of the changes.",
"while",
"(",
"!",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"stack",
".",
"pop",
"(",
")",
".",
"notifySubscribers",
"(",
"accept",
",",
"all",
")",
";",
"}",
"}"
] | Commit or cancel all pending context changes.
@param accept If true, pending changes are committed. If false, they are canceled.
@param all If false, only polled subscribers are notified. | [
"Commit",
"or",
"cancel",
"all",
"pending",
"context",
"changes",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextManager.java#L268-L281 |
mike706574/java-map-support | src/main/java/fun/mike/map/alpha/Get.java | Get.populatedUrl | public static <T> String populatedUrl(Map<String, T> map, String key) {
"""
Validates that the value from {@code map} for the given {@code key} is a
valid, populated string URL. Returns the value when valid; otherwise,
throws an {@code IllegalArgumentException}.
@param map a map
@param key a key
@param <T> the type of value
@return the string value
@throws java.util.NoSuchElementException if the required value is not
present
@throws java.lang.IllegalArgumentException if the value is in valid
"""
String url = populatedStringOfType(map, key, "URL");
UrlValidator.http(url)
.orThrow(String.format("Invalid URL value \"%s\" for key \"%s\"", url, key));
return url;
} | java | public static <T> String populatedUrl(Map<String, T> map, String key) {
String url = populatedStringOfType(map, key, "URL");
UrlValidator.http(url)
.orThrow(String.format("Invalid URL value \"%s\" for key \"%s\"", url, key));
return url;
} | [
"public",
"static",
"<",
"T",
">",
"String",
"populatedUrl",
"(",
"Map",
"<",
"String",
",",
"T",
">",
"map",
",",
"String",
"key",
")",
"{",
"String",
"url",
"=",
"populatedStringOfType",
"(",
"map",
",",
"key",
",",
"\"URL\"",
")",
";",
"UrlValidator",
".",
"http",
"(",
"url",
")",
".",
"orThrow",
"(",
"String",
".",
"format",
"(",
"\"Invalid URL value \\\"%s\\\" for key \\\"%s\\\"\"",
",",
"url",
",",
"key",
")",
")",
";",
"return",
"url",
";",
"}"
] | Validates that the value from {@code map} for the given {@code key} is a
valid, populated string URL. Returns the value when valid; otherwise,
throws an {@code IllegalArgumentException}.
@param map a map
@param key a key
@param <T> the type of value
@return the string value
@throws java.util.NoSuchElementException if the required value is not
present
@throws java.lang.IllegalArgumentException if the value is in valid | [
"Validates",
"that",
"the",
"value",
"from",
"{"
] | train | https://github.com/mike706574/java-map-support/blob/7cb09f34c24adfaca73ad25a3c3e05abec72eafe/src/main/java/fun/mike/map/alpha/Get.java#L52-L57 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/preview/CmsImageResourcePreview.java | CmsImageResourcePreview.getImageInfo | private void getImageInfo(final String resourcePath, final I_CmsSimpleCallback<CmsImageInfoBean> callback) {
"""
Returns the image info bean for the given resource.<p>
@param resourcePath the resource path
@param callback the calback to execute
"""
CmsRpcAction<CmsImageInfoBean> action = new CmsRpcAction<CmsImageInfoBean>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, true);
A_CmsResourcePreview.getService().getImageInfo(resourcePath, getLocale(), this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(CmsImageInfoBean result) {
stop(false);
callback.execute(result);
}
};
action.execute();
} | java | private void getImageInfo(final String resourcePath, final I_CmsSimpleCallback<CmsImageInfoBean> callback) {
CmsRpcAction<CmsImageInfoBean> action = new CmsRpcAction<CmsImageInfoBean>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, true);
A_CmsResourcePreview.getService().getImageInfo(resourcePath, getLocale(), this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(CmsImageInfoBean result) {
stop(false);
callback.execute(result);
}
};
action.execute();
} | [
"private",
"void",
"getImageInfo",
"(",
"final",
"String",
"resourcePath",
",",
"final",
"I_CmsSimpleCallback",
"<",
"CmsImageInfoBean",
">",
"callback",
")",
"{",
"CmsRpcAction",
"<",
"CmsImageInfoBean",
">",
"action",
"=",
"new",
"CmsRpcAction",
"<",
"CmsImageInfoBean",
">",
"(",
")",
"{",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()\n */",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"start",
"(",
"0",
",",
"true",
")",
";",
"A_CmsResourcePreview",
".",
"getService",
"(",
")",
".",
"getImageInfo",
"(",
"resourcePath",
",",
"getLocale",
"(",
")",
",",
"this",
")",
";",
"}",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)\n */",
"@",
"Override",
"protected",
"void",
"onResponse",
"(",
"CmsImageInfoBean",
"result",
")",
"{",
"stop",
"(",
"false",
")",
";",
"callback",
".",
"execute",
"(",
"result",
")",
";",
"}",
"}",
";",
"action",
".",
"execute",
"(",
")",
";",
"}"
] | Returns the image info bean for the given resource.<p>
@param resourcePath the resource path
@param callback the calback to execute | [
"Returns",
"the",
"image",
"info",
"bean",
"for",
"the",
"given",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/preview/CmsImageResourcePreview.java#L324-L350 |
jenkinsci/jenkins | core/src/main/java/hudson/scheduler/BaseParser.java | BaseParser.doHash | protected long doHash(int step, int field) throws ANTLRException {
"""
Uses {@link Hash} to choose a random (but stable) value from within this field.
@param step
Increments. For example, 15 if "H/15". Or {@link #NO_STEP} to indicate
the special constant for "H" without the step value.
"""
int u = UPPER_BOUNDS[field];
if (field==2) u = 28; // day of month can vary depending on month, so to make life simpler, just use [1,28] that's always safe
if (field==4) u = 6; // Both 0 and 7 of day of week are Sunday. For better distribution, limit upper bound to 6
return doHash(LOWER_BOUNDS[field], u, step, field);
} | java | protected long doHash(int step, int field) throws ANTLRException {
int u = UPPER_BOUNDS[field];
if (field==2) u = 28; // day of month can vary depending on month, so to make life simpler, just use [1,28] that's always safe
if (field==4) u = 6; // Both 0 and 7 of day of week are Sunday. For better distribution, limit upper bound to 6
return doHash(LOWER_BOUNDS[field], u, step, field);
} | [
"protected",
"long",
"doHash",
"(",
"int",
"step",
",",
"int",
"field",
")",
"throws",
"ANTLRException",
"{",
"int",
"u",
"=",
"UPPER_BOUNDS",
"[",
"field",
"]",
";",
"if",
"(",
"field",
"==",
"2",
")",
"u",
"=",
"28",
";",
"// day of month can vary depending on month, so to make life simpler, just use [1,28] that's always safe",
"if",
"(",
"field",
"==",
"4",
")",
"u",
"=",
"6",
";",
"// Both 0 and 7 of day of week are Sunday. For better distribution, limit upper bound to 6",
"return",
"doHash",
"(",
"LOWER_BOUNDS",
"[",
"field",
"]",
",",
"u",
",",
"step",
",",
"field",
")",
";",
"}"
] | Uses {@link Hash} to choose a random (but stable) value from within this field.
@param step
Increments. For example, 15 if "H/15". Or {@link #NO_STEP} to indicate
the special constant for "H" without the step value. | [
"Uses",
"{",
"@link",
"Hash",
"}",
"to",
"choose",
"a",
"random",
"(",
"but",
"stable",
")",
"value",
"from",
"within",
"this",
"field",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/scheduler/BaseParser.java#L96-L101 |
vladmihalcea/db-util | src/main/java/com/vladmihalcea/sql/SQLStatementCountValidator.java | SQLStatementCountValidator.assertDeleteCount | public static void assertDeleteCount(long expectedDeleteCount) {
"""
Assert delete statement count
@param expectedDeleteCount expected delete statement count
"""
QueryCount queryCount = QueryCountHolder.getGrandTotal();
long recordedDeleteCount = queryCount.getDelete();
if (expectedDeleteCount != recordedDeleteCount) {
throw new SQLDeleteCountMismatchException(expectedDeleteCount, recordedDeleteCount);
}
} | java | public static void assertDeleteCount(long expectedDeleteCount) {
QueryCount queryCount = QueryCountHolder.getGrandTotal();
long recordedDeleteCount = queryCount.getDelete();
if (expectedDeleteCount != recordedDeleteCount) {
throw new SQLDeleteCountMismatchException(expectedDeleteCount, recordedDeleteCount);
}
} | [
"public",
"static",
"void",
"assertDeleteCount",
"(",
"long",
"expectedDeleteCount",
")",
"{",
"QueryCount",
"queryCount",
"=",
"QueryCountHolder",
".",
"getGrandTotal",
"(",
")",
";",
"long",
"recordedDeleteCount",
"=",
"queryCount",
".",
"getDelete",
"(",
")",
";",
"if",
"(",
"expectedDeleteCount",
"!=",
"recordedDeleteCount",
")",
"{",
"throw",
"new",
"SQLDeleteCountMismatchException",
"(",
"expectedDeleteCount",
",",
"recordedDeleteCount",
")",
";",
"}",
"}"
] | Assert delete statement count
@param expectedDeleteCount expected delete statement count | [
"Assert",
"delete",
"statement",
"count"
] | train | https://github.com/vladmihalcea/db-util/blob/81c8c8421253c9869db1d4e221668d7afbd69fd0/src/main/java/com/vladmihalcea/sql/SQLStatementCountValidator.java#L132-L138 |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java | ResourceImpl.withTag | @SuppressWarnings("unchecked")
public final FluentModelImplT withTag(String key, String value) {
"""
Adds a tag to the resource.
@param key the key for the tag
@param value the value for the tag
@return the next stage of the definition/update
"""
if (this.inner().getTags() == null) {
this.inner().withTags(new HashMap<String, String>());
}
this.inner().getTags().put(key, value);
return (FluentModelImplT) this;
} | java | @SuppressWarnings("unchecked")
public final FluentModelImplT withTag(String key, String value) {
if (this.inner().getTags() == null) {
this.inner().withTags(new HashMap<String, String>());
}
this.inner().getTags().put(key, value);
return (FluentModelImplT) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"FluentModelImplT",
"withTag",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"inner",
"(",
")",
".",
"getTags",
"(",
")",
"==",
"null",
")",
"{",
"this",
".",
"inner",
"(",
")",
".",
"withTags",
"(",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}",
"this",
".",
"inner",
"(",
")",
".",
"getTags",
"(",
")",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"(",
"FluentModelImplT",
")",
"this",
";",
"}"
] | Adds a tag to the resource.
@param key the key for the tag
@param value the value for the tag
@return the next stage of the definition/update | [
"Adds",
"a",
"tag",
"to",
"the",
"resource",
"."
] | train | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java#L109-L116 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/IntersectionImpl.java | IntersectionImpl.wrapInstance | static IntersectionImpl wrapInstance(final WritableMemory srcMem, final long seed) {
"""
Wrap an Intersection target around the given source Memory containing intersection data.
@param srcMem The source Memory image.
<a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@return a IntersectionImpl that wraps a source Memory that contains an Intersection image
"""
final IntersectionImpl impl = new IntersectionImpl(srcMem, seed, false);
return (IntersectionImpl) internalWrapInstance(srcMem, impl);
} | java | static IntersectionImpl wrapInstance(final WritableMemory srcMem, final long seed) {
final IntersectionImpl impl = new IntersectionImpl(srcMem, seed, false);
return (IntersectionImpl) internalWrapInstance(srcMem, impl);
} | [
"static",
"IntersectionImpl",
"wrapInstance",
"(",
"final",
"WritableMemory",
"srcMem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"IntersectionImpl",
"impl",
"=",
"new",
"IntersectionImpl",
"(",
"srcMem",
",",
"seed",
",",
"false",
")",
";",
"return",
"(",
"IntersectionImpl",
")",
"internalWrapInstance",
"(",
"srcMem",
",",
"impl",
")",
";",
"}"
] | Wrap an Intersection target around the given source Memory containing intersection data.
@param srcMem The source Memory image.
<a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@return a IntersectionImpl that wraps a source Memory that contains an Intersection image | [
"Wrap",
"an",
"Intersection",
"target",
"around",
"the",
"given",
"source",
"Memory",
"containing",
"intersection",
"data",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/IntersectionImpl.java#L164-L167 |
datacleaner/AnalyzerBeans | env/xml-config/src/main/java/org/eobjects/analyzer/configuration/JaxbConfigurationReader.java | JaxbConfigurationReader.checkName | private static void checkName(String name, Class<?> type, List<? extends ReferenceData> previousEntries)
throws IllegalStateException {
"""
Checks if a string is a valid name of a component.
@param name
the name to be validated
@param type
the type of component (used for error messages)
@param previousEntries
the previous entries of that component type (for uniqueness
check)
@throws IllegalStateException
if the name is invalid
"""
if (StringUtils.isNullOrEmpty(name)) {
throw new IllegalStateException(type.getSimpleName() + " name cannot be null");
}
for (ReferenceData referenceData : previousEntries) {
if (name.equals(referenceData.getName())) {
throw new IllegalStateException(type.getSimpleName() + " name is not unique: " + name);
}
}
} | java | private static void checkName(String name, Class<?> type, List<? extends ReferenceData> previousEntries)
throws IllegalStateException {
if (StringUtils.isNullOrEmpty(name)) {
throw new IllegalStateException(type.getSimpleName() + " name cannot be null");
}
for (ReferenceData referenceData : previousEntries) {
if (name.equals(referenceData.getName())) {
throw new IllegalStateException(type.getSimpleName() + " name is not unique: " + name);
}
}
} | [
"private",
"static",
"void",
"checkName",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
",",
"List",
"<",
"?",
"extends",
"ReferenceData",
">",
"previousEntries",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"StringUtils",
".",
"isNullOrEmpty",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"type",
".",
"getSimpleName",
"(",
")",
"+",
"\" name cannot be null\"",
")",
";",
"}",
"for",
"(",
"ReferenceData",
"referenceData",
":",
"previousEntries",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"referenceData",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"type",
".",
"getSimpleName",
"(",
")",
"+",
"\" name is not unique: \"",
"+",
"name",
")",
";",
"}",
"}",
"}"
] | Checks if a string is a valid name of a component.
@param name
the name to be validated
@param type
the type of component (used for error messages)
@param previousEntries
the previous entries of that component type (for uniqueness
check)
@throws IllegalStateException
if the name is invalid | [
"Checks",
"if",
"a",
"string",
"is",
"a",
"valid",
"name",
"of",
"a",
"component",
"."
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/env/xml-config/src/main/java/org/eobjects/analyzer/configuration/JaxbConfigurationReader.java#L1250-L1260 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/form/SigninFormPanel.java | SigninFormPanel.newPasswordForgottenLink | protected MarkupContainer newPasswordForgottenLink(final String id, final IModel<T> model) {
"""
Factory method for create the new {@link MarkupContainer} of the {@link Link} for the
password forgotten. This method is invoked in the constructor from the derived classes and
can be overridden so users can provide their own version of a new {@link MarkupContainer} of
the {@link Link} for the password forgotten.
@param id
the id
@param model
the model
@return the new {@link MarkupContainer} of the {@link Link} for the password forgotten.
"""
final LinkPanel linkPanel = new LinkPanel(id,
ResourceModelFactory.newResourceModel(ResourceBundleKey.builder()
.key("password.forgotten.label").defaultValue("Password forgotten").build()))
{
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
public void onClick(final AjaxRequestTarget target)
{
onPasswordForgotten(target, form);
}
};
return linkPanel;
} | java | protected MarkupContainer newPasswordForgottenLink(final String id, final IModel<T> model)
{
final LinkPanel linkPanel = new LinkPanel(id,
ResourceModelFactory.newResourceModel(ResourceBundleKey.builder()
.key("password.forgotten.label").defaultValue("Password forgotten").build()))
{
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
public void onClick(final AjaxRequestTarget target)
{
onPasswordForgotten(target, form);
}
};
return linkPanel;
} | [
"protected",
"MarkupContainer",
"newPasswordForgottenLink",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"LinkPanel",
"linkPanel",
"=",
"new",
"LinkPanel",
"(",
"id",
",",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"ResourceBundleKey",
".",
"builder",
"(",
")",
".",
"key",
"(",
"\"password.forgotten.label\"",
")",
".",
"defaultValue",
"(",
"\"Password forgotten\"",
")",
".",
"build",
"(",
")",
")",
")",
"{",
"/**\n\t\t\t * The serialVersionUID\n\t\t\t */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n\t\t\t * {@inheritDoc}\n\t\t\t */",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"AjaxRequestTarget",
"target",
")",
"{",
"onPasswordForgotten",
"(",
"target",
",",
"form",
")",
";",
"}",
"}",
";",
"return",
"linkPanel",
";",
"}"
] | Factory method for create the new {@link MarkupContainer} of the {@link Link} for the
password forgotten. This method is invoked in the constructor from the derived classes and
can be overridden so users can provide their own version of a new {@link MarkupContainer} of
the {@link Link} for the password forgotten.
@param id
the id
@param model
the model
@return the new {@link MarkupContainer} of the {@link Link} for the password forgotten. | [
"Factory",
"method",
"for",
"create",
"the",
"new",
"{",
"@link",
"MarkupContainer",
"}",
"of",
"the",
"{",
"@link",
"Link",
"}",
"for",
"the",
"password",
"forgotten",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"new",
"{",
"@link",
"MarkupContainer",
"}",
"of",
"the",
"{",
"@link",
"Link",
"}",
"for",
"the",
"password",
"forgotten",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/in/form/SigninFormPanel.java#L173-L195 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionSpecificationOptionValuePersistenceImpl.java | CPDefinitionSpecificationOptionValuePersistenceImpl.removeByUuid_C | @Override
public void removeByUuid_C(String uuid, long companyId) {
"""
Removes all the cp definition specification option values where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID
"""
for (CPDefinitionSpecificationOptionValue cpDefinitionSpecificationOptionValue : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(cpDefinitionSpecificationOptionValue);
}
} | java | @Override
public void removeByUuid_C(String uuid, long companyId) {
for (CPDefinitionSpecificationOptionValue cpDefinitionSpecificationOptionValue : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(cpDefinitionSpecificationOptionValue);
}
} | [
"@",
"Override",
"public",
"void",
"removeByUuid_C",
"(",
"String",
"uuid",
",",
"long",
"companyId",
")",
"{",
"for",
"(",
"CPDefinitionSpecificationOptionValue",
"cpDefinitionSpecificationOptionValue",
":",
"findByUuid_C",
"(",
"uuid",
",",
"companyId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"cpDefinitionSpecificationOptionValue",
")",
";",
"}",
"}"
] | Removes all the cp definition specification option values where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID | [
"Removes",
"all",
"the",
"cp",
"definition",
"specification",
"option",
"values",
"where",
"uuid",
"=",
"?",
";",
"and",
"companyId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionSpecificationOptionValuePersistenceImpl.java#L1440-L1446 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java | ScriptUtil.getScript | public static ExecutableScript getScript(String language, String source, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) {
"""
Creates a new {@link ExecutableScript} from a source or resource. It excepts static and
dynamic sources and resources. Dynamic means that the source or resource is an expression
which will be evaluated during execution.
@param language the language of the script
@param source the source code of the script or an expression which evaluates to the source code
@param resource the resource path of the script code or an expression which evaluates to the resource path
@param expressionManager the expression manager to use to generate the expressions of dynamic scripts
@param scriptFactory the script factory used to create the script
@return the newly created script
@throws NotValidException if language is null or empty or both of source and resource are invalid
"""
ensureNotEmpty(NotValidException.class, "Script language", language);
ensureAtLeastOneNotNull(NotValidException.class, "No script source or resource was given", source, resource);
if (resource != null && !resource.isEmpty()) {
return getScriptFromResource(language, resource, expressionManager, scriptFactory);
}
else {
return getScriptFormSource(language, source, expressionManager, scriptFactory);
}
} | java | public static ExecutableScript getScript(String language, String source, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) {
ensureNotEmpty(NotValidException.class, "Script language", language);
ensureAtLeastOneNotNull(NotValidException.class, "No script source or resource was given", source, resource);
if (resource != null && !resource.isEmpty()) {
return getScriptFromResource(language, resource, expressionManager, scriptFactory);
}
else {
return getScriptFormSource(language, source, expressionManager, scriptFactory);
}
} | [
"public",
"static",
"ExecutableScript",
"getScript",
"(",
"String",
"language",
",",
"String",
"source",
",",
"String",
"resource",
",",
"ExpressionManager",
"expressionManager",
",",
"ScriptFactory",
"scriptFactory",
")",
"{",
"ensureNotEmpty",
"(",
"NotValidException",
".",
"class",
",",
"\"Script language\"",
",",
"language",
")",
";",
"ensureAtLeastOneNotNull",
"(",
"NotValidException",
".",
"class",
",",
"\"No script source or resource was given\"",
",",
"source",
",",
"resource",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
"&&",
"!",
"resource",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"getScriptFromResource",
"(",
"language",
",",
"resource",
",",
"expressionManager",
",",
"scriptFactory",
")",
";",
"}",
"else",
"{",
"return",
"getScriptFormSource",
"(",
"language",
",",
"source",
",",
"expressionManager",
",",
"scriptFactory",
")",
";",
"}",
"}"
] | Creates a new {@link ExecutableScript} from a source or resource. It excepts static and
dynamic sources and resources. Dynamic means that the source or resource is an expression
which will be evaluated during execution.
@param language the language of the script
@param source the source code of the script or an expression which evaluates to the source code
@param resource the resource path of the script code or an expression which evaluates to the resource path
@param expressionManager the expression manager to use to generate the expressions of dynamic scripts
@param scriptFactory the script factory used to create the script
@return the newly created script
@throws NotValidException if language is null or empty or both of source and resource are invalid | [
"Creates",
"a",
"new",
"{",
"@link",
"ExecutableScript",
"}",
"from",
"a",
"source",
"or",
"resource",
".",
"It",
"excepts",
"static",
"and",
"dynamic",
"sources",
"and",
"resources",
".",
"Dynamic",
"means",
"that",
"the",
"source",
"or",
"resource",
"is",
"an",
"expression",
"which",
"will",
"be",
"evaluated",
"during",
"execution",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java#L66-L75 |
webmetrics/browsermob-proxy | src/main/java/org/xbill/DNS/Address.java | Address.getByName | public static InetAddress
getByName(String name) throws UnknownHostException {
"""
Determines the IP address of a host
@param name The hostname to look up
@return The first matching IP address
@throws UnknownHostException The hostname does not have any addresses
"""
try {
return getByAddress(name);
} catch (UnknownHostException e) {
Record[] records = lookupHostName(name);
return addrFromRecord(name, records[0]);
}
} | java | public static InetAddress
getByName(String name) throws UnknownHostException {
try {
return getByAddress(name);
} catch (UnknownHostException e) {
Record[] records = lookupHostName(name);
return addrFromRecord(name, records[0]);
}
} | [
"public",
"static",
"InetAddress",
"getByName",
"(",
"String",
"name",
")",
"throws",
"UnknownHostException",
"{",
"try",
"{",
"return",
"getByAddress",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"Record",
"[",
"]",
"records",
"=",
"lookupHostName",
"(",
"name",
")",
";",
"return",
"addrFromRecord",
"(",
"name",
",",
"records",
"[",
"0",
"]",
")",
";",
"}",
"}"
] | Determines the IP address of a host
@param name The hostname to look up
@return The first matching IP address
@throws UnknownHostException The hostname does not have any addresses | [
"Determines",
"the",
"IP",
"address",
"of",
"a",
"host"
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/xbill/DNS/Address.java#L268-L276 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.