repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 188 | func_name stringlengths 7 127 | whole_func_string stringlengths 77 3.91k | language stringclasses 1
value | func_code_string stringlengths 77 3.91k | func_code_tokens listlengths 20 745 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 477 | split_name stringclasses 1
value | func_code_url stringlengths 111 288 |
|---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/ade/configuration/CmsConfigurationReader.java | CmsConfigurationReader.parseFolderOrName | public CmsContentFolderDescriptor parseFolderOrName(String basePath, I_CmsXmlContentLocation location)
throws CmsException {
if (location == null) {
return null;
}
I_CmsXmlContentValueLocation nameLoc = location.getSubValue(N_NAME);
I_CmsXmlContentValueLocation pathLoc = location.getSubValue(N_PATH);
I_CmsXmlContentValueLocation pageRelativeLoc = location.getSubValue(N_PAGE_RELATIVE);
if (nameLoc != null) {
String name = nameLoc.asString(m_cms);
return new CmsContentFolderDescriptor(
basePath == null ? null : CmsStringUtil.joinPaths(basePath, CmsADEManager.CONTENT_FOLDER_NAME),
name);
} else if (pathLoc != null) {
String path = pathLoc.asString(m_cms);
CmsResource folder = m_cms.readResource(path);
return new CmsContentFolderDescriptor(folder);
} else if (pageRelativeLoc != null) {
return CmsContentFolderDescriptor.createPageRelativeFolderDescriptor();
} else {
return null;
}
} | java | public CmsContentFolderDescriptor parseFolderOrName(String basePath, I_CmsXmlContentLocation location)
throws CmsException {
if (location == null) {
return null;
}
I_CmsXmlContentValueLocation nameLoc = location.getSubValue(N_NAME);
I_CmsXmlContentValueLocation pathLoc = location.getSubValue(N_PATH);
I_CmsXmlContentValueLocation pageRelativeLoc = location.getSubValue(N_PAGE_RELATIVE);
if (nameLoc != null) {
String name = nameLoc.asString(m_cms);
return new CmsContentFolderDescriptor(
basePath == null ? null : CmsStringUtil.joinPaths(basePath, CmsADEManager.CONTENT_FOLDER_NAME),
name);
} else if (pathLoc != null) {
String path = pathLoc.asString(m_cms);
CmsResource folder = m_cms.readResource(path);
return new CmsContentFolderDescriptor(folder);
} else if (pageRelativeLoc != null) {
return CmsContentFolderDescriptor.createPageRelativeFolderDescriptor();
} else {
return null;
}
} | [
"public",
"CmsContentFolderDescriptor",
"parseFolderOrName",
"(",
"String",
"basePath",
",",
"I_CmsXmlContentLocation",
"location",
")",
"throws",
"CmsException",
"{",
"if",
"(",
"location",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"I_CmsXmlContentValueLoca... | Parses a folder which may either be given as a path or as a folder name.<p>
@param basePath the base path for the configuration
@param location the XML content node from which to parse the folder
@return the folder bean
@throws CmsException if something goes wrong | [
"Parses",
"a",
"folder",
"which",
"may",
"either",
"be",
"given",
"as",
"a",
"path",
"or",
"as",
"a",
"folder",
"name",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsConfigurationReader.java#L502-L525 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqlltrim | public static void sqlltrim(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
singleArgumentFunctionCall(buf, "trim(leading from ", "ltrim", parsedArgs);
} | java | public static void sqlltrim(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
singleArgumentFunctionCall(buf, "trim(leading from ", "ltrim", parsedArgs);
} | [
"public",
"static",
"void",
"sqlltrim",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"singleArgumentFunctionCall",
"(",
"buf",
",",
"\"trim(leading from \"",
",",
"\"ltrim\"",
... | ltrim translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"ltrim",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L250-L252 |
jtrfp/javamod | src/main/java/de/quippy/javamod/multimedia/mp3/id3/ID3v1Tag.java | ID3v1Tag.checkHeader | private boolean checkHeader(RandomAccessInputStream raf) throws FileNotFoundException, IOException
{
boolean retval = false;
if (raf.length() > TAG_SIZE)
{
raf.seek(raf.length() - TAG_SIZE);
byte[] buf = new byte[3];
if (raf.read(buf) != 3)
{
throw new IOException("Error encountered reading ID3 header");
}
else
{
String result = new String(buf, 0, 3, ENC_TYPE);
retval = result.equals(TAG_START);
}
}
return retval;
} | java | private boolean checkHeader(RandomAccessInputStream raf) throws FileNotFoundException, IOException
{
boolean retval = false;
if (raf.length() > TAG_SIZE)
{
raf.seek(raf.length() - TAG_SIZE);
byte[] buf = new byte[3];
if (raf.read(buf) != 3)
{
throw new IOException("Error encountered reading ID3 header");
}
else
{
String result = new String(buf, 0, 3, ENC_TYPE);
retval = result.equals(TAG_START);
}
}
return retval;
} | [
"private",
"boolean",
"checkHeader",
"(",
"RandomAccessInputStream",
"raf",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"boolean",
"retval",
"=",
"false",
";",
"if",
"(",
"raf",
".",
"length",
"(",
")",
">",
"TAG_SIZE",
")",
"{",
"raf",
... | Checks whether a header for the id3 tag exists yet
@return true if a tag is found
@exception FileNotFoundException if an error occurs
@exception IOException if an error occurs | [
"Checks",
"whether",
"a",
"header",
"for",
"the",
"id3",
"tag",
"exists",
"yet"
] | train | https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/ID3v1Tag.java#L107-L128 |
defei/codelogger-utils | src/main/java/org/codelogger/utils/DateUtils.java | DateUtils.getDateOfHoursBack | public static Date getDateOfHoursBack(final int hoursBack, final Date date) {
return dateBack(Calendar.HOUR_OF_DAY, hoursBack, date);
} | java | public static Date getDateOfHoursBack(final int hoursBack, final Date date) {
return dateBack(Calendar.HOUR_OF_DAY, hoursBack, date);
} | [
"public",
"static",
"Date",
"getDateOfHoursBack",
"(",
"final",
"int",
"hoursBack",
",",
"final",
"Date",
"date",
")",
"{",
"return",
"dateBack",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hoursBack",
",",
"date",
")",
";",
"}"
] | Get specify hours back form given date.
@param hoursBack how many hours want to be back.
@param date date to be handled.
@return a new Date object. | [
"Get",
"specify",
"hours",
"back",
"form",
"given",
"date",
"."
] | train | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/DateUtils.java#L173-L176 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/ParameterUtil.java | ParameterUtil.requireIntParameter | public static int requireIntParameter (HttpServletRequest req, String name,
String invalidDataMessage, ParameterValidator validator)
throws DataValidationException
{
String value = getParameter(req, name, false);
validator.validateParameter(name, value);
return parseIntParameter(value, invalidDataMessage);
} | java | public static int requireIntParameter (HttpServletRequest req, String name,
String invalidDataMessage, ParameterValidator validator)
throws DataValidationException
{
String value = getParameter(req, name, false);
validator.validateParameter(name, value);
return parseIntParameter(value, invalidDataMessage);
} | [
"public",
"static",
"int",
"requireIntParameter",
"(",
"HttpServletRequest",
"req",
",",
"String",
"name",
",",
"String",
"invalidDataMessage",
",",
"ParameterValidator",
"validator",
")",
"throws",
"DataValidationException",
"{",
"String",
"value",
"=",
"getParameter",... | Fetches the supplied parameter from the request and converts it to an integer. If the
parameter does not exist or is not a well-formed integer, a data validation exception is
thrown with the supplied message. | [
"Fetches",
"the",
"supplied",
"parameter",
"from",
"the",
"request",
"and",
"converts",
"it",
"to",
"an",
"integer",
".",
"If",
"the",
"parameter",
"does",
"not",
"exist",
"or",
"is",
"not",
"a",
"well",
"-",
"formed",
"integer",
"a",
"data",
"validation",... | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/ParameterUtil.java#L98-L105 |
jingwei/krati | krati-main/src/main/java/krati/core/array/entry/EntryValueShort.java | EntryValueShort.updateArrayFile | @Override
public void updateArrayFile(DataWriter writer, long position) throws IOException {
writer.writeShort(position, val);
} | java | @Override
public void updateArrayFile(DataWriter writer, long position) throws IOException {
writer.writeShort(position, val);
} | [
"@",
"Override",
"public",
"void",
"updateArrayFile",
"(",
"DataWriter",
"writer",
",",
"long",
"position",
")",
"throws",
"IOException",
"{",
"writer",
".",
"writeShort",
"(",
"position",
",",
"val",
")",
";",
"}"
] | Writes this EntryValue at a given position of a data writer.
@param writer
@param position
@throws IOException | [
"Writes",
"this",
"EntryValue",
"at",
"a",
"given",
"position",
"of",
"a",
"data",
"writer",
"."
] | train | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/entry/EntryValueShort.java#L95-L98 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java | WikipediaTemplateInfo.getPageIdsContainingTemplateNames | public List<Integer> getPageIdsContainingTemplateNames(List<String> templateNames) throws WikiApiException{
return getFilteredPageIds(templateNames, true);
} | java | public List<Integer> getPageIdsContainingTemplateNames(List<String> templateNames) throws WikiApiException{
return getFilteredPageIds(templateNames, true);
} | [
"public",
"List",
"<",
"Integer",
">",
"getPageIdsContainingTemplateNames",
"(",
"List",
"<",
"String",
">",
"templateNames",
")",
"throws",
"WikiApiException",
"{",
"return",
"getFilteredPageIds",
"(",
"templateNames",
",",
"true",
")",
";",
"}"
] | Returns a list containing the ids of all pages that contain a template
the name of which equals any of the given Strings.
@param templateNames
the names of the template that we want to match
@return A list with the ids of all pages that contain any of the the
specified templates
@throws WikiApiException
If there was any error retrieving the page object (most
likely if the templates are corrupted) | [
"Returns",
"a",
"list",
"containing",
"the",
"ids",
"of",
"all",
"pages",
"that",
"contain",
"a",
"template",
"the",
"name",
"of",
"which",
"equals",
"any",
"of",
"the",
"given",
"Strings",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java#L975-L977 |
jbundle/jbundle | thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java | TaskProxy.makeRemoteTable | public RemoteTable makeRemoteTable(String strRecordClassName, String strTableSessionClassName, Map<String, Object> properties, Map<String, Object> propDatabase)
throws RemoteException
{
BaseTransport transport = this.createProxyTransport(MAKE_REMOTE_TABLE);
transport.addParam(NAME, strRecordClassName);
transport.addParam(SESSION_CLASS_NAME, strTableSessionClassName);
transport.addParam(PROPERTIES, properties);
transport.addParam(PROPERTIES_DB, propDatabase);
String strTableID = (String)transport.sendMessageAndGetReply();
// See if I have this one already
TableProxy tableProxy = null;
//x tableProxy = (TableProxy)this.getChildList().get(strTableID);
if (tableProxy == null)
tableProxy = new TableProxy(this, strTableID); // This will add it to my list
return tableProxy;
} | java | public RemoteTable makeRemoteTable(String strRecordClassName, String strTableSessionClassName, Map<String, Object> properties, Map<String, Object> propDatabase)
throws RemoteException
{
BaseTransport transport = this.createProxyTransport(MAKE_REMOTE_TABLE);
transport.addParam(NAME, strRecordClassName);
transport.addParam(SESSION_CLASS_NAME, strTableSessionClassName);
transport.addParam(PROPERTIES, properties);
transport.addParam(PROPERTIES_DB, propDatabase);
String strTableID = (String)transport.sendMessageAndGetReply();
// See if I have this one already
TableProxy tableProxy = null;
//x tableProxy = (TableProxy)this.getChildList().get(strTableID);
if (tableProxy == null)
tableProxy = new TableProxy(this, strTableID); // This will add it to my list
return tableProxy;
} | [
"public",
"RemoteTable",
"makeRemoteTable",
"(",
"String",
"strRecordClassName",
",",
"String",
"strTableSessionClassName",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"propDatabase",
")",
"throws",
... | Make a table for this database.
@param strRecordClassName The record class name.
@param strTableSessionClassName The (optional) session name for the table.
@param properties The properties for the remote table. | [
"Make",
"a",
"table",
"for",
"this",
"database",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java#L95-L110 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VpnGatewaysInner.java | VpnGatewaysInner.createOrUpdateAsync | public Observable<VpnGatewayInner> createOrUpdateAsync(String resourceGroupName, String gatewayName, VpnGatewayInner vpnGatewayParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, gatewayName, vpnGatewayParameters).map(new Func1<ServiceResponse<VpnGatewayInner>, VpnGatewayInner>() {
@Override
public VpnGatewayInner call(ServiceResponse<VpnGatewayInner> response) {
return response.body();
}
});
} | java | public Observable<VpnGatewayInner> createOrUpdateAsync(String resourceGroupName, String gatewayName, VpnGatewayInner vpnGatewayParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, gatewayName, vpnGatewayParameters).map(new Func1<ServiceResponse<VpnGatewayInner>, VpnGatewayInner>() {
@Override
public VpnGatewayInner call(ServiceResponse<VpnGatewayInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VpnGatewayInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"gatewayName",
",",
"VpnGatewayInner",
"vpnGatewayParameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName"... | Creates a virtual wan vpn gateway if it doesn't exist else updates the existing gateway.
@param resourceGroupName The resource group name of the VpnGateway.
@param gatewayName The name of the gateway.
@param vpnGatewayParameters Parameters supplied to create or Update a virtual wan vpn gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"a",
"virtual",
"wan",
"vpn",
"gateway",
"if",
"it",
"doesn",
"t",
"exist",
"else",
"updates",
"the",
"existing",
"gateway",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VpnGatewaysInner.java#L238-L245 |
marvinlabs/android-slideshow-widget | library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java | SlideShowView.onSizeChanged | @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (onClickedDrawable != null) {
onClickedDrawable.setBounds(0, 0, w, h);
}
} | java | @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (onClickedDrawable != null) {
onClickedDrawable.setBounds(0, 0, w, h);
}
} | [
"@",
"Override",
"protected",
"void",
"onSizeChanged",
"(",
"int",
"w",
",",
"int",
"h",
",",
"int",
"oldw",
",",
"int",
"oldh",
")",
"{",
"super",
".",
"onSizeChanged",
"(",
"w",
",",
"h",
",",
"oldw",
",",
"oldh",
")",
";",
"if",
"(",
"onClickedD... | /*
When the size of the view changes, the size of the selector must scale with it | [
"/",
"*",
"When",
"the",
"size",
"of",
"the",
"view",
"changes",
"the",
"size",
"of",
"the",
"selector",
"must",
"scale",
"with",
"it"
] | train | https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L291-L297 |
ben-manes/caffeine | caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java | Caffeine.buildAsync | @NonNull
public <K1 extends K, V1 extends V> AsyncLoadingCache<K1, V1> buildAsync(
@NonNull CacheLoader<? super K1, V1> loader) {
return buildAsync((AsyncCacheLoader<? super K1, V1>) loader);
} | java | @NonNull
public <K1 extends K, V1 extends V> AsyncLoadingCache<K1, V1> buildAsync(
@NonNull CacheLoader<? super K1, V1> loader) {
return buildAsync((AsyncCacheLoader<? super K1, V1>) loader);
} | [
"@",
"NonNull",
"public",
"<",
"K1",
"extends",
"K",
",",
"V1",
"extends",
"V",
">",
"AsyncLoadingCache",
"<",
"K1",
",",
"V1",
">",
"buildAsync",
"(",
"@",
"NonNull",
"CacheLoader",
"<",
"?",
"super",
"K1",
",",
"V1",
">",
"loader",
")",
"{",
"retur... | Builds a cache, which either returns a {@link CompletableFuture} already loaded or currently
computing the value for a given key, or atomically computes the value asynchronously through a
supplied mapping function or the supplied {@code CacheLoader}. If the asynchronous computation
fails or computes a {@code null} value then the entry will be automatically removed. Note that
multiple threads can concurrently load values for distinct keys.
<p>
This method does not alter the state of this {@code Caffeine} instance, so it can be invoked
again to create multiple independent caches.
<p>
This construction cannot be used with {@link #weakValues()}, {@link #softValues()}, or
{@link #writer(CacheWriter)}.
@param loader the cache loader used to obtain new values
@param <K1> the key type of the loader
@param <V1> the value type of the loader
@return a cache having the requested features | [
"Builds",
"a",
"cache",
"which",
"either",
"returns",
"a",
"{",
"@link",
"CompletableFuture",
"}",
"already",
"loaded",
"or",
"currently",
"computing",
"the",
"value",
"for",
"a",
"given",
"key",
"or",
"atomically",
"computes",
"the",
"value",
"asynchronously",
... | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java#L1018-L1022 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/data/MetadataFinder.java | MetadataFinder.addMetadataProviderForMedia | private void addMetadataProviderForMedia(String key, MetadataProvider provider) {
if (!metadataProviders.containsKey(key)) {
metadataProviders.put(key, Collections.newSetFromMap(new ConcurrentHashMap<MetadataProvider, Boolean>()));
}
Set<MetadataProvider> providers = metadataProviders.get(key);
providers.add(provider);
} | java | private void addMetadataProviderForMedia(String key, MetadataProvider provider) {
if (!metadataProviders.containsKey(key)) {
metadataProviders.put(key, Collections.newSetFromMap(new ConcurrentHashMap<MetadataProvider, Boolean>()));
}
Set<MetadataProvider> providers = metadataProviders.get(key);
providers.add(provider);
} | [
"private",
"void",
"addMetadataProviderForMedia",
"(",
"String",
"key",
",",
"MetadataProvider",
"provider",
")",
"{",
"if",
"(",
"!",
"metadataProviders",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"metadataProviders",
".",
"put",
"(",
"key",
",",
"Collec... | Internal method that adds a metadata provider to the set associated with a particular hash key, creating the
set if needed.
@param key the hashKey identifying the media for which this provider can offer metadata (or the empty string if
it can offer metadata for all media)
@param provider the metadata provider to be added to the active set | [
"Internal",
"method",
"that",
"adds",
"a",
"metadata",
"provider",
"to",
"the",
"set",
"associated",
"with",
"a",
"particular",
"hash",
"key",
"creating",
"the",
"set",
"if",
"needed",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/MetadataFinder.java#L1082-L1088 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/utils/BsfUtils.java | BsfUtils.selectDateFormat | public static String selectDateFormat(Locale locale, String format) {
String selFormat;
if (format == null) {
selFormat = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale)).toPattern();
// Since DateFormat.SHORT is silly, return a smart format
if (selFormat.equals("M/d/yy")) {
return "MM/dd/yyyy";
}
if (selFormat.equals("d/M/yy")) {
return "dd/MM/yyyy";
}
} else {
selFormat = format;
}
return selFormat;
} | java | public static String selectDateFormat(Locale locale, String format) {
String selFormat;
if (format == null) {
selFormat = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale)).toPattern();
// Since DateFormat.SHORT is silly, return a smart format
if (selFormat.equals("M/d/yy")) {
return "MM/dd/yyyy";
}
if (selFormat.equals("d/M/yy")) {
return "dd/MM/yyyy";
}
} else {
selFormat = format;
}
return selFormat;
} | [
"public",
"static",
"String",
"selectDateFormat",
"(",
"Locale",
"locale",
",",
"String",
"format",
")",
"{",
"String",
"selFormat",
";",
"if",
"(",
"format",
"==",
"null",
")",
"{",
"selFormat",
"=",
"(",
"(",
"SimpleDateFormat",
")",
"DateFormat",
".",
"... | Selects the Date Pattern to use based on the given Locale if the input
format is null
@param locale
Locale (may be the result of a call to selectLocale)
@param format
Input format String
@return Date Pattern eg. dd/MM/yyyy | [
"Selects",
"the",
"Date",
"Pattern",
"to",
"use",
"based",
"on",
"the",
"given",
"Locale",
"if",
"the",
"input",
"format",
"is",
"null"
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/utils/BsfUtils.java#L479-L495 |
zaproxy/zaproxy | src/org/parosproxy/paros/core/scanner/VariantCustom.java | VariantCustom.addParamPost | public void addParamPost(String name, String value) {
addParam(name, value, NameValuePair.TYPE_POST_DATA);
} | java | public void addParamPost(String name, String value) {
addParam(name, value, NameValuePair.TYPE_POST_DATA);
} | [
"public",
"void",
"addParamPost",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"addParam",
"(",
"name",
",",
"value",
",",
"NameValuePair",
".",
"TYPE_POST_DATA",
")",
";",
"}"
] | Support method to add a new PostData param to this custom variant
@param name the param name
@param value the value of this parameter | [
"Support",
"method",
"to",
"add",
"a",
"new",
"PostData",
"param",
"to",
"this",
"custom",
"variant"
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/core/scanner/VariantCustom.java#L161-L163 |
Jasig/uPortal | uPortal-core/src/main/java/org/apereo/portal/i18n/LocaleManager.java | LocaleManager.getLocales | public List<Locale> getLocales() {
// Need logic to construct ordered locale list.
// Consider creating a separate ILocaleResolver
// interface to do this work.
final List rslt = new ArrayList();
// Add highest priority locales first
addToLocaleList(rslt, sessionLocales);
addToLocaleList(rslt, userLocales);
// We will ignore browser locales until we know how to
// translate them into proper java.util.Locales
// addToLocaleList(locales, browserLocales);
addToLocaleList(rslt, portalLocales);
return rslt;
} | java | public List<Locale> getLocales() {
// Need logic to construct ordered locale list.
// Consider creating a separate ILocaleResolver
// interface to do this work.
final List rslt = new ArrayList();
// Add highest priority locales first
addToLocaleList(rslt, sessionLocales);
addToLocaleList(rslt, userLocales);
// We will ignore browser locales until we know how to
// translate them into proper java.util.Locales
// addToLocaleList(locales, browserLocales);
addToLocaleList(rslt, portalLocales);
return rslt;
} | [
"public",
"List",
"<",
"Locale",
">",
"getLocales",
"(",
")",
"{",
"// Need logic to construct ordered locale list.",
"// Consider creating a separate ILocaleResolver",
"// interface to do this work.",
"final",
"List",
"rslt",
"=",
"new",
"ArrayList",
"(",
")",
";",
"// Add... | Produces a sorted list of locales according to locale preferences obtained from several
places. The following priority is given: session, user, browser, portal, and jvm.
@return the sorted list of locales | [
"Produces",
"a",
"sorted",
"list",
"of",
"locales",
"according",
"to",
"locale",
"preferences",
"obtained",
"from",
"several",
"places",
".",
"The",
"following",
"priority",
"is",
"given",
":",
"session",
"user",
"browser",
"portal",
"and",
"jvm",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-core/src/main/java/org/apereo/portal/i18n/LocaleManager.java#L87-L100 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/LocaleDisplayNames.java | LocaleDisplayNames.getInstance | public static LocaleDisplayNames getInstance(ULocale locale, DialectHandling dialectHandling) {
LocaleDisplayNames result = null;
if (FACTORY_DIALECTHANDLING != null) {
try {
result = (LocaleDisplayNames) FACTORY_DIALECTHANDLING.invoke(null,
locale, dialectHandling);
} catch (InvocationTargetException e) {
// fall through
} catch (IllegalAccessException e) {
// fall through
}
}
if (result == null) {
result = new LastResortLocaleDisplayNames(locale, dialectHandling);
}
return result;
} | java | public static LocaleDisplayNames getInstance(ULocale locale, DialectHandling dialectHandling) {
LocaleDisplayNames result = null;
if (FACTORY_DIALECTHANDLING != null) {
try {
result = (LocaleDisplayNames) FACTORY_DIALECTHANDLING.invoke(null,
locale, dialectHandling);
} catch (InvocationTargetException e) {
// fall through
} catch (IllegalAccessException e) {
// fall through
}
}
if (result == null) {
result = new LastResortLocaleDisplayNames(locale, dialectHandling);
}
return result;
} | [
"public",
"static",
"LocaleDisplayNames",
"getInstance",
"(",
"ULocale",
"locale",
",",
"DialectHandling",
"dialectHandling",
")",
"{",
"LocaleDisplayNames",
"result",
"=",
"null",
";",
"if",
"(",
"FACTORY_DIALECTHANDLING",
"!=",
"null",
")",
"{",
"try",
"{",
"res... | Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale,
using the provided dialectHandling.
@param locale the display locale
@param dialectHandling how to select names for locales
@return a LocaleDisplayNames instance | [
"Returns",
"an",
"instance",
"of",
"LocaleDisplayNames",
"that",
"returns",
"names",
"formatted",
"for",
"the",
"provided",
"locale",
"using",
"the",
"provided",
"dialectHandling",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/LocaleDisplayNames.java#L76-L92 |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/Slice.java | Slice.getBytes | public void getBytes(int index, byte[] destination, int destinationIndex, int length)
{
checkPositionIndexes(index, index + length, this.length);
checkPositionIndexes(destinationIndex, destinationIndex + length, destination.length);
index += offset;
System.arraycopy(data, index, destination, destinationIndex, length);
} | java | public void getBytes(int index, byte[] destination, int destinationIndex, int length)
{
checkPositionIndexes(index, index + length, this.length);
checkPositionIndexes(destinationIndex, destinationIndex + length, destination.length);
index += offset;
System.arraycopy(data, index, destination, destinationIndex, length);
} | [
"public",
"void",
"getBytes",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"destination",
",",
"int",
"destinationIndex",
",",
"int",
"length",
")",
"{",
"checkPositionIndexes",
"(",
"index",
",",
"index",
"+",
"length",
",",
"this",
".",
"length",
")",
"... | Transfers this buffer's data to the specified destination starting at
the specified absolute {@code index}.
@param destinationIndex the first index of the destination
@param length the number of bytes to transfer
@throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
if the specified {@code dstIndex} is less than {@code 0},
if {@code index + length} is greater than
{@code this.capacity}, or
if {@code dstIndex + length} is greater than
{@code dst.length} | [
"Transfers",
"this",
"buffer",
"s",
"data",
"to",
"the",
"specified",
"destination",
"starting",
"at",
"the",
"specified",
"absolute",
"{",
"@code",
"index",
"}",
"."
] | train | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/Slice.java#L207-L213 |
Inbot/inbot-utils | src/main/java/io/inbot/utils/MiscUtils.java | MiscUtils.urlDecode | public static String urlDecode(String s) {
try {
return URLDecoder.decode(s, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("get a jdk that actually supports utf-8", e);
}
} | java | public static String urlDecode(String s) {
try {
return URLDecoder.decode(s, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("get a jdk that actually supports utf-8", e);
}
} | [
"public",
"static",
"String",
"urlDecode",
"(",
"String",
"s",
")",
"{",
"try",
"{",
"return",
"URLDecoder",
".",
"decode",
"(",
"s",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",... | Url decode a string and don't throw a checked exception. Uses UTF-8 as per RFC 3986.
@param s a string
@return decoded string | [
"Url",
"decode",
"a",
"string",
"and",
"don",
"t",
"throw",
"a",
"checked",
"exception",
".",
"Uses",
"UTF",
"-",
"8",
"as",
"per",
"RFC",
"3986",
"."
] | train | https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/MiscUtils.java#L44-L50 |
finmath/finmath-lib | src/main/java/net/finmath/marketdata2/model/curves/ForwardCurveInterpolation.java | ForwardCurveInterpolation.createForwardCurveFromDiscountFactors | public static ForwardCurveInterpolation createForwardCurveFromDiscountFactors(String name, double[] times, RandomVariable[] givenDiscountFactors, double paymentOffset) {
ForwardCurveInterpolation forwardCurveInterpolation = new ForwardCurveInterpolation(name, paymentOffset, InterpolationEntityForward.FORWARD, null);
if(times.length == 0) {
throw new IllegalArgumentException("Vector of times must not be empty.");
}
if(times[0] > 0) {
// Add first forward
RandomVariable forward = givenDiscountFactors[0].sub(1.0).pow(-1.0).div(times[0]);
forwardCurveInterpolation.addForward(null, 0.0, forward, true);
}
for(int timeIndex=0; timeIndex<times.length-1;timeIndex++) {
RandomVariable forward = givenDiscountFactors[timeIndex].div(givenDiscountFactors[timeIndex+1].sub(1.0)).div(times[timeIndex+1] - times[timeIndex]);
double fixingTime = times[timeIndex];
boolean isParameter = (fixingTime > 0);
forwardCurveInterpolation.addForward(null, fixingTime, forward, isParameter);
}
return forwardCurveInterpolation;
} | java | public static ForwardCurveInterpolation createForwardCurveFromDiscountFactors(String name, double[] times, RandomVariable[] givenDiscountFactors, double paymentOffset) {
ForwardCurveInterpolation forwardCurveInterpolation = new ForwardCurveInterpolation(name, paymentOffset, InterpolationEntityForward.FORWARD, null);
if(times.length == 0) {
throw new IllegalArgumentException("Vector of times must not be empty.");
}
if(times[0] > 0) {
// Add first forward
RandomVariable forward = givenDiscountFactors[0].sub(1.0).pow(-1.0).div(times[0]);
forwardCurveInterpolation.addForward(null, 0.0, forward, true);
}
for(int timeIndex=0; timeIndex<times.length-1;timeIndex++) {
RandomVariable forward = givenDiscountFactors[timeIndex].div(givenDiscountFactors[timeIndex+1].sub(1.0)).div(times[timeIndex+1] - times[timeIndex]);
double fixingTime = times[timeIndex];
boolean isParameter = (fixingTime > 0);
forwardCurveInterpolation.addForward(null, fixingTime, forward, isParameter);
}
return forwardCurveInterpolation;
} | [
"public",
"static",
"ForwardCurveInterpolation",
"createForwardCurveFromDiscountFactors",
"(",
"String",
"name",
",",
"double",
"[",
"]",
"times",
",",
"RandomVariable",
"[",
"]",
"givenDiscountFactors",
",",
"double",
"paymentOffset",
")",
"{",
"ForwardCurveInterpolation... | Create a forward curve from given times and discount factors.
The forward curve will have times.length-1 fixing times from times[0] to times[times.length-2]
<code>
forward[timeIndex] = (givenDiscountFactors[timeIndex]/givenDiscountFactors[timeIndex+1]-1.0) / (times[timeIndex+1] - times[timeIndex]);
</code>
Note: If time[0] > 0, then the discount factor 1.0 will inserted at time 0.0
@param name The name of this curve.
@param times A vector of given time points.
@param givenDiscountFactors A vector of given discount factors (corresponding to the given time points).
@param paymentOffset The maturity of the underlying index modeled by this curve.
@return A new ForwardCurve object. | [
"Create",
"a",
"forward",
"curve",
"from",
"given",
"times",
"and",
"discount",
"factors",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/marketdata2/model/curves/ForwardCurveInterpolation.java#L261-L282 |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/IndexedSourceMapConsumer.java | IndexedSourceMapConsumer.originalPositionFor | public OriginalPosition originalPositionFor(int line, int column, Bias bias) {
ParsedSection needle = new ParsedSection(new ParsedOffset(line, column), null);
// Find the section containing the generated position we're trying to map
// to an original position.
int sectionIndex = BinarySearch.search(needle, this._sections, (section1, section2) -> {
int cmp = section1.generatedOffset.generatedLine - section2.generatedOffset.generatedLine;
if (cmp != 0) {
return cmp;
}
return (section1.generatedOffset.generatedColumn - section2.generatedOffset.generatedColumn);
} , null);
ParsedSection section = this._sections.get(sectionIndex);
if (section == null) {
return new OriginalPosition();
}
return section.consumer.originalPositionFor(needle.generatedOffset.generatedLine - (section.generatedOffset.generatedLine - 1),
needle.generatedOffset.generatedColumn - (section.generatedOffset.generatedLine == needle.generatedOffset.generatedLine
? section.generatedOffset.generatedColumn - 1 : 0),
bias);
} | java | public OriginalPosition originalPositionFor(int line, int column, Bias bias) {
ParsedSection needle = new ParsedSection(new ParsedOffset(line, column), null);
// Find the section containing the generated position we're trying to map
// to an original position.
int sectionIndex = BinarySearch.search(needle, this._sections, (section1, section2) -> {
int cmp = section1.generatedOffset.generatedLine - section2.generatedOffset.generatedLine;
if (cmp != 0) {
return cmp;
}
return (section1.generatedOffset.generatedColumn - section2.generatedOffset.generatedColumn);
} , null);
ParsedSection section = this._sections.get(sectionIndex);
if (section == null) {
return new OriginalPosition();
}
return section.consumer.originalPositionFor(needle.generatedOffset.generatedLine - (section.generatedOffset.generatedLine - 1),
needle.generatedOffset.generatedColumn - (section.generatedOffset.generatedLine == needle.generatedOffset.generatedLine
? section.generatedOffset.generatedColumn - 1 : 0),
bias);
} | [
"public",
"OriginalPosition",
"originalPositionFor",
"(",
"int",
"line",
",",
"int",
"column",
",",
"Bias",
"bias",
")",
"{",
"ParsedSection",
"needle",
"=",
"new",
"ParsedSection",
"(",
"new",
"ParsedOffset",
"(",
"line",
",",
"column",
")",
",",
"null",
")... | Returns the original source, line, and column information for the generated source's line and column positions provided. The only argument is
an object with the following properties:
<ul>
<li>line: The line number in the generated source.</li>
<li>column: The column number in the generated source.</li>
</ul>
and an object is returned with the following properties:
<ul>
<li>source: The original source file, or null.</li>
<li>line: The line number in the original source, or null.</li>
<li>column: The column number in the original source, or null.</li>
<li>name: The original identifier, or null.</li>
</ul> | [
"Returns",
"the",
"original",
"source",
"line",
"and",
"column",
"information",
"for",
"the",
"generated",
"source",
"s",
"line",
"and",
"column",
"positions",
"provided",
".",
"The",
"only",
"argument",
"is",
"an",
"object",
"with",
"the",
"following",
"prope... | train | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/IndexedSourceMapConsumer.java#L156-L179 |
Red5/red5-server-common | src/main/java/org/red5/server/stream/StreamService.java | StreamService.sendNSStatus | private void sendNSStatus(IConnection conn, String statusCode, String description, String name, Number streamId) {
StreamService.sendNetStreamStatus(conn, statusCode, description, name, Status.STATUS, streamId);
} | java | private void sendNSStatus(IConnection conn, String statusCode, String description, String name, Number streamId) {
StreamService.sendNetStreamStatus(conn, statusCode, description, name, Status.STATUS, streamId);
} | [
"private",
"void",
"sendNSStatus",
"(",
"IConnection",
"conn",
",",
"String",
"statusCode",
",",
"String",
"description",
",",
"String",
"name",
",",
"Number",
"streamId",
")",
"{",
"StreamService",
".",
"sendNetStreamStatus",
"(",
"conn",
",",
"statusCode",
","... | Send NetStream.Status to the client.
@param conn
@param statusCode
see StatusCodes class
@param description
@param name
@param streamId | [
"Send",
"NetStream",
".",
"Status",
"to",
"the",
"client",
"."
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/stream/StreamService.java#L814-L816 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Image.java | Image.getInstance | public static Image getInstance(java.awt.Image image, java.awt.Color color)
throws BadElementException, IOException {
return Image.getInstance(image, color, false);
} | java | public static Image getInstance(java.awt.Image image, java.awt.Color color)
throws BadElementException, IOException {
return Image.getInstance(image, color, false);
} | [
"public",
"static",
"Image",
"getInstance",
"(",
"java",
".",
"awt",
".",
"Image",
"image",
",",
"java",
".",
"awt",
".",
"Color",
"color",
")",
"throws",
"BadElementException",
",",
"IOException",
"{",
"return",
"Image",
".",
"getInstance",
"(",
"image",
... | Gets an instance of an Image from a java.awt.Image.
@param image
the <CODE>java.awt.Image</CODE> to convert
@param color
if different from <CODE>null</CODE> the transparency pixels
are replaced by this color
@return an object of type <CODE>ImgRaw</CODE>
@throws BadElementException
on error
@throws IOException
on error | [
"Gets",
"an",
"instance",
"of",
"an",
"Image",
"from",
"a",
"java",
".",
"awt",
".",
"Image",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Image.java#L791-L794 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java | NumberUtil.formatPercent | public static String formatPercent(double number, int scale) {
final NumberFormat format = NumberFormat.getPercentInstance();
format.setMaximumFractionDigits(scale);
return format.format(number);
} | java | public static String formatPercent(double number, int scale) {
final NumberFormat format = NumberFormat.getPercentInstance();
format.setMaximumFractionDigits(scale);
return format.format(number);
} | [
"public",
"static",
"String",
"formatPercent",
"(",
"double",
"number",
",",
"int",
"scale",
")",
"{",
"final",
"NumberFormat",
"format",
"=",
"NumberFormat",
".",
"getPercentInstance",
"(",
")",
";",
"format",
".",
"setMaximumFractionDigits",
"(",
"scale",
")",... | 格式化百分比,小数采用四舍五入方式
@param number 值
@param scale 保留小数位数
@return 百分比
@since 3.2.3 | [
"格式化百分比,小数采用四舍五入方式"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java#L1038-L1042 |
alkacon/opencms-core | src/org/opencms/webdav/CmsWebdavServlet.java | CmsWebdavServlet.doUnlock | protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) {
String path = getRelativePath(req);
// Check if Webdav is read only
if (m_readOnly) {
resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
}
return;
}
// Check if resource is locked
if (isLocked(req)) {
resp.setStatus(CmsWebdavStatus.SC_LOCKED);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, path));
}
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_UNLOCK_ITEM_0));
}
m_session.unlock(path);
resp.setStatus(CmsWebdavStatus.SC_NO_CONTENT);
} | java | protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) {
String path = getRelativePath(req);
// Check if Webdav is read only
if (m_readOnly) {
resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
}
return;
}
// Check if resource is locked
if (isLocked(req)) {
resp.setStatus(CmsWebdavStatus.SC_LOCKED);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, path));
}
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_UNLOCK_ITEM_0));
}
m_session.unlock(path);
resp.setStatus(CmsWebdavStatus.SC_NO_CONTENT);
} | [
"protected",
"void",
"doUnlock",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"{",
"String",
"path",
"=",
"getRelativePath",
"(",
"req",
")",
";",
"// Check if Webdav is read only",
"if",
"(",
"m_readOnly",
")",
"{",
"resp",
".",
"s... | Process a UNLOCK WebDAV request for the specified resource.<p>
@param req the servlet request we are processing
@param resp the servlet response we are creating | [
"Process",
"a",
"UNLOCK",
"WebDAV",
"request",
"for",
"the",
"specified",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/webdav/CmsWebdavServlet.java#L2111-L2146 |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/FileStorage.java | FileStorage.onOutput | @Handler
public void onOutput(Output<ByteBuffer> event, Channel channel) {
Writer writer = outputWriters.get(channel);
if (writer != null) {
writer.write(event.buffer());
}
} | java | @Handler
public void onOutput(Output<ByteBuffer> event, Channel channel) {
Writer writer = outputWriters.get(channel);
if (writer != null) {
writer.write(event.buffer());
}
} | [
"@",
"Handler",
"public",
"void",
"onOutput",
"(",
"Output",
"<",
"ByteBuffer",
">",
"event",
",",
"Channel",
"channel",
")",
"{",
"Writer",
"writer",
"=",
"outputWriters",
".",
"get",
"(",
"channel",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"... | Handle {@link Output} events by writing them to the file, if
a channel exists.
@param event the event
@param channel the channel | [
"Handle",
"{",
"@link",
"Output",
"}",
"events",
"by",
"writing",
"them",
"to",
"the",
"file",
"if",
"a",
"channel",
"exists",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/FileStorage.java#L368-L374 |
js-lib-com/commons | src/main/java/js/util/Classes.java | Classes.setFieldValues | @SuppressWarnings("unchecked")
public static void setFieldValues(Object object, String fieldName, String valuesString)
{
Converter converter = ConverterRegistry.getConverter();
List<String> values = Strings.split(valuesString, ',');
Field field = getField(object.getClass(), fieldName);
Type type = field.getType();
Object instance = null;
if(Types.isArray(type)) {
Class<?> componentType = field.getClass().getComponentType();
instance = Array.newInstance(componentType, values.size());
for(int i = 0; i < values.size(); i++) {
Array.set(instance, i, converter.asObject(values.get(i), componentType));
}
}
else if(Types.isCollection(type)) {
Class<?> componentType = (Class<?>)((ParameterizedType)field.getGenericType()).getActualTypeArguments()[0];
instance = newCollection(type);
for(int i = 0; i < values.size(); i++) {
((Collection<Object>)instance).add(converter.asObject(values.get(i), componentType));
}
}
else {
throw new BugError("Cannot set values list to field type |%s|.", field.getType());
}
// at this point instance cannot be null
setFieldValue(object, field, instance);
} | java | @SuppressWarnings("unchecked")
public static void setFieldValues(Object object, String fieldName, String valuesString)
{
Converter converter = ConverterRegistry.getConverter();
List<String> values = Strings.split(valuesString, ',');
Field field = getField(object.getClass(), fieldName);
Type type = field.getType();
Object instance = null;
if(Types.isArray(type)) {
Class<?> componentType = field.getClass().getComponentType();
instance = Array.newInstance(componentType, values.size());
for(int i = 0; i < values.size(); i++) {
Array.set(instance, i, converter.asObject(values.get(i), componentType));
}
}
else if(Types.isCollection(type)) {
Class<?> componentType = (Class<?>)((ParameterizedType)field.getGenericType()).getActualTypeArguments()[0];
instance = newCollection(type);
for(int i = 0; i < values.size(); i++) {
((Collection<Object>)instance).add(converter.asObject(values.get(i), componentType));
}
}
else {
throw new BugError("Cannot set values list to field type |%s|.", field.getType());
}
// at this point instance cannot be null
setFieldValue(object, field, instance);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"void",
"setFieldValues",
"(",
"Object",
"object",
",",
"String",
"fieldName",
",",
"String",
"valuesString",
")",
"{",
"Converter",
"converter",
"=",
"ConverterRegistry",
".",
"getConverter",
... | Set values to a field of array or collection type. If named field is not of supported types throws bug exception.
This method has <code>valuesString</code> parameter that is a list of comma separated value objects. Split values
string and converter every resulting item to field component type.
@param object instance to set field value to or null if field is static,
@param fieldName field name,
@param valuesString comma separated values.
@throws ConverterException if there is no converter registered for field component type or parsing fails.
@throws BugError if named field type is not of supported types. | [
"Set",
"values",
"to",
"a",
"field",
"of",
"array",
"or",
"collection",
"type",
".",
"If",
"named",
"field",
"is",
"not",
"of",
"supported",
"types",
"throws",
"bug",
"exception",
".",
"This",
"method",
"has",
"<code",
">",
"valuesString<",
"/",
"code",
... | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Classes.java#L908-L938 |
Netflix/karyon | karyon2-governator/src/main/java/netflix/karyon/Karyon.java | Karyon.forTcpConnectionHandler | public static KaryonServer forTcpConnectionHandler(int port, ConnectionHandler<ByteBuf, ByteBuf> handler,
BootstrapModule... bootstrapModules) {
RxServer<ByteBuf, ByteBuf> server = RxNetty.newTcpServerBuilder(port, handler).build();
return new RxNettyServerBackedServer(server, bootstrapModules);
} | java | public static KaryonServer forTcpConnectionHandler(int port, ConnectionHandler<ByteBuf, ByteBuf> handler,
BootstrapModule... bootstrapModules) {
RxServer<ByteBuf, ByteBuf> server = RxNetty.newTcpServerBuilder(port, handler).build();
return new RxNettyServerBackedServer(server, bootstrapModules);
} | [
"public",
"static",
"KaryonServer",
"forTcpConnectionHandler",
"(",
"int",
"port",
",",
"ConnectionHandler",
"<",
"ByteBuf",
",",
"ByteBuf",
">",
"handler",
",",
"BootstrapModule",
"...",
"bootstrapModules",
")",
"{",
"RxServer",
"<",
"ByteBuf",
",",
"ByteBuf",
">... | Creates a new {@link KaryonServer} that has a single TCP server instance which delegates all connection
handling to {@link ConnectionHandler}.
The {@link RxServer} is created using {@link RxNetty#newTcpServerBuilder(int, ConnectionHandler)}
@param port Port for the server.
@param handler Connection Handler
@param bootstrapModules Additional bootstrapModules if any.
@return {@link KaryonServer} which is to be used to start the created server. | [
"Creates",
"a",
"new",
"{",
"@link",
"KaryonServer",
"}",
"that",
"has",
"a",
"single",
"TCP",
"server",
"instance",
"which",
"delegates",
"all",
"connection",
"handling",
"to",
"{",
"@link",
"ConnectionHandler",
"}",
".",
"The",
"{",
"@link",
"RxServer",
"}... | train | https://github.com/Netflix/karyon/blob/d50bc0ff37693ef3fbda373e90a109d1f92e0b9a/karyon2-governator/src/main/java/netflix/karyon/Karyon.java#L103-L107 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/Form.java | Form.setAttribute | public void setAttribute(String name, String value, String facet)
throws JspException
{
if (name != null) {
if (name.equals(ACTION) || name.equals(METHOD)) {
String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
registerTagError(s, null);
}
}
super.setAttribute(name, value, facet);
} | java | public void setAttribute(String name, String value, String facet)
throws JspException
{
if (name != null) {
if (name.equals(ACTION) || name.equals(METHOD)) {
String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
registerTagError(s, null);
}
}
super.setAttribute(name, value, facet);
} | [
"public",
"void",
"setAttribute",
"(",
"String",
"name",
",",
"String",
"value",
",",
"String",
"facet",
")",
"throws",
"JspException",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"ACTION",
")",
"||",
"name",
... | Base support for the attribute tag. This is overridden to prevent setting the <code>action</code>,
and <code>method</code> attributes.
@param name The name of the attribute. This value may not be null or the empty string.
@param value The value of the attribute. This may contain an expression.
@param facet The name of a facet to which the attribute will be applied. This is optional.
@throws JspException A JspException may be thrown if there is an error setting the attribute. | [
"Base",
"support",
"for",
"the",
"attribute",
"tag",
".",
"This",
"is",
"overridden",
"to",
"prevent",
"setting",
"the",
"<code",
">",
"action<",
"/",
"code",
">",
"and",
"<code",
">",
"method<",
"/",
"code",
">",
"attributes",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/Form.java#L270-L280 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/UnionPathIterator.java | UnionPathIterator.setRoot | public void setRoot(int context, Object environment)
{
super.setRoot(context, environment);
try
{
if (null != m_exprs)
{
int n = m_exprs.length;
DTMIterator newIters[] = new DTMIterator[n];
for (int i = 0; i < n; i++)
{
DTMIterator iter = m_exprs[i].asIterator(m_execContext, context);
newIters[i] = iter;
iter.nextNode();
}
m_iterators = newIters;
}
}
catch(Exception e)
{
throw new org.apache.xml.utils.WrappedRuntimeException(e);
}
} | java | public void setRoot(int context, Object environment)
{
super.setRoot(context, environment);
try
{
if (null != m_exprs)
{
int n = m_exprs.length;
DTMIterator newIters[] = new DTMIterator[n];
for (int i = 0; i < n; i++)
{
DTMIterator iter = m_exprs[i].asIterator(m_execContext, context);
newIters[i] = iter;
iter.nextNode();
}
m_iterators = newIters;
}
}
catch(Exception e)
{
throw new org.apache.xml.utils.WrappedRuntimeException(e);
}
} | [
"public",
"void",
"setRoot",
"(",
"int",
"context",
",",
"Object",
"environment",
")",
"{",
"super",
".",
"setRoot",
"(",
"context",
",",
"environment",
")",
";",
"try",
"{",
"if",
"(",
"null",
"!=",
"m_exprs",
")",
"{",
"int",
"n",
"=",
"m_exprs",
"... | Initialize the context values for this expression
after it is cloned.
@param context The XPath runtime context for this
transformation. | [
"Initialize",
"the",
"context",
"values",
"for",
"this",
"expression",
"after",
"it",
"is",
"cloned",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/UnionPathIterator.java#L67-L91 |
jaxio/celerio | celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java | EntityFactory.namerDefault | private void namerDefault(Entity entity) {
entity.put("searchForm", new ClassNamer2(entity, null, "web.domain", null, "SearchForm"));
entity.put("editForm", new ClassNamer2(entity, null, "web.domain", null, "EditForm"));
entity.put("graphLoader", new ClassNamer2(entity, null, "web.domain", null, "GraphLoader"));
entity.put("controller", new ClassNamer2(entity, null, "web.domain", null, "Controller"));
entity.put("excelExporter", new ClassNamer2(entity, null, "web.domain", null, "ExcelExporter"));
entity.put("lazyDataModel", new ClassNamer2(entity, null, "web.domain", null, "LazyDataModel"));
entity.put("fileUpload", new ClassNamer2(entity, null, "web.domain", null, "FileUpload"));
entity.put("fileDownload", new ClassNamer2(entity, null, "web.domain", null, "FileDownload"));
} | java | private void namerDefault(Entity entity) {
entity.put("searchForm", new ClassNamer2(entity, null, "web.domain", null, "SearchForm"));
entity.put("editForm", new ClassNamer2(entity, null, "web.domain", null, "EditForm"));
entity.put("graphLoader", new ClassNamer2(entity, null, "web.domain", null, "GraphLoader"));
entity.put("controller", new ClassNamer2(entity, null, "web.domain", null, "Controller"));
entity.put("excelExporter", new ClassNamer2(entity, null, "web.domain", null, "ExcelExporter"));
entity.put("lazyDataModel", new ClassNamer2(entity, null, "web.domain", null, "LazyDataModel"));
entity.put("fileUpload", new ClassNamer2(entity, null, "web.domain", null, "FileUpload"));
entity.put("fileDownload", new ClassNamer2(entity, null, "web.domain", null, "FileDownload"));
} | [
"private",
"void",
"namerDefault",
"(",
"Entity",
"entity",
")",
"{",
"entity",
".",
"put",
"(",
"\"searchForm\"",
",",
"new",
"ClassNamer2",
"(",
"entity",
",",
"null",
",",
"\"web.domain\"",
",",
"null",
",",
"\"SearchForm\"",
")",
")",
";",
"entity",
".... | Namers declared here can be overridden easily through configuration.
@param entity | [
"Namers",
"declared",
"here",
"can",
"be",
"overridden",
"easily",
"through",
"configuration",
"."
] | train | https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java#L246-L255 |
Azure/azure-sdk-for-java | resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/ResourceGroupsInner.java | ResourceGroupsInner.patchAsync | public Observable<ResourceGroupInner> patchAsync(String resourceGroupName, ResourceGroupInner parameters) {
return patchWithServiceResponseAsync(resourceGroupName, parameters).map(new Func1<ServiceResponse<ResourceGroupInner>, ResourceGroupInner>() {
@Override
public ResourceGroupInner call(ServiceResponse<ResourceGroupInner> response) {
return response.body();
}
});
} | java | public Observable<ResourceGroupInner> patchAsync(String resourceGroupName, ResourceGroupInner parameters) {
return patchWithServiceResponseAsync(resourceGroupName, parameters).map(new Func1<ServiceResponse<ResourceGroupInner>, ResourceGroupInner>() {
@Override
public ResourceGroupInner call(ServiceResponse<ResourceGroupInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ResourceGroupInner",
">",
"patchAsync",
"(",
"String",
"resourceGroupName",
",",
"ResourceGroupInner",
"parameters",
")",
"{",
"return",
"patchWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"parameters",
")",
".",
"map",
"(",
"... | Updates a resource group.
Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained.
@param resourceGroupName The name of the resource group to update. The name is case insensitive.
@param parameters Parameters supplied to update a resource group.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ResourceGroupInner object | [
"Updates",
"a",
"resource",
"group",
".",
"Resource",
"groups",
"can",
"be",
"updated",
"through",
"a",
"simple",
"PATCH",
"operation",
"to",
"a",
"group",
"address",
".",
"The",
"format",
"of",
"the",
"request",
"is",
"the",
"same",
"as",
"that",
"for",
... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/ResourceGroupsInner.java#L788-L795 |
liferay/com-liferay-commerce | commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java | CPDefinitionVirtualSettingPersistenceImpl.fetchByUUID_G | @Override
public CPDefinitionVirtualSetting fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
} | java | @Override
public CPDefinitionVirtualSetting fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
} | [
"@",
"Override",
"public",
"CPDefinitionVirtualSetting",
"fetchByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"{",
"return",
"fetchByUUID_G",
"(",
"uuid",
",",
"groupId",
",",
"true",
")",
";",
"}"
] | Returns the cp definition virtual setting where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param uuid the uuid
@param groupId the group ID
@return the matching cp definition virtual setting, or <code>null</code> if a matching cp definition virtual setting could not be found | [
"Returns",
"the",
"cp",
"definition",
"virtual",
"setting",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
... | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java#L711-L714 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java | ConfigurationsInner.get | public Map<String, String> get(String resourceGroupName, String clusterName, String configurationName) {
return getWithServiceResponseAsync(resourceGroupName, clusterName, configurationName).toBlocking().single().body();
} | java | public Map<String, String> get(String resourceGroupName, String clusterName, String configurationName) {
return getWithServiceResponseAsync(resourceGroupName, clusterName, configurationName).toBlocking().single().body();
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"get",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"String",
"configurationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"... | The configuration object for the specified cluster. This API is not recommended and might be removed in the future. Please consider using List configurations API instead.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param configurationName The name of the cluster configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the Map<String, String> object if successful. | [
"The",
"configuration",
"object",
"for",
"the",
"specified",
"cluster",
".",
"This",
"API",
"is",
"not",
"recommended",
"and",
"might",
"be",
"removed",
"in",
"the",
"future",
".",
"Please",
"consider",
"using",
"List",
"configurations",
"API",
"instead",
"."
... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java#L358-L360 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchRunner.java | IdentityPatchRunner.rollbackLast | public PatchingResult rollbackLast(final ContentVerificationPolicy contentPolicy, final boolean resetConfiguration, InstallationManager.InstallationModification modification) throws PatchingException {
// Determine the patch id to rollback
String patchId;
final List<String> oneOffs = modification.getPatchIDs();
if (oneOffs.isEmpty()) {
patchId = modification.getCumulativePatchID();
if (patchId == null || Constants.NOT_PATCHED.equals(patchId)) {
throw PatchLogger.ROOT_LOGGER.noPatchesApplied();
}
} else {
patchId = oneOffs.get(0);//oneOffs.get(oneOffs.size() - 1);
}
return rollbackPatch(patchId, contentPolicy, false, resetConfiguration, modification);
} | java | public PatchingResult rollbackLast(final ContentVerificationPolicy contentPolicy, final boolean resetConfiguration, InstallationManager.InstallationModification modification) throws PatchingException {
// Determine the patch id to rollback
String patchId;
final List<String> oneOffs = modification.getPatchIDs();
if (oneOffs.isEmpty()) {
patchId = modification.getCumulativePatchID();
if (patchId == null || Constants.NOT_PATCHED.equals(patchId)) {
throw PatchLogger.ROOT_LOGGER.noPatchesApplied();
}
} else {
patchId = oneOffs.get(0);//oneOffs.get(oneOffs.size() - 1);
}
return rollbackPatch(patchId, contentPolicy, false, resetConfiguration, modification);
} | [
"public",
"PatchingResult",
"rollbackLast",
"(",
"final",
"ContentVerificationPolicy",
"contentPolicy",
",",
"final",
"boolean",
"resetConfiguration",
",",
"InstallationManager",
".",
"InstallationModification",
"modification",
")",
"throws",
"PatchingException",
"{",
"// Det... | Rollback the last applied patch.
@param contentPolicy the content policy
@param resetConfiguration whether to reset the configuration
@param modification the installation modification
@return the patching result
@throws PatchingException | [
"Rollback",
"the",
"last",
"applied",
"patch",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchRunner.java#L284-L298 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsDelete.java | CmsDelete.performSingleDeleteOperation | protected void performSingleDeleteOperation(String resource, CmsResourceDeleteMode deleteOption)
throws CmsException {
// lock resource if autolock is enabled
checkLock(resource);
// delete the resource
getCms().deleteResource(resource, deleteOption);
} | java | protected void performSingleDeleteOperation(String resource, CmsResourceDeleteMode deleteOption)
throws CmsException {
// lock resource if autolock is enabled
checkLock(resource);
// delete the resource
getCms().deleteResource(resource, deleteOption);
} | [
"protected",
"void",
"performSingleDeleteOperation",
"(",
"String",
"resource",
",",
"CmsResourceDeleteMode",
"deleteOption",
")",
"throws",
"CmsException",
"{",
"// lock resource if autolock is enabled",
"checkLock",
"(",
"resource",
")",
";",
"// delete the resource",
"getC... | Performs the delete operation for a single VFS resource.<p>
@param resource the resource VFS path
@param deleteOption the delete option for sibling deletion
@throws CmsException if deleting the resource fails | [
"Performs",
"the",
"delete",
"operation",
"for",
"a",
"single",
"VFS",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsDelete.java#L415-L422 |
sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java | PipelineBuilder.addVariableExpr | public void addVariableExpr(final INodeReadTrx mTransaction, final String mVarName) {
assert getPipeStack().size() >= 1;
final AbsAxis bindingSeq = getPipeStack().pop().getExpr();
final AbsAxis axis = new VariableAxis(mTransaction, bindingSeq);
mVarRefMap.put(mVarName, axis);
if (getPipeStack().empty() || getExpression().getSize() != 0) {
addExpressionSingle();
}
getExpression().add(axis);
} | java | public void addVariableExpr(final INodeReadTrx mTransaction, final String mVarName) {
assert getPipeStack().size() >= 1;
final AbsAxis bindingSeq = getPipeStack().pop().getExpr();
final AbsAxis axis = new VariableAxis(mTransaction, bindingSeq);
mVarRefMap.put(mVarName, axis);
if (getPipeStack().empty() || getExpression().getSize() != 0) {
addExpressionSingle();
}
getExpression().add(axis);
} | [
"public",
"void",
"addVariableExpr",
"(",
"final",
"INodeReadTrx",
"mTransaction",
",",
"final",
"String",
"mVarName",
")",
"{",
"assert",
"getPipeStack",
"(",
")",
".",
"size",
"(",
")",
">=",
"1",
";",
"final",
"AbsAxis",
"bindingSeq",
"=",
"getPipeStack",
... | Adds a variable expression to the pipeline. Adds the expression that will
evaluate the results the variable holds.
@param mTransaction
Transaction to operate with.
@param mVarName
name of the variable | [
"Adds",
"a",
"variable",
"expression",
"to",
"the",
"pipeline",
".",
"Adds",
"the",
"expression",
"that",
"will",
"evaluate",
"the",
"results",
"the",
"variable",
"holds",
"."
] | train | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L705-L718 |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.withinLimit | protected boolean withinLimit(Integer limit, Collection<?> collection) {
if (limit == null) {
return true;
} else {
int value = limit.intValue();
return value <= 0 || value > collection.size();
}
} | java | protected boolean withinLimit(Integer limit, Collection<?> collection) {
if (limit == null) {
return true;
} else {
int value = limit.intValue();
return value <= 0 || value > collection.size();
}
} | [
"protected",
"boolean",
"withinLimit",
"(",
"Integer",
"limit",
",",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"if",
"(",
"limit",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"int",
"value",
"=",
"limit",
".",
"intValue"... | Returns true if we are within the limit value for the number of results in the collection | [
"Returns",
"true",
"if",
"we",
"are",
"within",
"the",
"limit",
"value",
"for",
"the",
"number",
"of",
"results",
"in",
"the",
"collection"
] | train | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L537-L544 |
prestodb/presto | presto-spi/src/main/java/com/facebook/presto/spi/block/MapBlockBuilder.java | MapBlockBuilder.buildHashTable | static void buildHashTable(Block keyBlock, int keyOffset, int keyCount, MethodHandle keyBlockHashCode, int[] outputHashTable, int hashTableOffset, int hashTableSize)
{
for (int i = 0; i < keyCount; i++) {
int hash = getHashPosition(keyBlock, keyOffset + i, keyBlockHashCode, hashTableSize);
while (true) {
if (outputHashTable[hashTableOffset + hash] == -1) {
outputHashTable[hashTableOffset + hash] = i;
break;
}
hash++;
if (hash == hashTableSize) {
hash = 0;
}
}
}
} | java | static void buildHashTable(Block keyBlock, int keyOffset, int keyCount, MethodHandle keyBlockHashCode, int[] outputHashTable, int hashTableOffset, int hashTableSize)
{
for (int i = 0; i < keyCount; i++) {
int hash = getHashPosition(keyBlock, keyOffset + i, keyBlockHashCode, hashTableSize);
while (true) {
if (outputHashTable[hashTableOffset + hash] == -1) {
outputHashTable[hashTableOffset + hash] = i;
break;
}
hash++;
if (hash == hashTableSize) {
hash = 0;
}
}
}
} | [
"static",
"void",
"buildHashTable",
"(",
"Block",
"keyBlock",
",",
"int",
"keyOffset",
",",
"int",
"keyCount",
",",
"MethodHandle",
"keyBlockHashCode",
",",
"int",
"[",
"]",
"outputHashTable",
",",
"int",
"hashTableOffset",
",",
"int",
"hashTableSize",
")",
"{",... | This method assumes that {@code keyBlock} has no duplicated entries (in the specified range) | [
"This",
"method",
"assumes",
"that",
"{"
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-spi/src/main/java/com/facebook/presto/spi/block/MapBlockBuilder.java#L466-L481 |
docusign/docusign-java-client | src/main/java/com/docusign/esign/api/EnvelopesApi.java | EnvelopesApi.listStatus | public EnvelopesInformation listStatus(String accountId, EnvelopeIdsRequest envelopeIdsRequest, EnvelopesApi.ListStatusOptions options) throws ApiException {
Object localVarPostBody = envelopeIdsRequest;
// verify the required parameter 'accountId' is set
if (accountId == null) {
throw new ApiException(400, "Missing the required parameter 'accountId' when calling listStatus");
}
// create path and map variables
String localVarPath = "/v2/accounts/{accountId}/envelopes/status".replaceAll("\\{format\\}","json")
.replaceAll("\\{" + "accountId" + "\\}", apiClient.escapeString(accountId.toString()));
// query params
java.util.List<Pair> localVarQueryParams = new java.util.ArrayList<Pair>();
java.util.Map<String, String> localVarHeaderParams = new java.util.HashMap<String, String>();
java.util.Map<String, Object> localVarFormParams = new java.util.HashMap<String, Object>();
if (options != null) {
localVarQueryParams.addAll(apiClient.parameterToPairs("", "ac_status", options.acStatus));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "block", options.block));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", options.count));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "email", options.email));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "envelope_ids", options.envelopeIds));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "from_date", options.fromDate));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "from_to_status", options.fromToStatus));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "start_position", options.startPosition));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", options.status));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "to_date", options.toDate));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "transaction_ids", options.transactionIds));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "user_name", options.userName));
}
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "docusignAccessCode" }; //{ };
GenericType<EnvelopesInformation> localVarReturnType = new GenericType<EnvelopesInformation>() {};
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} | java | public EnvelopesInformation listStatus(String accountId, EnvelopeIdsRequest envelopeIdsRequest, EnvelopesApi.ListStatusOptions options) throws ApiException {
Object localVarPostBody = envelopeIdsRequest;
// verify the required parameter 'accountId' is set
if (accountId == null) {
throw new ApiException(400, "Missing the required parameter 'accountId' when calling listStatus");
}
// create path and map variables
String localVarPath = "/v2/accounts/{accountId}/envelopes/status".replaceAll("\\{format\\}","json")
.replaceAll("\\{" + "accountId" + "\\}", apiClient.escapeString(accountId.toString()));
// query params
java.util.List<Pair> localVarQueryParams = new java.util.ArrayList<Pair>();
java.util.Map<String, String> localVarHeaderParams = new java.util.HashMap<String, String>();
java.util.Map<String, Object> localVarFormParams = new java.util.HashMap<String, Object>();
if (options != null) {
localVarQueryParams.addAll(apiClient.parameterToPairs("", "ac_status", options.acStatus));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "block", options.block));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", options.count));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "email", options.email));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "envelope_ids", options.envelopeIds));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "from_date", options.fromDate));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "from_to_status", options.fromToStatus));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "start_position", options.startPosition));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", options.status));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "to_date", options.toDate));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "transaction_ids", options.transactionIds));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "user_name", options.userName));
}
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "docusignAccessCode" }; //{ };
GenericType<EnvelopesInformation> localVarReturnType = new GenericType<EnvelopesInformation>() {};
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} | [
"public",
"EnvelopesInformation",
"listStatus",
"(",
"String",
"accountId",
",",
"EnvelopeIdsRequest",
"envelopeIdsRequest",
",",
"EnvelopesApi",
".",
"ListStatusOptions",
"options",
")",
"throws",
"ApiException",
"{",
"Object",
"localVarPostBody",
"=",
"envelopeIdsRequest"... | Gets the envelope status for the specified envelopes.
Retrieves the envelope status for the specified envelopes.
@param accountId The external account number (int) or account ID Guid. (required)
@param envelopeIdsRequest (optional)
@param options for modifying the method behavior.
@return EnvelopesInformation
@throws ApiException if fails to make API call | [
"Gets",
"the",
"envelope",
"status",
"for",
"the",
"specified",
"envelopes",
".",
"Retrieves",
"the",
"envelope",
"status",
"for",
"the",
"specified",
"envelopes",
"."
] | train | https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/EnvelopesApi.java#L3953-L4000 |
opencb/biodata | biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/coverage/CoverageSQLiteUtils.java | CoverageSQLiteUtils.calculateCoverate | public static void calculateCoverate(Path bamPath, Path sqlPath) throws IOException, AlignmentCoverageException {
BamManager bamManager = new BamManager(bamPath);
// Check if the bam index (.bai) does not exit, then create it
if (!bamPath.getParent().resolve(bamPath.getFileName().toString() + ".bai").toFile().exists()) {
bamManager.createIndex();
}
// Calculate coverage and store in SQLite
SAMFileHeader fileHeader = BamUtils.getFileHeader(bamPath);
// long start = System.currentTimeMillis();
initDatabase(fileHeader.getSequenceDictionary().getSequences(), sqlPath);
// System.out.println("SQLite database initialization, in " + ((System.currentTimeMillis() - start) / 1000.0f)
// + " s.");
Path coveragePath = sqlPath.toAbsolutePath().resolve(bamPath.getFileName() + COVERAGE_SUFFIX);
AlignmentOptions options = new AlignmentOptions();
options.setContained(false);
Iterator<SAMSequenceRecord> iterator = fileHeader.getSequenceDictionary().getSequences().iterator();
PrintWriter writer = new PrintWriter(coveragePath.toFile());
StringBuilder line;
// start = System.currentTimeMillis();
while (iterator.hasNext()) {
SAMSequenceRecord next = iterator.next();
for (int i = 0; i < next.getSequenceLength(); i += MINOR_CHUNK_SIZE) {
Region region = new Region(next.getSequenceName(), i + 1,
Math.min(i + MINOR_CHUNK_SIZE, next.getSequenceLength()));
RegionCoverage regionCoverage = bamManager.coverage(region, null, options);
int meanDepth = Math.min(regionCoverage.meanCoverage(), 255);
// File columns: chunk chromosome start end coverage
// chunk format: chrom_id_suffix, where:
// id: int value starting at 0
// suffix: chunkSize + k
// eg. 3_4_1k
line = new StringBuilder();
line.append(region.getChromosome()).append("_");
line.append(i / MINOR_CHUNK_SIZE).append("_").append(MINOR_CHUNK_SIZE / 1000).append("k");
line.append("\t").append(region.getChromosome());
line.append("\t").append(region.getStart());
line.append("\t").append(region.getEnd());
line.append("\t").append(meanDepth);
writer.println(line.toString());
}
}
writer.close();
// System.out.println("Mean coverage file creation, in " + ((System.currentTimeMillis() - start) / 1000.0f) + " s.");
// save file to db
// start = System.currentTimeMillis();
insertCoverageDB(bamPath, sqlPath);
// System.out.println("SQLite database population, in " + ((System.currentTimeMillis() - start) / 1000.0f) + " s.");
} | java | public static void calculateCoverate(Path bamPath, Path sqlPath) throws IOException, AlignmentCoverageException {
BamManager bamManager = new BamManager(bamPath);
// Check if the bam index (.bai) does not exit, then create it
if (!bamPath.getParent().resolve(bamPath.getFileName().toString() + ".bai").toFile().exists()) {
bamManager.createIndex();
}
// Calculate coverage and store in SQLite
SAMFileHeader fileHeader = BamUtils.getFileHeader(bamPath);
// long start = System.currentTimeMillis();
initDatabase(fileHeader.getSequenceDictionary().getSequences(), sqlPath);
// System.out.println("SQLite database initialization, in " + ((System.currentTimeMillis() - start) / 1000.0f)
// + " s.");
Path coveragePath = sqlPath.toAbsolutePath().resolve(bamPath.getFileName() + COVERAGE_SUFFIX);
AlignmentOptions options = new AlignmentOptions();
options.setContained(false);
Iterator<SAMSequenceRecord> iterator = fileHeader.getSequenceDictionary().getSequences().iterator();
PrintWriter writer = new PrintWriter(coveragePath.toFile());
StringBuilder line;
// start = System.currentTimeMillis();
while (iterator.hasNext()) {
SAMSequenceRecord next = iterator.next();
for (int i = 0; i < next.getSequenceLength(); i += MINOR_CHUNK_SIZE) {
Region region = new Region(next.getSequenceName(), i + 1,
Math.min(i + MINOR_CHUNK_SIZE, next.getSequenceLength()));
RegionCoverage regionCoverage = bamManager.coverage(region, null, options);
int meanDepth = Math.min(regionCoverage.meanCoverage(), 255);
// File columns: chunk chromosome start end coverage
// chunk format: chrom_id_suffix, where:
// id: int value starting at 0
// suffix: chunkSize + k
// eg. 3_4_1k
line = new StringBuilder();
line.append(region.getChromosome()).append("_");
line.append(i / MINOR_CHUNK_SIZE).append("_").append(MINOR_CHUNK_SIZE / 1000).append("k");
line.append("\t").append(region.getChromosome());
line.append("\t").append(region.getStart());
line.append("\t").append(region.getEnd());
line.append("\t").append(meanDepth);
writer.println(line.toString());
}
}
writer.close();
// System.out.println("Mean coverage file creation, in " + ((System.currentTimeMillis() - start) / 1000.0f) + " s.");
// save file to db
// start = System.currentTimeMillis();
insertCoverageDB(bamPath, sqlPath);
// System.out.println("SQLite database population, in " + ((System.currentTimeMillis() - start) / 1000.0f) + " s.");
} | [
"public",
"static",
"void",
"calculateCoverate",
"(",
"Path",
"bamPath",
",",
"Path",
"sqlPath",
")",
"throws",
"IOException",
",",
"AlignmentCoverageException",
"{",
"BamManager",
"bamManager",
"=",
"new",
"BamManager",
"(",
"bamPath",
")",
";",
"// Check if the ba... | Calculate the coverage for the input BAM file. The coverage is stored in a SQLite database
located in the sqlPath output directory.
@param bamPath BAM file
@param sqlPath Output dir where to store the SQLite database
@throws IOException IO exception | [
"Calculate",
"the",
"coverage",
"for",
"the",
"input",
"BAM",
"file",
".",
"The",
"coverage",
"is",
"stored",
"in",
"a",
"SQLite",
"database",
"located",
"in",
"the",
"sqlPath",
"output",
"directory",
"."
] | train | https://github.com/opencb/biodata/blob/21b3d51d71f578efab908422aca4bab7a73097b1/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/coverage/CoverageSQLiteUtils.java#L36-L92 |
tacitknowledge/discovery | src/main/java/com/tacitknowledge/util/discovery/ClasspathUtils.java | ClasspathUtils.getClasspathComponents | public static List getClasspathComponents()
{
List components = new LinkedList();
// walk the classloader hierarchy, trying to get all the components we can
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while ((null != cl) && (cl instanceof URLClassLoader))
{
URLClassLoader ucl = (URLClassLoader) cl;
components.addAll(getUrlClassLoaderClasspathComponents(ucl));
try
{
cl = ucl.getParent();
}
catch (SecurityException se)
{
cl = null;
}
}
// walking the hierarchy doesn't guarantee we get everything, so
// lets grab the system classpath for good measure.
String classpath = System.getProperty("java.class.path");
String separator = System.getProperty("path.separator");
StringTokenizer st = new StringTokenizer(classpath, separator);
while (st.hasMoreTokens())
{
String component = st.nextToken();
// Calling File.getPath() cleans up the path so that it's using
// the proper path separators for the host OS
component = getCanonicalPath(component);
components.add(component);
}
// Set removes any duplicates, return a list for the api.
return new LinkedList(new HashSet(components));
} | java | public static List getClasspathComponents()
{
List components = new LinkedList();
// walk the classloader hierarchy, trying to get all the components we can
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while ((null != cl) && (cl instanceof URLClassLoader))
{
URLClassLoader ucl = (URLClassLoader) cl;
components.addAll(getUrlClassLoaderClasspathComponents(ucl));
try
{
cl = ucl.getParent();
}
catch (SecurityException se)
{
cl = null;
}
}
// walking the hierarchy doesn't guarantee we get everything, so
// lets grab the system classpath for good measure.
String classpath = System.getProperty("java.class.path");
String separator = System.getProperty("path.separator");
StringTokenizer st = new StringTokenizer(classpath, separator);
while (st.hasMoreTokens())
{
String component = st.nextToken();
// Calling File.getPath() cleans up the path so that it's using
// the proper path separators for the host OS
component = getCanonicalPath(component);
components.add(component);
}
// Set removes any duplicates, return a list for the api.
return new LinkedList(new HashSet(components));
} | [
"public",
"static",
"List",
"getClasspathComponents",
"(",
")",
"{",
"List",
"components",
"=",
"new",
"LinkedList",
"(",
")",
";",
"// walk the classloader hierarchy, trying to get all the components we can",
"ClassLoader",
"cl",
"=",
"Thread",
".",
"currentThread",
"(",... | Returns the classpath as a list directory and archive names.
@return the classpath as a list of directory and archive file names; if
no components can be found then an empty list will be returned | [
"Returns",
"the",
"classpath",
"as",
"a",
"list",
"directory",
"and",
"archive",
"names",
"."
] | train | https://github.com/tacitknowledge/discovery/blob/700f5492c9cb5c0146d684acb38b71fd4ef4e97a/src/main/java/com/tacitknowledge/util/discovery/ClasspathUtils.java#L108-L146 |
apereo/cas | support/cas-server-support-pac4j-webflow/src/main/java/org/apereo/cas/web/flow/DelegatedClientAuthenticationAction.java | DelegatedClientAuthenticationAction.prepareForLoginPage | protected void prepareForLoginPage(final RequestContext context) {
val currentService = WebUtils.getService(context);
val service = authenticationRequestServiceSelectionStrategies.resolveService(currentService, WebApplicationService.class);
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);
val webContext = new J2EContext(request, response, this.sessionStore);
val urls = new LinkedHashSet<ProviderLoginPageConfiguration>();
this.clients
.findAllClients()
.stream()
.filter(client -> client instanceof IndirectClient && isDelegatedClientAuthorizedForService(client, service))
.map(IndirectClient.class::cast)
.forEach(client -> {
try {
val provider = buildProviderConfiguration(client, webContext, currentService);
provider.ifPresent(p -> {
urls.add(p);
if (p.isAutoRedirect()) {
WebUtils.putDelegatedAuthenticationProviderPrimary(context, p);
}
});
} catch (final Exception e) {
LOGGER.error("Cannot process client [{}]", client, e);
}
});
if (!urls.isEmpty()) {
context.getFlowScope().put(FLOW_ATTRIBUTE_PROVIDER_URLS, urls);
} else if (response.getStatus() != HttpStatus.UNAUTHORIZED.value()) {
LOGGER.warn("No delegated authentication providers could be determined based on the provided configuration. "
+ "Either no clients are configured, or the current access strategy rules prohibit CAS from using authentication providers for this request.");
}
} | java | protected void prepareForLoginPage(final RequestContext context) {
val currentService = WebUtils.getService(context);
val service = authenticationRequestServiceSelectionStrategies.resolveService(currentService, WebApplicationService.class);
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);
val webContext = new J2EContext(request, response, this.sessionStore);
val urls = new LinkedHashSet<ProviderLoginPageConfiguration>();
this.clients
.findAllClients()
.stream()
.filter(client -> client instanceof IndirectClient && isDelegatedClientAuthorizedForService(client, service))
.map(IndirectClient.class::cast)
.forEach(client -> {
try {
val provider = buildProviderConfiguration(client, webContext, currentService);
provider.ifPresent(p -> {
urls.add(p);
if (p.isAutoRedirect()) {
WebUtils.putDelegatedAuthenticationProviderPrimary(context, p);
}
});
} catch (final Exception e) {
LOGGER.error("Cannot process client [{}]", client, e);
}
});
if (!urls.isEmpty()) {
context.getFlowScope().put(FLOW_ATTRIBUTE_PROVIDER_URLS, urls);
} else if (response.getStatus() != HttpStatus.UNAUTHORIZED.value()) {
LOGGER.warn("No delegated authentication providers could be determined based on the provided configuration. "
+ "Either no clients are configured, or the current access strategy rules prohibit CAS from using authentication providers for this request.");
}
} | [
"protected",
"void",
"prepareForLoginPage",
"(",
"final",
"RequestContext",
"context",
")",
"{",
"val",
"currentService",
"=",
"WebUtils",
".",
"getService",
"(",
"context",
")",
";",
"val",
"service",
"=",
"authenticationRequestServiceSelectionStrategies",
".",
"reso... | Prepare the data for the login page.
@param context The current webflow context | [
"Prepare",
"the",
"data",
"for",
"the",
"login",
"page",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-pac4j-webflow/src/main/java/org/apereo/cas/web/flow/DelegatedClientAuthenticationAction.java#L304-L338 |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/process/ProcessEngineDriver.java | ProcessEngineDriver.getPackageHandler | private Process getPackageHandler(ProcessInstance masterInstance, Integer eventType) {
Process process = getProcessDefinition(masterInstance);
Process handler = getPackageHandler(process.getPackageName(), eventType);
if (handler != null && handler.getName().equals(process.getName())) {
logger.warn("Package handler recursion is not allowed. "
+ "Define an embedded handler in package handler: " + handler.getLabel());
}
return handler;
} | java | private Process getPackageHandler(ProcessInstance masterInstance, Integer eventType) {
Process process = getProcessDefinition(masterInstance);
Process handler = getPackageHandler(process.getPackageName(), eventType);
if (handler != null && handler.getName().equals(process.getName())) {
logger.warn("Package handler recursion is not allowed. "
+ "Define an embedded handler in package handler: " + handler.getLabel());
}
return handler;
} | [
"private",
"Process",
"getPackageHandler",
"(",
"ProcessInstance",
"masterInstance",
",",
"Integer",
"eventType",
")",
"{",
"Process",
"process",
"=",
"getProcessDefinition",
"(",
"masterInstance",
")",
";",
"Process",
"handler",
"=",
"getPackageHandler",
"(",
"proces... | Finds the relevant package handler for a master process instance. | [
"Finds",
"the",
"relevant",
"package",
"handler",
"for",
"a",
"master",
"process",
"instance",
"."
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/process/ProcessEngineDriver.java#L233-L241 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.eachLine | public static <T> T eachLine(URL url, @ClosureParams(value = FromString.class, options = {"String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(url, 1, closure);
} | java | public static <T> T eachLine(URL url, @ClosureParams(value = FromString.class, options = {"String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(url, 1, closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"eachLine",
"(",
"URL",
"url",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FromString",
".",
"class",
",",
"options",
"=",
"{",
"\"String\"",
",",
"\"String,Integer\"",
"}",
")",
"Closure",
"<",
"T",
">",
"clo... | Iterates through the lines read from the URL's associated input stream passing each
line to the given 1 or 2 arg closure. The stream is closed before this method returns.
@param url a URL to open and read
@param closure a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1)
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@see #eachLine(java.net.URL, int, groovy.lang.Closure)
@since 1.5.6 | [
"Iterates",
"through",
"the",
"lines",
"read",
"from",
"the",
"URL",
"s",
"associated",
"input",
"stream",
"passing",
"each",
"line",
"to",
"the",
"given",
"1",
"or",
"2",
"arg",
"closure",
".",
"The",
"stream",
"is",
"closed",
"before",
"this",
"method",
... | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L302-L304 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/utils/SchedulerUtils.java | SchedulerUtils.createTrigger | public static Trigger createTrigger(String identity, String groupName, String description, String cron) {
Objects.requireNonNull(identity, Required.IDENTITY.toString());
Objects.requireNonNull(groupName, Required.GROUP_NAME.toString());
Objects.requireNonNull(cron, Required.CRON.toString());
Preconditions.checkArgument(CronExpression.isValidExpression(cron), "cron expression is invalid");
return newTrigger()
.withIdentity(identity, groupName)
.withSchedule(cronSchedule(cron))
.withDescription(description)
.build();
} | java | public static Trigger createTrigger(String identity, String groupName, String description, String cron) {
Objects.requireNonNull(identity, Required.IDENTITY.toString());
Objects.requireNonNull(groupName, Required.GROUP_NAME.toString());
Objects.requireNonNull(cron, Required.CRON.toString());
Preconditions.checkArgument(CronExpression.isValidExpression(cron), "cron expression is invalid");
return newTrigger()
.withIdentity(identity, groupName)
.withSchedule(cronSchedule(cron))
.withDescription(description)
.build();
} | [
"public",
"static",
"Trigger",
"createTrigger",
"(",
"String",
"identity",
",",
"String",
"groupName",
",",
"String",
"description",
",",
"String",
"cron",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"identity",
",",
"Required",
".",
"IDENTITY",
".",
"toS... | Creates a new quartz scheduler Trigger, which can be used to
schedule a new job by passing it into {@link io.mangoo.scheduler.Scheduler#schedule(JobDetail, Trigger) schedule}
@param identity The name of the trigger
@param groupName The trigger group name
@param description The trigger description
@param cron The cron expression for the trigger
@return A new Trigger object | [
"Creates",
"a",
"new",
"quartz",
"scheduler",
"Trigger",
"which",
"can",
"be",
"used",
"to",
"schedule",
"a",
"new",
"job",
"by",
"passing",
"it",
"into",
"{",
"@link",
"io",
".",
"mangoo",
".",
"scheduler",
".",
"Scheduler#schedule",
"(",
"JobDetail",
"Tr... | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/utils/SchedulerUtils.java#L39-L50 |
kohsuke/jcifs | src/jcifs/smb/SmbFile.java | SmbFile.renameTo | public void renameTo( SmbFile dest ) throws SmbException {
if( getUncPath0().length() == 1 || dest.getUncPath0().length() == 1 ) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
resolveDfs(null);
dest.resolveDfs(null);
if (!tree.equals(dest.tree)) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
if( log.level >= 3 )
log.println( "renameTo: " + unc + " -> " + dest.unc );
attrExpiration = sizeExpiration = 0;
dest.attrExpiration = 0;
/*
* Rename Request / Response
*/
send( new SmbComRename( unc, dest.unc ), blank_resp() );
} | java | public void renameTo( SmbFile dest ) throws SmbException {
if( getUncPath0().length() == 1 || dest.getUncPath0().length() == 1 ) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
resolveDfs(null);
dest.resolveDfs(null);
if (!tree.equals(dest.tree)) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
if( log.level >= 3 )
log.println( "renameTo: " + unc + " -> " + dest.unc );
attrExpiration = sizeExpiration = 0;
dest.attrExpiration = 0;
/*
* Rename Request / Response
*/
send( new SmbComRename( unc, dest.unc ), blank_resp() );
} | [
"public",
"void",
"renameTo",
"(",
"SmbFile",
"dest",
")",
"throws",
"SmbException",
"{",
"if",
"(",
"getUncPath0",
"(",
")",
".",
"length",
"(",
")",
"==",
"1",
"||",
"dest",
".",
"getUncPath0",
"(",
")",
".",
"length",
"(",
")",
"==",
"1",
")",
"... | Changes the name of the file this <code>SmbFile</code> represents to the name
designated by the <code>SmbFile</code> argument.
<p/>
<i>Remember: <code>SmbFile</code>s are immutible and therefore
the path associated with this <code>SmbFile</code> object will not
change). To access the renamed file it is necessary to construct a
new <tt>SmbFile</tt></i>.
@param dest An <code>SmbFile</code> that represents the new pathname
@throws NullPointerException
If the <code>dest</code> argument is <code>null</code> | [
"Changes",
"the",
"name",
"of",
"the",
"file",
"this",
"<code",
">",
"SmbFile<",
"/",
"code",
">",
"represents",
"to",
"the",
"name",
"designated",
"by",
"the",
"<code",
">",
"SmbFile<",
"/",
"code",
">",
"argument",
".",
"<p",
"/",
">",
"<i",
">",
"... | train | https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/smb/SmbFile.java#L2057-L2080 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromGML.java | ST_GeomFromGML.toGeometry | public static Geometry toGeometry(String gmlFile, int srid) throws SAXException, IOException, ParserConfigurationException {
if (gmlFile == null) {
return null;
}
if (gf == null) {
gf = new GeometryFactory(new PrecisionModel(), srid);
}
GMLReader gMLReader = new GMLReader();
return gMLReader.read(gmlFile, gf);
} | java | public static Geometry toGeometry(String gmlFile, int srid) throws SAXException, IOException, ParserConfigurationException {
if (gmlFile == null) {
return null;
}
if (gf == null) {
gf = new GeometryFactory(new PrecisionModel(), srid);
}
GMLReader gMLReader = new GMLReader();
return gMLReader.read(gmlFile, gf);
} | [
"public",
"static",
"Geometry",
"toGeometry",
"(",
"String",
"gmlFile",
",",
"int",
"srid",
")",
"throws",
"SAXException",
",",
"IOException",
",",
"ParserConfigurationException",
"{",
"if",
"(",
"gmlFile",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
... | Read the GML representation with a specified SRID
@param gmlFile
@param srid
@return
@throws org.xml.sax.SAXException
@throws java.io.IOException
@throws javax.xml.parsers.ParserConfigurationException | [
"Read",
"the",
"GML",
"representation",
"with",
"a",
"specified",
"SRID"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromGML.java#L74-L83 |
lagom/lagom | service/javadsl/api/src/main/java/com/lightbend/lagom/javadsl/api/transport/MessageProtocol.java | MessageProtocol.withVersion | public MessageProtocol withVersion(String version) {
return new MessageProtocol(contentType, charset, Optional.ofNullable(version));
} | java | public MessageProtocol withVersion(String version) {
return new MessageProtocol(contentType, charset, Optional.ofNullable(version));
} | [
"public",
"MessageProtocol",
"withVersion",
"(",
"String",
"version",
")",
"{",
"return",
"new",
"MessageProtocol",
"(",
"contentType",
",",
"charset",
",",
"Optional",
".",
"ofNullable",
"(",
"version",
")",
")",
";",
"}"
] | Return a copy of this message protocol with the version set to the given version.
@param version The version to set.
@return A copy of this message protocol. | [
"Return",
"a",
"copy",
"of",
"this",
"message",
"protocol",
"with",
"the",
"version",
"set",
"to",
"the",
"given",
"version",
"."
] | train | https://github.com/lagom/lagom/blob/3763055a9d1aace793a5d970f4e688aea61b1a5a/service/javadsl/api/src/main/java/com/lightbend/lagom/javadsl/api/transport/MessageProtocol.java#L119-L121 |
baasbox/Android-SDK | library/src/main/java/com/baasbox/android/BaasDocument.java | BaasDocument.put | public BaasDocument put(String name, JsonArray value) {
data.put(checkKey(name), value);
return this;
} | java | public BaasDocument put(String name, JsonArray value) {
data.put(checkKey(name), value);
return this;
} | [
"public",
"BaasDocument",
"put",
"(",
"String",
"name",
",",
"JsonArray",
"value",
")",
"{",
"data",
".",
"put",
"(",
"checkKey",
"(",
"name",
")",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Associate <code>name</code> key to the {@link com.baasbox.android.json.JsonArray} <code>value</code>
in this document.
@param name a non <code>null</code> key
@param value a {@link com.baasbox.android.json.JsonArray}
@return this document with the new mapping created | [
"Associate",
"<code",
">",
"name<",
"/",
"code",
">",
"key",
"to",
"the",
"{",
"@link",
"com",
".",
"baasbox",
".",
"android",
".",
"json",
".",
"JsonArray",
"}",
"<code",
">",
"value<",
"/",
"code",
">",
"in",
"this",
"document",
"."
] | train | https://github.com/baasbox/Android-SDK/blob/6bb2203246b885b2ad63a7bfaf37c83caf15e0d8/library/src/main/java/com/baasbox/android/BaasDocument.java#L1061-L1064 |
ReactiveX/RxJavaComputationExpressions | src/main/java/rx/Statement.java | Statement.switchCase | public static <K, R> Observable<R> switchCase(Func0<? extends K> caseSelector,
Map<? super K, ? extends Observable<? extends R>> mapOfCases, Scheduler scheduler) {
return switchCase(caseSelector, mapOfCases, Observable.<R> empty().subscribeOn(scheduler));
} | java | public static <K, R> Observable<R> switchCase(Func0<? extends K> caseSelector,
Map<? super K, ? extends Observable<? extends R>> mapOfCases, Scheduler scheduler) {
return switchCase(caseSelector, mapOfCases, Observable.<R> empty().subscribeOn(scheduler));
} | [
"public",
"static",
"<",
"K",
",",
"R",
">",
"Observable",
"<",
"R",
">",
"switchCase",
"(",
"Func0",
"<",
"?",
"extends",
"K",
">",
"caseSelector",
",",
"Map",
"<",
"?",
"super",
"K",
",",
"?",
"extends",
"Observable",
"<",
"?",
"extends",
"R",
">... | Return a particular one of several possible Observables based on a case
selector and run it on the designated scheduler.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/switchCase.s.png" alt="">
@param <K>
the case key type
@param <R>
the result value type
@param caseSelector
the function that produces a case key when an
Observer subscribes
@param mapOfCases
a map that maps a case key to an Observable
@param scheduler
the scheduler where the empty observable is observed
@return a particular Observable chosen by key from the map of
Observables, or an empty Observable if no Observable matches the
key, but one that runs on the designated scheduler in either case | [
"Return",
"a",
"particular",
"one",
"of",
"several",
"possible",
"Observables",
"based",
"on",
"a",
"case",
"selector",
"and",
"run",
"it",
"on",
"the",
"designated",
"scheduler",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"src",
"=",
"https",
":",
"//... | train | https://github.com/ReactiveX/RxJavaComputationExpressions/blob/f9d04ab762223b36fad47402ac36ce7969320d69/src/main/java/rx/Statement.java#L75-L78 |
jhg023/SimpleNet | src/main/java/simplenet/Server.java | Server.writeAndFlushToAllExcept | @SafeVarargs
public final <T extends Client> void writeAndFlushToAllExcept(Packet packet, T... clients) {
writeHelper(packet::writeAndFlush, clients);
} | java | @SafeVarargs
public final <T extends Client> void writeAndFlushToAllExcept(Packet packet, T... clients) {
writeHelper(packet::writeAndFlush, clients);
} | [
"@",
"SafeVarargs",
"public",
"final",
"<",
"T",
"extends",
"Client",
">",
"void",
"writeAndFlushToAllExcept",
"(",
"Packet",
"packet",
",",
"T",
"...",
"clients",
")",
"{",
"writeHelper",
"(",
"packet",
"::",
"writeAndFlush",
",",
"clients",
")",
";",
"}"
] | Queues a {@link Packet} to a one or more {@link Client}s and calls {@link Client#flush()}, flushing all
previously-queued packets as well.
@param <T> A {@link Client} or any of its children.
@param clients A variable amount of {@link Client}s to exclude from receiving the {@link Packet}. | [
"Queues",
"a",
"{",
"@link",
"Packet",
"}",
"to",
"a",
"one",
"or",
"more",
"{",
"@link",
"Client",
"}",
"s",
"and",
"calls",
"{",
"@link",
"Client#flush",
"()",
"}",
"flushing",
"all",
"previously",
"-",
"queued",
"packets",
"as",
"well",
"."
] | train | https://github.com/jhg023/SimpleNet/blob/a5b55cbfe1768c6a28874f12adac3c748f2b509a/src/main/java/simplenet/Server.java#L283-L286 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/PerspectiveOps.java | PerspectiveOps.projectionSplit | public static void projectionSplit( DMatrixRMaj P , DMatrix3x3 M , DMatrix3 T ) {
M.a11 = P.data[0]; M.a12 = P.data[1]; M.a13 = P.data[2 ]; T.a1 = P.data[3 ];
M.a21 = P.data[4]; M.a22 = P.data[5]; M.a23 = P.data[6 ]; T.a2 = P.data[7 ];
M.a31 = P.data[8]; M.a32 = P.data[9]; M.a33 = P.data[10]; T.a3 = P.data[11];
} | java | public static void projectionSplit( DMatrixRMaj P , DMatrix3x3 M , DMatrix3 T ) {
M.a11 = P.data[0]; M.a12 = P.data[1]; M.a13 = P.data[2 ]; T.a1 = P.data[3 ];
M.a21 = P.data[4]; M.a22 = P.data[5]; M.a23 = P.data[6 ]; T.a2 = P.data[7 ];
M.a31 = P.data[8]; M.a32 = P.data[9]; M.a33 = P.data[10]; T.a3 = P.data[11];
} | [
"public",
"static",
"void",
"projectionSplit",
"(",
"DMatrixRMaj",
"P",
",",
"DMatrix3x3",
"M",
",",
"DMatrix3",
"T",
")",
"{",
"M",
".",
"a11",
"=",
"P",
".",
"data",
"[",
"0",
"]",
";",
"M",
".",
"a12",
"=",
"P",
".",
"data",
"[",
"1",
"]",
"... | Splits the projection matrix into a 3x3 matrix and 3x1 vector.
@param P (Input) 3x4 projection matirx
@param M (Output) M = P(:,0:2)
@param T (Output) T = P(:,3) | [
"Splits",
"the",
"projection",
"matrix",
"into",
"a",
"3x3",
"matrix",
"and",
"3x1",
"vector",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/PerspectiveOps.java#L664-L668 |
opengeospatial/teamengine | teamengine-core/src/main/java/com/occamlab/te/util/SoapUtils.java | SoapUtils.addNSdeclarations | public static void addNSdeclarations(Element source, Element target)
throws Exception {
NamedNodeMap sourceAttributes = source.getAttributes();
Attr attribute;
String attributeName;
for (int i = 0; i <= sourceAttributes.getLength() - 1; i++) {
attribute = (Attr) sourceAttributes.item(i);
attributeName = attribute.getName();
if (attributeName.startsWith("xmlns")
&& !attributeName.startsWith("xmlns:soap-env")) {
// System.out.println("XMLNS:" +
// attributeName+":"+attribute.getValue());
target.setAttribute(attributeName, attribute.getValue());
}
}
} | java | public static void addNSdeclarations(Element source, Element target)
throws Exception {
NamedNodeMap sourceAttributes = source.getAttributes();
Attr attribute;
String attributeName;
for (int i = 0; i <= sourceAttributes.getLength() - 1; i++) {
attribute = (Attr) sourceAttributes.item(i);
attributeName = attribute.getName();
if (attributeName.startsWith("xmlns")
&& !attributeName.startsWith("xmlns:soap-env")) {
// System.out.println("XMLNS:" +
// attributeName+":"+attribute.getValue());
target.setAttribute(attributeName, attribute.getValue());
}
}
} | [
"public",
"static",
"void",
"addNSdeclarations",
"(",
"Element",
"source",
",",
"Element",
"target",
")",
"throws",
"Exception",
"{",
"NamedNodeMap",
"sourceAttributes",
"=",
"source",
".",
"getAttributes",
"(",
")",
";",
"Attr",
"attribute",
";",
"String",
"att... | A method to copy namespaces declarations.
@param source
the source message containing the namespaces to be copied on
the target message.
@param target
the target message.
@author Simone Gianfranceschi | [
"A",
"method",
"to",
"copy",
"namespaces",
"declarations",
"."
] | train | https://github.com/opengeospatial/teamengine/blob/b6b890214b6784bbe19460bf753bdf28a9514bee/teamengine-core/src/main/java/com/occamlab/te/util/SoapUtils.java#L110-L125 |
languagetool-org/languagetool | languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java | AvsAnRule.suggestAorAn | public String suggestAorAn(String origWord) {
AnalyzedTokenReadings token = new AnalyzedTokenReadings(new AnalyzedToken(origWord, null, null), 0);
Determiner determiner = getCorrectDeterminerFor(token);
if (determiner == Determiner.A || determiner == Determiner.A_OR_AN) {
return "a " + origWord;
} else if (determiner == Determiner.AN) {
return "an " + origWord;
} else {
return origWord;
}
} | java | public String suggestAorAn(String origWord) {
AnalyzedTokenReadings token = new AnalyzedTokenReadings(new AnalyzedToken(origWord, null, null), 0);
Determiner determiner = getCorrectDeterminerFor(token);
if (determiner == Determiner.A || determiner == Determiner.A_OR_AN) {
return "a " + origWord;
} else if (determiner == Determiner.AN) {
return "an " + origWord;
} else {
return origWord;
}
} | [
"public",
"String",
"suggestAorAn",
"(",
"String",
"origWord",
")",
"{",
"AnalyzedTokenReadings",
"token",
"=",
"new",
"AnalyzedTokenReadings",
"(",
"new",
"AnalyzedToken",
"(",
"origWord",
",",
"null",
",",
"null",
")",
",",
"0",
")",
";",
"Determiner",
"dete... | Adds "a" or "an" to the English noun. Used for suggesting the proper form of the indefinite article.
For the rare cases where both "a" and "an" are considered okay (e.g. for "historical"), "a" is returned.
@param origWord Word that needs an article.
@return String containing the word with a determiner, or just the word if the word is an abbreviation. | [
"Adds",
"a",
"or",
"an",
"to",
"the",
"English",
"noun",
".",
"Used",
"for",
"suggesting",
"the",
"proper",
"form",
"of",
"the",
"indefinite",
"article",
".",
"For",
"the",
"rare",
"cases",
"where",
"both",
"a",
"and",
"an",
"are",
"considered",
"okay",
... | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnRule.java#L133-L143 |
cybazeitalia/emaze-dysfunctional | src/main/java/net/emaze/dysfunctional/Spies.java | Spies.spy2nd | public static <T1, T2, T3, R> TriFunction<T1, T2, T3, R> spy2nd(TriFunction<T1, T2, T3, R> function, Box<T2> param2) {
return spy(function, Box.<R>empty(), Box.<T1>empty(), param2, Box.<T3>empty());
} | java | public static <T1, T2, T3, R> TriFunction<T1, T2, T3, R> spy2nd(TriFunction<T1, T2, T3, R> function, Box<T2> param2) {
return spy(function, Box.<R>empty(), Box.<T1>empty(), param2, Box.<T3>empty());
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"R",
">",
"TriFunction",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"R",
">",
"spy2nd",
"(",
"TriFunction",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"R",
">",
"function",
",",
"Box",
"<",
"T2"... | Proxies a ternary function spying for second parameter
@param <R> the function result type
@param <T1> the function first parameter type
@param <T2> the function second parameter type
@param <T3> the function third parameter type
@param function the function that will be spied
@param param2 a box that will be containing the second spied parameter
@return the proxied function | [
"Proxies",
"a",
"ternary",
"function",
"spying",
"for",
"second",
"parameter"
] | train | https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/Spies.java#L224-L226 |
google/allocation-instrumenter | src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java | AllocationRecorder.getObjectSize | private static long getObjectSize(Object obj, boolean isArray, Instrumentation instr) {
if (isArray) {
return instr.getObjectSize(obj);
}
Class<?> clazz = obj.getClass();
Long classSize = classSizesMap.get(clazz);
if (classSize == null) {
classSize = instr.getObjectSize(obj);
classSizesMap.put(clazz, classSize);
}
return classSize;
} | java | private static long getObjectSize(Object obj, boolean isArray, Instrumentation instr) {
if (isArray) {
return instr.getObjectSize(obj);
}
Class<?> clazz = obj.getClass();
Long classSize = classSizesMap.get(clazz);
if (classSize == null) {
classSize = instr.getObjectSize(obj);
classSizesMap.put(clazz, classSize);
}
return classSize;
} | [
"private",
"static",
"long",
"getObjectSize",
"(",
"Object",
"obj",
",",
"boolean",
"isArray",
",",
"Instrumentation",
"instr",
")",
"{",
"if",
"(",
"isArray",
")",
"{",
"return",
"instr",
".",
"getObjectSize",
"(",
"obj",
")",
";",
"}",
"Class",
"<",
"?... | Returns the size of the given object. If the object is not an array, we check the cache first,
and update it as necessary.
@param obj the object.
@param isArray indicates if the given object is an array.
@param instr the instrumentation object to use for finding the object size
@return the size of the given object. | [
"Returns",
"the",
"size",
"of",
"the",
"given",
"object",
".",
"If",
"the",
"object",
"is",
"not",
"an",
"array",
"we",
"check",
"the",
"cache",
"first",
"and",
"update",
"it",
"as",
"necessary",
"."
] | train | https://github.com/google/allocation-instrumenter/blob/58d8473e8832e51f39ae7aa38328f61c4b747bff/src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java#L180-L193 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/Criteria.java | Criteria.addGreaterThanField | public void addGreaterThanField(String attribute, Object value)
{
// PAW
// addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));
addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getUserAlias(attribute)));
} | java | public void addGreaterThanField(String attribute, Object value)
{
// PAW
// addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));
addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getUserAlias(attribute)));
} | [
"public",
"void",
"addGreaterThanField",
"(",
"String",
"attribute",
",",
"Object",
"value",
")",
"{",
"// PAW\r",
"// addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));\r",
"addSelectionCriteria",
"(",
"FieldCriteria",
".",
"buildGreaterCriteri... | Adds Greater Than (>) criteria,
customer_id > person_id
@param attribute The field name to be used
@param value The field to compare with | [
"Adds",
"Greater",
"Than",
"(",
">",
")",
"criteria",
"customer_id",
">",
"person_id"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/Criteria.java#L521-L526 |
apache/incubator-gobblin | gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/data/management/trash/TrashCollectorJob.java | TrashCollectorJob.moveToTrash | public static boolean moveToTrash(FileSystem fs, Path path, Props props) throws IOException {
return TrashFactory.createTrash(fs, props.toProperties()).moveToTrash(path);
} | java | public static boolean moveToTrash(FileSystem fs, Path path, Props props) throws IOException {
return TrashFactory.createTrash(fs, props.toProperties()).moveToTrash(path);
} | [
"public",
"static",
"boolean",
"moveToTrash",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"Props",
"props",
")",
"throws",
"IOException",
"{",
"return",
"TrashFactory",
".",
"createTrash",
"(",
"fs",
",",
"props",
".",
"toProperties",
"(",
")",
")",
... | Move a path to trash. The absolute path of the input path will be replicated under the trash directory.
@param fs {@link org.apache.hadoop.fs.FileSystem} where path and trash exist.
@param path {@link org.apache.hadoop.fs.FileSystem} path to move to trash.
@param props {@link java.util.Properties} containing trash configuration.
@return true if move to trash was done successfully.
@throws IOException | [
"Move",
"a",
"path",
"to",
"trash",
".",
"The",
"absolute",
"path",
"of",
"the",
"input",
"path",
"will",
"be",
"replicated",
"under",
"the",
"trash",
"directory",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/data/management/trash/TrashCollectorJob.java#L67-L69 |
lucee/Lucee | core/src/main/java/lucee/runtime/net/mail/MailClient.java | MailClient.contains | private boolean contains(String ids[], String id) {
for (int i = 0; i < ids.length; i++) {
if (Operator.compare(ids[i], id) == 0) return true;
}
return false;
} | java | private boolean contains(String ids[], String id) {
for (int i = 0; i < ids.length; i++) {
if (Operator.compare(ids[i], id) == 0) return true;
}
return false;
} | [
"private",
"boolean",
"contains",
"(",
"String",
"ids",
"[",
"]",
",",
"String",
"id",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ids",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"Operator",
".",
"compare",
"(",
"ids",... | checks if a String Array (ids) has one element that is equal to id
@param ids
@param id
@return has element found or not | [
"checks",
"if",
"a",
"String",
"Array",
"(",
"ids",
")",
"has",
"one",
"element",
"that",
"is",
"equal",
"to",
"id"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/net/mail/MailClient.java#L645-L650 |
facebook/fresco | animated-base/src/main/java/com/facebook/imagepipeline/animated/impl/AnimatedImageCompositor.java | AnimatedImageCompositor.prepareCanvasWithClosestCachedFrame | private int prepareCanvasWithClosestCachedFrame(int previousFrameNumber, Canvas canvas) {
for (int index = previousFrameNumber; index >= 0; index--) {
FrameNeededResult neededResult = isFrameNeededForRendering(index);
switch (neededResult) {
case REQUIRED:
AnimatedDrawableFrameInfo frameInfo = mAnimatedDrawableBackend.getFrameInfo(index);
CloseableReference<Bitmap> startBitmap = mCallback.getCachedBitmap(index);
if (startBitmap != null) {
try {
canvas.drawBitmap(startBitmap.get(), 0, 0, null);
if (frameInfo.disposalMethod == DisposalMethod.DISPOSE_TO_BACKGROUND) {
disposeToBackground(canvas, frameInfo);
}
return index + 1;
} finally {
startBitmap.close();
}
} else {
if (isKeyFrame(index)) {
return index;
} else {
// Keep going.
break;
}
}
case NOT_REQUIRED:
return index + 1;
case ABORT:
return index;
case SKIP:
default:
// Keep going.
}
}
return 0;
} | java | private int prepareCanvasWithClosestCachedFrame(int previousFrameNumber, Canvas canvas) {
for (int index = previousFrameNumber; index >= 0; index--) {
FrameNeededResult neededResult = isFrameNeededForRendering(index);
switch (neededResult) {
case REQUIRED:
AnimatedDrawableFrameInfo frameInfo = mAnimatedDrawableBackend.getFrameInfo(index);
CloseableReference<Bitmap> startBitmap = mCallback.getCachedBitmap(index);
if (startBitmap != null) {
try {
canvas.drawBitmap(startBitmap.get(), 0, 0, null);
if (frameInfo.disposalMethod == DisposalMethod.DISPOSE_TO_BACKGROUND) {
disposeToBackground(canvas, frameInfo);
}
return index + 1;
} finally {
startBitmap.close();
}
} else {
if (isKeyFrame(index)) {
return index;
} else {
// Keep going.
break;
}
}
case NOT_REQUIRED:
return index + 1;
case ABORT:
return index;
case SKIP:
default:
// Keep going.
}
}
return 0;
} | [
"private",
"int",
"prepareCanvasWithClosestCachedFrame",
"(",
"int",
"previousFrameNumber",
",",
"Canvas",
"canvas",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"previousFrameNumber",
";",
"index",
">=",
"0",
";",
"index",
"--",
")",
"{",
"FrameNeededResult",
"ne... | Given a frame number, prepares the canvas to render based on the nearest cached frame
at or before the frame. On return the canvas will be prepared as if the nearest cached
frame had been rendered and disposed. The returned index is the next frame that needs to be
composited onto the canvas.
@param previousFrameNumber the frame number that is ones less than the one we're rendering
@param canvas the canvas to prepare
@return the index of the the next frame to process | [
"Given",
"a",
"frame",
"number",
"prepares",
"the",
"canvas",
"to",
"render",
"based",
"on",
"the",
"nearest",
"cached",
"frame",
"at",
"or",
"before",
"the",
"frame",
".",
"On",
"return",
"the",
"canvas",
"will",
"be",
"prepared",
"as",
"if",
"the",
"ne... | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/animated-base/src/main/java/com/facebook/imagepipeline/animated/impl/AnimatedImageCompositor.java#L148-L183 |
banq/jdonframework | src/main/java/com/jdon/container/pico/JdonPicoContainer.java | JdonPicoContainer.registerComponentImplementation | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters)
throws PicoRegistrationException {
ComponentAdapter componentAdapter = componentAdapterFactory.createComponentAdapter(componentKey, componentImplementation, parameters);
registerComponent(componentAdapter);
return componentAdapter;
} | java | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters)
throws PicoRegistrationException {
ComponentAdapter componentAdapter = componentAdapterFactory.createComponentAdapter(componentKey, componentImplementation, parameters);
registerComponent(componentAdapter);
return componentAdapter;
} | [
"public",
"ComponentAdapter",
"registerComponentImplementation",
"(",
"Object",
"componentKey",
",",
"Class",
"componentImplementation",
",",
"Parameter",
"[",
"]",
"parameters",
")",
"throws",
"PicoRegistrationException",
"{",
"ComponentAdapter",
"componentAdapter",
"=",
"... | {@inheritDoc} The returned ComponentAdapter will be instantiated by the
{@link ComponentAdapterFactory} passed to the container's constructor. | [
"{"
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/pico/JdonPicoContainer.java#L266-L271 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/returns/OrderNoteUrl.java | OrderNoteUrl.deleteReturnNoteUrl | public static MozuUrl deleteReturnNoteUrl(String noteId, String returnId)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/returns/{returnId}/notes/{noteId}");
formatter.formatUrl("noteId", noteId);
formatter.formatUrl("returnId", returnId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl deleteReturnNoteUrl(String noteId, String returnId)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/returns/{returnId}/notes/{noteId}");
formatter.formatUrl("noteId", noteId);
formatter.formatUrl("returnId", returnId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"deleteReturnNoteUrl",
"(",
"String",
"noteId",
",",
"String",
"returnId",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/returns/{returnId}/notes/{noteId}\"",
")",
";",
"formatter",
".",
"formatUr... | Get Resource Url for DeleteReturnNote
@param noteId Unique identifier of a particular note to retrieve.
@param returnId Unique identifier of the return whose items you want to get.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"DeleteReturnNote"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/returns/OrderNoteUrl.java#L80-L86 |
docker-java/docker-java | src/main/java/com/github/dockerjava/core/KeystoreSSLConfig.java | KeystoreSSLConfig.getSSLContext | @Override
public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
NoSuchAlgorithmException, KeyStoreException {
final SSLContext context = SSLContext.getInstance("TLS");
String httpProtocols = System.getProperty("https.protocols");
System.setProperty("https.protocols", "TLSv1");
if (httpProtocols != null) {
System.setProperty("https.protocols", httpProtocols);
}
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
.getDefaultAlgorithm());
keyManagerFactory.init(keystore, keystorePassword.toCharArray());
context.init(keyManagerFactory.getKeyManagers(), new TrustManager[] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
@Override
public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) {
}
@Override
public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) {
}
}
}, new SecureRandom());
return context;
} | java | @Override
public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
NoSuchAlgorithmException, KeyStoreException {
final SSLContext context = SSLContext.getInstance("TLS");
String httpProtocols = System.getProperty("https.protocols");
System.setProperty("https.protocols", "TLSv1");
if (httpProtocols != null) {
System.setProperty("https.protocols", httpProtocols);
}
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
.getDefaultAlgorithm());
keyManagerFactory.init(keystore, keystorePassword.toCharArray());
context.init(keyManagerFactory.getKeyManagers(), new TrustManager[] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
@Override
public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) {
}
@Override
public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) {
}
}
}, new SecureRandom());
return context;
} | [
"@",
"Override",
"public",
"SSLContext",
"getSSLContext",
"(",
")",
"throws",
"KeyManagementException",
",",
"UnrecoverableKeyException",
",",
"NoSuchAlgorithmException",
",",
"KeyStoreException",
"{",
"final",
"SSLContext",
"context",
"=",
"SSLContext",
".",
"getInstance... | Get the SSL Context out of the keystore.
@return java SSLContext
@throws KeyManagementException
@throws UnrecoverableKeyException
@throws NoSuchAlgorithmException
@throws KeyStoreException | [
"Get",
"the",
"SSL",
"Context",
"out",
"of",
"the",
"keystore",
"."
] | train | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/KeystoreSSLConfig.java#L75-L111 |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java | JadexConnector.createAgent | public void createAgent(String agent_name, String path) {
IComponentIdentifier agent = cmsService.createComponent(agent_name,
path, null, null).get(new ThreadSuspendable());
createdAgents.put(agent_name, agent);
} | java | public void createAgent(String agent_name, String path) {
IComponentIdentifier agent = cmsService.createComponent(agent_name,
path, null, null).get(new ThreadSuspendable());
createdAgents.put(agent_name, agent);
} | [
"public",
"void",
"createAgent",
"(",
"String",
"agent_name",
",",
"String",
"path",
")",
"{",
"IComponentIdentifier",
"agent",
"=",
"cmsService",
".",
"createComponent",
"(",
"agent_name",
",",
"path",
",",
"null",
",",
"null",
")",
".",
"get",
"(",
"new",
... | Creates a real agent in the platform
@param agent_name
The name that the agent is gonna have in the platform
@param path
The path of the description (xml) of the agent | [
"Creates",
"a",
"real",
"agent",
"in",
"the",
"platform"
] | train | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/platform/jadex/JadexConnector.java#L112-L116 |
tvesalainen/util | util/src/main/java/org/vesalainen/math/matrix/DoubleMatrix.java | DoubleMatrix.getInstance | public static DoubleMatrix getInstance(int rows, double... values)
{
if (rows < 1)
{
throw new IllegalArgumentException("rows");
}
if (values.length % rows != 0)
{
throw new IllegalArgumentException("not full rows");
}
return new DoubleMatrix(rows, Arrays.copyOf(values, values.length));
} | java | public static DoubleMatrix getInstance(int rows, double... values)
{
if (rows < 1)
{
throw new IllegalArgumentException("rows");
}
if (values.length % rows != 0)
{
throw new IllegalArgumentException("not full rows");
}
return new DoubleMatrix(rows, Arrays.copyOf(values, values.length));
} | [
"public",
"static",
"DoubleMatrix",
"getInstance",
"(",
"int",
"rows",
",",
"double",
"...",
"values",
")",
"{",
"if",
"(",
"rows",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"rows\"",
")",
";",
"}",
"if",
"(",
"values",
".",
... | Returns new DoubleMatrix initialized to values.
<p>E.g. 2x2 matrix has A00, A01, A10, A11
@param rows Number of rows
@param values Values row by row
@return | [
"Returns",
"new",
"DoubleMatrix",
"initialized",
"to",
"values",
".",
"<p",
">",
"E",
".",
"g",
".",
"2x2",
"matrix",
"has",
"A00",
"A01",
"A10",
"A11"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/matrix/DoubleMatrix.java#L638-L649 |
wcm-io/wcm-io-tooling | commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/ContentPackage.java | ContentPackage.addContent | public void addContent(String path, ContentElement content) throws IOException {
String fullPath = buildJcrPathForZip(path) + "/" + DOT_CONTENT_XML;
Document doc = xmlContentBuilder.buildContent(content);
writeXmlDocument(fullPath, doc);
} | java | public void addContent(String path, ContentElement content) throws IOException {
String fullPath = buildJcrPathForZip(path) + "/" + DOT_CONTENT_XML;
Document doc = xmlContentBuilder.buildContent(content);
writeXmlDocument(fullPath, doc);
} | [
"public",
"void",
"addContent",
"(",
"String",
"path",
",",
"ContentElement",
"content",
")",
"throws",
"IOException",
"{",
"String",
"fullPath",
"=",
"buildJcrPathForZip",
"(",
"path",
")",
"+",
"\"/\"",
"+",
"DOT_CONTENT_XML",
";",
"Document",
"doc",
"=",
"x... | Add some JCR content structure directly to the package.
@param path Full content path of content root node.
@param content Hierarchy of content elements.
@throws IOException I/O exception | [
"Add",
"some",
"JCR",
"content",
"structure",
"directly",
"to",
"the",
"package",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/ContentPackage.java#L151-L155 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.getPackageLink | public Content getPackageLink(PackageElement packageElement, CharSequence label) {
return getPackageLink(packageElement, new StringContent(label));
} | java | public Content getPackageLink(PackageElement packageElement, CharSequence label) {
return getPackageLink(packageElement, new StringContent(label));
} | [
"public",
"Content",
"getPackageLink",
"(",
"PackageElement",
"packageElement",
",",
"CharSequence",
"label",
")",
"{",
"return",
"getPackageLink",
"(",
"packageElement",
",",
"new",
"StringContent",
"(",
"label",
")",
")",
";",
"}"
] | Return the link to the given package.
@param packageElement the package to link to.
@param label the label for the link.
@return a content tree for the package link. | [
"Return",
"the",
"link",
"to",
"the",
"given",
"package",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java#L1096-L1098 |
OpenLiberty/open-liberty | dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RecoveryDirectorImpl.java | RecoveryDirectorImpl.terminationComplete | @Override
public void terminationComplete(RecoveryAgent recoveryAgent, FailureScope failureScope) throws InvalidFailureScopeException {
if (tc.isEntryEnabled())
Tr.entry(tc, "terminationComplete", new Object[] { recoveryAgent, failureScope, this });
final boolean removed = removeTerminationRecord(recoveryAgent, failureScope);
if (!removed) {
if (tc.isEventEnabled())
Tr.event(tc, "The supplied FailureScope was not recognized as an outstaning termination request for this RecoveryAgent");
if (tc.isEntryEnabled())
Tr.exit(tc, "terminationComplete", "InvalidFailureScopeException");
throw new InvalidFailureScopeException(null);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "terminationComplete");
} | java | @Override
public void terminationComplete(RecoveryAgent recoveryAgent, FailureScope failureScope) throws InvalidFailureScopeException {
if (tc.isEntryEnabled())
Tr.entry(tc, "terminationComplete", new Object[] { recoveryAgent, failureScope, this });
final boolean removed = removeTerminationRecord(recoveryAgent, failureScope);
if (!removed) {
if (tc.isEventEnabled())
Tr.event(tc, "The supplied FailureScope was not recognized as an outstaning termination request for this RecoveryAgent");
if (tc.isEntryEnabled())
Tr.exit(tc, "terminationComplete", "InvalidFailureScopeException");
throw new InvalidFailureScopeException(null);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "terminationComplete");
} | [
"@",
"Override",
"public",
"void",
"terminationComplete",
"(",
"RecoveryAgent",
"recoveryAgent",
",",
"FailureScope",
"failureScope",
")",
"throws",
"InvalidFailureScopeException",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"("... | <p>
Invoked by a client service to indicate recovery processing for the identified
FailureScope ceased. The client service supplies its RecoveryAgent reference to
identify itself.
</p>
<p>
The RecoveryDirector will then pass the termination request on to other registered
client services.
</p>
@param recoveryAgent The client services RecoveryAgent instance.
@param failureScope The unit of recovery that is completed.
@exception InvalidFailureScopeException The supplied FailureScope was not recognized as
outstanding unit of recovery for the client
service. | [
"<p",
">",
"Invoked",
"by",
"a",
"client",
"service",
"to",
"indicate",
"recovery",
"processing",
"for",
"the",
"identified",
"FailureScope",
"ceased",
".",
"The",
"client",
"service",
"supplies",
"its",
"RecoveryAgent",
"reference",
"to",
"identify",
"itself",
... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RecoveryDirectorImpl.java#L550-L567 |
google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.markUnusedParameters | private void markUnusedParameters(Node paramList, Scope fparamScope) {
for (Node param = paramList.getFirstChild(); param != null; param = param.getNext()) {
if (param.isUnusedParameter()) {
continue;
}
Node lValue = nameOfParam(param);
if (lValue == null) {
continue;
}
VarInfo varInfo = traverseNameNode(lValue, fparamScope);
if (varInfo.isRemovable()) {
param.setUnusedParameter(true);
compiler.reportChangeToEnclosingScope(paramList);
}
}
} | java | private void markUnusedParameters(Node paramList, Scope fparamScope) {
for (Node param = paramList.getFirstChild(); param != null; param = param.getNext()) {
if (param.isUnusedParameter()) {
continue;
}
Node lValue = nameOfParam(param);
if (lValue == null) {
continue;
}
VarInfo varInfo = traverseNameNode(lValue, fparamScope);
if (varInfo.isRemovable()) {
param.setUnusedParameter(true);
compiler.reportChangeToEnclosingScope(paramList);
}
}
} | [
"private",
"void",
"markUnusedParameters",
"(",
"Node",
"paramList",
",",
"Scope",
"fparamScope",
")",
"{",
"for",
"(",
"Node",
"param",
"=",
"paramList",
".",
"getFirstChild",
"(",
")",
";",
"param",
"!=",
"null",
";",
"param",
"=",
"param",
".",
"getNext... | Mark any remaining unused parameters as being unused so it can be used elsewhere.
@param paramList list of function's parameters
@param fparamScope | [
"Mark",
"any",
"remaining",
"unused",
"parameters",
"as",
"being",
"unused",
"so",
"it",
"can",
"be",
"used",
"elsewhere",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1415-L1432 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java | LiveEventsInner.beginStart | public void beginStart(String resourceGroupName, String accountName, String liveEventName) {
beginStartWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).toBlocking().single().body();
} | java | public void beginStart(String resourceGroupName, String accountName, String liveEventName) {
beginStartWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).toBlocking().single().body();
} | [
"public",
"void",
"beginStart",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"liveEventName",
")",
"{",
"beginStartWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"liveEventName",
")",
".",
"toBlocking",
... | Start Live Event.
Starts an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Start",
"Live",
"Event",
".",
"Starts",
"an",
"existing",
"Live",
"Event",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java#L1197-L1199 |
cloudfoundry/uaa | server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java | IdpMetadataGenerator.getDiscoveryResponseURL | protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) {
if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null
&& extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) {
return extendedMetadata.getIdpDiscoveryResponseURL();
} else {
Map<String, String> params = new HashMap<String, String>();
params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true");
return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params);
}
} | java | protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) {
if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null
&& extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) {
return extendedMetadata.getIdpDiscoveryResponseURL();
} else {
Map<String, String> params = new HashMap<String, String>();
params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true");
return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params);
}
} | [
"protected",
"String",
"getDiscoveryResponseURL",
"(",
"String",
"entityBaseURL",
",",
"String",
"entityAlias",
")",
"{",
"if",
"(",
"extendedMetadata",
"!=",
"null",
"&&",
"extendedMetadata",
".",
"getIdpDiscoveryResponseURL",
"(",
")",
"!=",
"null",
"&&",
"extende... | Provides set discovery response url or generates a default when none was provided. Primarily value set on
extenedMetadata property idpDiscoveryResponseURL is used, when empty local property customDiscoveryResponseURL
is used, when empty URL is automatically generated.
@param entityBaseURL
base URL for generation of endpoints
@param entityAlias
alias of entity, or null when there's no alias required
@return URL to use for IDP discovery response | [
"Provides",
"set",
"discovery",
"response",
"url",
"or",
"generates",
"a",
"default",
"when",
"none",
"was",
"provided",
".",
"Primarily",
"value",
"set",
"on",
"extenedMetadata",
"property",
"idpDiscoveryResponseURL",
"is",
"used",
"when",
"empty",
"local",
"prop... | train | https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L795-L804 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Waiter.java | Waiter.waitForLogMessage | public boolean waitForLogMessage(String logMessage, int timeout){
StringBuilder stringBuilder = new StringBuilder();
long endTime = SystemClock.uptimeMillis() + timeout;
while (SystemClock.uptimeMillis() <= endTime) {
if(getLog(stringBuilder).lastIndexOf(logMessage) != -1){
return true;
}
sleeper.sleep();
}
return false;
} | java | public boolean waitForLogMessage(String logMessage, int timeout){
StringBuilder stringBuilder = new StringBuilder();
long endTime = SystemClock.uptimeMillis() + timeout;
while (SystemClock.uptimeMillis() <= endTime) {
if(getLog(stringBuilder).lastIndexOf(logMessage) != -1){
return true;
}
sleeper.sleep();
}
return false;
} | [
"public",
"boolean",
"waitForLogMessage",
"(",
"String",
"logMessage",
",",
"int",
"timeout",
")",
"{",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"long",
"endTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
"+",
"ti... | Waits for a log message to appear.
Requires read logs permission (android.permission.READ_LOGS) in AndroidManifest.xml of the application under test.
@param logMessage the log message to wait for
@param timeout the amount of time in milliseconds to wait
@return true if log message appears and false if it does not appear before the timeout | [
"Waits",
"for",
"a",
"log",
"message",
"to",
"appear",
".",
"Requires",
"read",
"logs",
"permission",
"(",
"android",
".",
"permission",
".",
"READ_LOGS",
")",
"in",
"AndroidManifest",
".",
"xml",
"of",
"the",
"application",
"under",
"test",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L730-L742 |
biojava/biojava | biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java | WorkSheet.readCSV | static public WorkSheet readCSV(String fileName, char delimiter) throws Exception {
return readCSV(new File(fileName), delimiter);
} | java | static public WorkSheet readCSV(String fileName, char delimiter) throws Exception {
return readCSV(new File(fileName), delimiter);
} | [
"static",
"public",
"WorkSheet",
"readCSV",
"(",
"String",
"fileName",
",",
"char",
"delimiter",
")",
"throws",
"Exception",
"{",
"return",
"readCSV",
"(",
"new",
"File",
"(",
"fileName",
")",
",",
"delimiter",
")",
";",
"}"
] | Read a CSV/Tab delimitted file where you pass in the delimiter
@param fileName
@param delimiter
@return
@throws Exception | [
"Read",
"a",
"CSV",
"/",
"Tab",
"delimitted",
"file",
"where",
"you",
"pass",
"in",
"the",
"delimiter"
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java#L1452-L1456 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java | SqlConnRunner.findBy | public List<Entity> findBy(Connection conn, String tableName, String field, Object value) throws SQLException{
return findAll(conn, Entity.create(tableName).set(field, value));
} | java | public List<Entity> findBy(Connection conn, String tableName, String field, Object value) throws SQLException{
return findAll(conn, Entity.create(tableName).set(field, value));
} | [
"public",
"List",
"<",
"Entity",
">",
"findBy",
"(",
"Connection",
"conn",
",",
"String",
"tableName",
",",
"String",
"field",
",",
"Object",
"value",
")",
"throws",
"SQLException",
"{",
"return",
"findAll",
"(",
"conn",
",",
"Entity",
".",
"create",
"(",
... | 根据某个字段名条件查询数据列表,返回所有字段
@param conn 数据库连接对象
@param tableName 表名
@param field 字段名
@param value 字段值
@return 数据对象列表
@throws SQLException SQL执行异常 | [
"根据某个字段名条件查询数据列表,返回所有字段"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java#L399-L401 |
Axway/Grapes | utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java | GrapesClient.getModuleOrganization | public Organization getModuleOrganization(final String moduleName, final String moduleVersion) throws GrapesCommunicationException {
final Client client = getClient();
final WebResource resource = client.resource(serverURL).path(RequestUtils.getModuleOrganizationPath(moduleName, moduleVersion));
final ClientResponse response = resource
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to get module's organization";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
return response.getEntity(Organization.class);
} | java | public Organization getModuleOrganization(final String moduleName, final String moduleVersion) throws GrapesCommunicationException {
final Client client = getClient();
final WebResource resource = client.resource(serverURL).path(RequestUtils.getModuleOrganizationPath(moduleName, moduleVersion));
final ClientResponse response = resource
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to get module's organization";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
return response.getEntity(Organization.class);
} | [
"public",
"Organization",
"getModuleOrganization",
"(",
"final",
"String",
"moduleName",
",",
"final",
"String",
"moduleVersion",
")",
"throws",
"GrapesCommunicationException",
"{",
"final",
"Client",
"client",
"=",
"getClient",
"(",
")",
";",
"final",
"WebResource",
... | Returns the organization of a given module
@return Organization | [
"Returns",
"the",
"organization",
"of",
"a",
"given",
"module"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java#L822-L839 |
qiujuer/Genius-Android | caprice/ui/src/main/java/net/qiujuer/genius/ui/Ui.java | Ui.changeColorAlpha | public static int changeColorAlpha(int color, int alpha) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
return alpha << 24 | r << 16 | g << 8 | b;
} | java | public static int changeColorAlpha(int color, int alpha) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
return alpha << 24 | r << 16 | g << 8 | b;
} | [
"public",
"static",
"int",
"changeColorAlpha",
"(",
"int",
"color",
",",
"int",
"alpha",
")",
"{",
"int",
"r",
"=",
"(",
"color",
">>",
"16",
")",
"&",
"0xFF",
";",
"int",
"g",
"=",
"(",
"color",
">>",
"8",
")",
"&",
"0xFF",
";",
"int",
"b",
"=... | Change the color to new alpha
@param color Color
@param alpha New alpha
@return New alpha color | [
"Change",
"the",
"color",
"to",
"new",
"alpha"
] | train | https://github.com/qiujuer/Genius-Android/blob/babefaf1321f5883a21cada582b6fa5104adc648/caprice/ui/src/main/java/net/qiujuer/genius/ui/Ui.java#L124-L129 |
mozilla/rhino | src/org/mozilla/javascript/ScriptRuntime.java | ScriptRuntime.throwError | public static JavaScriptException throwError(Context cx, Scriptable scope,
String message) {
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
final Scriptable error = newBuiltinObject(cx, scope,
TopLevel.Builtins.Error, new Object[] { message, filename, Integer.valueOf(linep[0]) });
return new JavaScriptException(error, filename, linep[0]);
} | java | public static JavaScriptException throwError(Context cx, Scriptable scope,
String message) {
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
final Scriptable error = newBuiltinObject(cx, scope,
TopLevel.Builtins.Error, new Object[] { message, filename, Integer.valueOf(linep[0]) });
return new JavaScriptException(error, filename, linep[0]);
} | [
"public",
"static",
"JavaScriptException",
"throwError",
"(",
"Context",
"cx",
",",
"Scriptable",
"scope",
",",
"String",
"message",
")",
"{",
"int",
"[",
"]",
"linep",
"=",
"{",
"0",
"}",
";",
"String",
"filename",
"=",
"Context",
".",
"getSourcePositionFro... | Equivalent to executing "new Error(message, sourceFileName, sourceLineNo)" from JavaScript.
@param cx the current context
@param scope the current scope
@param message the message
@return a JavaScriptException you should throw | [
"Equivalent",
"to",
"executing",
"new",
"Error",
"(",
"message",
"sourceFileName",
"sourceLineNo",
")",
"from",
"JavaScript",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptRuntime.java#L4558-L4565 |
eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/validation/CancelableDiagnostician.java | CancelableDiagnostician.isCanceled | @Deprecated
protected boolean isCanceled(Map<Object, Object> context) {
CancelIndicator indicator = getCancelIndicator(context);
return indicator != null && indicator.isCanceled();
} | java | @Deprecated
protected boolean isCanceled(Map<Object, Object> context) {
CancelIndicator indicator = getCancelIndicator(context);
return indicator != null && indicator.isCanceled();
} | [
"@",
"Deprecated",
"protected",
"boolean",
"isCanceled",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"context",
")",
"{",
"CancelIndicator",
"indicator",
"=",
"getCancelIndicator",
"(",
"context",
")",
";",
"return",
"indicator",
"!=",
"null",
"&&",
"indica... | <p>
Use {@link #checkCanceled} instead to throw a platform specific cancellation exception.
</p> | [
"<p",
">",
"Use",
"{"
] | train | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/validation/CancelableDiagnostician.java#L55-L59 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/reflect/ReflectionUtils.java | ReflectionUtils.setFieldIfPossible | public static void setFieldIfPossible(Class type, String name, Object value) {
Optional<Field> declaredField = findDeclaredField(type, name);
if (declaredField.isPresent()) {
Field field = declaredField.get();
Optional<?> converted = ConversionService.SHARED.convert(value, field.getType());
if (converted.isPresent()) {
field.setAccessible(true);
try {
field.set(type, converted.get());
} catch (IllegalAccessException e) {
// ignore
}
} else {
field.setAccessible(true);
try {
field.set(type, null);
} catch (IllegalAccessException e) {
// ignore
}
}
}
} | java | public static void setFieldIfPossible(Class type, String name, Object value) {
Optional<Field> declaredField = findDeclaredField(type, name);
if (declaredField.isPresent()) {
Field field = declaredField.get();
Optional<?> converted = ConversionService.SHARED.convert(value, field.getType());
if (converted.isPresent()) {
field.setAccessible(true);
try {
field.set(type, converted.get());
} catch (IllegalAccessException e) {
// ignore
}
} else {
field.setAccessible(true);
try {
field.set(type, null);
} catch (IllegalAccessException e) {
// ignore
}
}
}
} | [
"public",
"static",
"void",
"setFieldIfPossible",
"(",
"Class",
"type",
",",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"Optional",
"<",
"Field",
">",
"declaredField",
"=",
"findDeclaredField",
"(",
"type",
",",
"name",
")",
";",
"if",
"(",
"decla... | Finds a field in the type or super type.
@param type The type
@param name The field name
@param value The value | [
"Finds",
"a",
"field",
"in",
"the",
"type",
"or",
"super",
"type",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/reflect/ReflectionUtils.java#L325-L346 |
EdwardRaff/JSAT | JSAT/src/jsat/math/optimization/oned/GoldenSearch.java | GoldenSearch.findMin | public static double findMin(double min, double max, Function1D f, double eps, int maxSteps)
{
double a = min, b = max;
double fa = f.f(a), fb = f.f(b);
double c = b - goldenRatio * (b - a);
double d = a + goldenRatio * (b - a);
double fc = f.f(c);
double fd = f.f(d);
while(Math.abs(c-d) > eps && maxSteps-- > 0)
{
if (fc < fd)
{
// (b, f(b)) ← (d, f(d))
b = d;
fb = fd;
//(d, f(d)) ← (c, f(c))
d = c;
fd = fc;
// update c = b + φ (a - b) and f(c)
c = b - goldenRatio * (b - a);
fc = f.f(c);
}
else
{
//(a, f(a)) ← (c, f(c))
a = c;
fa = fc;
//(c, f(c)) ← (d, f(d))
c = d;
fc = fd;
// update d = a + φ (b - a) and f(d)
d = a + goldenRatio * (b - a);
fd = f.f(d);
}
}
return (a+b)/2;
} | java | public static double findMin(double min, double max, Function1D f, double eps, int maxSteps)
{
double a = min, b = max;
double fa = f.f(a), fb = f.f(b);
double c = b - goldenRatio * (b - a);
double d = a + goldenRatio * (b - a);
double fc = f.f(c);
double fd = f.f(d);
while(Math.abs(c-d) > eps && maxSteps-- > 0)
{
if (fc < fd)
{
// (b, f(b)) ← (d, f(d))
b = d;
fb = fd;
//(d, f(d)) ← (c, f(c))
d = c;
fd = fc;
// update c = b + φ (a - b) and f(c)
c = b - goldenRatio * (b - a);
fc = f.f(c);
}
else
{
//(a, f(a)) ← (c, f(c))
a = c;
fa = fc;
//(c, f(c)) ← (d, f(d))
c = d;
fc = fd;
// update d = a + φ (b - a) and f(d)
d = a + goldenRatio * (b - a);
fd = f.f(d);
}
}
return (a+b)/2;
} | [
"public",
"static",
"double",
"findMin",
"(",
"double",
"min",
",",
"double",
"max",
",",
"Function1D",
"f",
",",
"double",
"eps",
",",
"int",
"maxSteps",
")",
"{",
"double",
"a",
"=",
"min",
",",
"b",
"=",
"max",
";",
"double",
"fa",
"=",
"f",
"."... | Attempts to numerically find the value {@code x} that minimizes the one
dimensional function {@code f(x)} in the range {@code [min, max]}.
@param min the minimum of the search range
@param max the maximum of the search range
@param f the one dimensional function to minimize
@param eps the desired accuracy of the returned value
@param maxSteps the maximum number of search steps to take
@return the value {@code x} that appears to minimize {@code f(x)} | [
"Attempts",
"to",
"numerically",
"find",
"the",
"value",
"{",
"@code",
"x",
"}",
"that",
"minimizes",
"the",
"one",
"dimensional",
"function",
"{",
"@code",
"f",
"(",
"x",
")",
"}",
"in",
"the",
"range",
"{",
"@code",
"[",
"min",
"max",
"]",
"}",
"."... | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/optimization/oned/GoldenSearch.java#L42-L81 |
javalite/activejdbc | activejdbc/src/main/java/org/javalite/activejdbc/Errors.java | Errors.get | public String get(String attributeName, Object... params) {
if (attributeName == null) throw new NullPointerException("attributeName cannot be null");
return validators.get(attributeName).formatMessage(locale, params);
} | java | public String get(String attributeName, Object... params) {
if (attributeName == null) throw new NullPointerException("attributeName cannot be null");
return validators.get(attributeName).formatMessage(locale, params);
} | [
"public",
"String",
"get",
"(",
"String",
"attributeName",
",",
"Object",
"...",
"params",
")",
"{",
"if",
"(",
"attributeName",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"attributeName cannot be null\"",
")",
";",
"return",
"validators",
... | Provides a message from the resource bundle <code>activejdbc_messages</code> which is merged
with parameters. This methods expects the message in the resource bundle to be parametrized.
This message is configured for a validator using a Fluent Interface when declaring a validator:
<pre>
public class Temperature extends Model {
static{
validateRange("temp", 0, 100).message("temperature cannot be less than {0} or more than {1}");
}
}
</pre>
@param attributeName name of attribute in error.
@param params list of parameters for a message. The order of parameters in this list will correspond to the
numeric order in the parameters listed in the message and has nothing to do with a physical order. This means
that the 0th parameter in the list will correspond to <code>{0}</code>, 1st to <code>{1}</code> and so on.
@return a message from the resource bundle <code>activejdbc_messages</code> with default locale, which is merged
with parameters. | [
"Provides",
"a",
"message",
"from",
"the",
"resource",
"bundle",
"<code",
">",
"activejdbc_messages<",
"/",
"code",
">",
"which",
"is",
"merged",
"with",
"parameters",
".",
"This",
"methods",
"expects",
"the",
"message",
"in",
"the",
"resource",
"bundle",
"to"... | train | https://github.com/javalite/activejdbc/blob/ffcf5457cace19622a8f71e856cbbbe9e7dd5fcc/activejdbc/src/main/java/org/javalite/activejdbc/Errors.java#L91-L95 |
chanjarster/weixin-java-tools | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/res/StringManager.java | StringManager.getString | public String getString(final String key, final Object... args) {
String value = getString(key);
if (value == null) {
value = key;
}
MessageFormat mf = new MessageFormat(value);
mf.setLocale(locale);
return mf.format(args, new StringBuffer(), null).toString();
} | java | public String getString(final String key, final Object... args) {
String value = getString(key);
if (value == null) {
value = key;
}
MessageFormat mf = new MessageFormat(value);
mf.setLocale(locale);
return mf.format(args, new StringBuffer(), null).toString();
} | [
"public",
"String",
"getString",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"String",
"value",
"=",
"getString",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"key",
";",
"}",
"... | Get a string from the underlying resource bundle and format
it with the given set of arguments.
@param key
@param args | [
"Get",
"a",
"string",
"from",
"the",
"underlying",
"resource",
"bundle",
"and",
"format",
"it",
"with",
"the",
"given",
"set",
"of",
"arguments",
"."
] | train | https://github.com/chanjarster/weixin-java-tools/blob/2a0b1c30c0f60c2de466cb8933c945bc0d391edf/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/res/StringManager.java#L151-L160 |
mgm-tp/jfunk | jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/WebDriverTool.java | WebDriverTool.openNewWindow | public String openNewWindow(final Runnable openCommand, final long timeoutSeconds) {
String oldHandle = webDriver.getWindowHandle();
final Set<String> existingWindowHandles = webDriver.getWindowHandles();
openCommand.run();
Function<WebDriver, String> function = new Function<WebDriver, String>() {
@Override
public String apply(final WebDriver input) {
Set<String> newWindowHandles = webDriver.getWindowHandles();
SetView<String> newWindows = difference(newWindowHandles, existingWindowHandles);
if (newWindows.isEmpty()) {
throw new NotFoundException("No new window found.");
}
return getOnlyElement(newWindows);
}
@Override
public String toString() {
return "new window to open";
}
};
String newHandle = waitFor(function, timeoutSeconds);
webDriver.switchTo().window(newHandle);
return oldHandle;
} | java | public String openNewWindow(final Runnable openCommand, final long timeoutSeconds) {
String oldHandle = webDriver.getWindowHandle();
final Set<String> existingWindowHandles = webDriver.getWindowHandles();
openCommand.run();
Function<WebDriver, String> function = new Function<WebDriver, String>() {
@Override
public String apply(final WebDriver input) {
Set<String> newWindowHandles = webDriver.getWindowHandles();
SetView<String> newWindows = difference(newWindowHandles, existingWindowHandles);
if (newWindows.isEmpty()) {
throw new NotFoundException("No new window found.");
}
return getOnlyElement(newWindows);
}
@Override
public String toString() {
return "new window to open";
}
};
String newHandle = waitFor(function, timeoutSeconds);
webDriver.switchTo().window(newHandle);
return oldHandle;
} | [
"public",
"String",
"openNewWindow",
"(",
"final",
"Runnable",
"openCommand",
",",
"final",
"long",
"timeoutSeconds",
")",
"{",
"String",
"oldHandle",
"=",
"webDriver",
".",
"getWindowHandle",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"existingWindowHan... | Opens a new window and switches to it. The window to switch to is determined by diffing
the given {@code existingWindowHandles} with the current ones. The difference must be
exactly one window handle which is then used to switch to.
@param openCommand
logic for opening the new window
@param timeoutSeconds
the timeout in seconds to wait for the new window to open
@return the handle of the window that opened the new window | [
"Opens",
"a",
"new",
"window",
"and",
"switches",
"to",
"it",
".",
"The",
"window",
"to",
"switch",
"to",
"is",
"determined",
"by",
"diffing",
"the",
"given",
"{",
"@code",
"existingWindowHandles",
"}",
"with",
"the",
"current",
"ones",
".",
"The",
"differ... | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/WebDriverTool.java#L808-L834 |
ben-manes/caffeine | jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java | CacheProxy.replaceNoCopyOrAwait | private V replaceNoCopyOrAwait(K key, V value) {
requireNonNull(value);
V copy = copyOf(value);
@SuppressWarnings("unchecked")
V[] replaced = (V[]) new Object[1];
cache.asMap().computeIfPresent(key, (k, expirable) -> {
if (!expirable.isEternal() && expirable.hasExpired(currentTimeMillis())) {
dispatcher.publishExpired(this, key, expirable.get());
statistics.recordEvictions(1L);
return null;
}
publishToCacheWriter(writer::write, () -> new EntryProxy<>(key, value));
long expireTimeMS = getWriteExpireTimeMS(/* created */ false);
if (expireTimeMS == Long.MIN_VALUE) {
expireTimeMS = expirable.getExpireTimeMS();
}
dispatcher.publishUpdated(this, key, expirable.get(), copy);
replaced[0] = expirable.get();
return new Expirable<>(copy, expireTimeMS);
});
return replaced[0];
} | java | private V replaceNoCopyOrAwait(K key, V value) {
requireNonNull(value);
V copy = copyOf(value);
@SuppressWarnings("unchecked")
V[] replaced = (V[]) new Object[1];
cache.asMap().computeIfPresent(key, (k, expirable) -> {
if (!expirable.isEternal() && expirable.hasExpired(currentTimeMillis())) {
dispatcher.publishExpired(this, key, expirable.get());
statistics.recordEvictions(1L);
return null;
}
publishToCacheWriter(writer::write, () -> new EntryProxy<>(key, value));
long expireTimeMS = getWriteExpireTimeMS(/* created */ false);
if (expireTimeMS == Long.MIN_VALUE) {
expireTimeMS = expirable.getExpireTimeMS();
}
dispatcher.publishUpdated(this, key, expirable.get(), copy);
replaced[0] = expirable.get();
return new Expirable<>(copy, expireTimeMS);
});
return replaced[0];
} | [
"private",
"V",
"replaceNoCopyOrAwait",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"requireNonNull",
"(",
"value",
")",
";",
"V",
"copy",
"=",
"copyOf",
"(",
"value",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"V",
"[",
"]",
"repl... | Replaces the entry for the specified key only if it is currently mapped to some value. The
entry is not store-by-value copied nor does the method wait for synchronous listeners to
complete.
@param key key with which the specified value is associated
@param value value to be associated with the specified key
@return the old value | [
"Replaces",
"the",
"entry",
"for",
"the",
"specified",
"key",
"only",
"if",
"it",
"is",
"currently",
"mapped",
"to",
"some",
"value",
".",
"The",
"entry",
"is",
"not",
"store",
"-",
"by",
"-",
"value",
"copied",
"nor",
"does",
"the",
"method",
"wait",
... | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java#L681-L703 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/dataconversion/EncodingUtils.java | EncodingUtils.toStorage | public static Object toStorage(Object toStore, Encoder encoder, Wrapper wrapper) {
if (encoder == null || wrapper == null) {
throw new IllegalArgumentException("Both Encoder and Wrapper must be provided!");
}
if (toStore == null) return null;
return wrapper.wrap(encoder.toStorage(toStore));
} | java | public static Object toStorage(Object toStore, Encoder encoder, Wrapper wrapper) {
if (encoder == null || wrapper == null) {
throw new IllegalArgumentException("Both Encoder and Wrapper must be provided!");
}
if (toStore == null) return null;
return wrapper.wrap(encoder.toStorage(toStore));
} | [
"public",
"static",
"Object",
"toStorage",
"(",
"Object",
"toStore",
",",
"Encoder",
"encoder",
",",
"Wrapper",
"wrapper",
")",
"{",
"if",
"(",
"encoder",
"==",
"null",
"||",
"wrapper",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",... | Encode object to storage format.
@param toStore Object to be encoded.
@param encoder the {@link Encoder} used for data conversion.
@param wrapper the {@link Wrapper} used to decorate the converted data.
@return Object decoded and unwrapped. | [
"Encode",
"object",
"to",
"storage",
"format",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/dataconversion/EncodingUtils.java#L38-L44 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java | DscConfigurationsInner.get | public DscConfigurationInner get(String resourceGroupName, String automationAccountName, String configurationName) {
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).toBlocking().single().body();
} | java | public DscConfigurationInner get(String resourceGroupName, String automationAccountName, String configurationName) {
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).toBlocking().single().body();
} | [
"public",
"DscConfigurationInner",
"get",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"configurationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"configu... | Retrieve the configuration identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DscConfigurationInner object if successful. | [
"Retrieve",
"the",
"configuration",
"identified",
"by",
"configuration",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java#L199-L201 |
jhalterman/lyra | src/main/java/net/jodah/lyra/config/RecoveryPolicy.java | RecoveryPolicy.withBackoff | @Override
public RecoveryPolicy withBackoff(Duration interval, Duration maxInterval, int intervalMultiplier) {
return super.withBackoff(interval, maxInterval, intervalMultiplier);
} | java | @Override
public RecoveryPolicy withBackoff(Duration interval, Duration maxInterval, int intervalMultiplier) {
return super.withBackoff(interval, maxInterval, intervalMultiplier);
} | [
"@",
"Override",
"public",
"RecoveryPolicy",
"withBackoff",
"(",
"Duration",
"interval",
",",
"Duration",
"maxInterval",
",",
"int",
"intervalMultiplier",
")",
"{",
"return",
"super",
".",
"withBackoff",
"(",
"interval",
",",
"maxInterval",
",",
"intervalMultiplier"... | Sets the {@code interval} to pause for between attempts, exponentially backing of to the
{@code maxInterval} multiplying successive intervals by the {@code intervalMultiplier}.
@throws NullPointerException if {@code interval} or {@code maxInterval} are null
@throws IllegalArgumentException if {@code interval} is <= 0, {@code interval} is >=
{@code maxInterval} or the {@code intervalMultiplier} is <= 1 | [
"Sets",
"the",
"{",
"@code",
"interval",
"}",
"to",
"pause",
"for",
"between",
"attempts",
"exponentially",
"backing",
"of",
"to",
"the",
"{",
"@code",
"maxInterval",
"}",
"multiplying",
"successive",
"intervals",
"by",
"the",
"{",
"@code",
"intervalMultiplier",... | train | https://github.com/jhalterman/lyra/blob/ce347a69357fef1b34e92d92a4f9e68792d81255/src/main/java/net/jodah/lyra/config/RecoveryPolicy.java#L101-L104 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/stats/JMStats.java | JMStats.calPercentPrecisely | public static double calPercentPrecisely(Number target, Number total) {
double targetD = target.doubleValue();
double totalD = total.doubleValue();
return targetD == totalD ? 100d : targetD / totalD * 100;
} | java | public static double calPercentPrecisely(Number target, Number total) {
double targetD = target.doubleValue();
double totalD = total.doubleValue();
return targetD == totalD ? 100d : targetD / totalD * 100;
} | [
"public",
"static",
"double",
"calPercentPrecisely",
"(",
"Number",
"target",
",",
"Number",
"total",
")",
"{",
"double",
"targetD",
"=",
"target",
".",
"doubleValue",
"(",
")",
";",
"double",
"totalD",
"=",
"total",
".",
"doubleValue",
"(",
")",
";",
"ret... | Cal percent precisely double.
@param target the target
@param total the total
@return the double | [
"Cal",
"percent",
"precisely",
"double",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/JMStats.java#L230-L234 |
marklogic/marklogic-sesame | marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java | MarkLogicRepositoryConnection.configureWriteCache | @Override
public void configureWriteCache(long initDelay, long delayCache, long cacheSize){
client.initTimer(initDelay, delayCache,cacheSize);
} | java | @Override
public void configureWriteCache(long initDelay, long delayCache, long cacheSize){
client.initTimer(initDelay, delayCache,cacheSize);
} | [
"@",
"Override",
"public",
"void",
"configureWriteCache",
"(",
"long",
"initDelay",
",",
"long",
"delayCache",
",",
"long",
"cacheSize",
")",
"{",
"client",
".",
"initTimer",
"(",
"initDelay",
",",
"delayCache",
",",
"cacheSize",
")",
";",
"}"
] | customise write cache interval and cache size.
@param initDelay - initial interval before write cache is checked
@param delayCache - interval (ms) to check write cache
@param cacheSize - size (# triples) of write cache | [
"customise",
"write",
"cache",
"interval",
"and",
"cache",
"size",
"."
] | train | https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1374-L1377 |
opendatatrentino/s-match | src/main/java/it/unitn/disi/smatch/oracles/wordnet/WordNet.java | WordNet.traverseTree | private static boolean traverseTree(PointerTargetTree syn, PointerTargetNodeList ptnl, Synset source) {
java.util.List MGListsList = syn.toList();
for (Object aMGListsList : MGListsList) {
PointerTargetNodeList MGList = (PointerTargetNodeList) aMGListsList;
for (Object aMGList : MGList) {
Synset toAdd = ((PointerTargetNode) aMGList).getSynset();
if (toAdd.equals(source)) {
return true;
}
}
}
for (Object aPtnl : ptnl) {
Synset toAdd = ((PointerTargetNode) aPtnl).getSynset();
if (toAdd.equals(source)) {
return true;
}
}
return false;
} | java | private static boolean traverseTree(PointerTargetTree syn, PointerTargetNodeList ptnl, Synset source) {
java.util.List MGListsList = syn.toList();
for (Object aMGListsList : MGListsList) {
PointerTargetNodeList MGList = (PointerTargetNodeList) aMGListsList;
for (Object aMGList : MGList) {
Synset toAdd = ((PointerTargetNode) aMGList).getSynset();
if (toAdd.equals(source)) {
return true;
}
}
}
for (Object aPtnl : ptnl) {
Synset toAdd = ((PointerTargetNode) aPtnl).getSynset();
if (toAdd.equals(source)) {
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"traverseTree",
"(",
"PointerTargetTree",
"syn",
",",
"PointerTargetNodeList",
"ptnl",
",",
"Synset",
"source",
")",
"{",
"java",
".",
"util",
".",
"List",
"MGListsList",
"=",
"syn",
".",
"toList",
"(",
")",
";",
"for",
"(",
... | traverses PointerTargetTree.
@param syn synonyms
@param ptnl target node list
@param source source synset
@return if source was found | [
"traverses",
"PointerTargetTree",
"."
] | train | https://github.com/opendatatrentino/s-match/blob/ba5982ef406b7010c2f92592e43887a485935aa1/src/main/java/it/unitn/disi/smatch/oracles/wordnet/WordNet.java#L436-L454 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRouteGatewaysInner.java | ExpressRouteGatewaysInner.createOrUpdateAsync | public Observable<ExpressRouteGatewayInner> createOrUpdateAsync(String resourceGroupName, String expressRouteGatewayName, ExpressRouteGatewayInner putExpressRouteGatewayParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, expressRouteGatewayName, putExpressRouteGatewayParameters).map(new Func1<ServiceResponse<ExpressRouteGatewayInner>, ExpressRouteGatewayInner>() {
@Override
public ExpressRouteGatewayInner call(ServiceResponse<ExpressRouteGatewayInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRouteGatewayInner> createOrUpdateAsync(String resourceGroupName, String expressRouteGatewayName, ExpressRouteGatewayInner putExpressRouteGatewayParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, expressRouteGatewayName, putExpressRouteGatewayParameters).map(new Func1<ServiceResponse<ExpressRouteGatewayInner>, ExpressRouteGatewayInner>() {
@Override
public ExpressRouteGatewayInner call(ServiceResponse<ExpressRouteGatewayInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRouteGatewayInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"expressRouteGatewayName",
",",
"ExpressRouteGatewayInner",
"putExpressRouteGatewayParameters",
")",
"{",
"return",
"createOrUpdateWithServiceRe... | Creates or updates a ExpressRoute gateway in a specified resource group.
@param resourceGroupName The name of the resource group.
@param expressRouteGatewayName The name of the ExpressRoute gateway.
@param putExpressRouteGatewayParameters Parameters required in an ExpressRoute gateway PUT operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"ExpressRoute",
"gateway",
"in",
"a",
"specified",
"resource",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRouteGatewaysInner.java#L297-L304 |
apache/flink | flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopOutputFormatBase.java | HadoopOutputFormatBase.open | @Override
public void open(int taskNumber, int numTasks) throws IOException {
// enforce sequential open() calls
synchronized (OPEN_MUTEX) {
if (Integer.toString(taskNumber + 1).length() > 6) {
throw new IOException("Task id too large.");
}
TaskAttemptID taskAttemptID = TaskAttemptID.forName("attempt__0000_r_"
+ String.format("%" + (6 - Integer.toString(taskNumber + 1).length()) + "s", " ").replace(" ", "0")
+ Integer.toString(taskNumber + 1)
+ "_0");
this.jobConf.set("mapred.task.id", taskAttemptID.toString());
this.jobConf.setInt("mapred.task.partition", taskNumber + 1);
// for hadoop 2.2
this.jobConf.set("mapreduce.task.attempt.id", taskAttemptID.toString());
this.jobConf.setInt("mapreduce.task.partition", taskNumber + 1);
this.context = new TaskAttemptContextImpl(this.jobConf, taskAttemptID);
this.outputCommitter = this.jobConf.getOutputCommitter();
JobContext jobContext = new JobContextImpl(this.jobConf, new JobID());
this.outputCommitter.setupJob(jobContext);
this.recordWriter = this.mapredOutputFormat.getRecordWriter(null, this.jobConf, Integer.toString(taskNumber + 1), new HadoopDummyProgressable());
}
} | java | @Override
public void open(int taskNumber, int numTasks) throws IOException {
// enforce sequential open() calls
synchronized (OPEN_MUTEX) {
if (Integer.toString(taskNumber + 1).length() > 6) {
throw new IOException("Task id too large.");
}
TaskAttemptID taskAttemptID = TaskAttemptID.forName("attempt__0000_r_"
+ String.format("%" + (6 - Integer.toString(taskNumber + 1).length()) + "s", " ").replace(" ", "0")
+ Integer.toString(taskNumber + 1)
+ "_0");
this.jobConf.set("mapred.task.id", taskAttemptID.toString());
this.jobConf.setInt("mapred.task.partition", taskNumber + 1);
// for hadoop 2.2
this.jobConf.set("mapreduce.task.attempt.id", taskAttemptID.toString());
this.jobConf.setInt("mapreduce.task.partition", taskNumber + 1);
this.context = new TaskAttemptContextImpl(this.jobConf, taskAttemptID);
this.outputCommitter = this.jobConf.getOutputCommitter();
JobContext jobContext = new JobContextImpl(this.jobConf, new JobID());
this.outputCommitter.setupJob(jobContext);
this.recordWriter = this.mapredOutputFormat.getRecordWriter(null, this.jobConf, Integer.toString(taskNumber + 1), new HadoopDummyProgressable());
}
} | [
"@",
"Override",
"public",
"void",
"open",
"(",
"int",
"taskNumber",
",",
"int",
"numTasks",
")",
"throws",
"IOException",
"{",
"// enforce sequential open() calls",
"synchronized",
"(",
"OPEN_MUTEX",
")",
"{",
"if",
"(",
"Integer",
".",
"toString",
"(",
"taskNu... | create the temporary output file for hadoop RecordWriter.
@param taskNumber The number of the parallel instance.
@param numTasks The number of parallel tasks.
@throws java.io.IOException | [
"create",
"the",
"temporary",
"output",
"file",
"for",
"hadoop",
"RecordWriter",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopOutputFormatBase.java#L111-L141 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/tileprovider/MapTileProviderBase.java | MapTileProviderBase.mapTileRequestExpiredTile | @Override
public void mapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable) {
putTileIntoCache(pState.getMapTile(), pDrawable, ExpirableBitmapDrawable.getState(pDrawable));
// tell our caller we've finished and it should update its view
for (final Handler handler : mTileRequestCompleteHandlers) {
if (handler != null) {
handler.sendEmptyMessage(MAPTILE_SUCCESS_ID);
}
}
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"MapTileProviderBase.mapTileRequestExpiredTile(): " + MapTileIndex.toString(pState.getMapTile()));
}
} | java | @Override
public void mapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable) {
putTileIntoCache(pState.getMapTile(), pDrawable, ExpirableBitmapDrawable.getState(pDrawable));
// tell our caller we've finished and it should update its view
for (final Handler handler : mTileRequestCompleteHandlers) {
if (handler != null) {
handler.sendEmptyMessage(MAPTILE_SUCCESS_ID);
}
}
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"MapTileProviderBase.mapTileRequestExpiredTile(): " + MapTileIndex.toString(pState.getMapTile()));
}
} | [
"@",
"Override",
"public",
"void",
"mapTileRequestExpiredTile",
"(",
"MapTileRequestState",
"pState",
",",
"Drawable",
"pDrawable",
")",
"{",
"putTileIntoCache",
"(",
"pState",
".",
"getMapTile",
"(",
")",
",",
"pDrawable",
",",
"ExpirableBitmapDrawable",
".",
"getS... | Called by implementation class methods indicating that they have produced an expired result
that can be used but better results may be delivered later. The tile is added to the cache,
and a MAPTILE_SUCCESS_ID message is sent.
@param pState
the map tile request state object
@param pDrawable
the Drawable of the map tile | [
"Called",
"by",
"implementation",
"class",
"methods",
"indicating",
"that",
"they",
"have",
"produced",
"an",
"expired",
"result",
"that",
"can",
"be",
"used",
"but",
"better",
"results",
"may",
"be",
"delivered",
"later",
".",
"The",
"tile",
"is",
"added",
... | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/tileprovider/MapTileProviderBase.java#L217-L231 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.authentication.builtin/src/com/ibm/ws/security/authentication/internal/AuthenticationServiceImpl.java | AuthenticationServiceImpl.delegate | @Override
public Subject delegate(String roleName, String appName) {
Subject runAsSubject = getRunAsSubjectFromProvider(roleName, appName);
return runAsSubject;
} | java | @Override
public Subject delegate(String roleName, String appName) {
Subject runAsSubject = getRunAsSubjectFromProvider(roleName, appName);
return runAsSubject;
} | [
"@",
"Override",
"public",
"Subject",
"delegate",
"(",
"String",
"roleName",
",",
"String",
"appName",
")",
"{",
"Subject",
"runAsSubject",
"=",
"getRunAsSubjectFromProvider",
"(",
"roleName",
",",
"appName",
")",
";",
"return",
"runAsSubject",
";",
"}"
] | Gets the delegation subject based on the currently configured delegation provider
or the MethodDelegationProvider if one is not configured.
@param roleName the name of the role, used to look up the corresponding user.
@param appName the name of the application, used to look up the corresponding user.
@return subject a subject representing the user that is mapped to the given run-as role.
@throws IllegalArgumentException | [
"Gets",
"the",
"delegation",
"subject",
"based",
"on",
"the",
"currently",
"configured",
"delegation",
"provider",
"or",
"the",
"MethodDelegationProvider",
"if",
"one",
"is",
"not",
"configured",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.authentication.builtin/src/com/ibm/ws/security/authentication/internal/AuthenticationServiceImpl.java#L539-L543 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/config/ProcessingParameters.java | ProcessingParameters.mergedParams | public ProcessingParameters mergedParams(Map<String, String> pConfig) {
if (pConfig == null) {
return this;
} else {
Map<ConfigKey,String> newParams = new HashMap<ConfigKey, String>();
newParams.putAll(params);
newParams.putAll(convertToConfigMap(pConfig));
return new ProcessingParameters(newParams, pathInfo);
}
} | java | public ProcessingParameters mergedParams(Map<String, String> pConfig) {
if (pConfig == null) {
return this;
} else {
Map<ConfigKey,String> newParams = new HashMap<ConfigKey, String>();
newParams.putAll(params);
newParams.putAll(convertToConfigMap(pConfig));
return new ProcessingParameters(newParams, pathInfo);
}
} | [
"public",
"ProcessingParameters",
"mergedParams",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"pConfig",
")",
"{",
"if",
"(",
"pConfig",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"else",
"{",
"Map",
"<",
"ConfigKey",
",",
"String",
">",
"n... | Merge in a configuration and return a ProcessingParameters object representing
the merged values
@param pConfig config to merge in
@return a new ProcessingParameters instance if the given config is not null. Otherwise this object
is returned. | [
"Merge",
"in",
"a",
"configuration",
"and",
"return",
"a",
"ProcessingParameters",
"object",
"representing",
"the",
"merged",
"values"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/config/ProcessingParameters.java#L70-L79 |
haraldk/TwelveMonkeys | common/common-image/src/main/java/com/twelvemonkeys/image/AreaAverageOp.java | AreaAverageOp.createCompatibleDestImage | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
ColorModel cm = destCM != null ? destCM : src.getColorModel();
return new BufferedImage(cm,
ImageUtil.createCompatibleWritableRaster(src, cm, width, height),
cm.isAlphaPremultiplied(), null);
} | java | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
ColorModel cm = destCM != null ? destCM : src.getColorModel();
return new BufferedImage(cm,
ImageUtil.createCompatibleWritableRaster(src, cm, width, height),
cm.isAlphaPremultiplied(), null);
} | [
"public",
"BufferedImage",
"createCompatibleDestImage",
"(",
"BufferedImage",
"src",
",",
"ColorModel",
"destCM",
")",
"{",
"ColorModel",
"cm",
"=",
"destCM",
"!=",
"null",
"?",
"destCM",
":",
"src",
".",
"getColorModel",
"(",
")",
";",
"return",
"new",
"Buffe... | (but are there ever any time we want to implemnet RasterOp and not BIOp?) | [
"(",
"but",
"are",
"there",
"ever",
"any",
"time",
"we",
"want",
"to",
"implemnet",
"RasterOp",
"and",
"not",
"BIOp?",
")"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/AreaAverageOp.java#L385-L390 |
aspectran/aspectran | web/src/main/java/com/aspectran/web/support/multipart/inmemory/MemoryFileItemFactory.java | MemoryFileItemFactory.createItem | public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) {
return new MemoryFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold);
} | java | public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) {
return new MemoryFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold);
} | [
"public",
"FileItem",
"createItem",
"(",
"String",
"fieldName",
",",
"String",
"contentType",
",",
"boolean",
"isFormField",
",",
"String",
"fileName",
")",
"{",
"return",
"new",
"MemoryFileItem",
"(",
"fieldName",
",",
"contentType",
",",
"isFormField",
",",
"f... | Create a new {@link MemoryFileItem} instance from the supplied parameters
and the local factory configuration.
@param fieldName the name of the form field
@param contentType the content type of the form field
@param isFormField {@code true} if this is a plain form field; {@code false} otherwise
@param fileName the name of the uploaded file, if any, as supplied by the browser or other client
@return the newly created file item | [
"Create",
"a",
"new",
"{",
"@link",
"MemoryFileItem",
"}",
"instance",
"from",
"the",
"supplied",
"parameters",
"and",
"the",
"local",
"factory",
"configuration",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/multipart/inmemory/MemoryFileItemFactory.java#L39-L41 |
cternes/openkeepass | src/main/java/de/slackspace/openkeepass/domain/KeePassHeader.java | KeePassHeader.getBytes | public byte[] getBytes() {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
stream.write(DATABASE_V2_FILE_SIGNATURE_1);
stream.write(DATABASE_V2_FILE_SIGNATURE_2);
stream.write(DATABASE_V2_FILE_VERSION);
for (int i = 2; i < 11; i++) {
byte[] headerValue = getValue(i);
// Write index
stream.write(i);
// Write length
byte[] length = new byte[] { (byte) headerValue.length, 0 };
stream.write(length);
// Write value
stream.write(headerValue);
}
// Write terminating flag
stream.write(getEndOfHeader());
return stream.toByteArray();
} catch (IOException e) {
throw new KeePassHeaderUnreadableException("Could not write header value to stream", e);
}
} | java | public byte[] getBytes() {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
stream.write(DATABASE_V2_FILE_SIGNATURE_1);
stream.write(DATABASE_V2_FILE_SIGNATURE_2);
stream.write(DATABASE_V2_FILE_VERSION);
for (int i = 2; i < 11; i++) {
byte[] headerValue = getValue(i);
// Write index
stream.write(i);
// Write length
byte[] length = new byte[] { (byte) headerValue.length, 0 };
stream.write(length);
// Write value
stream.write(headerValue);
}
// Write terminating flag
stream.write(getEndOfHeader());
return stream.toByteArray();
} catch (IOException e) {
throw new KeePassHeaderUnreadableException("Could not write header value to stream", e);
}
} | [
"public",
"byte",
"[",
"]",
"getBytes",
"(",
")",
"{",
"try",
"{",
"ByteArrayOutputStream",
"stream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"stream",
".",
"write",
"(",
"DATABASE_V2_FILE_SIGNATURE_1",
")",
";",
"stream",
".",
"write",
"(",
"DAT... | Returns the whole header as byte array.
@return header as byte array | [
"Returns",
"the",
"whole",
"header",
"as",
"byte",
"array",
"."
] | train | https://github.com/cternes/openkeepass/blob/4a354aecaea38af3c0dce5eb81b533f297e8d94f/src/main/java/de/slackspace/openkeepass/domain/KeePassHeader.java#L227-L256 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/subdoc/MutateInBuilder.java | MutateInBuilder.withDurability | public MutateInBuilder withDurability(PersistTo persistTo, ReplicateTo replicateTo) {
asyncBuilder.withDurability(persistTo, replicateTo);
return this;
} | java | public MutateInBuilder withDurability(PersistTo persistTo, ReplicateTo replicateTo) {
asyncBuilder.withDurability(persistTo, replicateTo);
return this;
} | [
"public",
"MutateInBuilder",
"withDurability",
"(",
"PersistTo",
"persistTo",
",",
"ReplicateTo",
"replicateTo",
")",
"{",
"asyncBuilder",
".",
"withDurability",
"(",
"persistTo",
",",
"replicateTo",
")",
";",
"return",
"this",
";",
"}"
] | Set both a persistence and replication durability constraints for the whole mutation.
@param persistTo the persistence durability constraint to observe.
@param replicateTo the replication durability constraint to observe.
@return this builder for chaining. | [
"Set",
"both",
"a",
"persistence",
"and",
"replication",
"durability",
"constraints",
"for",
"the",
"whole",
"mutation",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/subdoc/MutateInBuilder.java#L480-L483 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/tree/TreeElement.java | TreeElement.addChild | public void addChild(int offset, TreeElement child)
throws IllegalArgumentException
{
child.setSelected(false);
child.setParent(this);
if (_children == null)
_children = new ArrayList();
_children.add(offset, child);
//Need to rename all affected!
int size = _children.size();
for (int i = offset; i < size; i++) {
TreeElement thisChild = (TreeElement) _children.get(i);
thisChild.updateName(this, i);
}
} | java | public void addChild(int offset, TreeElement child)
throws IllegalArgumentException
{
child.setSelected(false);
child.setParent(this);
if (_children == null)
_children = new ArrayList();
_children.add(offset, child);
//Need to rename all affected!
int size = _children.size();
for (int i = offset; i < size; i++) {
TreeElement thisChild = (TreeElement) _children.get(i);
thisChild.updateName(this, i);
}
} | [
"public",
"void",
"addChild",
"(",
"int",
"offset",
",",
"TreeElement",
"child",
")",
"throws",
"IllegalArgumentException",
"{",
"child",
".",
"setSelected",
"(",
"false",
")",
";",
"child",
".",
"setParent",
"(",
"this",
")",
";",
"if",
"(",
"_children",
... | Add a new child node at the specified position in the child list.
@param offset Zero-relative offset at which the new node
should be inserted
@param child The new child node
@throws IllegalArgumentException if the name of the new child
node is not unique | [
"Add",
"a",
"new",
"child",
"node",
"at",
"the",
"specified",
"position",
"in",
"the",
"child",
"list",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/tree/TreeElement.java#L613-L629 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.