repository_name stringlengths 7 54 | func_path_in_repository stringlengths 18 196 | func_name stringlengths 7 107 | whole_func_string stringlengths 76 3.82k | language stringclasses 1
value | func_code_string stringlengths 76 3.82k | func_code_tokens listlengths 22 717 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 508 | split_name stringclasses 1
value | func_code_url stringlengths 111 310 |
|---|---|---|---|---|---|---|---|---|---|---|
albfernandez/itext2 | src/main/java/com/lowagie/text/Table.java | Table.insertTable | public void insertTable(Table aTable, Point aLocation) {
if (aTable == null) {
throw new NullPointerException("insertTable - table has null-value");
}
if (aLocation == null) {
throw new NullPointerException("insertTable - point has null-value");
}
mTableInserted = true;
aTable.complete();
if (aLocation.y > columns) {
throw new IllegalArgumentException("insertTable -- wrong columnposition("+ aLocation.y + ") of location; max =" + columns);
}
int rowCount = aLocation.x + 1 - rows.size();
int i = 0;
if ( rowCount > 0 ) { //create new rows ?
for (; i < rowCount; i++) {
rows.add(new Row(columns));
}
}
rows.get(aLocation.x).setElement(aTable,aLocation.y);
setCurrentLocationToNextValidPosition(aLocation);
} | java | public void insertTable(Table aTable, Point aLocation) {
if (aTable == null) {
throw new NullPointerException("insertTable - table has null-value");
}
if (aLocation == null) {
throw new NullPointerException("insertTable - point has null-value");
}
mTableInserted = true;
aTable.complete();
if (aLocation.y > columns) {
throw new IllegalArgumentException("insertTable -- wrong columnposition("+ aLocation.y + ") of location; max =" + columns);
}
int rowCount = aLocation.x + 1 - rows.size();
int i = 0;
if ( rowCount > 0 ) { //create new rows ?
for (; i < rowCount; i++) {
rows.add(new Row(columns));
}
}
rows.get(aLocation.x).setElement(aTable,aLocation.y);
setCurrentLocationToNextValidPosition(aLocation);
} | [
"public",
"void",
"insertTable",
"(",
"Table",
"aTable",
",",
"Point",
"aLocation",
")",
"{",
"if",
"(",
"aTable",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"insertTable - table has null-value\"",
")",
";",
"}",
"if",
"(",
"aLocati... | To put a table within the existing table at the given position
generateTable will of course re-arrange the widths of the columns.
@param aTable the table you want to insert
@param aLocation a <CODE>Point</CODE> | [
"To",
"put",
"a",
"table",
"within",
"the",
"existing",
"table",
"at",
"the",
"given",
"position",
"generateTable",
"will",
"of",
"course",
"re",
"-",
"arrange",
"the",
"widths",
"of",
"the",
"columns",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Table.java#L820-L846 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/TimeZoneGenericNames.java | TimeZoneGenericNames.createGenericMatchInfo | private GenericMatchInfo createGenericMatchInfo(MatchInfo matchInfo) {
GenericNameType nameType = null;
TimeType timeType = TimeType.UNKNOWN;
switch (matchInfo.nameType()) {
case LONG_STANDARD:
nameType = GenericNameType.LONG;
timeType = TimeType.STANDARD;
break;
case LONG_GENERIC:
nameType = GenericNameType.LONG;
break;
case SHORT_STANDARD:
nameType = GenericNameType.SHORT;
timeType = TimeType.STANDARD;
break;
case SHORT_GENERIC:
nameType = GenericNameType.SHORT;
break;
default:
throw new IllegalArgumentException("Unexpected MatchInfo name type - " + matchInfo.nameType());
}
String tzID = matchInfo.tzID();
if (tzID == null) {
String mzID = matchInfo.mzID();
assert(mzID != null);
tzID = _tznames.getReferenceZoneID(mzID, getTargetRegion());
}
assert(tzID != null);
GenericMatchInfo gmatch = new GenericMatchInfo(nameType, tzID, matchInfo.matchLength(), timeType);
return gmatch;
} | java | private GenericMatchInfo createGenericMatchInfo(MatchInfo matchInfo) {
GenericNameType nameType = null;
TimeType timeType = TimeType.UNKNOWN;
switch (matchInfo.nameType()) {
case LONG_STANDARD:
nameType = GenericNameType.LONG;
timeType = TimeType.STANDARD;
break;
case LONG_GENERIC:
nameType = GenericNameType.LONG;
break;
case SHORT_STANDARD:
nameType = GenericNameType.SHORT;
timeType = TimeType.STANDARD;
break;
case SHORT_GENERIC:
nameType = GenericNameType.SHORT;
break;
default:
throw new IllegalArgumentException("Unexpected MatchInfo name type - " + matchInfo.nameType());
}
String tzID = matchInfo.tzID();
if (tzID == null) {
String mzID = matchInfo.mzID();
assert(mzID != null);
tzID = _tznames.getReferenceZoneID(mzID, getTargetRegion());
}
assert(tzID != null);
GenericMatchInfo gmatch = new GenericMatchInfo(nameType, tzID, matchInfo.matchLength(), timeType);
return gmatch;
} | [
"private",
"GenericMatchInfo",
"createGenericMatchInfo",
"(",
"MatchInfo",
"matchInfo",
")",
"{",
"GenericNameType",
"nameType",
"=",
"null",
";",
"TimeType",
"timeType",
"=",
"TimeType",
".",
"UNKNOWN",
";",
"switch",
"(",
"matchInfo",
".",
"nameType",
"(",
")",
... | Returns a <code>GenericMatchInfo</code> for the given <code>MatchInfo</code>.
@param matchInfo the MatchInfo
@return A GenericMatchInfo | [
"Returns",
"a",
"<code",
">",
"GenericMatchInfo<",
"/",
"code",
">",
"for",
"the",
"given",
"<code",
">",
"MatchInfo<",
"/",
"code",
">",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/TimeZoneGenericNames.java#L796-L829 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java | BeetlUtil.render | public static String render(Template template, Map<String, Object> bindingMap) {
template.binding(bindingMap);
return template.render();
} | java | public static String render(Template template, Map<String, Object> bindingMap) {
template.binding(bindingMap);
return template.render();
} | [
"public",
"static",
"String",
"render",
"(",
"Template",
"template",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"bindingMap",
")",
"{",
"template",
".",
"binding",
"(",
"bindingMap",
")",
";",
"return",
"template",
".",
"render",
"(",
")",
";",
"}"
] | 渲染模板
@param template {@link Template}
@param bindingMap 绑定参数
@return 渲染后的内容 | [
"渲染模板"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java#L181-L184 |
jillesvangurp/jsonj | src/main/java/com/github/jsonj/tools/JsonBuilder.java | JsonBuilder.putArray | public @Nonnull JsonBuilder putArray(String key, String... values) {
JsonArray jjArray = new JsonArray();
for (String string : values) {
jjArray.add(primitive(string));
}
object.put(key, jjArray);
return this;
} | java | public @Nonnull JsonBuilder putArray(String key, String... values) {
JsonArray jjArray = new JsonArray();
for (String string : values) {
jjArray.add(primitive(string));
}
object.put(key, jjArray);
return this;
} | [
"public",
"@",
"Nonnull",
"JsonBuilder",
"putArray",
"(",
"String",
"key",
",",
"String",
"...",
"values",
")",
"{",
"JsonArray",
"jjArray",
"=",
"new",
"JsonArray",
"(",
")",
";",
"for",
"(",
"String",
"string",
":",
"values",
")",
"{",
"jjArray",
".",
... | Add a JsonArray to the object with the string values added.
@param key key
@param values one or more {@link String} values
values that go in the array
@return the builder | [
"Add",
"a",
"JsonArray",
"to",
"the",
"object",
"with",
"the",
"string",
"values",
"added",
"."
] | train | https://github.com/jillesvangurp/jsonj/blob/1da0c44c5bdb60c0cd806c48d2da5a8a75bf84af/src/main/java/com/github/jsonj/tools/JsonBuilder.java#L125-L132 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/event/CopySoundexHandler.java | CopySoundexHandler.syncClonedListener | public boolean syncClonedListener(BaseField field, FieldListener listener, boolean bInitCalled)
{
if (!bInitCalled)
((CopySoundexHandler)listener).init(null, m_iFieldSeq);
return super.syncClonedListener(field, listener, true);
} | java | public boolean syncClonedListener(BaseField field, FieldListener listener, boolean bInitCalled)
{
if (!bInitCalled)
((CopySoundexHandler)listener).init(null, m_iFieldSeq);
return super.syncClonedListener(field, listener, true);
} | [
"public",
"boolean",
"syncClonedListener",
"(",
"BaseField",
"field",
",",
"FieldListener",
"listener",
",",
"boolean",
"bInitCalled",
")",
"{",
"if",
"(",
"!",
"bInitCalled",
")",
"(",
"(",
"CopySoundexHandler",
")",
"listener",
")",
".",
"init",
"(",
"null",... | Set this cloned listener to the same state at this listener.
@param field The field this new listener will be added to.
@param The new listener to sync to this.
@param Has the init method been called?
@return True if I called init. | [
"Set",
"this",
"cloned",
"listener",
"to",
"the",
"same",
"state",
"at",
"this",
"listener",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/CopySoundexHandler.java#L63-L68 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/SharesInner.java | SharesInner.getAsync | public Observable<ShareInner> getAsync(String deviceName, String name, String resourceGroupName) {
return getWithServiceResponseAsync(deviceName, name, resourceGroupName).map(new Func1<ServiceResponse<ShareInner>, ShareInner>() {
@Override
public ShareInner call(ServiceResponse<ShareInner> response) {
return response.body();
}
});
} | java | public Observable<ShareInner> getAsync(String deviceName, String name, String resourceGroupName) {
return getWithServiceResponseAsync(deviceName, name, resourceGroupName).map(new Func1<ServiceResponse<ShareInner>, ShareInner>() {
@Override
public ShareInner call(ServiceResponse<ShareInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ShareInner",
">",
"getAsync",
"(",
"String",
"deviceName",
",",
"String",
"name",
",",
"String",
"resourceGroupName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"deviceName",
",",
"name",
",",
"resourceGroupName",
")",
".... | Gets a share by name.
@param deviceName The device name.
@param name The share name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ShareInner object | [
"Gets",
"a",
"share",
"by",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/SharesInner.java#L264-L271 |
alkacon/opencms-core | src/org/opencms/security/CmsRoleManager.java | CmsRoleManager.hasRoleForResource | public boolean hasRoleForResource(CmsObject cms, CmsRole role, String resourceName) {
CmsResource resource;
try {
resource = cms.readResource(resourceName, CmsResourceFilter.ALL);
} catch (CmsException e) {
// ignore
return false;
}
return m_securityManager.hasRoleForResource(
cms.getRequestContext(),
cms.getRequestContext().getCurrentUser(),
role,
resource);
} | java | public boolean hasRoleForResource(CmsObject cms, CmsRole role, String resourceName) {
CmsResource resource;
try {
resource = cms.readResource(resourceName, CmsResourceFilter.ALL);
} catch (CmsException e) {
// ignore
return false;
}
return m_securityManager.hasRoleForResource(
cms.getRequestContext(),
cms.getRequestContext().getCurrentUser(),
role,
resource);
} | [
"public",
"boolean",
"hasRoleForResource",
"(",
"CmsObject",
"cms",
",",
"CmsRole",
"role",
",",
"String",
"resourceName",
")",
"{",
"CmsResource",
"resource",
";",
"try",
"{",
"resource",
"=",
"cms",
".",
"readResource",
"(",
"resourceName",
",",
"CmsResourceFi... | Checks if the given context user has the given role for the given resource.<p>
@param cms the opencms context
@param role the role to check
@param resourceName the name of the resource to check
@return <code>true</code> if the given context user has the given role for the given resource | [
"Checks",
"if",
"the",
"given",
"context",
"user",
"has",
"the",
"given",
"role",
"for",
"the",
"given",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/security/CmsRoleManager.java#L479-L493 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java | IndexHeapMemoryCostUtil.estimateMapCost | public static long estimateMapCost(long size, boolean ordered, boolean usesCachedQueryableEntries) {
long mapCost;
if (ordered) {
mapCost = BASE_CONCURRENT_SKIP_LIST_MAP_COST + size * CONCURRENT_SKIP_LIST_MAP_ENTRY_COST;
} else {
mapCost = BASE_CONCURRENT_HASH_MAP_COST + size * CONCURRENT_HASH_MAP_ENTRY_COST;
}
long queryableEntriesCost;
if (usesCachedQueryableEntries) {
queryableEntriesCost = size * CACHED_QUERYABLE_ENTRY_COST;
} else {
queryableEntriesCost = size * QUERY_ENTRY_COST;
}
return mapCost + queryableEntriesCost;
} | java | public static long estimateMapCost(long size, boolean ordered, boolean usesCachedQueryableEntries) {
long mapCost;
if (ordered) {
mapCost = BASE_CONCURRENT_SKIP_LIST_MAP_COST + size * CONCURRENT_SKIP_LIST_MAP_ENTRY_COST;
} else {
mapCost = BASE_CONCURRENT_HASH_MAP_COST + size * CONCURRENT_HASH_MAP_ENTRY_COST;
}
long queryableEntriesCost;
if (usesCachedQueryableEntries) {
queryableEntriesCost = size * CACHED_QUERYABLE_ENTRY_COST;
} else {
queryableEntriesCost = size * QUERY_ENTRY_COST;
}
return mapCost + queryableEntriesCost;
} | [
"public",
"static",
"long",
"estimateMapCost",
"(",
"long",
"size",
",",
"boolean",
"ordered",
",",
"boolean",
"usesCachedQueryableEntries",
")",
"{",
"long",
"mapCost",
";",
"if",
"(",
"ordered",
")",
"{",
"mapCost",
"=",
"BASE_CONCURRENT_SKIP_LIST_MAP_COST",
"+"... | Estimates the on-heap memory cost of a map backing an index.
@param size the size of the map to estimate the cost
of.
@param ordered {@code true} if the index managing the
map being estimated is ordered, {@code
false} otherwise.
@param usesCachedQueryableEntries {@code true} if queryable entries indexed
by the associated index are cached, {@code
false} otherwise.
@return the estimated map cost. | [
"Estimates",
"the",
"on",
"-",
"heap",
"memory",
"cost",
"of",
"a",
"map",
"backing",
"an",
"index",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/IndexHeapMemoryCostUtil.java#L135-L151 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ClassUtils.java | ClassUtils.isAnnotationPresent | @NullSafe
public static boolean isAnnotationPresent(Class<? extends Annotation> annotation, AnnotatedElement... members) {
return stream(ArrayUtils.nullSafeArray(members, AnnotatedElement.class))
.anyMatch(member -> member != null && member.isAnnotationPresent(annotation));
} | java | @NullSafe
public static boolean isAnnotationPresent(Class<? extends Annotation> annotation, AnnotatedElement... members) {
return stream(ArrayUtils.nullSafeArray(members, AnnotatedElement.class))
.anyMatch(member -> member != null && member.isAnnotationPresent(annotation));
} | [
"@",
"NullSafe",
"public",
"static",
"boolean",
"isAnnotationPresent",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
",",
"AnnotatedElement",
"...",
"members",
")",
"{",
"return",
"stream",
"(",
"ArrayUtils",
".",
"nullSafeArray",
"(",
"mem... | Determines whether the specified Annotation meta-data is present on the given "annotated" members,
such as fields and methods.
@param annotation the Annotation used in the detection for presence on the given members.
@param members the members of a class type or object to inspect for the presence of the specified Annotation.
@return a boolean value indicating whether the specified Annotation is present on any of the given members.
@see java.lang.annotation.Annotation
@see java.lang.reflect.AccessibleObject#isAnnotationPresent(Class) | [
"Determines",
"whether",
"the",
"specified",
"Annotation",
"meta",
"-",
"data",
"is",
"present",
"on",
"the",
"given",
"annotated",
"members",
"such",
"as",
"fields",
"and",
"methods",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ClassUtils.java#L592-L596 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java | HtmlTree.A_ID | public static HtmlTree A_ID(HtmlStyle styleClass, String id, Content body) {
HtmlTree htmltree = A_ID(id, body);
if (styleClass != null)
htmltree.addStyle(styleClass);
return htmltree;
} | java | public static HtmlTree A_ID(HtmlStyle styleClass, String id, Content body) {
HtmlTree htmltree = A_ID(id, body);
if (styleClass != null)
htmltree.addStyle(styleClass);
return htmltree;
} | [
"public",
"static",
"HtmlTree",
"A_ID",
"(",
"HtmlStyle",
"styleClass",
",",
"String",
"id",
",",
"Content",
"body",
")",
"{",
"HtmlTree",
"htmltree",
"=",
"A_ID",
"(",
"id",
",",
"body",
")",
";",
"if",
"(",
"styleClass",
"!=",
"null",
")",
"htmltree",
... | Generates an HTML anchor tag with a style class, id attribute and a body.
@param styleClass stylesheet class for the tag
@param id id for the anchor tag
@param body body for the anchor tag
@return an HtmlTree object | [
"Generates",
"an",
"HTML",
"anchor",
"tag",
"with",
"a",
"style",
"class",
"id",
"attribute",
"and",
"a",
"body",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java#L275-L280 |
SonarSource/sonarqube | server/sonar-server-common/src/main/java/org/sonar/server/log/ServerProcessLogging.java | ServerProcessLogging.configureDirectToConsoleLoggers | private void configureDirectToConsoleLoggers(LoggerContext context, String... loggerNames) {
RootLoggerConfig config = newRootLoggerConfigBuilder()
.setProcessId(ProcessId.APP)
.setThreadIdFieldPattern("")
.build();
String logPattern = helper.buildLogPattern(config);
ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", logPattern);
for (String loggerName : loggerNames) {
Logger consoleLogger = context.getLogger(loggerName);
consoleLogger.setAdditive(false);
consoleLogger.addAppender(consoleAppender);
}
} | java | private void configureDirectToConsoleLoggers(LoggerContext context, String... loggerNames) {
RootLoggerConfig config = newRootLoggerConfigBuilder()
.setProcessId(ProcessId.APP)
.setThreadIdFieldPattern("")
.build();
String logPattern = helper.buildLogPattern(config);
ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", logPattern);
for (String loggerName : loggerNames) {
Logger consoleLogger = context.getLogger(loggerName);
consoleLogger.setAdditive(false);
consoleLogger.addAppender(consoleAppender);
}
} | [
"private",
"void",
"configureDirectToConsoleLoggers",
"(",
"LoggerContext",
"context",
",",
"String",
"...",
"loggerNames",
")",
"{",
"RootLoggerConfig",
"config",
"=",
"newRootLoggerConfigBuilder",
"(",
")",
".",
"setProcessId",
"(",
"ProcessId",
".",
"APP",
")",
"... | Setup one or more specified loggers to be non additive and to print to System.out which will be caught by the Main
Process and written to sonar.log. | [
"Setup",
"one",
"or",
"more",
"specified",
"loggers",
"to",
"be",
"non",
"additive",
"and",
"to",
"print",
"to",
"System",
".",
"out",
"which",
"will",
"be",
"caught",
"by",
"the",
"Main",
"Process",
"and",
"written",
"to",
"sonar",
".",
"log",
"."
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/log/ServerProcessLogging.java#L140-L153 |
leadware/jpersistence-tools | jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/utils/DAOValidatorHelper.java | DAOValidatorHelper.isExpressionContainsFunction | public static boolean isExpressionContainsFunction(String expression) {
// Si la chaine est vide : false
if(expression == null || expression.trim().length() == 0) {
// On retourne false
return false;
}
// On split
return isExpressionContainPattern(expression, FUNC_CHAIN_PATTERN);
} | java | public static boolean isExpressionContainsFunction(String expression) {
// Si la chaine est vide : false
if(expression == null || expression.trim().length() == 0) {
// On retourne false
return false;
}
// On split
return isExpressionContainPattern(expression, FUNC_CHAIN_PATTERN);
} | [
"public",
"static",
"boolean",
"isExpressionContainsFunction",
"(",
"String",
"expression",
")",
"{",
"// Si la chaine est vide : false\r",
"if",
"(",
"expression",
"==",
"null",
"||",
"expression",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",... | Methode permettant de verifier si un chemin contient des Fonctions
@param expression Chaine a controler
@return Resultat de la verification | [
"Methode",
"permettant",
"de",
"verifier",
"si",
"un",
"chemin",
"contient",
"des",
"Fonctions"
] | train | https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/utils/DAOValidatorHelper.java#L554-L565 |
vlingo/vlingo-actors | src/main/java/io/vlingo/actors/Stage.java | Stage.allocateMailbox | private Mailbox allocateMailbox(final Definition definition, final Address address, final Mailbox maybeMailbox) {
final Mailbox mailbox = maybeMailbox != null ?
maybeMailbox : ActorFactory.actorMailbox(this, address, definition);
return mailbox;
} | java | private Mailbox allocateMailbox(final Definition definition, final Address address, final Mailbox maybeMailbox) {
final Mailbox mailbox = maybeMailbox != null ?
maybeMailbox : ActorFactory.actorMailbox(this, address, definition);
return mailbox;
} | [
"private",
"Mailbox",
"allocateMailbox",
"(",
"final",
"Definition",
"definition",
",",
"final",
"Address",
"address",
",",
"final",
"Mailbox",
"maybeMailbox",
")",
"{",
"final",
"Mailbox",
"mailbox",
"=",
"maybeMailbox",
"!=",
"null",
"?",
"maybeMailbox",
":",
... | Answers a Mailbox for an Actor. If maybeMailbox is allocated answer it; otherwise
answer a newly allocated Mailbox. (INTERNAL ONLY)
@param definition the Definition of the newly created Actor
@param address the Address allocated to the Actor
@param maybeMailbox the possible Mailbox
@return Mailbox | [
"Answers",
"a",
"Mailbox",
"for",
"an",
"Actor",
".",
"If",
"maybeMailbox",
"is",
"allocated",
"answer",
"it",
";",
"otherwise",
"answer",
"a",
"newly",
"allocated",
"Mailbox",
".",
"(",
"INTERNAL",
"ONLY",
")"
] | train | https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/Stage.java#L573-L577 |
google/closure-compiler | src/com/google/javascript/jscomp/parsing/parser/Parser.java | Parser.reportError | @FormatMethod
private void reportError(Token token, @FormatString String message, Object... arguments) {
if (token == null) {
reportError(message, arguments);
} else {
errorReporter.reportError(token.getStart(), message, arguments);
}
} | java | @FormatMethod
private void reportError(Token token, @FormatString String message, Object... arguments) {
if (token == null) {
reportError(message, arguments);
} else {
errorReporter.reportError(token.getStart(), message, arguments);
}
} | [
"@",
"FormatMethod",
"private",
"void",
"reportError",
"(",
"Token",
"token",
",",
"@",
"FormatString",
"String",
"message",
",",
"Object",
"...",
"arguments",
")",
"{",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"reportError",
"(",
"message",
",",
"argum... | Reports an error message at a given token.
@param token The location to report the message at.
@param message The message to report in String.format style.
@param arguments The arguments to fill in the message format. | [
"Reports",
"an",
"error",
"message",
"at",
"a",
"given",
"token",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/parser/Parser.java#L4227-L4234 |
WiQuery/wiquery | wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/position/PositionAlignmentOptions.java | PositionAlignmentOptions.setVerticalAlignment | public PositionAlignmentOptions setVerticalAlignment(PositionRelation verticalAlignment, int offsetTop)
{
switch (verticalAlignment)
{
case TOP:
case CENTER:
case BOTTOM:
break;
default:
throw new IllegalArgumentException("Illegal value for the vertical alignment property");
}
this.verticalAlignment = verticalAlignment;
this.offsetTop = offsetTop;
return this;
} | java | public PositionAlignmentOptions setVerticalAlignment(PositionRelation verticalAlignment, int offsetTop)
{
switch (verticalAlignment)
{
case TOP:
case CENTER:
case BOTTOM:
break;
default:
throw new IllegalArgumentException("Illegal value for the vertical alignment property");
}
this.verticalAlignment = verticalAlignment;
this.offsetTop = offsetTop;
return this;
} | [
"public",
"PositionAlignmentOptions",
"setVerticalAlignment",
"(",
"PositionRelation",
"verticalAlignment",
",",
"int",
"offsetTop",
")",
"{",
"switch",
"(",
"verticalAlignment",
")",
"{",
"case",
"TOP",
":",
"case",
"CENTER",
":",
"case",
"BOTTOM",
":",
"break",
... | Set the verticalAlignment property with an offset. One of TOP, CENTER, BOTTOM.
@param verticalAlignment
@param offsetTop
@return the instance | [
"Set",
"the",
"verticalAlignment",
"property",
"with",
"an",
"offset",
".",
"One",
"of",
"TOP",
"CENTER",
"BOTTOM",
"."
] | train | https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/position/PositionAlignmentOptions.java#L289-L304 |
redlink-gmbh/redlink-java-sdk | src/main/java/io/redlink/sdk/impl/analysis/model/Enhancements.java | Enhancements.getBestAnnotations | public Multimap<TextAnnotation, EntityAnnotation> getBestAnnotations() {
Ordering<EntityAnnotation> o = new Ordering<EntityAnnotation>() {
@Override
public int compare(EntityAnnotation left, EntityAnnotation right) {
return Doubles.compare(left.confidence, right.confidence);
}
}.reverse();
Multimap<TextAnnotation, EntityAnnotation> result = ArrayListMultimap.create();
for (TextAnnotation ta : getTextAnnotations()) {
List<EntityAnnotation> eas = o.sortedCopy(getEntityAnnotations(ta));
if (!eas.isEmpty()) {
Collection<EntityAnnotation> highest = new HashSet<>();
Double confidence = eas.get(0).getConfidence();
for (EntityAnnotation ea : eas) {
if (ea.confidence < confidence) {
break;
} else {
highest.add(ea);
}
}
result.putAll(ta, highest);
}
}
return result;
} | java | public Multimap<TextAnnotation, EntityAnnotation> getBestAnnotations() {
Ordering<EntityAnnotation> o = new Ordering<EntityAnnotation>() {
@Override
public int compare(EntityAnnotation left, EntityAnnotation right) {
return Doubles.compare(left.confidence, right.confidence);
}
}.reverse();
Multimap<TextAnnotation, EntityAnnotation> result = ArrayListMultimap.create();
for (TextAnnotation ta : getTextAnnotations()) {
List<EntityAnnotation> eas = o.sortedCopy(getEntityAnnotations(ta));
if (!eas.isEmpty()) {
Collection<EntityAnnotation> highest = new HashSet<>();
Double confidence = eas.get(0).getConfidence();
for (EntityAnnotation ea : eas) {
if (ea.confidence < confidence) {
break;
} else {
highest.add(ea);
}
}
result.putAll(ta, highest);
}
}
return result;
} | [
"public",
"Multimap",
"<",
"TextAnnotation",
",",
"EntityAnnotation",
">",
"getBestAnnotations",
"(",
")",
"{",
"Ordering",
"<",
"EntityAnnotation",
">",
"o",
"=",
"new",
"Ordering",
"<",
"EntityAnnotation",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int"... | Returns the best {@link EntityAnnotation}s (those with the highest confidence value) for each extracted {@link TextAnnotation}
@return best annotations | [
"Returns",
"the",
"best",
"{",
"@link",
"EntityAnnotation",
"}",
"s",
"(",
"those",
"with",
"the",
"highest",
"confidence",
"value",
")",
"for",
"each",
"extracted",
"{",
"@link",
"TextAnnotation",
"}"
] | train | https://github.com/redlink-gmbh/redlink-java-sdk/blob/c412ff11bd80da52ade09f2483ab29cdbff5a28a/src/main/java/io/redlink/sdk/impl/analysis/model/Enhancements.java#L292-L319 |
google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createAsyncGeneratorWrapperReference | Node createAsyncGeneratorWrapperReference(JSType originalFunctionType, Scope scope) {
Node ctor = createQName(scope, "$jscomp.AsyncGeneratorWrapper");
if (isAddingTypes() && !ctor.getJSType().isUnknownType()) {
// if ctor has the unknown type, we must have not injected the required runtime
// libraries - hopefully because this is in a test using NonInjectingCompiler.
// e.g get `number` from `AsyncIterable<number>`
JSType yieldedType =
originalFunctionType
.toMaybeFunctionType()
.getReturnType()
.getInstantiatedTypeArgument(getNativeType(JSTypeNative.ASYNC_ITERABLE_TYPE));
// e.g. replace
// AsyncGeneratorWrapper<T>
// with
// AsyncGeneratorWrapper<number>
ctor.setJSType(replaceTemplate(ctor.getJSType(), yieldedType));
}
return ctor;
} | java | Node createAsyncGeneratorWrapperReference(JSType originalFunctionType, Scope scope) {
Node ctor = createQName(scope, "$jscomp.AsyncGeneratorWrapper");
if (isAddingTypes() && !ctor.getJSType().isUnknownType()) {
// if ctor has the unknown type, we must have not injected the required runtime
// libraries - hopefully because this is in a test using NonInjectingCompiler.
// e.g get `number` from `AsyncIterable<number>`
JSType yieldedType =
originalFunctionType
.toMaybeFunctionType()
.getReturnType()
.getInstantiatedTypeArgument(getNativeType(JSTypeNative.ASYNC_ITERABLE_TYPE));
// e.g. replace
// AsyncGeneratorWrapper<T>
// with
// AsyncGeneratorWrapper<number>
ctor.setJSType(replaceTemplate(ctor.getJSType(), yieldedType));
}
return ctor;
} | [
"Node",
"createAsyncGeneratorWrapperReference",
"(",
"JSType",
"originalFunctionType",
",",
"Scope",
"scope",
")",
"{",
"Node",
"ctor",
"=",
"createQName",
"(",
"scope",
",",
"\"$jscomp.AsyncGeneratorWrapper\"",
")",
";",
"if",
"(",
"isAddingTypes",
"(",
")",
"&&",
... | Creates a reference to $jscomp.AsyncGeneratorWrapper with the template filled in to match the
original function.
@param originalFunctionType the type of the async generator function that needs transpilation | [
"Creates",
"a",
"reference",
"to",
"$jscomp",
".",
"AsyncGeneratorWrapper",
"with",
"the",
"template",
"filled",
"in",
"to",
"match",
"the",
"original",
"function",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L903-L925 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/PhotosGeoApi.java | PhotosGeoApi.setPerms | public Response setPerms(String photoId, boolean isPublic, boolean isContact, boolean isFriend, boolean isFamily) throws JinxException {
JinxUtils.validateParams(photoId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.geo.setPerms");
params.put("photo_id", photoId);
params.put("is_public", isPublic ? "1" : "0");
params.put("is_contact", isContact ? "1" : "0");
params.put("is_friend", isFriend ? "1" : "0");
params.put("is_family", isFamily ? "1" : "0");
return jinx.flickrPost(params, Response.class);
} | java | public Response setPerms(String photoId, boolean isPublic, boolean isContact, boolean isFriend, boolean isFamily) throws JinxException {
JinxUtils.validateParams(photoId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.geo.setPerms");
params.put("photo_id", photoId);
params.put("is_public", isPublic ? "1" : "0");
params.put("is_contact", isContact ? "1" : "0");
params.put("is_friend", isFriend ? "1" : "0");
params.put("is_family", isFamily ? "1" : "0");
return jinx.flickrPost(params, Response.class);
} | [
"public",
"Response",
"setPerms",
"(",
"String",
"photoId",
",",
"boolean",
"isPublic",
",",
"boolean",
"isContact",
",",
"boolean",
"isFriend",
",",
"boolean",
"isFamily",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"photoId",
... | Set the permission for who may view the geo data associated with a photo.
<br>
This method requires authentication with 'write' permission.
@param photoId (Required) The id of the photo to set permissions for.
@param isPublic viewing permissions for the photo location data to public.
@param isContact viewing permissions for the photo location data to contacts.
@param isFriend viewing permissions for the photo location data to friends.
@param isFamily viewing permissions for the photo location data to family.
@return object with the status of the requested operation.
@throws JinxException if required parameters are missing, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.geo.setPerms.html">flickr.photos.geo.setPerms</a> | [
"Set",
"the",
"permission",
"for",
"who",
"may",
"view",
"the",
"geo",
"data",
"associated",
"with",
"a",
"photo",
".",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"write",
"permission",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/PhotosGeoApi.java#L281-L291 |
sebastiangraf/jSCSI | bundles/initiator/src/main/java/org/jscsi/initiator/Configuration.java | Configuration.getSetting | public final String getSetting (final String targetName, final int connectionID, final OperationalTextKey textKey) throws OperationalTextKeyException {
try {
final SessionConfiguration sc;
synchronized (sessionConfigs) {
sc = sessionConfigs.get(targetName);
synchronized (sc) {
if (sc != null) {
String value = sc.getSetting(connectionID, textKey);
if (value != null) { return value; }
}
}
}
} catch (OperationalTextKeyException e) {
// we had not find a session/connection entry, so we have to search
// in the
// global settings
}
final SettingEntry se;
synchronized (globalConfig) {
se = globalConfig.get(textKey);
synchronized (se) {
if (se != null) { return se.getValue(); }
}
}
throw new OperationalTextKeyException("No OperationalTextKey entry found for key: " + textKey.value());
} | java | public final String getSetting (final String targetName, final int connectionID, final OperationalTextKey textKey) throws OperationalTextKeyException {
try {
final SessionConfiguration sc;
synchronized (sessionConfigs) {
sc = sessionConfigs.get(targetName);
synchronized (sc) {
if (sc != null) {
String value = sc.getSetting(connectionID, textKey);
if (value != null) { return value; }
}
}
}
} catch (OperationalTextKeyException e) {
// we had not find a session/connection entry, so we have to search
// in the
// global settings
}
final SettingEntry se;
synchronized (globalConfig) {
se = globalConfig.get(textKey);
synchronized (se) {
if (se != null) { return se.getValue(); }
}
}
throw new OperationalTextKeyException("No OperationalTextKey entry found for key: " + textKey.value());
} | [
"public",
"final",
"String",
"getSetting",
"(",
"final",
"String",
"targetName",
",",
"final",
"int",
"connectionID",
",",
"final",
"OperationalTextKey",
"textKey",
")",
"throws",
"OperationalTextKeyException",
"{",
"try",
"{",
"final",
"SessionConfiguration",
"sc",
... | Returns the value of a single parameter, instead of all values.
@param targetName Name of the iSCSI Target to connect.
@param connectionID The ID of the connection to retrieve.
@param textKey The name of the parameter.
@return The value of the given parameter.
@throws OperationalTextKeyException If the given parameter cannot be found. | [
"Returns",
"the",
"value",
"of",
"a",
"single",
"parameter",
"instead",
"of",
"all",
"values",
"."
] | train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/initiator/src/main/java/org/jscsi/initiator/Configuration.java#L205-L235 |
bbottema/simple-java-mail | modules/core-module/src/main/java/org/simplejavamail/config/ConfigLoader.java | ConfigLoader.loadProperties | public static synchronized Map<Property, Object> loadProperties(final @Nullable InputStream inputStream, final boolean addProperties) {
final Properties prop = new Properties();
try {
prop.load(checkArgumentNotEmpty(inputStream, "InputStream was null"));
} catch (final IOException e) {
throw new IllegalStateException("error reading properties file from inputstream", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
if (!addProperties) {
RESOLVED_PROPERTIES.clear();
}
RESOLVED_PROPERTIES.putAll(readProperties(prop));
return unmodifiableMap(RESOLVED_PROPERTIES);
} | java | public static synchronized Map<Property, Object> loadProperties(final @Nullable InputStream inputStream, final boolean addProperties) {
final Properties prop = new Properties();
try {
prop.load(checkArgumentNotEmpty(inputStream, "InputStream was null"));
} catch (final IOException e) {
throw new IllegalStateException("error reading properties file from inputstream", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
if (!addProperties) {
RESOLVED_PROPERTIES.clear();
}
RESOLVED_PROPERTIES.putAll(readProperties(prop));
return unmodifiableMap(RESOLVED_PROPERTIES);
} | [
"public",
"static",
"synchronized",
"Map",
"<",
"Property",
",",
"Object",
">",
"loadProperties",
"(",
"final",
"@",
"Nullable",
"InputStream",
"inputStream",
",",
"final",
"boolean",
"addProperties",
")",
"{",
"final",
"Properties",
"prop",
"=",
"new",
"Propert... | Loads properties from {@link InputStream}. Calling this method only has effect on new Email and Mailer instances after this.
@param inputStream Source of property key=value pairs separated by newline \n characters.
@param addProperties Flag to indicate if the new properties should be added or replacing the old properties.
@return The updated properties map that is used internally. | [
"Loads",
"properties",
"from",
"{",
"@link",
"InputStream",
"}",
".",
"Calling",
"this",
"method",
"only",
"has",
"effect",
"on",
"new",
"Email",
"and",
"Mailer",
"instances",
"after",
"this",
"."
] | train | https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/core-module/src/main/java/org/simplejavamail/config/ConfigLoader.java#L260-L282 |
google/auto | common/src/main/java/com/google/auto/common/MoreElements.java | MoreElements.getLocalAndInheritedMethods | public static ImmutableSet<ExecutableElement> getLocalAndInheritedMethods(
TypeElement type, Types typeUtils, Elements elementUtils) {
return getLocalAndInheritedMethods(type, new ExplicitOverrides(typeUtils));
} | java | public static ImmutableSet<ExecutableElement> getLocalAndInheritedMethods(
TypeElement type, Types typeUtils, Elements elementUtils) {
return getLocalAndInheritedMethods(type, new ExplicitOverrides(typeUtils));
} | [
"public",
"static",
"ImmutableSet",
"<",
"ExecutableElement",
">",
"getLocalAndInheritedMethods",
"(",
"TypeElement",
"type",
",",
"Types",
"typeUtils",
",",
"Elements",
"elementUtils",
")",
"{",
"return",
"getLocalAndInheritedMethods",
"(",
"type",
",",
"new",
"Expli... | Returns the set of all non-private methods from {@code type}, including methods that it
inherits from its ancestors. Inherited methods that are overridden are not included in the
result. So if {@code type} defines {@code public String toString()}, the returned set will
contain that method, but not the {@code toString()} method defined by {@code Object}.
<p>The returned set may contain more than one method with the same signature, if
{@code type} inherits those methods from different ancestors. For example, if it
inherits from unrelated interfaces {@code One} and {@code Two} which each define
{@code void foo();}, and if it does not itself override the {@code foo()} method,
then both {@code One.foo()} and {@code Two.foo()} will be in the returned set.
@param type the type whose own and inherited methods are to be returned
@param typeUtils a {@link Types} object, typically returned by
{@link javax.annotation.processing.AbstractProcessor#processingEnv processingEnv}<!--
-->.{@link javax.annotation.processing.ProcessingEnvironment#getTypeUtils
getTypeUtils()}
@param elementUtils an {@link Elements} object, typically returned by
{@link javax.annotation.processing.AbstractProcessor#processingEnv processingEnv}<!--
-->.{@link javax.annotation.processing.ProcessingEnvironment#getElementUtils
getElementUtils()} | [
"Returns",
"the",
"set",
"of",
"all",
"non",
"-",
"private",
"methods",
"from",
"{",
"@code",
"type",
"}",
"including",
"methods",
"that",
"it",
"inherits",
"from",
"its",
"ancestors",
".",
"Inherited",
"methods",
"that",
"are",
"overridden",
"are",
"not",
... | train | https://github.com/google/auto/blob/4158a5fa71f1ef763e683b627f4d29bc04cfde9d/common/src/main/java/com/google/auto/common/MoreElements.java#L329-L332 |
apache/incubator-gobblin | gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java | GobblinServiceJobScheduler.scheduleSpecsFromCatalog | private void scheduleSpecsFromCatalog() {
Iterator<URI> specUris = null;
long startTime = System.currentTimeMillis();
try {
specUris = this.flowCatalog.get().getSpecURIs();
} catch (SpecSerDeException ssde) {
throw new RuntimeException("Failed to get the iterator of all Spec URIS", ssde);
}
try {
while (specUris.hasNext()) {
Spec spec = null;
try {
spec = this.flowCatalog.get().getSpec(specUris.next());
} catch (SpecNotFoundException snfe) {
_log.error(String.format("The URI %s discovered in SpecStore is missing in FlowCatlog"
+ ", suspecting current modification on SpecStore", specUris.next()), snfe);
}
//Disable FLOW_RUN_IMMEDIATELY on service startup or leadership change
if (spec instanceof FlowSpec) {
Spec modifiedSpec = disableFlowRunImmediatelyOnStart((FlowSpec) spec);
onAddSpec(modifiedSpec);
} else {
onAddSpec(spec);
}
}
} finally {
this.flowCatalog.get().getMetrics().updateGetSpecTime(startTime);
}
} | java | private void scheduleSpecsFromCatalog() {
Iterator<URI> specUris = null;
long startTime = System.currentTimeMillis();
try {
specUris = this.flowCatalog.get().getSpecURIs();
} catch (SpecSerDeException ssde) {
throw new RuntimeException("Failed to get the iterator of all Spec URIS", ssde);
}
try {
while (specUris.hasNext()) {
Spec spec = null;
try {
spec = this.flowCatalog.get().getSpec(specUris.next());
} catch (SpecNotFoundException snfe) {
_log.error(String.format("The URI %s discovered in SpecStore is missing in FlowCatlog"
+ ", suspecting current modification on SpecStore", specUris.next()), snfe);
}
//Disable FLOW_RUN_IMMEDIATELY on service startup or leadership change
if (spec instanceof FlowSpec) {
Spec modifiedSpec = disableFlowRunImmediatelyOnStart((FlowSpec) spec);
onAddSpec(modifiedSpec);
} else {
onAddSpec(spec);
}
}
} finally {
this.flowCatalog.get().getMetrics().updateGetSpecTime(startTime);
}
} | [
"private",
"void",
"scheduleSpecsFromCatalog",
"(",
")",
"{",
"Iterator",
"<",
"URI",
">",
"specUris",
"=",
"null",
";",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"specUris",
"=",
"this",
".",
"flowCatalog",
"... | Load all {@link FlowSpec}s from {@link FlowCatalog} as one of the initialization step,
and make schedulers be aware of that. | [
"Load",
"all",
"{",
"@link",
"FlowSpec",
"}",
"s",
"from",
"{",
"@link",
"FlowCatalog",
"}",
"as",
"one",
"of",
"the",
"initialization",
"step",
"and",
"make",
"schedulers",
"be",
"aware",
"of",
"that",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java#L139-L171 |
exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lnkproducer/LinkGenerator.java | LinkGenerator.writeZeroString | private void writeZeroString(String outString, OutputStream outStream) throws IOException
{
simpleWriteString(outString, outStream);
outStream.write(0);
outStream.write(0);
} | java | private void writeZeroString(String outString, OutputStream outStream) throws IOException
{
simpleWriteString(outString, outStream);
outStream.write(0);
outStream.write(0);
} | [
"private",
"void",
"writeZeroString",
"(",
"String",
"outString",
",",
"OutputStream",
"outStream",
")",
"throws",
"IOException",
"{",
"simpleWriteString",
"(",
"outString",
",",
"outStream",
")",
";",
"outStream",
".",
"write",
"(",
"0",
")",
";",
"outStream",
... | Writes zero-string into stream.
@param outString string
@param outStream stream
@throws IOException {@link IOException} | [
"Writes",
"zero",
"-",
"string",
"into",
"stream",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lnkproducer/LinkGenerator.java#L350-L355 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkInterfaceTapConfigurationsInner.java | NetworkInterfaceTapConfigurationsInner.createOrUpdateAsync | public Observable<NetworkInterfaceTapConfigurationInner> createOrUpdateAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName, NetworkInterfaceTapConfigurationInner tapConfigurationParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkInterfaceTapConfigurationInner> createOrUpdateAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName, NetworkInterfaceTapConfigurationInner tapConfigurationParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkInterfaceTapConfigurationInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
",",
"String",
"tapConfigurationName",
",",
"NetworkInterfaceTapConfigurationInner",
"tapConfigurationParamet... | Creates or updates a Tap configuration in the specified NetworkInterface.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param tapConfigurationName The name of the tap configuration.
@param tapConfigurationParameters Parameters supplied to the create or update tap configuration operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"Tap",
"configuration",
"in",
"the",
"specified",
"NetworkInterface",
"."
] | 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/NetworkInterfaceTapConfigurationsInner.java#L391-L398 |
sahan/RoboZombie | robozombie/src/main/java/com/lonepulse/robozombie/AbstractGenericFactory.java | AbstractGenericFactory.newInstance | @Override
public OUTPUT newInstance(INPUT input, INPUT... inputs) throws FAILURE {
StringBuilder builder = new StringBuilder()
.append(getClass().getName())
.append(".newInstance(Input, Input...) is unsupported.");
throw new UnsupportedOperationException(builder.toString());
} | java | @Override
public OUTPUT newInstance(INPUT input, INPUT... inputs) throws FAILURE {
StringBuilder builder = new StringBuilder()
.append(getClass().getName())
.append(".newInstance(Input, Input...) is unsupported.");
throw new UnsupportedOperationException(builder.toString());
} | [
"@",
"Override",
"public",
"OUTPUT",
"newInstance",
"(",
"INPUT",
"input",
",",
"INPUT",
"...",
"inputs",
")",
"throws",
"FAILURE",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"getClass",
"(",
")",
".",
"getN... | <p><b>Unsupported</b>. Override to provide an implementation.</p>
<p>See {@link GenericFactory#newInstance(Object, Object...)}</p>
@since 1.3.0 | [
"<p",
">",
"<b",
">",
"Unsupported<",
"/",
"b",
">",
".",
"Override",
"to",
"provide",
"an",
"implementation",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sahan/RoboZombie/blob/2e02f0d41647612e9d89360c5c48811ea86b33c8/robozombie/src/main/java/com/lonepulse/robozombie/AbstractGenericFactory.java#L83-L91 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueService.java | QueueService.createLocalQueueStats | public LocalQueueStats createLocalQueueStats(String name, int partitionId) {
LocalQueueStatsImpl stats = getLocalQueueStatsImpl(name);
stats.setOwnedItemCount(0);
stats.setBackupItemCount(0);
QueueContainer container = containerMap.get(name);
if (container == null) {
return stats;
}
Address thisAddress = nodeEngine.getClusterService().getThisAddress();
IPartition partition = partitionService.getPartition(partitionId, false);
Address owner = partition.getOwnerOrNull();
if (thisAddress.equals(owner)) {
stats.setOwnedItemCount(container.size());
} else if (owner != null) {
stats.setBackupItemCount(container.backupSize());
}
container.setStats(stats);
return stats;
} | java | public LocalQueueStats createLocalQueueStats(String name, int partitionId) {
LocalQueueStatsImpl stats = getLocalQueueStatsImpl(name);
stats.setOwnedItemCount(0);
stats.setBackupItemCount(0);
QueueContainer container = containerMap.get(name);
if (container == null) {
return stats;
}
Address thisAddress = nodeEngine.getClusterService().getThisAddress();
IPartition partition = partitionService.getPartition(partitionId, false);
Address owner = partition.getOwnerOrNull();
if (thisAddress.equals(owner)) {
stats.setOwnedItemCount(container.size());
} else if (owner != null) {
stats.setBackupItemCount(container.backupSize());
}
container.setStats(stats);
return stats;
} | [
"public",
"LocalQueueStats",
"createLocalQueueStats",
"(",
"String",
"name",
",",
"int",
"partitionId",
")",
"{",
"LocalQueueStatsImpl",
"stats",
"=",
"getLocalQueueStatsImpl",
"(",
"name",
")",
";",
"stats",
".",
"setOwnedItemCount",
"(",
"0",
")",
";",
"stats",
... | Returns the local queue statistics for the given name and
partition ID. If this node is the owner for the partition,
returned stats contain {@link LocalQueueStats#getOwnedItemCount()},
otherwise it contains {@link LocalQueueStats#getBackupItemCount()}.
@param name the name of the queue for which the statistics are returned
@param partitionId the partition ID for which the statistics are returned
@return the statistics | [
"Returns",
"the",
"local",
"queue",
"statistics",
"for",
"the",
"given",
"name",
"and",
"partition",
"ID",
".",
"If",
"this",
"node",
"is",
"the",
"owner",
"for",
"the",
"partition",
"returned",
"stats",
"contain",
"{",
"@link",
"LocalQueueStats#getOwnedItemCoun... | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/collection/impl/queue/QueueService.java#L310-L330 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/cluster/RedisClusterClient.java | RedisClusterClient.connectToNodeAsync | <K, V> ConnectionFuture<StatefulRedisConnection<K, V>> connectToNodeAsync(RedisCodec<K, V> codec, String nodeId,
RedisChannelWriter clusterWriter, Mono<SocketAddress> socketAddressSupplier) {
assertNotNull(codec);
assertNotEmpty(initialUris);
LettuceAssert.notNull(socketAddressSupplier, "SocketAddressSupplier must not be null");
ClusterNodeEndpoint endpoint = new ClusterNodeEndpoint(clientOptions, getResources(), clusterWriter);
RedisChannelWriter writer = endpoint;
if (CommandExpiryWriter.isSupported(clientOptions)) {
writer = new CommandExpiryWriter(writer, clientOptions, clientResources);
}
StatefulRedisConnectionImpl<K, V> connection = new StatefulRedisConnectionImpl<K, V>(writer, codec, timeout);
ConnectionFuture<StatefulRedisConnection<K, V>> connectionFuture = connectStatefulAsync(connection, codec, endpoint,
getFirstUri(), socketAddressSupplier, () -> new CommandHandler(clientOptions, clientResources, endpoint));
return connectionFuture.whenComplete((conn, throwable) -> {
if (throwable != null) {
connection.close();
}
});
} | java | <K, V> ConnectionFuture<StatefulRedisConnection<K, V>> connectToNodeAsync(RedisCodec<K, V> codec, String nodeId,
RedisChannelWriter clusterWriter, Mono<SocketAddress> socketAddressSupplier) {
assertNotNull(codec);
assertNotEmpty(initialUris);
LettuceAssert.notNull(socketAddressSupplier, "SocketAddressSupplier must not be null");
ClusterNodeEndpoint endpoint = new ClusterNodeEndpoint(clientOptions, getResources(), clusterWriter);
RedisChannelWriter writer = endpoint;
if (CommandExpiryWriter.isSupported(clientOptions)) {
writer = new CommandExpiryWriter(writer, clientOptions, clientResources);
}
StatefulRedisConnectionImpl<K, V> connection = new StatefulRedisConnectionImpl<K, V>(writer, codec, timeout);
ConnectionFuture<StatefulRedisConnection<K, V>> connectionFuture = connectStatefulAsync(connection, codec, endpoint,
getFirstUri(), socketAddressSupplier, () -> new CommandHandler(clientOptions, clientResources, endpoint));
return connectionFuture.whenComplete((conn, throwable) -> {
if (throwable != null) {
connection.close();
}
});
} | [
"<",
"K",
",",
"V",
">",
"ConnectionFuture",
"<",
"StatefulRedisConnection",
"<",
"K",
",",
"V",
">",
">",
"connectToNodeAsync",
"(",
"RedisCodec",
"<",
"K",
",",
"V",
">",
"codec",
",",
"String",
"nodeId",
",",
"RedisChannelWriter",
"clusterWriter",
",",
... | Create a connection to a redis socket address.
@param codec Use this codec to encode/decode keys and values, must not be {@literal null}
@param nodeId the nodeId
@param clusterWriter global cluster writer
@param socketAddressSupplier supplier for the socket address
@param <K> Key type
@param <V> Value type
@return A new connection | [
"Create",
"a",
"connection",
"to",
"a",
"redis",
"socket",
"address",
"."
] | train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java#L482-L507 |
OpenLiberty/open-liberty | dev/com.ibm.ws.diagnostics/src/com/ibm/ws/diagnostics/AbstractMBeanIntrospector.java | AbstractMBeanIntrospector.introspectMBeanAttributes | @FFDCIgnore(Throwable.class)
void introspectMBeanAttributes(MBeanServer mbeanServer, ObjectName mbean, PrintWriter writer) {
try {
// Dump the description and the canonical form of the object name
writer.println();
writer.print(mbeanServer.getMBeanInfo(mbean).getDescription());
writer.println(" (" + mbean.getCanonicalName() + ")");
// Iterate over the attributes of the mbean. For each, capture the name
// and then attempt format the attribute.
String indent = INDENT;
MBeanAttributeInfo[] attrs = mbeanServer.getMBeanInfo(mbean).getAttributes();
for (MBeanAttributeInfo attr : attrs) {
StringBuilder sb = new StringBuilder();
sb.append(indent).append(attr.getName()).append(": ");
sb.append(getFormattedAttribute(mbeanServer, mbean, attr, indent));
writer.println(sb.toString());
}
} catch (Throwable t) {
Throwable rootCause = t;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
StringBuilder sb = new StringBuilder();
sb.append("<<Introspection failed: ");
sb.append(rootCause.getMessage() != null ? rootCause.getMessage() : rootCause);
sb.append(">>");
writer.println(sb.toString());
}
} | java | @FFDCIgnore(Throwable.class)
void introspectMBeanAttributes(MBeanServer mbeanServer, ObjectName mbean, PrintWriter writer) {
try {
// Dump the description and the canonical form of the object name
writer.println();
writer.print(mbeanServer.getMBeanInfo(mbean).getDescription());
writer.println(" (" + mbean.getCanonicalName() + ")");
// Iterate over the attributes of the mbean. For each, capture the name
// and then attempt format the attribute.
String indent = INDENT;
MBeanAttributeInfo[] attrs = mbeanServer.getMBeanInfo(mbean).getAttributes();
for (MBeanAttributeInfo attr : attrs) {
StringBuilder sb = new StringBuilder();
sb.append(indent).append(attr.getName()).append(": ");
sb.append(getFormattedAttribute(mbeanServer, mbean, attr, indent));
writer.println(sb.toString());
}
} catch (Throwable t) {
Throwable rootCause = t;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
StringBuilder sb = new StringBuilder();
sb.append("<<Introspection failed: ");
sb.append(rootCause.getMessage() != null ? rootCause.getMessage() : rootCause);
sb.append(">>");
writer.println(sb.toString());
}
} | [
"@",
"FFDCIgnore",
"(",
"Throwable",
".",
"class",
")",
"void",
"introspectMBeanAttributes",
"(",
"MBeanServer",
"mbeanServer",
",",
"ObjectName",
"mbean",
",",
"PrintWriter",
"writer",
")",
"{",
"try",
"{",
"// Dump the description and the canonical form of the object na... | Introspect an MBean's attributes. Introspection will capture the MBean's
description, its canonical object name, and its attributes. When attributes
are a complex {@link OpenType}, an attempt will be made to format the complex
type. Primitives and types that do not have metadata will be formatted
with {@linkplain String#valueOf}.
@param mbeanServer the mbean server hosting the mbean
@param mbean the mbean to introspect
@param writer the print writer to write the instrospection to | [
"Introspect",
"an",
"MBean",
"s",
"attributes",
".",
"Introspection",
"will",
"capture",
"the",
"MBean",
"s",
"description",
"its",
"canonical",
"object",
"name",
"and",
"its",
"attributes",
".",
"When",
"attributes",
"are",
"a",
"complex",
"{",
"@link",
"Open... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.diagnostics/src/com/ibm/ws/diagnostics/AbstractMBeanIntrospector.java#L89-L118 |
XiaoMi/chronos | chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/HostPort.java | HostPort.parseHostPort | public static HostPort parseHostPort(String string) {
String[] strings = string.split("_");
return new HostPort(strings[0], Integer.parseInt(strings[1]));
} | java | public static HostPort parseHostPort(String string) {
String[] strings = string.split("_");
return new HostPort(strings[0], Integer.parseInt(strings[1]));
} | [
"public",
"static",
"HostPort",
"parseHostPort",
"(",
"String",
"string",
")",
"{",
"String",
"[",
"]",
"strings",
"=",
"string",
".",
"split",
"(",
"\"_\"",
")",
";",
"return",
"new",
"HostPort",
"(",
"strings",
"[",
"0",
"]",
",",
"Integer",
".",
"pa... | Parse a host_port string to construct the HostPost object.
@param string the host_port string
@return the HostPort object | [
"Parse",
"a",
"host_port",
"string",
"to",
"construct",
"the",
"HostPost",
"object",
"."
] | train | https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/HostPort.java#L39-L42 |
belaban/JGroups | src/org/jgroups/fork/ForkChannel.java | ForkChannel.disconnect | @Override
public ForkChannel disconnect() {
if(state != State.CONNECTED)
return this;
prot_stack.down(new Event(Event.DISCONNECT, local_addr)); // will be discarded by ForkProtocol
prot_stack.stopStack(cluster_name);
((ForkProtocolStack)prot_stack).remove(fork_channel_id);
nullFields();
state=State.OPEN;
notifyChannelDisconnected(this);
return this;
} | java | @Override
public ForkChannel disconnect() {
if(state != State.CONNECTED)
return this;
prot_stack.down(new Event(Event.DISCONNECT, local_addr)); // will be discarded by ForkProtocol
prot_stack.stopStack(cluster_name);
((ForkProtocolStack)prot_stack).remove(fork_channel_id);
nullFields();
state=State.OPEN;
notifyChannelDisconnected(this);
return this;
} | [
"@",
"Override",
"public",
"ForkChannel",
"disconnect",
"(",
")",
"{",
"if",
"(",
"state",
"!=",
"State",
".",
"CONNECTED",
")",
"return",
"this",
";",
"prot_stack",
".",
"down",
"(",
"new",
"Event",
"(",
"Event",
".",
"DISCONNECT",
",",
"local_addr",
")... | Removes the fork-channel from the fork-stack's hashmap and resets its state. Does <em>not</em> affect the
main-channel | [
"Removes",
"the",
"fork",
"-",
"channel",
"from",
"the",
"fork",
"-",
"stack",
"s",
"hashmap",
"and",
"resets",
"its",
"state",
".",
"Does",
"<em",
">",
"not<",
"/",
"em",
">",
"affect",
"the",
"main",
"-",
"channel"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/fork/ForkChannel.java#L180-L191 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/MetatypeUtils.java | MetatypeUtils.collapseWhitespace | @Trivial
private static String collapseWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
if (isSpace(value.charAt(i))) {
return collapse0(value, i, length);
}
}
return value;
} | java | @Trivial
private static String collapseWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
if (isSpace(value.charAt(i))) {
return collapse0(value, i, length);
}
}
return value;
} | [
"@",
"Trivial",
"private",
"static",
"String",
"collapseWhitespace",
"(",
"String",
"value",
")",
"{",
"final",
"int",
"length",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
... | Collapses contiguous sequences of whitespace to a single 0x20.
Leading and trailing whitespace is removed. | [
"Collapses",
"contiguous",
"sequences",
"of",
"whitespace",
"to",
"a",
"single",
"0x20",
".",
"Leading",
"and",
"trailing",
"whitespace",
"is",
"removed",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/MetatypeUtils.java#L557-L566 |
lastaflute/lastaflute | src/main/java/org/lastaflute/web/response/HtmlResponse.java | HtmlResponse.useForm | public <FORM> HtmlResponse useForm(Class<FORM> formType, PushedFormOpCall<FORM> opLambda) {
assertArgumentNotNull("formType", formType);
assertArgumentNotNull("opLambda", opLambda);
this.pushedFormInfo = createPushedFormInfo(formType, createPushedFormOption(opLambda));
return this;
} | java | public <FORM> HtmlResponse useForm(Class<FORM> formType, PushedFormOpCall<FORM> opLambda) {
assertArgumentNotNull("formType", formType);
assertArgumentNotNull("opLambda", opLambda);
this.pushedFormInfo = createPushedFormInfo(formType, createPushedFormOption(opLambda));
return this;
} | [
"public",
"<",
"FORM",
">",
"HtmlResponse",
"useForm",
"(",
"Class",
"<",
"FORM",
">",
"formType",
",",
"PushedFormOpCall",
"<",
"FORM",
">",
"opLambda",
")",
"{",
"assertArgumentNotNull",
"(",
"\"formType\"",
",",
"formType",
")",
";",
"assertArgumentNotNull",
... | Set up the HTML response as using action form with internal initial value. <br>
And you can use the action form in your HTML template.
<pre>
<span style="color: #3F7E5E">// case of internal initial value</span>
@Execute
<span style="color: #70226C">public</span> HtmlResponse index() {
<span style="color: #70226C">return</span> asHtml(<span style="color: #0000C0">path_Sea_SeaJsp</span>).<span style="color: #CC4747">useForm</span>(SeaForm.<span style="color: #70226C">class</span>, op <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> op.<span style="color: #994747">setup</span>(form <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> ...));
}
</pre>
@param formType The type of action form. (NotNull)
@param opLambda The callback for option of the form, provides new-created form instance, so you can setup it. (NotNull)
@return this. (NotNull) | [
"Set",
"up",
"the",
"HTML",
"response",
"as",
"using",
"action",
"form",
"with",
"internal",
"initial",
"value",
".",
"<br",
">",
"And",
"you",
"can",
"use",
"the",
"action",
"form",
"in",
"your",
"HTML",
"template",
".",
"<pre",
">",
"<span",
"style",
... | train | https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/response/HtmlResponse.java#L247-L252 |
ManfredTremmel/gwt-bean-validators | gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/apache/commons/beanutils/PropertyUtils.java | PropertyUtils.getProperty | public static Object getProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (pbean == null) {
throw new NoSuchMethodException("A null object has no getters");
}
if (pname == null) {
throw new NoSuchMethodException("No method to get property for null");
}
final int posPoint = pname.indexOf('.');
try {
final AbstractGwtValidator validator =
(AbstractGwtValidator) Validation.buildDefaultValidatorFactory().getValidator();
if (posPoint >= 0) {
final Object subObject = validator.getProperty(pbean, pname.substring(0, posPoint));
if (subObject == null) {
throw new NestedNullException(
"Null property value for '" + pname + "' on bean class '" + pbean.getClass() + "'");
}
return getProperty(subObject, pname.substring(posPoint + 1));
}
return validator.getProperty(pbean, pname);
} catch (final ReflectiveOperationException e) {
throw new InvocationTargetException(e);
}
} | java | public static Object getProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (pbean == null) {
throw new NoSuchMethodException("A null object has no getters");
}
if (pname == null) {
throw new NoSuchMethodException("No method to get property for null");
}
final int posPoint = pname.indexOf('.');
try {
final AbstractGwtValidator validator =
(AbstractGwtValidator) Validation.buildDefaultValidatorFactory().getValidator();
if (posPoint >= 0) {
final Object subObject = validator.getProperty(pbean, pname.substring(0, posPoint));
if (subObject == null) {
throw new NestedNullException(
"Null property value for '" + pname + "' on bean class '" + pbean.getClass() + "'");
}
return getProperty(subObject, pname.substring(posPoint + 1));
}
return validator.getProperty(pbean, pname);
} catch (final ReflectiveOperationException e) {
throw new InvocationTargetException(e);
}
} | [
"public",
"static",
"Object",
"getProperty",
"(",
"final",
"Object",
"pbean",
",",
"final",
"String",
"pname",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"if",
"(",
"pbean",
"==",
"null",
")",
"{",... | <p>
Return the value of the specified property of the specified bean, no matter which property
reference format is used, with no type conversions.
</p>
<p>
For more details see <code>PropertyUtilsBean</code>.
</p>
@param pbean Bean whose property is to be extracted
@param pname Possibly indexed and/or nested name of the property to be extracted
@return the property value
@exception IllegalAccessException if the caller does not have access to the property accessor
method
@exception IllegalArgumentException if <code>bean</code> or <code>name</code> is null
@exception InvocationTargetException if the property accessor method throws an exception
@exception NoSuchMethodException if an accessor method for this propety cannot be found
@see PropertyUtilsBean#getProperty | [
"<p",
">",
"Return",
"the",
"value",
"of",
"the",
"specified",
"property",
"of",
"the",
"specified",
"bean",
"no",
"matter",
"which",
"property",
"reference",
"format",
"is",
"used",
"with",
"no",
"type",
"conversions",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/apache/commons/beanutils/PropertyUtils.java#L55-L81 |
dadoonet/elasticsearch-beyonder | src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java | IndexElasticsearchUpdater.updateSettings | @Deprecated
public static void updateSettings(Client client, String root, String index) throws Exception {
String settings = IndexSettingsReader.readUpdateSettings(root, index);
updateIndexWithSettingsInElasticsearch(client, index, settings);
} | java | @Deprecated
public static void updateSettings(Client client, String root, String index) throws Exception {
String settings = IndexSettingsReader.readUpdateSettings(root, index);
updateIndexWithSettingsInElasticsearch(client, index, settings);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"updateSettings",
"(",
"Client",
"client",
",",
"String",
"root",
",",
"String",
"index",
")",
"throws",
"Exception",
"{",
"String",
"settings",
"=",
"IndexSettingsReader",
".",
"readUpdateSettings",
"(",
"root",
",... | Update index settings in Elasticsearch. Read also _update_settings.json if exists.
@param client Elasticsearch client
@param root dir within the classpath
@param index Index name
@throws Exception if the elasticsearch API call is failing | [
"Update",
"index",
"settings",
"in",
"Elasticsearch",
".",
"Read",
"also",
"_update_settings",
".",
"json",
"if",
"exists",
"."
] | train | https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L184-L188 |
io7m/jaffirm | com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Invariants.java | Invariants.checkInvariantD | public static double checkInvariantD(
final double value,
final boolean condition,
final DoubleFunction<String> describer)
{
return innerCheckInvariantD(value, condition, describer);
} | java | public static double checkInvariantD(
final double value,
final boolean condition,
final DoubleFunction<String> describer)
{
return innerCheckInvariantD(value, condition, describer);
} | [
"public",
"static",
"double",
"checkInvariantD",
"(",
"final",
"double",
"value",
",",
"final",
"boolean",
"condition",
",",
"final",
"DoubleFunction",
"<",
"String",
">",
"describer",
")",
"{",
"return",
"innerCheckInvariantD",
"(",
"value",
",",
"condition",
"... | A {@code double} specialized version of {@link #checkInvariant(Object,
boolean, Function)}
@param value The value
@param condition The predicate
@param describer The describer of the predicate
@return value
@throws InvariantViolationException If the predicate is false | [
"A",
"{",
"@code",
"double",
"}",
"specialized",
"version",
"of",
"{",
"@link",
"#checkInvariant",
"(",
"Object",
"boolean",
"Function",
")",
"}"
] | train | https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Invariants.java#L551-L557 |
MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.reduceQuality | public ImageHandlerBuilder reduceQuality(float qualityPercent) {
ImageWriter imageWriter = ImageIO.getImageWritersByFormatName(fn.extension()).next();
if (imageWriter != null) {
ImageWriteParam writeParam = imageWriter.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(qualityPercent);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageWriter.setOutput(new MemoryCacheImageOutputStream(baos));
try {
imageWriter.write(null, new IIOImage(image, null, null), writeParam);
imageWriter.dispose();
} catch (IOException e) {
throw new ControllerException(e);
}
try {
BufferedImage lowImage = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
image.flush();
image = lowImage;
} catch (IOException e) {
throw new ControllerException(e);
}
}
return this;
} | java | public ImageHandlerBuilder reduceQuality(float qualityPercent) {
ImageWriter imageWriter = ImageIO.getImageWritersByFormatName(fn.extension()).next();
if (imageWriter != null) {
ImageWriteParam writeParam = imageWriter.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(qualityPercent);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageWriter.setOutput(new MemoryCacheImageOutputStream(baos));
try {
imageWriter.write(null, new IIOImage(image, null, null), writeParam);
imageWriter.dispose();
} catch (IOException e) {
throw new ControllerException(e);
}
try {
BufferedImage lowImage = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
image.flush();
image = lowImage;
} catch (IOException e) {
throw new ControllerException(e);
}
}
return this;
} | [
"public",
"ImageHandlerBuilder",
"reduceQuality",
"(",
"float",
"qualityPercent",
")",
"{",
"ImageWriter",
"imageWriter",
"=",
"ImageIO",
".",
"getImageWritersByFormatName",
"(",
"fn",
".",
"extension",
"(",
")",
")",
".",
"next",
"(",
")",
";",
"if",
"(",
"im... | Uses compression quality of <code>qualityPercent</code>.
Can be applied multiple times
@param qualityPercent the percentage of compression quality wanted. Must be between 0.0 and 1.0
@return this for chaining | [
"Uses",
"compression",
"quality",
"of",
"<code",
">",
"qualityPercent<",
"/",
"code",
">",
".",
"Can",
"be",
"applied",
"multiple",
"times"
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L220-L245 |
lukas-krecan/JsonUnit | json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java | JsonUnitResultMatchers.isNotEqualTo | public ResultMatcher isNotEqualTo(final Object expected) {
return new AbstractResultMatcher(path, configuration) {
public void doMatch(Object actual) {
Diff diff = createDiff(expected, actual);
if (diff.similar()) {
failWithMessage("JSON is equal.");
}
}
};
} | java | public ResultMatcher isNotEqualTo(final Object expected) {
return new AbstractResultMatcher(path, configuration) {
public void doMatch(Object actual) {
Diff diff = createDiff(expected, actual);
if (diff.similar()) {
failWithMessage("JSON is equal.");
}
}
};
} | [
"public",
"ResultMatcher",
"isNotEqualTo",
"(",
"final",
"Object",
"expected",
")",
"{",
"return",
"new",
"AbstractResultMatcher",
"(",
"path",
",",
"configuration",
")",
"{",
"public",
"void",
"doMatch",
"(",
"Object",
"actual",
")",
"{",
"Diff",
"diff",
"=",... | Fails if compared documents are equal. The expected object is converted to JSON
before comparison. Ignores order of sibling nodes and whitespaces. | [
"Fails",
"if",
"compared",
"documents",
"are",
"equal",
".",
"The",
"expected",
"object",
"is",
"converted",
"to",
"JSON",
"before",
"comparison",
".",
"Ignores",
"order",
"of",
"sibling",
"nodes",
"and",
"whitespaces",
"."
] | train | https://github.com/lukas-krecan/JsonUnit/blob/2b12ed792e8dd787bddd6f3b8eb2325737435791/json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java#L126-L135 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java | FileUtilities.deleteFileOrDir | public static boolean deleteFileOrDir( File filehandle ) {
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
boolean isdel = filehandle.delete();
if (!isdel) {
// if it didn't work, which often happens on windows systems,
// remove on exit
filehandle.deleteOnExit();
}
return isdel;
} | java | public static boolean deleteFileOrDir( File filehandle ) {
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
boolean isdel = filehandle.delete();
if (!isdel) {
// if it didn't work, which often happens on windows systems,
// remove on exit
filehandle.deleteOnExit();
}
return isdel;
} | [
"public",
"static",
"boolean",
"deleteFileOrDir",
"(",
"File",
"filehandle",
")",
"{",
"if",
"(",
"filehandle",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"children",
"=",
"filehandle",
".",
"list",
"(",
")",
";",
"for",
"(",
"int",
"i... | Returns true if all deletions were successful. If a deletion fails, the method stops
attempting to delete and returns false.
@param filehandle
@return true if all deletions were successful | [
"Returns",
"true",
"if",
"all",
"deletions",
"were",
"successful",
".",
"If",
"a",
"deletion",
"fails",
"the",
"method",
"stops",
"attempting",
"to",
"delete",
"and",
"returns",
"false",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java#L183-L204 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java | ServerStatusFile.getNextMessage | private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
} | java | private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
} | [
"private",
"ServerStatusMessage",
"getNextMessage",
"(",
"BufferedReader",
"reader",
")",
"throws",
"Exception",
"{",
"boolean",
"messageStarted",
"=",
"false",
";",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"... | return the next message, or null if there are no more messages in the file | [
"return",
"the",
"next",
"message",
"or",
"null",
"if",
"there",
"are",
"no",
"more",
"messages",
"in",
"the",
"file"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java#L210-L248 |
fuinorg/event-store-commons | eshttp/src/main/java/org/fuin/esc/eshttp/ESHttpUtils.java | ESHttpUtils.parseDocument | @NotNull
public static Document parseDocument(@NotNull final DocumentBuilder builder,
@NotNull final InputStream inputStream) {
Contract.requireArgNotNull("builder", builder);
Contract.requireArgNotNull("inputStream", inputStream);
try {
return builder.parse(inputStream);
} catch (final SAXException | IOException ex) {
throw new RuntimeException("Failed to parse XML", ex);
}
} | java | @NotNull
public static Document parseDocument(@NotNull final DocumentBuilder builder,
@NotNull final InputStream inputStream) {
Contract.requireArgNotNull("builder", builder);
Contract.requireArgNotNull("inputStream", inputStream);
try {
return builder.parse(inputStream);
} catch (final SAXException | IOException ex) {
throw new RuntimeException("Failed to parse XML", ex);
}
} | [
"@",
"NotNull",
"public",
"static",
"Document",
"parseDocument",
"(",
"@",
"NotNull",
"final",
"DocumentBuilder",
"builder",
",",
"@",
"NotNull",
"final",
"InputStream",
"inputStream",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"builder\"",
",",
"build... | Parse the document and wraps checked exceptions into runtime exceptions.
@param builder
Builder to use.
@param inputStream
Input stream with XML.
@return Document. | [
"Parse",
"the",
"document",
"and",
"wraps",
"checked",
"exceptions",
"into",
"runtime",
"exceptions",
"."
] | train | https://github.com/fuinorg/event-store-commons/blob/ea175582d8cda2b5a6d2fe52bbb2f1c183eee77c/eshttp/src/main/java/org/fuin/esc/eshttp/ESHttpUtils.java#L153-L163 |
googleads/googleads-java-lib | examples/adwords_axis/src/main/java/adwords/axis/v201809/optimization/EstimateKeywordTraffic.java | EstimateKeywordTraffic.calculateMean | private static Double calculateMean(Money minMoney, Money maxMoney) {
if (minMoney == null || maxMoney == null) {
return null;
}
return calculateMean(minMoney.getMicroAmount(), maxMoney.getMicroAmount());
} | java | private static Double calculateMean(Money minMoney, Money maxMoney) {
if (minMoney == null || maxMoney == null) {
return null;
}
return calculateMean(minMoney.getMicroAmount(), maxMoney.getMicroAmount());
} | [
"private",
"static",
"Double",
"calculateMean",
"(",
"Money",
"minMoney",
",",
"Money",
"maxMoney",
")",
"{",
"if",
"(",
"minMoney",
"==",
"null",
"||",
"maxMoney",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"calculateMean",
"(",
"minMon... | Returns the mean of the {@code microAmount} of the two Money values if neither is null, else
returns null. | [
"Returns",
"the",
"mean",
"of",
"the",
"{"
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/optimization/EstimateKeywordTraffic.java#L283-L288 |
zaproxy/zaproxy | src/org/apache/commons/httpclient/HttpMethodBase.java | HttpMethodBase.readResponseHeaders | protected void readResponseHeaders(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace("enter HttpMethodBase.readResponseHeaders(HttpState,"
+ "HttpConnection)");
getResponseHeaderGroup().clear();
Header[] headers = HttpParser.parseHeaders(
conn.getResponseInputStream(), getParams().getHttpElementCharset());
// Wire logging moved to HttpParser
getResponseHeaderGroup().setHeaders(headers);
} | java | protected void readResponseHeaders(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace("enter HttpMethodBase.readResponseHeaders(HttpState,"
+ "HttpConnection)");
getResponseHeaderGroup().clear();
Header[] headers = HttpParser.parseHeaders(
conn.getResponseInputStream(), getParams().getHttpElementCharset());
// Wire logging moved to HttpParser
getResponseHeaderGroup().setHeaders(headers);
} | [
"protected",
"void",
"readResponseHeaders",
"(",
"HttpState",
"state",
",",
"HttpConnection",
"conn",
")",
"throws",
"IOException",
",",
"HttpException",
"{",
"LOG",
".",
"trace",
"(",
"\"enter HttpMethodBase.readResponseHeaders(HttpState,\"",
"+",
"\"HttpConnection)\"",
... | Reads the response headers from the given {@link HttpConnection connection}.
<p>
Subclasses may want to override this method to to customize the
processing.
</p>
<p>
"It must be possible to combine the multiple header fields into one
"field-name: field-value" pair, without changing the semantics of the
message, by appending each subsequent field-value to the first, each
separated by a comma." - HTTP/1.0 (4.3)
</p>
@param state the {@link HttpState state} information associated with this method
@param conn the {@link HttpConnection connection} used to execute
this HTTP method
@throws IOException if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
@throws HttpException if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.
@see #readResponse
@see #processResponseHeaders | [
"Reads",
"the",
"response",
"headers",
"from",
"the",
"given",
"{",
"@link",
"HttpConnection",
"connection",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/apache/commons/httpclient/HttpMethodBase.java#L2063-L2074 |
jenkinsci/jenkins | core/src/main/java/hudson/model/Descriptor.java | Descriptor.newInstancesFromHeteroList | public static <T extends Describable<T>>
List<T> newInstancesFromHeteroList(StaplerRequest req, JSONObject formData, String key,
Collection<? extends Descriptor<T>> descriptors) throws FormException {
return newInstancesFromHeteroList(req,formData.get(key),descriptors);
} | java | public static <T extends Describable<T>>
List<T> newInstancesFromHeteroList(StaplerRequest req, JSONObject formData, String key,
Collection<? extends Descriptor<T>> descriptors) throws FormException {
return newInstancesFromHeteroList(req,formData.get(key),descriptors);
} | [
"public",
"static",
"<",
"T",
"extends",
"Describable",
"<",
"T",
">",
">",
"List",
"<",
"T",
">",
"newInstancesFromHeteroList",
"(",
"StaplerRequest",
"req",
",",
"JSONObject",
"formData",
",",
"String",
"key",
",",
"Collection",
"<",
"?",
"extends",
"Descr... | Used to build {@link Describable} instance list from {@code <f:hetero-list>} tag.
@param req
Request that represents the form submission.
@param formData
Structured form data that represents the contains data for the list of describables.
@param key
The JSON property name for 'formData' that represents the data for the list of describables.
@param descriptors
List of descriptors to create instances from.
@return
Can be empty but never null. | [
"Used",
"to",
"build",
"{",
"@link",
"Describable",
"}",
"instance",
"list",
"from",
"{",
"@code",
"<f",
":",
"hetero",
"-",
"list",
">",
"}",
"tag",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/Descriptor.java#L1017-L1022 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/LocalDate.java | LocalDate.ofYearDay | public static LocalDate ofYearDay(int year, int dayOfYear) {
YEAR.checkValidValue(year);
DAY_OF_YEAR.checkValidValue(dayOfYear);
boolean leap = IsoChronology.INSTANCE.isLeapYear(year);
if (dayOfYear == 366 && leap == false) {
throw new DateTimeException("Invalid date 'DayOfYear 366' as '" + year + "' is not a leap year");
}
Month moy = Month.of((dayOfYear - 1) / 31 + 1);
int monthEnd = moy.firstDayOfYear(leap) + moy.length(leap) - 1;
if (dayOfYear > monthEnd) {
moy = moy.plus(1);
}
int dom = dayOfYear - moy.firstDayOfYear(leap) + 1;
return create(year, moy, dom);
} | java | public static LocalDate ofYearDay(int year, int dayOfYear) {
YEAR.checkValidValue(year);
DAY_OF_YEAR.checkValidValue(dayOfYear);
boolean leap = IsoChronology.INSTANCE.isLeapYear(year);
if (dayOfYear == 366 && leap == false) {
throw new DateTimeException("Invalid date 'DayOfYear 366' as '" + year + "' is not a leap year");
}
Month moy = Month.of((dayOfYear - 1) / 31 + 1);
int monthEnd = moy.firstDayOfYear(leap) + moy.length(leap) - 1;
if (dayOfYear > monthEnd) {
moy = moy.plus(1);
}
int dom = dayOfYear - moy.firstDayOfYear(leap) + 1;
return create(year, moy, dom);
} | [
"public",
"static",
"LocalDate",
"ofYearDay",
"(",
"int",
"year",
",",
"int",
"dayOfYear",
")",
"{",
"YEAR",
".",
"checkValidValue",
"(",
"year",
")",
";",
"DAY_OF_YEAR",
".",
"checkValidValue",
"(",
"dayOfYear",
")",
";",
"boolean",
"leap",
"=",
"IsoChronol... | Obtains an instance of {@code LocalDate} from a year and day-of-year.
<p>
The day-of-year must be valid for the year, otherwise an exception will be thrown.
@param year the year to represent, from MIN_YEAR to MAX_YEAR
@param dayOfYear the day-of-year to represent, from 1 to 366
@return the local date, not null
@throws DateTimeException if the value of any field is out of range
@throws DateTimeException if the day-of-year is invalid for the month-year | [
"Obtains",
"an",
"instance",
"of",
"{",
"@code",
"LocalDate",
"}",
"from",
"a",
"year",
"and",
"day",
"-",
"of",
"-",
"year",
".",
"<p",
">",
"The",
"day",
"-",
"of",
"-",
"year",
"must",
"be",
"valid",
"for",
"the",
"year",
"otherwise",
"an",
"exc... | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/LocalDate.java#L254-L268 |
xwiki/xwiki-rendering | xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java | IconTransformation.convertToDeepTree | private Block convertToDeepTree(Block sourceTree, String iconName)
{
XDOM targetTree = new XDOM(Collections.<Block>emptyList());
Block pointer = targetTree;
for (Block block : sourceTree.getChildren()) {
pointer.addChild(block);
pointer = block;
}
// Add an image block as the last block
pointer.addChild(new ImageBlock(new ResourceReference(iconName, ResourceType.ICON), true));
return targetTree;
} | java | private Block convertToDeepTree(Block sourceTree, String iconName)
{
XDOM targetTree = new XDOM(Collections.<Block>emptyList());
Block pointer = targetTree;
for (Block block : sourceTree.getChildren()) {
pointer.addChild(block);
pointer = block;
}
// Add an image block as the last block
pointer.addChild(new ImageBlock(new ResourceReference(iconName, ResourceType.ICON), true));
return targetTree;
} | [
"private",
"Block",
"convertToDeepTree",
"(",
"Block",
"sourceTree",
",",
"String",
"iconName",
")",
"{",
"XDOM",
"targetTree",
"=",
"new",
"XDOM",
"(",
"Collections",
".",
"<",
"Block",
">",
"emptyList",
"(",
")",
")",
";",
"Block",
"pointer",
"=",
"targe... | Converts a standard XDOM tree into a deep tree: sibling are transformed into parent/child relationships and the
leaf node is an Image node referencing the passed icon name.
@param sourceTree the source tree to modify
@param iconName the name of the icon to display when a match is found
@return the modified tree | [
"Converts",
"a",
"standard",
"XDOM",
"tree",
"into",
"a",
"deep",
"tree",
":",
"sibling",
"are",
"transformed",
"into",
"parent",
"/",
"child",
"relationships",
"and",
"the",
"leaf",
"node",
"is",
"an",
"Image",
"node",
"referencing",
"the",
"passed",
"icon"... | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java#L136-L147 |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/MutableClock.java | MutableClock.withZone | @Override
public MutableClock withZone(ZoneId zone) {
Objects.requireNonNull(zone, "zone");
if (zone.equals(this.zone)) {
return this;
}
return new MutableClock(instantHolder, zone);
} | java | @Override
public MutableClock withZone(ZoneId zone) {
Objects.requireNonNull(zone, "zone");
if (zone.equals(this.zone)) {
return this;
}
return new MutableClock(instantHolder, zone);
} | [
"@",
"Override",
"public",
"MutableClock",
"withZone",
"(",
"ZoneId",
"zone",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"zone",
",",
"\"zone\"",
")",
";",
"if",
"(",
"zone",
".",
"equals",
"(",
"this",
".",
"zone",
")",
")",
"{",
"return",
"this... | Returns a {@code MutableClock} that uses the specified time-zone and that
has shared updates with this clock.
<p>
Two clocks with shared updates always have the same instant, and all
updates applied to either clock affect both clocks.
@param zone the time-zone to use for the returned clock, not null
@return a view of this clock in the specified time-zone, not null | [
"Returns",
"a",
"{",
"@code",
"MutableClock",
"}",
"that",
"uses",
"the",
"specified",
"time",
"-",
"zone",
"and",
"that",
"has",
"shared",
"updates",
"with",
"this",
"clock",
".",
"<p",
">",
"Two",
"clocks",
"with",
"shared",
"updates",
"always",
"have",
... | train | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/MutableClock.java#L291-L298 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/TitlePaneMenuButtonPainter.java | TitlePaneMenuButtonPainter.paintMenu | private void paintMenu(Graphics2D g, JComponent c, int width, int height, ButtonColors colors) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setColor(colors.top);
g.drawLine(0, 0, width - 2, 0);
g.setColor(colors.leftOuter);
g.drawLine(0, 0, 0, height - 4);
g.setColor(colors.leftInner);
g.drawLine(1, 1, 1, height - 4);
g.drawLine(2, height - 3, 2, height - 3);
Shape s = decodeInterior(width, height);
g.setColor(colors.interior);
g.fill(s);
s = decodeEdge(width, height);
g.setColor(colors.edge);
g.draw(s);
g.setColor(colors.edgeShade);
g.drawLine(2, height - 2, 2, height - 2);
g.drawLine(1, height - 3, 1, height - 3);
g.drawLine(0, height - 4, 0, height - 4);
s = decodeShadow(width, height);
g.setColor(colors.shadow);
g.draw(s);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
s = decodeMarkInterior(width, height);
g.setColor(colors.markInterior);
g.fill(s);
s = decodeMarkBorder(width, height);
g.setColor(colors.markBorder);
g.draw(s);
} | java | private void paintMenu(Graphics2D g, JComponent c, int width, int height, ButtonColors colors) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setColor(colors.top);
g.drawLine(0, 0, width - 2, 0);
g.setColor(colors.leftOuter);
g.drawLine(0, 0, 0, height - 4);
g.setColor(colors.leftInner);
g.drawLine(1, 1, 1, height - 4);
g.drawLine(2, height - 3, 2, height - 3);
Shape s = decodeInterior(width, height);
g.setColor(colors.interior);
g.fill(s);
s = decodeEdge(width, height);
g.setColor(colors.edge);
g.draw(s);
g.setColor(colors.edgeShade);
g.drawLine(2, height - 2, 2, height - 2);
g.drawLine(1, height - 3, 1, height - 3);
g.drawLine(0, height - 4, 0, height - 4);
s = decodeShadow(width, height);
g.setColor(colors.shadow);
g.draw(s);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
s = decodeMarkInterior(width, height);
g.setColor(colors.markInterior);
g.fill(s);
s = decodeMarkBorder(width, height);
g.setColor(colors.markBorder);
g.draw(s);
} | [
"private",
"void",
"paintMenu",
"(",
"Graphics2D",
"g",
",",
"JComponent",
"c",
",",
"int",
"width",
",",
"int",
"height",
",",
"ButtonColors",
"colors",
")",
"{",
"g",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_ANTIALIASING",
",",
"RenderingHin... | Paint the button using the specified colors.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
@param colors the color set to use to paint the button. | [
"Paint",
"the",
"button",
"using",
"the",
"specified",
"colors",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/TitlePaneMenuButtonPainter.java#L147-L187 |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java | SecureUtil.generateAlgorithm | public static String generateAlgorithm(AsymmetricAlgorithm asymmetricAlgorithm, DigestAlgorithm digestAlgorithm) {
final String digestPart = (null == digestAlgorithm) ? "NONE" : digestAlgorithm.name();
return StrUtil.format("{}with{}", digestPart, asymmetricAlgorithm.getValue());
} | java | public static String generateAlgorithm(AsymmetricAlgorithm asymmetricAlgorithm, DigestAlgorithm digestAlgorithm) {
final String digestPart = (null == digestAlgorithm) ? "NONE" : digestAlgorithm.name();
return StrUtil.format("{}with{}", digestPart, asymmetricAlgorithm.getValue());
} | [
"public",
"static",
"String",
"generateAlgorithm",
"(",
"AsymmetricAlgorithm",
"asymmetricAlgorithm",
",",
"DigestAlgorithm",
"digestAlgorithm",
")",
"{",
"final",
"String",
"digestPart",
"=",
"(",
"null",
"==",
"digestAlgorithm",
")",
"?",
"\"NONE\"",
":",
"digestAlg... | 生成算法,格式为XXXwithXXX
@param asymmetricAlgorithm 非对称算法
@param digestAlgorithm 摘要算法
@return 算法
@since 4.4.1 | [
"生成算法,格式为XXXwithXXX"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java#L277-L280 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF5.java | CommonOps_DDF5.multAddOuter | public static void multAddOuter( double alpha , DMatrix5x5 A , double beta , DMatrix5 u , DMatrix5 v , DMatrix5x5 C ) {
C.a11 = alpha*A.a11 + beta*u.a1*v.a1;
C.a12 = alpha*A.a12 + beta*u.a1*v.a2;
C.a13 = alpha*A.a13 + beta*u.a1*v.a3;
C.a14 = alpha*A.a14 + beta*u.a1*v.a4;
C.a15 = alpha*A.a15 + beta*u.a1*v.a5;
C.a21 = alpha*A.a21 + beta*u.a2*v.a1;
C.a22 = alpha*A.a22 + beta*u.a2*v.a2;
C.a23 = alpha*A.a23 + beta*u.a2*v.a3;
C.a24 = alpha*A.a24 + beta*u.a2*v.a4;
C.a25 = alpha*A.a25 + beta*u.a2*v.a5;
C.a31 = alpha*A.a31 + beta*u.a3*v.a1;
C.a32 = alpha*A.a32 + beta*u.a3*v.a2;
C.a33 = alpha*A.a33 + beta*u.a3*v.a3;
C.a34 = alpha*A.a34 + beta*u.a3*v.a4;
C.a35 = alpha*A.a35 + beta*u.a3*v.a5;
C.a41 = alpha*A.a41 + beta*u.a4*v.a1;
C.a42 = alpha*A.a42 + beta*u.a4*v.a2;
C.a43 = alpha*A.a43 + beta*u.a4*v.a3;
C.a44 = alpha*A.a44 + beta*u.a4*v.a4;
C.a45 = alpha*A.a45 + beta*u.a4*v.a5;
C.a51 = alpha*A.a51 + beta*u.a5*v.a1;
C.a52 = alpha*A.a52 + beta*u.a5*v.a2;
C.a53 = alpha*A.a53 + beta*u.a5*v.a3;
C.a54 = alpha*A.a54 + beta*u.a5*v.a4;
C.a55 = alpha*A.a55 + beta*u.a5*v.a5;
} | java | public static void multAddOuter( double alpha , DMatrix5x5 A , double beta , DMatrix5 u , DMatrix5 v , DMatrix5x5 C ) {
C.a11 = alpha*A.a11 + beta*u.a1*v.a1;
C.a12 = alpha*A.a12 + beta*u.a1*v.a2;
C.a13 = alpha*A.a13 + beta*u.a1*v.a3;
C.a14 = alpha*A.a14 + beta*u.a1*v.a4;
C.a15 = alpha*A.a15 + beta*u.a1*v.a5;
C.a21 = alpha*A.a21 + beta*u.a2*v.a1;
C.a22 = alpha*A.a22 + beta*u.a2*v.a2;
C.a23 = alpha*A.a23 + beta*u.a2*v.a3;
C.a24 = alpha*A.a24 + beta*u.a2*v.a4;
C.a25 = alpha*A.a25 + beta*u.a2*v.a5;
C.a31 = alpha*A.a31 + beta*u.a3*v.a1;
C.a32 = alpha*A.a32 + beta*u.a3*v.a2;
C.a33 = alpha*A.a33 + beta*u.a3*v.a3;
C.a34 = alpha*A.a34 + beta*u.a3*v.a4;
C.a35 = alpha*A.a35 + beta*u.a3*v.a5;
C.a41 = alpha*A.a41 + beta*u.a4*v.a1;
C.a42 = alpha*A.a42 + beta*u.a4*v.a2;
C.a43 = alpha*A.a43 + beta*u.a4*v.a3;
C.a44 = alpha*A.a44 + beta*u.a4*v.a4;
C.a45 = alpha*A.a45 + beta*u.a4*v.a5;
C.a51 = alpha*A.a51 + beta*u.a5*v.a1;
C.a52 = alpha*A.a52 + beta*u.a5*v.a2;
C.a53 = alpha*A.a53 + beta*u.a5*v.a3;
C.a54 = alpha*A.a54 + beta*u.a5*v.a4;
C.a55 = alpha*A.a55 + beta*u.a5*v.a5;
} | [
"public",
"static",
"void",
"multAddOuter",
"(",
"double",
"alpha",
",",
"DMatrix5x5",
"A",
",",
"double",
"beta",
",",
"DMatrix5",
"u",
",",
"DMatrix5",
"v",
",",
"DMatrix5x5",
"C",
")",
"{",
"C",
".",
"a11",
"=",
"alpha",
"*",
"A",
".",
"a11",
"+",... | C = αA + βu*v<sup>T</sup>
@param alpha scale factor applied to A
@param A matrix
@param beta scale factor applies to outer product
@param u vector
@param v vector
@param C Storage for solution. Can be same instance as A. | [
"C",
"=",
"&alpha",
";",
"A",
"+",
"&beta",
";",
"u",
"*",
"v<sup",
">",
"T<",
"/",
"sup",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF5.java#L999-L1025 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/auth/AbstractAuthenticationStrategy.java | AbstractAuthenticationStrategy.resolveUser | private User resolveUser(RequestContext requestContext, List<String> emails) {
User user = null;
UserEmailDAO userEmailDAO = new UserEmailDAO();
for (String email : emails) {
UserEmail userEmail = userEmailDAO.findByAddress(email);
if (userEmail != null) {
if (user == null) {
user = userEmail.getUser();
}
else if (!user.getId().equals(userEmail.getUser().getId())) {
Messages messages = Messages.getInstance();
Locale locale = requestContext.getRequest().getLocale();
throw new SmvcRuntimeException(EdelfoiStatusCode.LOGIN_MULTIPLE_ACCOUNTS, messages.getText(locale, "exception.1023.loginMultipleAccounts"));
}
}
}
return user;
} | java | private User resolveUser(RequestContext requestContext, List<String> emails) {
User user = null;
UserEmailDAO userEmailDAO = new UserEmailDAO();
for (String email : emails) {
UserEmail userEmail = userEmailDAO.findByAddress(email);
if (userEmail != null) {
if (user == null) {
user = userEmail.getUser();
}
else if (!user.getId().equals(userEmail.getUser().getId())) {
Messages messages = Messages.getInstance();
Locale locale = requestContext.getRequest().getLocale();
throw new SmvcRuntimeException(EdelfoiStatusCode.LOGIN_MULTIPLE_ACCOUNTS, messages.getText(locale, "exception.1023.loginMultipleAccounts"));
}
}
}
return user;
} | [
"private",
"User",
"resolveUser",
"(",
"RequestContext",
"requestContext",
",",
"List",
"<",
"String",
">",
"emails",
")",
"{",
"User",
"user",
"=",
"null",
";",
"UserEmailDAO",
"userEmailDAO",
"=",
"new",
"UserEmailDAO",
"(",
")",
";",
"for",
"(",
"String",... | Determines a common <code>User</code> corresponding to the given list of e-mail addresses. If none of the e-mail addresses are in
use, returns <code>null</code>. If the e-mail addresses are associated to multiple user accounts, an <code>SmvcRuntimeException</code>
is thrown.
@param requestContext Request context
@param emails The list of e-mail addresses to validate
@return The common <code>User</code> corresponding to the given list of e-mail addresses, or <code>null</code> if the addresses are
not in use
@throws SmvcRuntimeException If the e-mail addresses are associated to multiple user accounts | [
"Determines",
"a",
"common",
"<code",
">",
"User<",
"/",
"code",
">",
"corresponding",
"to",
"the",
"given",
"list",
"of",
"e",
"-",
"mail",
"addresses",
".",
"If",
"none",
"of",
"the",
"e",
"-",
"mail",
"addresses",
"are",
"in",
"use",
"returns",
"<co... | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/auth/AbstractAuthenticationStrategy.java#L140-L157 |
domaframework/doma-gen | src/main/java/org/seasar/doma/extension/gen/ClassDescSupport.java | ClassDescSupport.isImportTargetPackage | protected boolean isImportTargetPackage(ClassDesc classDesc, String importPackageName) {
if (importPackageName == null) {
return false;
}
if (importPackageName.isEmpty()) {
return false;
}
if (importPackageName.equals(classDesc.getPackageName())) {
return false;
}
if (importPackageName.equals("java.lang")) {
return false;
}
return true;
} | java | protected boolean isImportTargetPackage(ClassDesc classDesc, String importPackageName) {
if (importPackageName == null) {
return false;
}
if (importPackageName.isEmpty()) {
return false;
}
if (importPackageName.equals(classDesc.getPackageName())) {
return false;
}
if (importPackageName.equals("java.lang")) {
return false;
}
return true;
} | [
"protected",
"boolean",
"isImportTargetPackage",
"(",
"ClassDesc",
"classDesc",
",",
"String",
"importPackageName",
")",
"{",
"if",
"(",
"importPackageName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"importPackageName",
".",
"isEmpty",
"("... | インポート対象のパッケージの場合 {@code true} を返します。
@param classDesc クラス記述
@param importPackageName インポートするパッケージ名
@return インポート対象のパッケージの場合 {@code true} | [
"インポート対象のパッケージの場合",
"{",
"@code",
"true",
"}",
"を返します。"
] | train | https://github.com/domaframework/doma-gen/blob/8046e0b28d2167d444125f206ce36e554b3ee616/src/main/java/org/seasar/doma/extension/gen/ClassDescSupport.java#L73-L87 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java | Types.isAssignable | public boolean isAssignable(Type t, Type s, Warner warn) {
if (t.hasTag(ERROR))
return true;
if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
int value = ((Number)t.constValue()).intValue();
switch (s.getTag()) {
case BYTE:
case CHAR:
case SHORT:
case INT:
if (s.getTag().checkRange(value))
return true;
break;
case CLASS:
switch (unboxedType(s).getTag()) {
case BYTE:
case CHAR:
case SHORT:
return isAssignable(t, unboxedType(s), warn);
}
break;
}
}
return isConvertible(t, s, warn);
} | java | public boolean isAssignable(Type t, Type s, Warner warn) {
if (t.hasTag(ERROR))
return true;
if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
int value = ((Number)t.constValue()).intValue();
switch (s.getTag()) {
case BYTE:
case CHAR:
case SHORT:
case INT:
if (s.getTag().checkRange(value))
return true;
break;
case CLASS:
switch (unboxedType(s).getTag()) {
case BYTE:
case CHAR:
case SHORT:
return isAssignable(t, unboxedType(s), warn);
}
break;
}
}
return isConvertible(t, s, warn);
} | [
"public",
"boolean",
"isAssignable",
"(",
"Type",
"t",
",",
"Type",
"s",
",",
"Warner",
"warn",
")",
"{",
"if",
"(",
"t",
".",
"hasTag",
"(",
"ERROR",
")",
")",
"return",
"true",
";",
"if",
"(",
"t",
".",
"getTag",
"(",
")",
".",
"isSubRangeOf",
... | Is t assignable to s?<br>
Equivalent to subtype except for constant values and raw
types.<br>
(not defined for Method and ForAll types) | [
"Is",
"t",
"assignable",
"to",
"s?<br",
">",
"Equivalent",
"to",
"subtype",
"except",
"for",
"constant",
"values",
"and",
"raw",
"types",
".",
"<br",
">",
"(",
"not",
"defined",
"for",
"Method",
"and",
"ForAll",
"types",
")"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java#L2047-L2071 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/A_CmsGroupEditor.java | A_CmsGroupEditor.setSaveEnabled | protected void setSaveEnabled(boolean enabled, String disabledMessage) {
if (m_saveButton != null) {
if (enabled) {
m_saveButton.enable();
} else {
m_saveButton.disable(disabledMessage);
}
}
} | java | protected void setSaveEnabled(boolean enabled, String disabledMessage) {
if (m_saveButton != null) {
if (enabled) {
m_saveButton.enable();
} else {
m_saveButton.disable(disabledMessage);
}
}
} | [
"protected",
"void",
"setSaveEnabled",
"(",
"boolean",
"enabled",
",",
"String",
"disabledMessage",
")",
"{",
"if",
"(",
"m_saveButton",
"!=",
"null",
")",
"{",
"if",
"(",
"enabled",
")",
"{",
"m_saveButton",
".",
"enable",
"(",
")",
";",
"}",
"else",
"{... | Enables or disables the save button.<p>
@param enabled <code>true</code> to enable the save button
@param disabledMessage the message to display when the button is disabled | [
"Enables",
"or",
"disables",
"the",
"save",
"button",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/A_CmsGroupEditor.java#L615-L624 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java | AdapterUtil.createXAException | public static XAException createXAException(String key, Object args, int xaErrorCode) {
XAException xaX = new XAException(
args == null ?
getNLSMessage(key) :
getNLSMessage(key, args));
xaX.errorCode = xaErrorCode;
return xaX;
} | java | public static XAException createXAException(String key, Object args, int xaErrorCode) {
XAException xaX = new XAException(
args == null ?
getNLSMessage(key) :
getNLSMessage(key, args));
xaX.errorCode = xaErrorCode;
return xaX;
} | [
"public",
"static",
"XAException",
"createXAException",
"(",
"String",
"key",
",",
"Object",
"args",
",",
"int",
"xaErrorCode",
")",
"{",
"XAException",
"xaX",
"=",
"new",
"XAException",
"(",
"args",
"==",
"null",
"?",
"getNLSMessage",
"(",
"key",
")",
":",
... | Create an XAException with a translated error message and an XA error code.
The XAException constructors provided by the XAException API allow only for either an
error message or an XA error code to be specified. This method constructs an
XAException with both. The error message is created from the NLS key and arguments.
@param key the NLS key.
@param args Object or Object[] listing parameters for the message; can be null if none.
@param xaErrorCode the XA error code.
@return a newly constructed XAException with the specified XA error code and a
descriptive error message. | [
"Create",
"an",
"XAException",
"with",
"a",
"translated",
"error",
"message",
"and",
"an",
"XA",
"error",
"code",
".",
"The",
"XAException",
"constructors",
"provided",
"by",
"the",
"XAException",
"API",
"allow",
"only",
"for",
"either",
"an",
"error",
"messag... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java#L142-L151 |
lucee/Lucee | core/src/main/java/lucee/runtime/schedule/StorageUtil.java | StorageUtil.toDate | public Date toDate(Element el, String attributeName, Date defaultValue) {
return new DateImpl(toDateTime(el, attributeName, defaultValue));
} | java | public Date toDate(Element el, String attributeName, Date defaultValue) {
return new DateImpl(toDateTime(el, attributeName, defaultValue));
} | [
"public",
"Date",
"toDate",
"(",
"Element",
"el",
",",
"String",
"attributeName",
",",
"Date",
"defaultValue",
")",
"{",
"return",
"new",
"DateImpl",
"(",
"toDateTime",
"(",
"el",
",",
"attributeName",
",",
"defaultValue",
")",
")",
";",
"}"
] | reads a XML Element Attribute ans cast it to a Date
@param el XML Element to read Attribute from it
@param attributeName Name of the Attribute to read
@param defaultValue if attribute doesn't exist return default value
@return Attribute Value | [
"reads",
"a",
"XML",
"Element",
"Attribute",
"ans",
"cast",
"it",
"to",
"a",
"Date"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/schedule/StorageUtil.java#L287-L289 |
ops4j/org.ops4j.pax.web | pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/util/ServicePropertiesUtils.java | ServicePropertiesUtils.getIntegerProperty | public static Integer getIntegerProperty(final ServiceReference<?> serviceReference, final String key) {
NullArgumentException.validateNotNull(serviceReference, "Service reference");
NullArgumentException.validateNotEmpty(key, true, "Property key");
final Object value = serviceReference.getProperty(key);
if (value instanceof Integer) {
return (Integer) value;
} else if (value != null) {
try {
return Integer.parseInt(String.valueOf(value));
} catch (NumberFormatException e) {
final String message = String.format("Property [%s] value must be an Integer: %s", key, e.getMessage());
LOG.error(message, e);
return null;
}
} else {
return null;
}
} | java | public static Integer getIntegerProperty(final ServiceReference<?> serviceReference, final String key) {
NullArgumentException.validateNotNull(serviceReference, "Service reference");
NullArgumentException.validateNotEmpty(key, true, "Property key");
final Object value = serviceReference.getProperty(key);
if (value instanceof Integer) {
return (Integer) value;
} else if (value != null) {
try {
return Integer.parseInt(String.valueOf(value));
} catch (NumberFormatException e) {
final String message = String.format("Property [%s] value must be an Integer: %s", key, e.getMessage());
LOG.error(message, e);
return null;
}
} else {
return null;
}
} | [
"public",
"static",
"Integer",
"getIntegerProperty",
"(",
"final",
"ServiceReference",
"<",
"?",
">",
"serviceReference",
",",
"final",
"String",
"key",
")",
"{",
"NullArgumentException",
".",
"validateNotNull",
"(",
"serviceReference",
",",
"\"Service reference\"",
"... | Returns a property as Integer.
@param serviceReference service reference; cannot be null
@param key property key; cannot be null
@return property value; null if property is not set or property value is
not an Integer
@throws NullArgumentException - If service reference is null - If key is null | [
"Returns",
"a",
"property",
"as",
"Integer",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.web/blob/9ecf3676c1d316be0d43ea7fcfdc8f0defffc2a2/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/util/ServicePropertiesUtils.java#L93-L110 |
windup/windup | config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java | RuleProviderSorter.checkForCycles | private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph)
{
CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
if (cycleDetector.detectCycles())
{
// if we have cycles, then try to throw an exception with some usable data
Set<RuleProvider> cycles = cycleDetector.findCycles();
StringBuilder errorSB = new StringBuilder();
for (RuleProvider cycle : cycles)
{
errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator());
Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle);
for (RuleProvider subCycle : subCycleSet)
{
errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator());
}
}
throw new RuntimeException("Dependency cycles detected: " + errorSB.toString());
}
} | java | private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph)
{
CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
if (cycleDetector.detectCycles())
{
// if we have cycles, then try to throw an exception with some usable data
Set<RuleProvider> cycles = cycleDetector.findCycles();
StringBuilder errorSB = new StringBuilder();
for (RuleProvider cycle : cycles)
{
errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator());
Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle);
for (RuleProvider subCycle : subCycleSet)
{
errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator());
}
}
throw new RuntimeException("Dependency cycles detected: " + errorSB.toString());
}
} | [
"private",
"void",
"checkForCycles",
"(",
"DefaultDirectedWeightedGraph",
"<",
"RuleProvider",
",",
"DefaultEdge",
">",
"graph",
")",
"{",
"CycleDetector",
"<",
"RuleProvider",
",",
"DefaultEdge",
">",
"cycleDetector",
"=",
"new",
"CycleDetector",
"<>",
"(",
"graph"... | Use the jgrapht cycle checker to detect any cycles in the provided dependency graph. | [
"Use",
"the",
"jgrapht",
"cycle",
"checker",
"to",
"detect",
"any",
"cycles",
"in",
"the",
"provided",
"dependency",
"graph",
"."
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java#L267-L287 |
udoprog/ffwd-client-java | src/main/java/com/google/protobuf250/CodedInputStream.java | CodedInputStream.readRawVarint32 | static int readRawVarint32(final InputStream input) throws IOException {
final int firstByte = input.read();
if (firstByte == -1) {
throw InvalidProtocolBufferException.truncatedMessage();
}
return readRawVarint32(firstByte, input);
} | java | static int readRawVarint32(final InputStream input) throws IOException {
final int firstByte = input.read();
if (firstByte == -1) {
throw InvalidProtocolBufferException.truncatedMessage();
}
return readRawVarint32(firstByte, input);
} | [
"static",
"int",
"readRawVarint32",
"(",
"final",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"final",
"int",
"firstByte",
"=",
"input",
".",
"read",
"(",
")",
";",
"if",
"(",
"firstByte",
"==",
"-",
"1",
")",
"{",
"throw",
"InvalidProtocolB... | Reads a varint from the input one byte at a time, so that it does not
read any bytes after the end of the varint. If you simply wrapped the
stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)}
then you would probably end up reading past the end of the varint since
CodedInputStream buffers its input. | [
"Reads",
"a",
"varint",
"from",
"the",
"input",
"one",
"byte",
"at",
"a",
"time",
"so",
"that",
"it",
"does",
"not",
"read",
"any",
"bytes",
"after",
"the",
"end",
"of",
"the",
"varint",
".",
"If",
"you",
"simply",
"wrapped",
"the",
"stream",
"in",
"... | train | https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/CodedInputStream.java#L413-L419 |
hawkular/hawkular-agent | hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/platform/OshiPlatformCache.java | OshiPlatformCache.getMetric | public Double getMetric(PlatformResourceType type, String name, ID metricToCollect) {
switch (type) {
case OPERATING_SYSTEM: {
return getOperatingSystemMetric(metricToCollect);
}
case MEMORY: {
return getMemoryMetric(metricToCollect);
}
case FILE_STORE: {
return getFileStoreMetric(name, metricToCollect);
}
case PROCESSOR: {
return getProcessorMetric(name, metricToCollect);
}
case POWER_SOURCE: {
return getPowerSourceMetric(name, metricToCollect);
}
default: {
throw new IllegalArgumentException(
"Platform resource [" + type + "][" + name + "] does not have metrics");
}
}
} | java | public Double getMetric(PlatformResourceType type, String name, ID metricToCollect) {
switch (type) {
case OPERATING_SYSTEM: {
return getOperatingSystemMetric(metricToCollect);
}
case MEMORY: {
return getMemoryMetric(metricToCollect);
}
case FILE_STORE: {
return getFileStoreMetric(name, metricToCollect);
}
case PROCESSOR: {
return getProcessorMetric(name, metricToCollect);
}
case POWER_SOURCE: {
return getPowerSourceMetric(name, metricToCollect);
}
default: {
throw new IllegalArgumentException(
"Platform resource [" + type + "][" + name + "] does not have metrics");
}
}
} | [
"public",
"Double",
"getMetric",
"(",
"PlatformResourceType",
"type",
",",
"String",
"name",
",",
"ID",
"metricToCollect",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"OPERATING_SYSTEM",
":",
"{",
"return",
"getOperatingSystemMetric",
"(",
"metricToCollect"... | Given a platform resource type, a name, and a metric name, this will return that metric's value,
or null if there is no resource that can be identified by the name and type.
@param type identifies the platform resource whose metric is to be collected
@param name name of the resource whose metric is to be collected
@param metricToCollect the metric to collect
@return the value of the metric, or null if there is no resource identified by the name | [
"Given",
"a",
"platform",
"resource",
"type",
"a",
"name",
"and",
"a",
"metric",
"name",
"this",
"will",
"return",
"that",
"metric",
"s",
"value",
"or",
"null",
"if",
"there",
"is",
"no",
"resource",
"that",
"can",
"be",
"identified",
"by",
"the",
"name"... | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/platform/OshiPlatformCache.java#L372-L394 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/dialogs/ListSelectDialog.java | ListSelectDialog.showDialog | public static <T> T showDialog(WindowBasedTextGUI textGUI, String title, String description, int listBoxHeight, T... items) {
int width = 0;
for(T item: items) {
width = Math.max(width, TerminalTextUtils.getColumnWidth(item.toString()));
}
width += 2;
return showDialog(textGUI, title, description, new TerminalSize(width, listBoxHeight), items);
} | java | public static <T> T showDialog(WindowBasedTextGUI textGUI, String title, String description, int listBoxHeight, T... items) {
int width = 0;
for(T item: items) {
width = Math.max(width, TerminalTextUtils.getColumnWidth(item.toString()));
}
width += 2;
return showDialog(textGUI, title, description, new TerminalSize(width, listBoxHeight), items);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"showDialog",
"(",
"WindowBasedTextGUI",
"textGUI",
",",
"String",
"title",
",",
"String",
"description",
",",
"int",
"listBoxHeight",
",",
"T",
"...",
"items",
")",
"{",
"int",
"width",
"=",
"0",
";",
"for",
"(",
... | Shortcut for quickly creating a new dialog
@param textGUI Text GUI to add the dialog to
@param title Title of the dialog
@param description Description of the dialog
@param listBoxHeight Maximum height of the list box, scrollbars will be used if there are more items
@param items Items in the dialog
@param <T> Type of items in the dialog
@return The selected item or {@code null} if cancelled | [
"Shortcut",
"for",
"quickly",
"creating",
"a",
"new",
"dialog"
] | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/dialogs/ListSelectDialog.java#L142-L149 |
nguyenq/tess4j | src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java | ImageIOHelper.getImageByteBuffer | public static ByteBuffer getImageByteBuffer(RenderedImage image) {
ColorModel cm = image.getColorModel();
WritableRaster wr = image.getData().createCompatibleWritableRaster(image.getWidth(), image.getHeight());
image.copyData(wr);
BufferedImage bi = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
return convertImageData(bi);
} | java | public static ByteBuffer getImageByteBuffer(RenderedImage image) {
ColorModel cm = image.getColorModel();
WritableRaster wr = image.getData().createCompatibleWritableRaster(image.getWidth(), image.getHeight());
image.copyData(wr);
BufferedImage bi = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
return convertImageData(bi);
} | [
"public",
"static",
"ByteBuffer",
"getImageByteBuffer",
"(",
"RenderedImage",
"image",
")",
"{",
"ColorModel",
"cm",
"=",
"image",
".",
"getColorModel",
"(",
")",
";",
"WritableRaster",
"wr",
"=",
"image",
".",
"getData",
"(",
")",
".",
"createCompatibleWritable... | Gets pixel data of an <code>RenderedImage</code> object.
@param image an <code>RenderedImage</code> object
@return a byte buffer of pixel data | [
"Gets",
"pixel",
"data",
"of",
"an",
"<code",
">",
"RenderedImage<",
"/",
"code",
">",
"object",
"."
] | train | https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java#L269-L275 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/util/MethodUtils.java | MethodUtils.invokeGetter | public static Object invokeGetter(Object object, String getterName, Object[] args)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
int index = getterName.indexOf('.');
if (index > 0) {
String getterName2 = getterName.substring(0, index);
Object o = invokeGetter(object, getterName2);
return invokeGetter(o, getterName.substring(index + 1), args);
} else {
if (!getterName.startsWith("get") && !getterName.startsWith("is")) {
getterName = "get" + getterName.substring(0, 1).toUpperCase(Locale.US) + getterName.substring(1);
}
return invokeMethod(object, getterName, args);
}
} | java | public static Object invokeGetter(Object object, String getterName, Object[] args)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
int index = getterName.indexOf('.');
if (index > 0) {
String getterName2 = getterName.substring(0, index);
Object o = invokeGetter(object, getterName2);
return invokeGetter(o, getterName.substring(index + 1), args);
} else {
if (!getterName.startsWith("get") && !getterName.startsWith("is")) {
getterName = "get" + getterName.substring(0, 1).toUpperCase(Locale.US) + getterName.substring(1);
}
return invokeMethod(object, getterName, args);
}
} | [
"public",
"static",
"Object",
"invokeGetter",
"(",
"Object",
"object",
",",
"String",
"getterName",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"int",
"index",
"=",
... | Gets an Object property from a bean.
@param object the bean
@param getterName the property name or getter method name
@param args use this arguments
@return the property value (as an Object)
@throws NoSuchMethodException the no such method exception
@throws IllegalAccessException the illegal access exception
@throws InvocationTargetException the invocation target exception | [
"Gets",
"an",
"Object",
"property",
"from",
"a",
"bean",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/MethodUtils.java#L127-L140 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/CheckedExceptionsFactory.java | CheckedExceptionsFactory.newCloneNotSupportedException | public static CloneNotSupportedException newCloneNotSupportedException(String message, Object... args) {
return newCloneNotSupportedException(null, message, args);
} | java | public static CloneNotSupportedException newCloneNotSupportedException(String message, Object... args) {
return newCloneNotSupportedException(null, message, args);
} | [
"public",
"static",
"CloneNotSupportedException",
"newCloneNotSupportedException",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"newCloneNotSupportedException",
"(",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] | Constructs and initializes a new {@link CloneNotSupportedException} with the given {@link String message}
formatted with the given {@link Object[] arguments}.
@param message {@link String} describing the {@link CloneNotSupportedException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link CloneNotSupportedException} with the given {@link String message}.
@see #newCloneNotSupportedException(Throwable, String, Object...)
@see java.lang.CloneNotSupportedException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"CloneNotSupportedException",
"}",
"with",
"the",
"given",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/CheckedExceptionsFactory.java#L45-L47 |
dwdyer/watchmaker | examples/src/java/main/org/uncommons/watchmaker/examples/monalisa/PolygonImageEvaluator.java | PolygonImageEvaluator.getFitness | public double getFitness(List<ColouredPolygon> candidate,
List<? extends List<ColouredPolygon>> population)
{
// Use one renderer per thread because they are not thread safe.
Renderer<List<ColouredPolygon>, BufferedImage> renderer = threadLocalRenderer.get();
if (renderer == null)
{
renderer = new PolygonImageRenderer(new Dimension(width, height),
false,
transform);
threadLocalRenderer.set(renderer);
}
BufferedImage candidateImage = renderer.render(candidate);
Raster candidateImageData = candidateImage.getData();
int[] candidatePixelValues = new int[targetPixels.length];
candidatePixelValues = (int[]) candidateImageData.getDataElements(0,
0,
candidateImageData.getWidth(),
candidateImageData.getHeight(),
candidatePixelValues);
double fitness = 0;
for (int i = 0; i < targetPixels.length; i++)
{
fitness += comparePixels(targetPixels[i], candidatePixelValues[i]);
}
return fitness;
} | java | public double getFitness(List<ColouredPolygon> candidate,
List<? extends List<ColouredPolygon>> population)
{
// Use one renderer per thread because they are not thread safe.
Renderer<List<ColouredPolygon>, BufferedImage> renderer = threadLocalRenderer.get();
if (renderer == null)
{
renderer = new PolygonImageRenderer(new Dimension(width, height),
false,
transform);
threadLocalRenderer.set(renderer);
}
BufferedImage candidateImage = renderer.render(candidate);
Raster candidateImageData = candidateImage.getData();
int[] candidatePixelValues = new int[targetPixels.length];
candidatePixelValues = (int[]) candidateImageData.getDataElements(0,
0,
candidateImageData.getWidth(),
candidateImageData.getHeight(),
candidatePixelValues);
double fitness = 0;
for (int i = 0; i < targetPixels.length; i++)
{
fitness += comparePixels(targetPixels[i], candidatePixelValues[i]);
}
return fitness;
} | [
"public",
"double",
"getFitness",
"(",
"List",
"<",
"ColouredPolygon",
">",
"candidate",
",",
"List",
"<",
"?",
"extends",
"List",
"<",
"ColouredPolygon",
">",
">",
"population",
")",
"{",
"// Use one renderer per thread because they are not thread safe.",
"Renderer",
... | Render the polygons as an image and then do a pixel-by-pixel comparison
against the target image. The fitness score is the total error. A lower
score means a closer match.
@param candidate The image to evaluate.
@param population Not used.
@return A number indicating how close the candidate image is to the target image
(lower is better). | [
"Render",
"the",
"polygons",
"as",
"an",
"image",
"and",
"then",
"do",
"a",
"pixel",
"-",
"by",
"-",
"pixel",
"comparison",
"against",
"the",
"target",
"image",
".",
"The",
"fitness",
"score",
"is",
"the",
"total",
"error",
".",
"A",
"lower",
"score",
... | train | https://github.com/dwdyer/watchmaker/blob/33d942350e6bf7d9a17b9262a4f898158530247e/examples/src/java/main/org/uncommons/watchmaker/examples/monalisa/PolygonImageEvaluator.java#L113-L142 |
Azure/azure-sdk-for-java | kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/ClustersInner.java | ClustersInner.startAsync | public Observable<Void> startAsync(String resourceGroupName, String clusterName) {
return startWithServiceResponseAsync(resourceGroupName, clusterName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> startAsync(String resourceGroupName, String clusterName) {
return startWithServiceResponseAsync(resourceGroupName, clusterName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"startAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
")",
"{",
"return",
"startWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
... | Starts a Kusto cluster.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Starts",
"a",
"Kusto",
"cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/ClustersInner.java#L907-L914 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/core/EventUtil.java | EventUtil.initEventHandlerInstance | public static synchronized void initEventHandlerInstance(int maxEntries,
int flushPeriodMs)
{
if (eventHandler.get() == null)
{
eventHandler.set(new EventHandler(maxEntries, flushPeriodMs));
}
//eventHandler.startFlusher();
} | java | public static synchronized void initEventHandlerInstance(int maxEntries,
int flushPeriodMs)
{
if (eventHandler.get() == null)
{
eventHandler.set(new EventHandler(maxEntries, flushPeriodMs));
}
//eventHandler.startFlusher();
} | [
"public",
"static",
"synchronized",
"void",
"initEventHandlerInstance",
"(",
"int",
"maxEntries",
",",
"int",
"flushPeriodMs",
")",
"{",
"if",
"(",
"eventHandler",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"eventHandler",
".",
"set",
"(",
"new",
"EventHa... | Initializes the common eventHandler instance for all sessions/threads
@param maxEntries - maximum number of buffered events before flush
@param flushPeriodMs - period of time between asynchronous buffer flushes | [
"Initializes",
"the",
"common",
"eventHandler",
"instance",
"for",
"all",
"sessions",
"/",
"threads"
] | train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/EventUtil.java#L43-L51 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getAllContinentPOIID | public void getAllContinentPOIID(int continentID, int floorID, int regionID, int mapID, Callback<List<Integer>> callback) throws NullPointerException {
gw2API.getAllContinentPOIIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).enqueue(callback);
} | java | public void getAllContinentPOIID(int continentID, int floorID, int regionID, int mapID, Callback<List<Integer>> callback) throws NullPointerException {
gw2API.getAllContinentPOIIDs(Integer.toString(continentID), Integer.toString(floorID), Integer.toString(regionID), Integer.toString(mapID)).enqueue(callback);
} | [
"public",
"void",
"getAllContinentPOIID",
"(",
"int",
"continentID",
",",
"int",
"floorID",
",",
"int",
"regionID",
",",
"int",
"mapID",
",",
"Callback",
"<",
"List",
"<",
"Integer",
">",
">",
"callback",
")",
"throws",
"NullPointerException",
"{",
"gw2API",
... | For more info on continents API go <a href="https://wiki.guildwars2.com/wiki/API:2/continents">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param continentID {@link Continent#id}
@param floorID {@link ContinentFloor#id}
@param regionID {@link ContinentRegion#id}
@param mapID {@link ContinentMap#id}
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws NullPointerException if given {@link Callback} is empty
@see ContinentMap.PoI continents map PoI info | [
"For",
"more",
"info",
"on",
"continents",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"continents",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"use... | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1177-L1179 |
pebble/pebble-android-sdk | PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java | PebbleKit.registerReceivedDataHandler | public static BroadcastReceiver registerReceivedDataHandler(final Context context,
final PebbleDataReceiver receiver) {
return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE, receiver);
} | java | public static BroadcastReceiver registerReceivedDataHandler(final Context context,
final PebbleDataReceiver receiver) {
return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE, receiver);
} | [
"public",
"static",
"BroadcastReceiver",
"registerReceivedDataHandler",
"(",
"final",
"Context",
"context",
",",
"final",
"PebbleDataReceiver",
"receiver",
")",
"{",
"return",
"registerBroadcastReceiverInternal",
"(",
"context",
",",
"INTENT_APP_RECEIVE",
",",
"receiver",
... | A convenience function to assist in programatically registering a broadcast receiver for the 'RECEIVE' intent.
To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the
Activity's {@link android.app.Activity#onPause()} method.
@param context
The context in which to register the BroadcastReceiver.
@param receiver
The receiver to be registered.
@return The registered receiver.
@see Constants#INTENT_APP_RECEIVE | [
"A",
"convenience",
"function",
"to",
"assist",
"in",
"programatically",
"registering",
"a",
"broadcast",
"receiver",
"for",
"the",
"RECEIVE",
"intent",
"."
] | train | https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L426-L429 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mime/MimeTypeParser.java | MimeTypeParser.safeParseMimeType | @Nullable
public static MimeType safeParseMimeType (@Nullable final String sMimeType,
@Nonnull final EMimeQuoting eQuotingAlgorithm)
{
try
{
return parseMimeType (sMimeType, eQuotingAlgorithm);
}
catch (final MimeTypeParserException ex)
{
return null;
}
} | java | @Nullable
public static MimeType safeParseMimeType (@Nullable final String sMimeType,
@Nonnull final EMimeQuoting eQuotingAlgorithm)
{
try
{
return parseMimeType (sMimeType, eQuotingAlgorithm);
}
catch (final MimeTypeParserException ex)
{
return null;
}
} | [
"@",
"Nullable",
"public",
"static",
"MimeType",
"safeParseMimeType",
"(",
"@",
"Nullable",
"final",
"String",
"sMimeType",
",",
"@",
"Nonnull",
"final",
"EMimeQuoting",
"eQuotingAlgorithm",
")",
"{",
"try",
"{",
"return",
"parseMimeType",
"(",
"sMimeType",
",",
... | Try to convert the string representation of a MIME type to an object. The
default quoting algorithm {@link CMimeType#DEFAULT_QUOTING} is used to
un-quote strings. Compared to {@link #parseMimeType(String, EMimeQuoting)}
this method swallows all {@link MimeTypeParserException} and simply returns
<code>null</code>.
@param sMimeType
The string representation to be converted. May be <code>null</code>.
@param eQuotingAlgorithm
The quoting algorithm to be used to un-quote parameter values. May
not be <code>null</code>.
@return <code>null</code> if the parsed string is empty or not a valid mime
type. | [
"Try",
"to",
"convert",
"the",
"string",
"representation",
"of",
"a",
"MIME",
"type",
"to",
"an",
"object",
".",
"The",
"default",
"quoting",
"algorithm",
"{",
"@link",
"CMimeType#DEFAULT_QUOTING",
"}",
"is",
"used",
"to",
"un",
"-",
"quote",
"strings",
".",... | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mime/MimeTypeParser.java#L418-L430 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java | FilteredCursor.applyFilter | public static <S extends Storable> Cursor<S> applyFilter(Cursor<S> cursor,
Class<S> type,
String filter,
Object... filterValues)
{
Filter<S> f = Filter.filterFor(type, filter).bind();
FilterValues<S> fv = f.initialFilterValues().withValues(filterValues);
return applyFilter(f, fv, cursor);
} | java | public static <S extends Storable> Cursor<S> applyFilter(Cursor<S> cursor,
Class<S> type,
String filter,
Object... filterValues)
{
Filter<S> f = Filter.filterFor(type, filter).bind();
FilterValues<S> fv = f.initialFilterValues().withValues(filterValues);
return applyFilter(f, fv, cursor);
} | [
"public",
"static",
"<",
"S",
"extends",
"Storable",
">",
"Cursor",
"<",
"S",
">",
"applyFilter",
"(",
"Cursor",
"<",
"S",
">",
"cursor",
",",
"Class",
"<",
"S",
">",
"type",
",",
"String",
"filter",
",",
"Object",
"...",
"filterValues",
")",
"{",
"F... | Returns a Cursor that is filtered by the given filter expression and values.
@param cursor cursor to wrap
@param type type of storable
@param filter filter to apply
@param filterValues values for filter
@return wrapped cursor which filters results
@throws IllegalStateException if any values are not specified
@throws IllegalArgumentException if any argument is null
@since 1.2 | [
"Returns",
"a",
"Cursor",
"that",
"is",
"filtered",
"by",
"the",
"given",
"filter",
"expression",
"and",
"values",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java#L49-L57 |
hal/elemento | core/src/main/java/org/jboss/gwt/elemento/core/Elements.java | Elements.lazyInsertBefore | public static void lazyInsertBefore(Element newElement, Element before) {
if (!before.parentNode.contains(newElement)) {
before.parentNode.insertBefore(newElement, before);
}
} | java | public static void lazyInsertBefore(Element newElement, Element before) {
if (!before.parentNode.contains(newElement)) {
before.parentNode.insertBefore(newElement, before);
}
} | [
"public",
"static",
"void",
"lazyInsertBefore",
"(",
"Element",
"newElement",
",",
"Element",
"before",
")",
"{",
"if",
"(",
"!",
"before",
".",
"parentNode",
".",
"contains",
"(",
"newElement",
")",
")",
"{",
"before",
".",
"parentNode",
".",
"insertBefore"... | Inserts the specified element into the parent of the before element if not already present. If parent already
contains child, this method does nothing. | [
"Inserts",
"the",
"specified",
"element",
"into",
"the",
"parent",
"of",
"the",
"before",
"element",
"if",
"not",
"already",
"present",
".",
"If",
"parent",
"already",
"contains",
"child",
"this",
"method",
"does",
"nothing",
"."
] | train | https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L688-L692 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/MPXReader.java | MPXReader.addDateRange | private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} | java | private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} | [
"private",
"void",
"addDateRange",
"(",
"ProjectCalendarHours",
"hours",
",",
"Date",
"start",
",",
"Date",
"end",
")",
"{",
"if",
"(",
"start",
"!=",
"null",
"&&",
"end",
"!=",
"null",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
... | Get a date range that correctly handles the case where the end time
is midnight. In this instance the end time should be the start of the
next day.
@param hours calendar hours
@param start start date
@param end end date | [
"Get",
"a",
"date",
"range",
"that",
"correctly",
"handles",
"the",
"case",
"where",
"the",
"end",
"time",
"is",
"midnight",
".",
"In",
"this",
"instance",
"the",
"end",
"time",
"should",
"be",
"the",
"start",
"of",
"the",
"next",
"day",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXReader.java#L649-L664 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java | JDBC4ClientConnection.updateApplicationCatalog | public ClientResponse updateApplicationCatalog(File catalogPath, File deploymentPath)
throws IOException, NoConnectionsException, ProcCallException
{
ClientImpl currentClient = this.getClient();
try {
return currentClient.updateApplicationCatalog(catalogPath, deploymentPath);
}
catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
} | java | public ClientResponse updateApplicationCatalog(File catalogPath, File deploymentPath)
throws IOException, NoConnectionsException, ProcCallException
{
ClientImpl currentClient = this.getClient();
try {
return currentClient.updateApplicationCatalog(catalogPath, deploymentPath);
}
catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
} | [
"public",
"ClientResponse",
"updateApplicationCatalog",
"(",
"File",
"catalogPath",
",",
"File",
"deploymentPath",
")",
"throws",
"IOException",
",",
"NoConnectionsException",
",",
"ProcCallException",
"{",
"ClientImpl",
"currentClient",
"=",
"this",
".",
"getClient",
"... | Synchronously invokes UpdateApplicationCatalog procedure. Blocks until a result is available.
A {@link ProcCallException} is thrown if the response is anything other then success.
@param catalogPath
Path to the catalog jar file.
@param deploymentPath
Path to the deployment file
@return array of VoltTable results
@throws IOException
If the files cannot be serialized
@throws NoConnectionException
@throws ProcCallException | [
"Synchronously",
"invokes",
"UpdateApplicationCatalog",
"procedure",
".",
"Blocks",
"until",
"a",
"result",
"is",
"available",
".",
"A",
"{",
"@link",
"ProcCallException",
"}",
"is",
"thrown",
"if",
"the",
"response",
"is",
"anything",
"other",
"then",
"success",
... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java#L540-L551 |
ttddyy/datasource-proxy | src/main/java/net/ttddyy/dsproxy/listener/logging/DefaultQueryLogEntryCreator.java | DefaultQueryLogEntryCreator.writeParamsEntry | protected void writeParamsEntry(StringBuilder sb, ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
boolean isPrepared = execInfo.getStatementType() == StatementType.PREPARED;
sb.append("Params:[");
for (QueryInfo queryInfo : queryInfoList) {
for (List<ParameterSetOperation> parameters : queryInfo.getParametersList()) {
SortedMap<String, String> paramMap = getParametersToDisplay(parameters);
// parameters per batch.
// for prepared: (val1,val2,...)
// for callable: (key1=val1,key2=val2,...)
if (isPrepared) {
writeParamsForSinglePreparedEntry(sb, paramMap, execInfo, queryInfoList);
} else {
writeParamsForSingleCallableEntry(sb, paramMap, execInfo, queryInfoList);
}
}
}
chompIfEndWith(sb, ',');
sb.append("]");
} | java | protected void writeParamsEntry(StringBuilder sb, ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
boolean isPrepared = execInfo.getStatementType() == StatementType.PREPARED;
sb.append("Params:[");
for (QueryInfo queryInfo : queryInfoList) {
for (List<ParameterSetOperation> parameters : queryInfo.getParametersList()) {
SortedMap<String, String> paramMap = getParametersToDisplay(parameters);
// parameters per batch.
// for prepared: (val1,val2,...)
// for callable: (key1=val1,key2=val2,...)
if (isPrepared) {
writeParamsForSinglePreparedEntry(sb, paramMap, execInfo, queryInfoList);
} else {
writeParamsForSingleCallableEntry(sb, paramMap, execInfo, queryInfoList);
}
}
}
chompIfEndWith(sb, ',');
sb.append("]");
} | [
"protected",
"void",
"writeParamsEntry",
"(",
"StringBuilder",
"sb",
",",
"ExecutionInfo",
"execInfo",
",",
"List",
"<",
"QueryInfo",
">",
"queryInfoList",
")",
"{",
"boolean",
"isPrepared",
"=",
"execInfo",
".",
"getStatementType",
"(",
")",
"==",
"StatementType"... | Write query parameters.
<p>default for prepared: Params:[(foo,100),(bar,101)],
<p>default for callable: Params:[(1=foo,key=100),(1=bar,key=101)],
@param sb StringBuilder to write
@param execInfo execution info
@param queryInfoList query info list
@since 1.3.3 | [
"Write",
"query",
"parameters",
"."
] | train | https://github.com/ttddyy/datasource-proxy/blob/62163ccf9a569a99aa3ad9f9151a32567447a62e/src/main/java/net/ttddyy/dsproxy/listener/logging/DefaultQueryLogEntryCreator.java#L258-L282 |
haraldk/TwelveMonkeys | common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java | FileUtil.getDirectoryname | public static String getDirectoryname(final String pPath, final char pSeparator) {
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return ""; // Assume only filename
}
return pPath.substring(0, index);
} | java | public static String getDirectoryname(final String pPath, final char pSeparator) {
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return ""; // Assume only filename
}
return pPath.substring(0, index);
} | [
"public",
"static",
"String",
"getDirectoryname",
"(",
"final",
"String",
"pPath",
",",
"final",
"char",
"pSeparator",
")",
"{",
"int",
"index",
"=",
"pPath",
".",
"lastIndexOf",
"(",
"pSeparator",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"retur... | Extracts the directory path without the filename, from a complete
filename path.
@param pPath The full filename path.
@param pSeparator the separator char used in {@code pPath}
@return the path without the filename.
@see File#getParent
@see #getFilename | [
"Extracts",
"the",
"directory",
"path",
"without",
"the",
"filename",
"from",
"a",
"complete",
"filename",
"path",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L436-L443 |
Talend/tesb-rt-se | locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java | SLPropertiesImpl.addProperty | public void addProperty(String name, String... values) {
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
} | java | public void addProperty(String name, String... values) {
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
} | [
"public",
"void",
"addProperty",
"(",
"String",
"name",
",",
"String",
"...",
"values",
")",
"{",
"List",
"<",
"String",
">",
"valueList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"value",
":",
"values",
")",
... | Add a property with the given name and the given list of values to this Properties object. Name
and values are trimmed before the property is added.
@param name the name of the property, must not be <code>null</code>.
@param values the values of the property, must no be <code>null</code>,
none of the values must be <code>null</code> | [
"Add",
"a",
"property",
"with",
"the",
"given",
"name",
"and",
"the",
"given",
"list",
"of",
"values",
"to",
"this",
"Properties",
"object",
".",
"Name",
"and",
"values",
"are",
"trimmed",
"before",
"the",
"property",
"is",
"added",
"."
] | train | https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java#L52-L58 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java | DependentFileFilter.init | public void init(Record record, String thisFileFieldName, BaseField fldThisFile, String thisFileFieldName2, BaseField fldThisFile2, String thisFileFieldName3, BaseField fldThisFile3)
{
super.init(record);
this.thisFileFieldName = thisFileFieldName;
m_fldThisFile = fldThisFile;
this.thisFileFieldName2 = thisFileFieldName2;
m_fldThisFile2 = fldThisFile2;
this.thisFileFieldName3 = thisFileFieldName3;
m_fldThisFile3 = fldThisFile3;
m_bInitialKey = true;
m_bEndKey = true;
} | java | public void init(Record record, String thisFileFieldName, BaseField fldThisFile, String thisFileFieldName2, BaseField fldThisFile2, String thisFileFieldName3, BaseField fldThisFile3)
{
super.init(record);
this.thisFileFieldName = thisFileFieldName;
m_fldThisFile = fldThisFile;
this.thisFileFieldName2 = thisFileFieldName2;
m_fldThisFile2 = fldThisFile2;
this.thisFileFieldName3 = thisFileFieldName3;
m_fldThisFile3 = fldThisFile3;
m_bInitialKey = true;
m_bEndKey = true;
} | [
"public",
"void",
"init",
"(",
"Record",
"record",
",",
"String",
"thisFileFieldName",
",",
"BaseField",
"fldThisFile",
",",
"String",
"thisFileFieldName2",
",",
"BaseField",
"fldThisFile2",
",",
"String",
"thisFileFieldName3",
",",
"BaseField",
"fldThisFile3",
")",
... | Constructor.
@param record My owner (usually passed as null, and set on addListener in setOwner()).
@param iFieldSeq The First field sequence of the key.
@param fldThisFile The first field
@param iFieldSeq2 The Second field sequence of the key (-1 for none).
@param fldThisFile2 The second field
@param iFieldSeq3 The Third field sequence of the key (-1 for none).
@param fldThisFile3 The third field | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java#L68-L79 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.uploadNewVersion | public BoxFile.Info uploadNewVersion(InputStream fileContent, String fileContentSHA1) {
return this.uploadNewVersion(fileContent, fileContentSHA1, null);
} | java | public BoxFile.Info uploadNewVersion(InputStream fileContent, String fileContentSHA1) {
return this.uploadNewVersion(fileContent, fileContentSHA1, null);
} | [
"public",
"BoxFile",
".",
"Info",
"uploadNewVersion",
"(",
"InputStream",
"fileContent",
",",
"String",
"fileContentSHA1",
")",
"{",
"return",
"this",
".",
"uploadNewVersion",
"(",
"fileContent",
",",
"fileContentSHA1",
",",
"null",
")",
";",
"}"
] | Uploads a new version of this file, replacing the current version. Note that only users with premium accounts
will be able to view and recover previous versions of the file.
@param fileContent a stream containing the new file contents.
@param fileContentSHA1 a string containing the SHA1 hash of the new file contents.
@return the uploaded file version. | [
"Uploads",
"a",
"new",
"version",
"of",
"this",
"file",
"replacing",
"the",
"current",
"version",
".",
"Note",
"that",
"only",
"users",
"with",
"premium",
"accounts",
"will",
"be",
"able",
"to",
"view",
"and",
"recover",
"previous",
"versions",
"of",
"the",
... | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L810-L812 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java | ResourceBundlesHandlerImpl.executeGlobalPreprocessing | private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
} | java | private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
} | [
"private",
"void",
"executeGlobalPreprocessing",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundlesToBuild",
",",
"boolean",
"processBundleFlag",
",",
"StopWatch",
"stopWatch",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"resourceTypePreprocessor",... | Executes the global preprocessing
@param bundlesToBuild
The list of bundles to rebuild
@param processBundleFlag
the flag indicating if the bundles needs to be processed
@param stopWatch
the stopWatch | [
"Executes",
"the",
"global",
"preprocessing"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L732-L756 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java | SegmentServiceImpl.readMetaSegment | private boolean readMetaSegment(ReadStream is, int crc)
throws IOException
{
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
SegmentExtent segment = new SegmentExtent(_segmentId++, address, length);
SegmentMeta segmentMeta = findSegmentMeta(length);
segmentMeta.addSegment(segment);
return true;
} | java | private boolean readMetaSegment(ReadStream is, int crc)
throws IOException
{
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
SegmentExtent segment = new SegmentExtent(_segmentId++, address, length);
SegmentMeta segmentMeta = findSegmentMeta(length);
segmentMeta.addSegment(segment);
return true;
} | [
"private",
"boolean",
"readMetaSegment",
"(",
"ReadStream",
"is",
",",
"int",
"crc",
")",
"throws",
"IOException",
"{",
"long",
"value",
"=",
"BitsUtil",
".",
"readLong",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generate",
"(",
"crc",
",",
"... | metadata for a segment
<pre><code>
address int48
length int16
crc int32
</code></pre> | [
"metadata",
"for",
"a",
"segment"
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java#L822-L846 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/LinkClustering.java | LinkClustering.calculateEdgeSimMatrix | private Matrix calculateEdgeSimMatrix(
final List<Edge> edgeList, final SparseMatrix sm) {
final int numEdges = edgeList.size();
final Matrix edgeSimMatrix =
new SparseSymmetricMatrix(
new SparseHashMatrix(numEdges, numEdges));
Object key = workQueue.registerTaskGroup(numEdges);
for (int i = 0; i < numEdges; ++i) {
final int row = i;
workQueue.add(key, new Runnable() {
public void run() {
for (int j = row; j < numEdges; ++j) {
Edge e1 = edgeList.get(row);
Edge e2 = edgeList.get(j);
double sim = getEdgeSimilarity(sm, e1, e2);
if (sim > 0) {
// The symmetric matrix handles the (j,i) case
edgeSimMatrix.set(row, j, sim);
}
}
}
});
}
workQueue.await(key);
return edgeSimMatrix;
} | java | private Matrix calculateEdgeSimMatrix(
final List<Edge> edgeList, final SparseMatrix sm) {
final int numEdges = edgeList.size();
final Matrix edgeSimMatrix =
new SparseSymmetricMatrix(
new SparseHashMatrix(numEdges, numEdges));
Object key = workQueue.registerTaskGroup(numEdges);
for (int i = 0; i < numEdges; ++i) {
final int row = i;
workQueue.add(key, new Runnable() {
public void run() {
for (int j = row; j < numEdges; ++j) {
Edge e1 = edgeList.get(row);
Edge e2 = edgeList.get(j);
double sim = getEdgeSimilarity(sm, e1, e2);
if (sim > 0) {
// The symmetric matrix handles the (j,i) case
edgeSimMatrix.set(row, j, sim);
}
}
}
});
}
workQueue.await(key);
return edgeSimMatrix;
} | [
"private",
"Matrix",
"calculateEdgeSimMatrix",
"(",
"final",
"List",
"<",
"Edge",
">",
"edgeList",
",",
"final",
"SparseMatrix",
"sm",
")",
"{",
"final",
"int",
"numEdges",
"=",
"edgeList",
".",
"size",
"(",
")",
";",
"final",
"Matrix",
"edgeSimMatrix",
"=",... | Calculates the similarity matrix for the edges. The similarity matrix is
symmetric.
@param edgeList the list of all edges known to the system
@param sm a square matrix whose values denote edges between the rows.
@return the similarity matrix | [
"Calculates",
"the",
"similarity",
"matrix",
"for",
"the",
"edges",
".",
"The",
"similarity",
"matrix",
"is",
"symmetric",
"."
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/LinkClustering.java#L373-L402 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.getTagAsync | public Observable<Tag> getTagAsync(UUID projectId, UUID tagId, GetTagOptionalParameter getTagOptionalParameter) {
return getTagWithServiceResponseAsync(projectId, tagId, getTagOptionalParameter).map(new Func1<ServiceResponse<Tag>, Tag>() {
@Override
public Tag call(ServiceResponse<Tag> response) {
return response.body();
}
});
} | java | public Observable<Tag> getTagAsync(UUID projectId, UUID tagId, GetTagOptionalParameter getTagOptionalParameter) {
return getTagWithServiceResponseAsync(projectId, tagId, getTagOptionalParameter).map(new Func1<ServiceResponse<Tag>, Tag>() {
@Override
public Tag call(ServiceResponse<Tag> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Tag",
">",
"getTagAsync",
"(",
"UUID",
"projectId",
",",
"UUID",
"tagId",
",",
"GetTagOptionalParameter",
"getTagOptionalParameter",
")",
"{",
"return",
"getTagWithServiceResponseAsync",
"(",
"projectId",
",",
"tagId",
",",
"getTagOptiona... | Get information about a specific tag.
@param projectId The project this tag belongs to
@param tagId The tag id
@param getTagOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Tag object | [
"Get",
"information",
"about",
"a",
"specific",
"tag",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L804-L811 |
threerings/nenya | core/src/main/java/com/threerings/miso/client/MisoScenePanel.java | MisoScenePanel.getPath | public Path getPath (Sprite sprite, int x, int y, boolean loose)
{
// sanity check
if (sprite == null) {
throw new IllegalArgumentException(
"Can't get path for null sprite [x=" + x + ", y=" + y + ".");
}
// get the destination tile coordinates
Point src = MisoUtil.screenToTile(
_metrics, sprite.getX(), sprite.getY(), new Point());
Point dest = MisoUtil.screenToTile(_metrics, x, y, new Point());
// compute our longest path from the screen size
int longestPath = 3 * (getWidth() / _metrics.tilewid);
// get a reasonable tile path through the scene
long start = System.currentTimeMillis();
List<Point> points = AStarPathUtil.getPath(
this, sprite, longestPath, src.x, src.y, dest.x, dest.y, loose);
long duration = System.currentTimeMillis() - start;
// sanity check the number of nodes searched so that we can keep an eye out for bogosity
if (duration > 500L) {
int considered = AStarPathUtil.getConsidered();
log.warning("Considered " + considered + " nodes for path from " +
StringUtil.toString(src) + " to " +
StringUtil.toString(dest) +
" [duration=" + duration + "].");
}
// construct a path object to guide the sprite on its merry way
return (points == null) ? null :
new TilePath(_metrics, sprite, points, x, y);
} | java | public Path getPath (Sprite sprite, int x, int y, boolean loose)
{
// sanity check
if (sprite == null) {
throw new IllegalArgumentException(
"Can't get path for null sprite [x=" + x + ", y=" + y + ".");
}
// get the destination tile coordinates
Point src = MisoUtil.screenToTile(
_metrics, sprite.getX(), sprite.getY(), new Point());
Point dest = MisoUtil.screenToTile(_metrics, x, y, new Point());
// compute our longest path from the screen size
int longestPath = 3 * (getWidth() / _metrics.tilewid);
// get a reasonable tile path through the scene
long start = System.currentTimeMillis();
List<Point> points = AStarPathUtil.getPath(
this, sprite, longestPath, src.x, src.y, dest.x, dest.y, loose);
long duration = System.currentTimeMillis() - start;
// sanity check the number of nodes searched so that we can keep an eye out for bogosity
if (duration > 500L) {
int considered = AStarPathUtil.getConsidered();
log.warning("Considered " + considered + " nodes for path from " +
StringUtil.toString(src) + " to " +
StringUtil.toString(dest) +
" [duration=" + duration + "].");
}
// construct a path object to guide the sprite on its merry way
return (points == null) ? null :
new TilePath(_metrics, sprite, points, x, y);
} | [
"public",
"Path",
"getPath",
"(",
"Sprite",
"sprite",
",",
"int",
"x",
",",
"int",
"y",
",",
"boolean",
"loose",
")",
"{",
"// sanity check",
"if",
"(",
"sprite",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't get path for ... | Computes a path for the specified sprite to the specified tile coordinates.
@param loose if true, an approximate path will be returned if a complete path cannot be
located. This path will navigate the sprite "legally" as far as possible and then walk the
sprite in a straight line to its final destination. This is generally only useful if the
the path goes "off screen". | [
"Computes",
"a",
"path",
"for",
"the",
"specified",
"sprite",
"to",
"the",
"specified",
"tile",
"coordinates",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/MisoScenePanel.java#L280-L314 |
codelibs/fess | src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java | FessMessages.addSuccessUploadDesignFile | public FessMessages addSuccessUploadDesignFile(String property, String arg0) {
assertPropertyNotNull(property);
add(property, new UserMessage(SUCCESS_upload_design_file, arg0));
return this;
} | java | public FessMessages addSuccessUploadDesignFile(String property, String arg0) {
assertPropertyNotNull(property);
add(property, new UserMessage(SUCCESS_upload_design_file, arg0));
return this;
} | [
"public",
"FessMessages",
"addSuccessUploadDesignFile",
"(",
"String",
"property",
",",
"String",
"arg0",
")",
"{",
"assertPropertyNotNull",
"(",
"property",
")",
";",
"add",
"(",
"property",
",",
"new",
"UserMessage",
"(",
"SUCCESS_upload_design_file",
",",
"arg0",... | Add the created action message for the key 'success.upload_design_file' with parameters.
<pre>
message: Uploaded {0}.
</pre>
@param property The property name for the message. (NotNull)
@param arg0 The parameter arg0 for message. (NotNull)
@return this. (NotNull) | [
"Add",
"the",
"created",
"action",
"message",
"for",
"the",
"key",
"success",
".",
"upload_design_file",
"with",
"parameters",
".",
"<pre",
">",
"message",
":",
"Uploaded",
"{",
"0",
"}",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java#L2331-L2335 |
alkacon/opencms-core | src/org/opencms/widgets/CmsMultiSelectGroupWidget.java | CmsMultiSelectGroupWidget.parseConfiguration | private void parseConfiguration(CmsObject cms, CmsMessages widgetDialog) {
String configString = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog);
Map<String, String> config = CmsStringUtil.splitAsMap(configString, "|", "=");
// get the list of group names to show
String groups = config.get(CONFIGURATION_GROUPS);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(groups)) {
m_groupNames = CmsStringUtil.splitAsList(groups, ',', true);
}
// get the regular expression to filter the groups
String filter = config.get(CONFIGURATION_GROUPFILTER);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
try {
m_groupFilter = Pattern.compile(filter);
} catch (PatternSyntaxException e) {
// log pattern syntax errors
LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_WIDGET_SELECTGROUP_PATTERN_1, filter));
}
}
// get the OU to read the groups from
m_ouFqn = config.get(CONFIGURATION_OUFQN);
if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_ouFqn)) {
m_ouFqn = "";
} else if (!m_ouFqn.endsWith(CmsOrganizationalUnit.SEPARATOR)) {
m_ouFqn += CmsOrganizationalUnit.SEPARATOR;
}
// set the flag to include sub OUs
m_includeSubOus = Boolean.parseBoolean(config.get(CONFIGURATION_INCLUDESUBOUS));
m_defaultAllAvailable = Boolean.parseBoolean(config.get(CONFIGURATION_DEFAULT_ALL));
} | java | private void parseConfiguration(CmsObject cms, CmsMessages widgetDialog) {
String configString = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog);
Map<String, String> config = CmsStringUtil.splitAsMap(configString, "|", "=");
// get the list of group names to show
String groups = config.get(CONFIGURATION_GROUPS);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(groups)) {
m_groupNames = CmsStringUtil.splitAsList(groups, ',', true);
}
// get the regular expression to filter the groups
String filter = config.get(CONFIGURATION_GROUPFILTER);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
try {
m_groupFilter = Pattern.compile(filter);
} catch (PatternSyntaxException e) {
// log pattern syntax errors
LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_WIDGET_SELECTGROUP_PATTERN_1, filter));
}
}
// get the OU to read the groups from
m_ouFqn = config.get(CONFIGURATION_OUFQN);
if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_ouFqn)) {
m_ouFqn = "";
} else if (!m_ouFqn.endsWith(CmsOrganizationalUnit.SEPARATOR)) {
m_ouFqn += CmsOrganizationalUnit.SEPARATOR;
}
// set the flag to include sub OUs
m_includeSubOus = Boolean.parseBoolean(config.get(CONFIGURATION_INCLUDESUBOUS));
m_defaultAllAvailable = Boolean.parseBoolean(config.get(CONFIGURATION_DEFAULT_ALL));
} | [
"private",
"void",
"parseConfiguration",
"(",
"CmsObject",
"cms",
",",
"CmsMessages",
"widgetDialog",
")",
"{",
"String",
"configString",
"=",
"CmsMacroResolver",
".",
"resolveMacros",
"(",
"getConfiguration",
"(",
")",
",",
"cms",
",",
"widgetDialog",
")",
";",
... | Parses the widget configuration string.<p>
@param cms the current users OpenCms context
@param widgetDialog the dialog of this widget | [
"Parses",
"the",
"widget",
"configuration",
"string",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/CmsMultiSelectGroupWidget.java#L477-L506 |
alkacon/opencms-core | src/org/opencms/main/OpenCmsCore.java | OpenCmsCore.initCmsObject | private CmsObject initCmsObject(HttpServletRequest req, HttpServletResponse res) throws IOException, CmsException {
return initCmsObject(req, res, true);
} | java | private CmsObject initCmsObject(HttpServletRequest req, HttpServletResponse res) throws IOException, CmsException {
return initCmsObject(req, res, true);
} | [
"private",
"CmsObject",
"initCmsObject",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
")",
"throws",
"IOException",
",",
"CmsException",
"{",
"return",
"initCmsObject",
"(",
"req",
",",
"res",
",",
"true",
")",
";",
"}"
] | Handles the user authentification for each request sent to OpenCms.<p>
User authentification is done in three steps:
<ol>
<li>Session authentification: OpenCms stores information of all authentificated
users in an internal storage based on the users session.</li>
<li>Authorization handler authentification: If the session authentification fails,
the current configured authorization handler is called.</li>
<li>Default user: When both authentification methods fail, the user is set to
the default (Guest) user.</li>
</ol>
@param req the current http request
@param res the current http response
@return the initialized cms context
@throws IOException if user authentication fails
@throws CmsException in case something goes wrong | [
"Handles",
"the",
"user",
"authentification",
"for",
"each",
"request",
"sent",
"to",
"OpenCms",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/OpenCmsCore.java#L2969-L2972 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/util/zip/ZipUtils.java | ZipUtils.zipEntry | static ZipOutputStream zipEntry(ZipEntry entry, ZipOutputStream outputStream) {
try {
outputStream.putNextEntry(entry);
}
catch (IOException cause) {
throw newSystemException(cause,"Failed to zip entry [%s]", entry.getName());
}
IOUtils.doSafeIo(outputStream::closeEntry);
return outputStream;
} | java | static ZipOutputStream zipEntry(ZipEntry entry, ZipOutputStream outputStream) {
try {
outputStream.putNextEntry(entry);
}
catch (IOException cause) {
throw newSystemException(cause,"Failed to zip entry [%s]", entry.getName());
}
IOUtils.doSafeIo(outputStream::closeEntry);
return outputStream;
} | [
"static",
"ZipOutputStream",
"zipEntry",
"(",
"ZipEntry",
"entry",
",",
"ZipOutputStream",
"outputStream",
")",
"{",
"try",
"{",
"outputStream",
".",
"putNextEntry",
"(",
"entry",
")",
";",
"}",
"catch",
"(",
"IOException",
"cause",
")",
"{",
"throw",
"newSyst... | Zips the contents of the individual {@link ZipEntry} to the supplied {@link ZipOutputStream}.
@param entry {@link ZipEntry} to compress and add to the supplied {@link ZipOutputStream}.
@param outputStream {@link ZipOutputStream} used to zip the contents of the given {@link ZipEntry}.
@return the given {@link ZipOutputStream}.
@throws SystemException if {@link ZipEntry} could not be compressed and added to
the supplied {@link ZipOutputStream}.
@see java.util.zip.ZipOutputStream
@see java.util.zip.ZipEntry | [
"Zips",
"the",
"contents",
"of",
"the",
"individual",
"{",
"@link",
"ZipEntry",
"}",
"to",
"the",
"supplied",
"{",
"@link",
"ZipOutputStream",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/zip/ZipUtils.java#L255-L267 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java | Validator.expectMax | public void expectMax(String name, double maxLength, String message) {
String value = Optional.ofNullable(get(name)).orElse("");
if (StringUtils.isNumeric(value)) {
if (Double.parseDouble(value) > maxLength) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
}
} else {
if (value.length() > maxLength) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
}
}
} | java | public void expectMax(String name, double maxLength, String message) {
String value = Optional.ofNullable(get(name)).orElse("");
if (StringUtils.isNumeric(value)) {
if (Double.parseDouble(value) > maxLength) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
}
} else {
if (value.length() > maxLength) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
}
}
} | [
"public",
"void",
"expectMax",
"(",
"String",
"name",
",",
"double",
"maxLength",
",",
"String",
"message",
")",
"{",
"String",
"value",
"=",
"Optional",
".",
"ofNullable",
"(",
"get",
"(",
"name",
")",
")",
".",
"orElse",
"(",
"\"\"",
")",
";",
"if",
... | Validates a given field to have a maximum length
@param name The field to check
@param maxLength The maximum length
@param message A custom error message instead of the default one | [
"Validates",
"a",
"given",
"field",
"to",
"have",
"a",
"maximum",
"length"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java#L151-L163 |
mbenson/therian | core/src/main/java/therian/TherianContext.java | TherianContext.supports | public synchronized <RESULT> boolean supports(final Operation<RESULT> operation, Hint... hints) {
final Frame<RESULT> frame = new Frame<>(Phase.SUPPORT_CHECK, operation, hints);
try {
return handle(frame);
} catch (Frame.RecursionException e) {
return false;
}
} | java | public synchronized <RESULT> boolean supports(final Operation<RESULT> operation, Hint... hints) {
final Frame<RESULT> frame = new Frame<>(Phase.SUPPORT_CHECK, operation, hints);
try {
return handle(frame);
} catch (Frame.RecursionException e) {
return false;
}
} | [
"public",
"synchronized",
"<",
"RESULT",
">",
"boolean",
"supports",
"(",
"final",
"Operation",
"<",
"RESULT",
">",
"operation",
",",
"Hint",
"...",
"hints",
")",
"{",
"final",
"Frame",
"<",
"RESULT",
">",
"frame",
"=",
"new",
"Frame",
"<>",
"(",
"Phase"... | Learn whether {@code operation} is supported by this context.
@param operation
@return boolean
@throws NullPointerException on {@code null} input | [
"Learn",
"whether",
"{",
"@code",
"operation",
"}",
"is",
"supported",
"by",
"this",
"context",
"."
] | train | https://github.com/mbenson/therian/blob/0653505f73e2a6f5b0abc394ea6d83af03408254/core/src/main/java/therian/TherianContext.java#L359-L366 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/sr/BasicStreamReader.java | BasicStreamReader.skipEquals | protected final char skipEquals(String name, String eofMsg)
throws XMLStreamException
{
char c = getNextInCurrAfterWS(eofMsg);
if (c != '=') {
throwUnexpectedChar(c, " in xml declaration; expected '=' to follow pseudo-attribute '"+name+"'");
}
// trailing space?
return getNextInCurrAfterWS(eofMsg);
} | java | protected final char skipEquals(String name, String eofMsg)
throws XMLStreamException
{
char c = getNextInCurrAfterWS(eofMsg);
if (c != '=') {
throwUnexpectedChar(c, " in xml declaration; expected '=' to follow pseudo-attribute '"+name+"'");
}
// trailing space?
return getNextInCurrAfterWS(eofMsg);
} | [
"protected",
"final",
"char",
"skipEquals",
"(",
"String",
"name",
",",
"String",
"eofMsg",
")",
"throws",
"XMLStreamException",
"{",
"char",
"c",
"=",
"getNextInCurrAfterWS",
"(",
"eofMsg",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"{",
"throwUnexpec... | Method that checks that input following is of form
'[S]* '=' [S]*' (as per XML specs, production #25).
Will push back non-white space characters as necessary, in
case no equals char is encountered. | [
"Method",
"that",
"checks",
"that",
"input",
"following",
"is",
"of",
"form",
"[",
"S",
"]",
"*",
"=",
"[",
"S",
"]",
"*",
"(",
"as",
"per",
"XML",
"specs",
"production",
"#25",
")",
".",
"Will",
"push",
"back",
"non",
"-",
"white",
"space",
"chara... | train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/sr/BasicStreamReader.java#L2395-L2404 |
eserating/siren4j | src/main/java/com/google/code/siren4j/util/ReflectionUtils.java | ReflectionUtils.getSetter | public static Method getSetter(Class<?> clazz, Field f) {
Method setter = null;
for (Method m : clazz.getMethods()) {
if (ReflectionUtils.isSetter(m) &&
m.getName().equals(SETTER_PREFIX + StringUtils.capitalize(f.getName()))) {
setter = m;
break;
}
}
return setter;
} | java | public static Method getSetter(Class<?> clazz, Field f) {
Method setter = null;
for (Method m : clazz.getMethods()) {
if (ReflectionUtils.isSetter(m) &&
m.getName().equals(SETTER_PREFIX + StringUtils.capitalize(f.getName()))) {
setter = m;
break;
}
}
return setter;
} | [
"public",
"static",
"Method",
"getSetter",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Field",
"f",
")",
"{",
"Method",
"setter",
"=",
"null",
";",
"for",
"(",
"Method",
"m",
":",
"clazz",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"Reflecti... | Retrieve the setter for the specified class/field if it exists.
@param clazz
@param f
@return | [
"Retrieve",
"the",
"setter",
"for",
"the",
"specified",
"class",
"/",
"field",
"if",
"it",
"exists",
"."
] | train | https://github.com/eserating/siren4j/blob/f12e3185076ad920352ec4f6eb2a071a3683505f/src/main/java/com/google/code/siren4j/util/ReflectionUtils.java#L194-L204 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java | SARLJvmModelInferrer.appendGeneratedAnnotation | protected void appendGeneratedAnnotation(JvmAnnotationTarget target, GenerationContext context, String sarlCode) {
final GeneratorConfig config = context.getGeneratorConfig();
if (config.isGenerateGeneratedAnnotation()) {
addAnnotationSafe(target, Generated.class, getClass().getName());
}
if (target instanceof JvmFeature) {
addAnnotationSafe(target, SyntheticMember.class);
}
if (!Strings.isNullOrEmpty(sarlCode)) {
addAnnotationSafe(target, SarlSourceCode.class, sarlCode);
}
} | java | protected void appendGeneratedAnnotation(JvmAnnotationTarget target, GenerationContext context, String sarlCode) {
final GeneratorConfig config = context.getGeneratorConfig();
if (config.isGenerateGeneratedAnnotation()) {
addAnnotationSafe(target, Generated.class, getClass().getName());
}
if (target instanceof JvmFeature) {
addAnnotationSafe(target, SyntheticMember.class);
}
if (!Strings.isNullOrEmpty(sarlCode)) {
addAnnotationSafe(target, SarlSourceCode.class, sarlCode);
}
} | [
"protected",
"void",
"appendGeneratedAnnotation",
"(",
"JvmAnnotationTarget",
"target",
",",
"GenerationContext",
"context",
",",
"String",
"sarlCode",
")",
"{",
"final",
"GeneratorConfig",
"config",
"=",
"context",
".",
"getGeneratorConfig",
"(",
")",
";",
"if",
"(... | Add the @Generated annotation to the given target.
@param target the target of the annotation.
@param context the generation context.
@param sarlCode the code that is the cause of the generation. | [
"Add",
"the",
"@Generated",
"annotation",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2486-L2499 |
jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.simpleElement | private String simpleElement(StructureDefinition sd, ElementDefinition ed, String typ) {
String addldef = "";
ElementDefinition.ElementDefinitionBindingComponent binding = ed.getBinding();
if(binding.hasStrength() && binding.getStrength() == Enumerations.BindingStrength.REQUIRED && "code".equals(typ)) {
ValueSet vs = resolveBindingReference(sd, binding.getValueSet());
if (vs != null) {
addldef = tmplt(VALUESET_DEFN_TEMPLATE).add("vsn", vsprefix(vs.getUrl())).render();
required_value_sets.add(vs);
}
}
// TODO: check whether value sets and fixed are mutually exclusive
if(ed.hasFixed()) {
addldef = tmplt(FIXED_VALUE_TEMPLATE).add("val", ed.getFixed().primitiveValue()).render();
}
return tmplt(SIMPLE_ELEMENT_DEFN_TEMPLATE).add("typ", typ).add("vsdef", addldef).render();
} | java | private String simpleElement(StructureDefinition sd, ElementDefinition ed, String typ) {
String addldef = "";
ElementDefinition.ElementDefinitionBindingComponent binding = ed.getBinding();
if(binding.hasStrength() && binding.getStrength() == Enumerations.BindingStrength.REQUIRED && "code".equals(typ)) {
ValueSet vs = resolveBindingReference(sd, binding.getValueSet());
if (vs != null) {
addldef = tmplt(VALUESET_DEFN_TEMPLATE).add("vsn", vsprefix(vs.getUrl())).render();
required_value_sets.add(vs);
}
}
// TODO: check whether value sets and fixed are mutually exclusive
if(ed.hasFixed()) {
addldef = tmplt(FIXED_VALUE_TEMPLATE).add("val", ed.getFixed().primitiveValue()).render();
}
return tmplt(SIMPLE_ELEMENT_DEFN_TEMPLATE).add("typ", typ).add("vsdef", addldef).render();
} | [
"private",
"String",
"simpleElement",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
",",
"String",
"typ",
")",
"{",
"String",
"addldef",
"=",
"\"\"",
";",
"ElementDefinition",
".",
"ElementDefinitionBindingComponent",
"binding",
"=",
"ed",
".",
... | Generate a type reference and optional value set definition
@param sd Containing StructureDefinition
@param ed Element being defined
@param typ Element type
@return Type definition | [
"Generate",
"a",
"type",
"reference",
"and",
"optional",
"value",
"set",
"definition"
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L520-L535 |
ben-manes/caffeine | simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/FrequentlyUsedPolicy.java | FrequentlyUsedPolicy.onHit | private void onHit(Node node) {
policyStats.recordHit();
int newCount = node.freq.count + 1;
FrequencyNode freqN = (node.freq.next.count == newCount)
? node.freq.next
: new FrequencyNode(newCount, node.freq);
node.remove();
if (node.freq.isEmpty()) {
node.freq.remove();
}
node.freq = freqN;
node.append();
} | java | private void onHit(Node node) {
policyStats.recordHit();
int newCount = node.freq.count + 1;
FrequencyNode freqN = (node.freq.next.count == newCount)
? node.freq.next
: new FrequencyNode(newCount, node.freq);
node.remove();
if (node.freq.isEmpty()) {
node.freq.remove();
}
node.freq = freqN;
node.append();
} | [
"private",
"void",
"onHit",
"(",
"Node",
"node",
")",
"{",
"policyStats",
".",
"recordHit",
"(",
")",
";",
"int",
"newCount",
"=",
"node",
".",
"freq",
".",
"count",
"+",
"1",
";",
"FrequencyNode",
"freqN",
"=",
"(",
"node",
".",
"freq",
".",
"next",... | Moves the entry to the next higher frequency list, creating it if necessary. | [
"Moves",
"the",
"entry",
"to",
"the",
"next",
"higher",
"frequency",
"list",
"creating",
"it",
"if",
"necessary",
"."
] | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/FrequentlyUsedPolicy.java#L87-L100 |
paylogic/java-fogbugz | src/main/java/org/paylogic/fogbugz/FogbugzManager.java | FogbugzManager.mapToFogbugzUrl | private String mapToFogbugzUrl(Map<String, String> params) throws UnsupportedEncodingException {
String output = this.getFogbugzUrl();
for (String key : params.keySet()) {
String value = params.get(key);
if (!value.isEmpty()) {
output += "&" + URLEncoder.encode(key, "UTF-8") + "=" + URLEncoder.encode(value, "UTF-8");
}
}
FogbugzManager.log.info("Generated URL to send to Fogbugz: " + output);
return output;
} | java | private String mapToFogbugzUrl(Map<String, String> params) throws UnsupportedEncodingException {
String output = this.getFogbugzUrl();
for (String key : params.keySet()) {
String value = params.get(key);
if (!value.isEmpty()) {
output += "&" + URLEncoder.encode(key, "UTF-8") + "=" + URLEncoder.encode(value, "UTF-8");
}
}
FogbugzManager.log.info("Generated URL to send to Fogbugz: " + output);
return output;
} | [
"private",
"String",
"mapToFogbugzUrl",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"UnsupportedEncodingException",
"{",
"String",
"output",
"=",
"this",
".",
"getFogbugzUrl",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"para... | Helper method to create API url from Map, with proper encoding.
@param params Map with parameters to encode.
@return String which represents API URL. | [
"Helper",
"method",
"to",
"create",
"API",
"url",
"from",
"Map",
"with",
"proper",
"encoding",
"."
] | train | https://github.com/paylogic/java-fogbugz/blob/75651d82b2476e9ba2a0805311e18ee36882c2df/src/main/java/org/paylogic/fogbugz/FogbugzManager.java#L92-L102 |
aws/aws-sdk-java | aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SendUsersMessageResponse.java | SendUsersMessageResponse.setResult | public void setResult(java.util.Map<String, java.util.Map<String, EndpointMessageResult>> result) {
this.result = result;
} | java | public void setResult(java.util.Map<String, java.util.Map<String, EndpointMessageResult>> result) {
this.result = result;
} | [
"public",
"void",
"setResult",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"EndpointMessageResult",
">",
">",
"result",
")",
"{",
"this",
".",
"result",
"=",
"result",
";",
"}"
] | An object that shows the endpoints that were messaged for each user. The object provides a list of user IDs. For
each user ID, it provides the endpoint IDs that were messaged. For each endpoint ID, it provides an
EndpointMessageResult object.
@param result
An object that shows the endpoints that were messaged for each user. The object provides a list of user
IDs. For each user ID, it provides the endpoint IDs that were messaged. For each endpoint ID, it provides
an EndpointMessageResult object. | [
"An",
"object",
"that",
"shows",
"the",
"endpoints",
"that",
"were",
"messaged",
"for",
"each",
"user",
".",
"The",
"object",
"provides",
"a",
"list",
"of",
"user",
"IDs",
".",
"For",
"each",
"user",
"ID",
"it",
"provides",
"the",
"endpoint",
"IDs",
"tha... | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SendUsersMessageResponse.java#L133-L135 |
OpenNTF/JavascriptAggregator | jaggr-core/src/main/java/com/ibm/jaggr/core/impl/transport/DojoHttpTransport.java | DojoHttpTransport.endModules | protected String endModules(HttpServletRequest request, Object arg) {
String result = ""; //$NON-NLS-1$
if (RequestUtil.isServerExpandedLayers(request) &&
request.getParameter(REQUESTEDMODULESCOUNT_REQPARAM) != null) { // it's a loader generated request
result = "});\r\n"; //$NON-NLS-1$
}
return result;
} | java | protected String endModules(HttpServletRequest request, Object arg) {
String result = ""; //$NON-NLS-1$
if (RequestUtil.isServerExpandedLayers(request) &&
request.getParameter(REQUESTEDMODULESCOUNT_REQPARAM) != null) { // it's a loader generated request
result = "});\r\n"; //$NON-NLS-1$
}
return result;
} | [
"protected",
"String",
"endModules",
"(",
"HttpServletRequest",
"request",
",",
"Object",
"arg",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"//$NON-NLS-1$\r",
"if",
"(",
"RequestUtil",
".",
"isServerExpandedLayers",
"(",
"request",
")",
"&&",
"request",
"."... | Handles the
{@link com.ibm.jaggr.core.transport.IHttpTransport.LayerContributionType#END_MODULES}
layer listener event.
<p>
See {@link #beginModules(HttpServletRequest, Object)}
@param request
the http request object
@param arg
the set of module names. The iteration order of the set is guaranteed to be
the same as the order of the preceding
{@link com.ibm.jaggr.core.transport.IHttpTransport.LayerContributionType#BEFORE_FIRST_MODULE},
{@link com.ibm.jaggr.core.transport.IHttpTransport.LayerContributionType#BEFORE_SUBSEQUENT_MODULE},
and
{@link com.ibm.jaggr.core.transport.IHttpTransport.LayerContributionType#AFTER_MODULE}
events.
@return the layer contribution | [
"Handles",
"the",
"{",
"@link",
"com",
".",
"ibm",
".",
"jaggr",
".",
"core",
".",
"transport",
".",
"IHttpTransport",
".",
"LayerContributionType#END_MODULES",
"}",
"layer",
"listener",
"event",
".",
"<p",
">",
"See",
"{",
"@link",
"#beginModules",
"(",
"Ht... | train | https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/transport/DojoHttpTransport.java#L390-L397 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java | ZooKeeperUtils.createSubmittedJobGraphs | public static ZooKeeperSubmittedJobGraphStore createSubmittedJobGraphs(
CuratorFramework client,
Configuration configuration) throws Exception {
checkNotNull(configuration, "Configuration");
RetrievableStateStorageHelper<SubmittedJobGraph> stateStorage = createFileSystemStateStorage(configuration, "submittedJobGraph");
// ZooKeeper submitted jobs root dir
String zooKeeperSubmittedJobsPath = configuration.getString(HighAvailabilityOptions.HA_ZOOKEEPER_JOBGRAPHS_PATH);
// Ensure that the job graphs path exists
client.newNamespaceAwareEnsurePath(zooKeeperSubmittedJobsPath)
.ensure(client.getZookeeperClient());
// All operations will have the path as root
CuratorFramework facade = client.usingNamespace(client.getNamespace() + zooKeeperSubmittedJobsPath);
final String zooKeeperFullSubmittedJobsPath = client.getNamespace() + zooKeeperSubmittedJobsPath;
final ZooKeeperStateHandleStore<SubmittedJobGraph> zooKeeperStateHandleStore = new ZooKeeperStateHandleStore<>(facade, stateStorage);
final PathChildrenCache pathCache = new PathChildrenCache(facade, "/", false);
return new ZooKeeperSubmittedJobGraphStore(
zooKeeperFullSubmittedJobsPath,
zooKeeperStateHandleStore,
pathCache);
} | java | public static ZooKeeperSubmittedJobGraphStore createSubmittedJobGraphs(
CuratorFramework client,
Configuration configuration) throws Exception {
checkNotNull(configuration, "Configuration");
RetrievableStateStorageHelper<SubmittedJobGraph> stateStorage = createFileSystemStateStorage(configuration, "submittedJobGraph");
// ZooKeeper submitted jobs root dir
String zooKeeperSubmittedJobsPath = configuration.getString(HighAvailabilityOptions.HA_ZOOKEEPER_JOBGRAPHS_PATH);
// Ensure that the job graphs path exists
client.newNamespaceAwareEnsurePath(zooKeeperSubmittedJobsPath)
.ensure(client.getZookeeperClient());
// All operations will have the path as root
CuratorFramework facade = client.usingNamespace(client.getNamespace() + zooKeeperSubmittedJobsPath);
final String zooKeeperFullSubmittedJobsPath = client.getNamespace() + zooKeeperSubmittedJobsPath;
final ZooKeeperStateHandleStore<SubmittedJobGraph> zooKeeperStateHandleStore = new ZooKeeperStateHandleStore<>(facade, stateStorage);
final PathChildrenCache pathCache = new PathChildrenCache(facade, "/", false);
return new ZooKeeperSubmittedJobGraphStore(
zooKeeperFullSubmittedJobsPath,
zooKeeperStateHandleStore,
pathCache);
} | [
"public",
"static",
"ZooKeeperSubmittedJobGraphStore",
"createSubmittedJobGraphs",
"(",
"CuratorFramework",
"client",
",",
"Configuration",
"configuration",
")",
"throws",
"Exception",
"{",
"checkNotNull",
"(",
"configuration",
",",
"\"Configuration\"",
")",
";",
"Retrievab... | Creates a {@link ZooKeeperSubmittedJobGraphStore} instance.
@param client The {@link CuratorFramework} ZooKeeper client to use
@param configuration {@link Configuration} object
@return {@link ZooKeeperSubmittedJobGraphStore} instance
@throws Exception if the submitted job graph store cannot be created | [
"Creates",
"a",
"{",
"@link",
"ZooKeeperSubmittedJobGraphStore",
"}",
"instance",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java#L237-L265 |
waldheinz/fat32-lib | src/main/java/de/waldheinz/fs/fat/ShortNameGenerator.java | ShortNameGenerator.generateShortName | public ShortName generateShortName(String longFullName)
throws IllegalStateException {
longFullName =
stripLeadingPeriods(longFullName).toUpperCase(Locale.ROOT);
final String longName;
final String longExt;
final int dotIdx = longFullName.lastIndexOf('.');
final boolean forceSuffix;
if (dotIdx == -1) {
/* no dot in the name */
forceSuffix = !cleanString(longFullName);
longName = tidyString(longFullName);
longExt = ""; /* so no extension */
} else {
/* split at the dot */
forceSuffix = !cleanString(longFullName.substring(
0, dotIdx));
longName = tidyString(longFullName.substring(0, dotIdx));
longExt = tidyString(longFullName.substring(dotIdx + 1));
}
final String shortExt = (longExt.length() > 3) ?
longExt.substring(0, 3) : longExt;
if (forceSuffix || (longName.length() > 8) ||
usedNames.contains(new ShortName(longName, shortExt).
asSimpleString().toLowerCase(Locale.ROOT))) {
/* we have to append the "~n" suffix */
final int maxLongIdx = Math.min(longName.length(), 8);
for (int i=1; i < 99999; i++) {
final String serial = "~" + i; //NOI18N
final int serialLen = serial.length();
final String shortName = longName.substring(
0, Math.min(maxLongIdx, 8-serialLen)) + serial;
final ShortName result = new ShortName(shortName, shortExt);
if (!usedNames.contains(
result.asSimpleString().toLowerCase(Locale.ROOT))) {
return result;
}
}
throw new IllegalStateException(
"could not generate short name for \""
+ longFullName + "\"");
}
return new ShortName(longName, shortExt);
} | java | public ShortName generateShortName(String longFullName)
throws IllegalStateException {
longFullName =
stripLeadingPeriods(longFullName).toUpperCase(Locale.ROOT);
final String longName;
final String longExt;
final int dotIdx = longFullName.lastIndexOf('.');
final boolean forceSuffix;
if (dotIdx == -1) {
/* no dot in the name */
forceSuffix = !cleanString(longFullName);
longName = tidyString(longFullName);
longExt = ""; /* so no extension */
} else {
/* split at the dot */
forceSuffix = !cleanString(longFullName.substring(
0, dotIdx));
longName = tidyString(longFullName.substring(0, dotIdx));
longExt = tidyString(longFullName.substring(dotIdx + 1));
}
final String shortExt = (longExt.length() > 3) ?
longExt.substring(0, 3) : longExt;
if (forceSuffix || (longName.length() > 8) ||
usedNames.contains(new ShortName(longName, shortExt).
asSimpleString().toLowerCase(Locale.ROOT))) {
/* we have to append the "~n" suffix */
final int maxLongIdx = Math.min(longName.length(), 8);
for (int i=1; i < 99999; i++) {
final String serial = "~" + i; //NOI18N
final int serialLen = serial.length();
final String shortName = longName.substring(
0, Math.min(maxLongIdx, 8-serialLen)) + serial;
final ShortName result = new ShortName(shortName, shortExt);
if (!usedNames.contains(
result.asSimpleString().toLowerCase(Locale.ROOT))) {
return result;
}
}
throw new IllegalStateException(
"could not generate short name for \""
+ longFullName + "\"");
}
return new ShortName(longName, shortExt);
} | [
"public",
"ShortName",
"generateShortName",
"(",
"String",
"longFullName",
")",
"throws",
"IllegalStateException",
"{",
"longFullName",
"=",
"stripLeadingPeriods",
"(",
"longFullName",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"ROOT",
")",
";",
"final",
"String",... | Generates a new unique 8.3 file name that is not already contained in
the set specified to the constructor.
@param longFullName the long file name to generate the short name for
@return the generated 8.3 file name
@throws IllegalStateException if no unused short name could be found | [
"Generates",
"a",
"new",
"unique",
"8",
".",
"3",
"file",
"name",
"that",
"is",
"not",
"already",
"contained",
"in",
"the",
"set",
"specified",
"to",
"the",
"constructor",
"."
] | train | https://github.com/waldheinz/fat32-lib/blob/3d8f1a986339573576e02eb0b6ea49bfdc9cce26/src/main/java/de/waldheinz/fs/fat/ShortNameGenerator.java#L116-L171 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java | AddressDivision.matchesWithMask | public boolean matchesWithMask(long lowerValue, long upperValue, long mask) {
if(lowerValue == upperValue) {
return matchesWithMask(lowerValue, mask);
}
if(!isMultiple()) {
//we know lowerValue and upperValue are not the same, so impossible to match those two values with a single value
return false;
}
long thisValue = getDivisionValue();
long thisUpperValue = getUpperDivisionValue();
if(!isMaskCompatibleWithRange(thisValue, thisUpperValue, mask, getMaxValue())) {
return false;
}
return lowerValue == (thisValue & mask) && upperValue == (thisUpperValue & mask);
} | java | public boolean matchesWithMask(long lowerValue, long upperValue, long mask) {
if(lowerValue == upperValue) {
return matchesWithMask(lowerValue, mask);
}
if(!isMultiple()) {
//we know lowerValue and upperValue are not the same, so impossible to match those two values with a single value
return false;
}
long thisValue = getDivisionValue();
long thisUpperValue = getUpperDivisionValue();
if(!isMaskCompatibleWithRange(thisValue, thisUpperValue, mask, getMaxValue())) {
return false;
}
return lowerValue == (thisValue & mask) && upperValue == (thisUpperValue & mask);
} | [
"public",
"boolean",
"matchesWithMask",
"(",
"long",
"lowerValue",
",",
"long",
"upperValue",
",",
"long",
"mask",
")",
"{",
"if",
"(",
"lowerValue",
"==",
"upperValue",
")",
"{",
"return",
"matchesWithMask",
"(",
"lowerValue",
",",
"mask",
")",
";",
"}",
... | returns whether masking with the given mask results in a valid contiguous range for this segment,
and if it does, if it matches the range obtained when masking the given values with the same mask.
@param lowerValue
@param upperValue
@param mask
@return | [
"returns",
"whether",
"masking",
"with",
"the",
"given",
"mask",
"results",
"in",
"a",
"valid",
"contiguous",
"range",
"for",
"this",
"segment",
"and",
"if",
"it",
"does",
"if",
"it",
"matches",
"the",
"range",
"obtained",
"when",
"masking",
"the",
"given",
... | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java#L266-L280 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.