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 |
|---|---|---|---|---|---|---|---|---|---|---|
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java | DebugUtil.printDebug | public static void printDebug(final Properties pProperties, final PrintStream pPrintStream) {
if (pPrintStream == null) {
System.err.println(PRINTSTREAM_IS_NULL_ERROR_MESSAGE);
return;
}
if (pProperties == null) {
pPrintStream.println(PROPERTIES_IS_NULL_ERROR_MESSAGE);
return;
} else if (pProperties.isEmpty()) {
pPrintStream.println(PROPERTIES_IS_EMPTY_ERROR_MESSAGE);
return;
}
for (Enumeration e = pProperties.propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
pPrintStream.println(key + ": " + pProperties.getProperty(key));
}
} | java | public static void printDebug(final Properties pProperties, final PrintStream pPrintStream) {
if (pPrintStream == null) {
System.err.println(PRINTSTREAM_IS_NULL_ERROR_MESSAGE);
return;
}
if (pProperties == null) {
pPrintStream.println(PROPERTIES_IS_NULL_ERROR_MESSAGE);
return;
} else if (pProperties.isEmpty()) {
pPrintStream.println(PROPERTIES_IS_EMPTY_ERROR_MESSAGE);
return;
}
for (Enumeration e = pProperties.propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
pPrintStream.println(key + ": " + pProperties.getProperty(key));
}
} | [
"public",
"static",
"void",
"printDebug",
"(",
"final",
"Properties",
"pProperties",
",",
"final",
"PrintStream",
"pPrintStream",
")",
"{",
"if",
"(",
"pPrintStream",
"==",
"null",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"PRINTSTREAM_IS_NULL_ERROR_M... | Prints the content of a {@code java.util.Properties} to a {@code java.io.PrintStream}.
<p>
@param pProperties the {@code java.util.Properties} to be printed.
@param pPrintStream the {@code java.io.PrintStream} for flushing the results.
@see <a href="http://java.sun.com/products/jdk/1.3/docs/api/java/util/Properties.html">{@code java.util.Properties}</a> | [
"Prints",
"the",
"content",
"of",
"a",
"{"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java#L698-L716 |
damianszczepanik/cucumber-reporting | src/main/java/net/masterthought/cucumber/json/Feature.java | Feature.setMetaData | public void setMetaData(int jsonFileNo, Configuration configuration) {
for (Element element : elements) {
element.setMetaData(this);
if (element.isScenario()) {
scenarios.add(element);
}
}
reportFileName = calculateReportFileName(jsonFileNo);
featureStatus = calculateFeatureStatus();
calculateSteps();
} | java | public void setMetaData(int jsonFileNo, Configuration configuration) {
for (Element element : elements) {
element.setMetaData(this);
if (element.isScenario()) {
scenarios.add(element);
}
}
reportFileName = calculateReportFileName(jsonFileNo);
featureStatus = calculateFeatureStatus();
calculateSteps();
} | [
"public",
"void",
"setMetaData",
"(",
"int",
"jsonFileNo",
",",
"Configuration",
"configuration",
")",
"{",
"for",
"(",
"Element",
"element",
":",
"elements",
")",
"{",
"element",
".",
"setMetaData",
"(",
"this",
")",
";",
"if",
"(",
"element",
".",
"isSce... | Sets additional information and calculates values which should be calculated during object creation.
@param jsonFileNo index of the JSON file
@param configuration configuration for the report | [
"Sets",
"additional",
"information",
"and",
"calculates",
"values",
"which",
"should",
"be",
"calculated",
"during",
"object",
"creation",
"."
] | train | https://github.com/damianszczepanik/cucumber-reporting/blob/9ffe0d4a9c0aec161b0988a930a8312ba36dc742/src/main/java/net/masterthought/cucumber/json/Feature.java#L156-L169 |
tvbarthel/Cheerleader | library/src/main/java/fr/tvbarthel/cheerleader/library/player/NotificationManager.java | NotificationManager.initNotificationBuilder | private void initNotificationBuilder(Context context) {
// inti builder.
mNotificationBuilder = new NotificationCompat.Builder(context);
mNotificationView = new RemoteViews(context.getPackageName(),
R.layout.simple_sound_cloud_notification);
mNotificationExpandedView = new RemoteViews(context.getPackageName(),
R.layout.simple_sound_cloud_notification_expanded);
// add right icon on Lollipop.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
addSmallIcon(mNotificationView);
addSmallIcon(mNotificationExpandedView);
}
// set pending intents
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_previous, mPreviousPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_previous, mPreviousPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_next, mNextPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_next, mNextPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_play, mTogglePlaybackPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_play, mTogglePlaybackPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_clear, mClearPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_clear, mClearPendingIntent);
// add icon for action bar.
mNotificationBuilder.setSmallIcon(mNotificationConfig.getNotificationIcon());
// set the remote view.
mNotificationBuilder.setContent(mNotificationView);
// set the notification priority.
mNotificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
mNotificationBuilder.setStyle(new NotificationCompat.DecoratedCustomViewStyle());
// set the content intent.
Class<?> playerActivity = mNotificationConfig.getNotificationActivity();
if (playerActivity != null) {
Intent i = new Intent(context, playerActivity);
PendingIntent contentIntent = PendingIntent.getActivity(context, REQUEST_DISPLAYING_CONTROLLER,
i, PendingIntent.FLAG_UPDATE_CURRENT);
mNotificationBuilder.setContentIntent(contentIntent);
}
} | java | private void initNotificationBuilder(Context context) {
// inti builder.
mNotificationBuilder = new NotificationCompat.Builder(context);
mNotificationView = new RemoteViews(context.getPackageName(),
R.layout.simple_sound_cloud_notification);
mNotificationExpandedView = new RemoteViews(context.getPackageName(),
R.layout.simple_sound_cloud_notification_expanded);
// add right icon on Lollipop.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
addSmallIcon(mNotificationView);
addSmallIcon(mNotificationExpandedView);
}
// set pending intents
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_previous, mPreviousPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_previous, mPreviousPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_next, mNextPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_next, mNextPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_play, mTogglePlaybackPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_play, mTogglePlaybackPendingIntent);
mNotificationView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_clear, mClearPendingIntent);
mNotificationExpandedView.setOnClickPendingIntent(
R.id.simple_sound_cloud_notification_clear, mClearPendingIntent);
// add icon for action bar.
mNotificationBuilder.setSmallIcon(mNotificationConfig.getNotificationIcon());
// set the remote view.
mNotificationBuilder.setContent(mNotificationView);
// set the notification priority.
mNotificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
mNotificationBuilder.setStyle(new NotificationCompat.DecoratedCustomViewStyle());
// set the content intent.
Class<?> playerActivity = mNotificationConfig.getNotificationActivity();
if (playerActivity != null) {
Intent i = new Intent(context, playerActivity);
PendingIntent contentIntent = PendingIntent.getActivity(context, REQUEST_DISPLAYING_CONTROLLER,
i, PendingIntent.FLAG_UPDATE_CURRENT);
mNotificationBuilder.setContentIntent(contentIntent);
}
} | [
"private",
"void",
"initNotificationBuilder",
"(",
"Context",
"context",
")",
"{",
"// inti builder.",
"mNotificationBuilder",
"=",
"new",
"NotificationCompat",
".",
"Builder",
"(",
"context",
")",
";",
"mNotificationView",
"=",
"new",
"RemoteViews",
"(",
"context",
... | Init all static components of the notification.
@param context context used to instantiate the builder. | [
"Init",
"all",
"static",
"components",
"of",
"the",
"notification",
"."
] | train | https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/NotificationManager.java#L313-L365 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java | MultiUserChatLightManager.unblockUsers | public void unblockUsers(DomainBareJid mucLightService, List<Jid> usersJids)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
HashMap<Jid, Boolean> users = new HashMap<>();
for (Jid jid : usersJids) {
users.put(jid, true);
}
sendUnblockUsers(mucLightService, users);
} | java | public void unblockUsers(DomainBareJid mucLightService, List<Jid> usersJids)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
HashMap<Jid, Boolean> users = new HashMap<>();
for (Jid jid : usersJids) {
users.put(jid, true);
}
sendUnblockUsers(mucLightService, users);
} | [
"public",
"void",
"unblockUsers",
"(",
"DomainBareJid",
"mucLightService",
",",
"List",
"<",
"Jid",
">",
"usersJids",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"HashMap",
"<",
"Jid"... | Unblock users.
@param mucLightService
@param usersJids
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException | [
"Unblock",
"users",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L401-L408 |
bbottema/simple-java-mail | modules/simple-java-mail/src/main/java/org/simplejavamail/converter/internal/mimemessage/MimeMessageParser.java | MimeMessageParser.isMimeType | @SuppressWarnings("WeakerAccess")
public static boolean isMimeType(@Nonnull final MimePart part, @Nonnull final String mimeType) {
// Do not use part.isMimeType(String) as it is broken for MimeBodyPart
// and does not really check the actual content type.
try {
final ContentType contentType = new ContentType(retrieveDataHandler(part).getContentType());
return contentType.match(mimeType);
} catch (final ParseException ex) {
return retrieveContentType(part).equalsIgnoreCase(mimeType);
}
} | java | @SuppressWarnings("WeakerAccess")
public static boolean isMimeType(@Nonnull final MimePart part, @Nonnull final String mimeType) {
// Do not use part.isMimeType(String) as it is broken for MimeBodyPart
// and does not really check the actual content type.
try {
final ContentType contentType = new ContentType(retrieveDataHandler(part).getContentType());
return contentType.match(mimeType);
} catch (final ParseException ex) {
return retrieveContentType(part).equalsIgnoreCase(mimeType);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"static",
"boolean",
"isMimeType",
"(",
"@",
"Nonnull",
"final",
"MimePart",
"part",
",",
"@",
"Nonnull",
"final",
"String",
"mimeType",
")",
"{",
"// Do not use part.isMimeType(String) as it is broken for... | Checks whether the MimePart contains an object of the given mime type.
@param part the current MimePart
@param mimeType the mime type to check
@return {@code true} if the MimePart matches the given mime type, {@code false} otherwise | [
"Checks",
"whether",
"the",
"MimePart",
"contains",
"an",
"object",
"of",
"the",
"given",
"mime",
"type",
"."
] | train | https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/simple-java-mail/src/main/java/org/simplejavamail/converter/internal/mimemessage/MimeMessageParser.java#L300-L311 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.installationTemplate_templateName_partitionScheme_POST | public void installationTemplate_templateName_partitionScheme_POST(String templateName, String name, Long priority) throws IOException {
String qPath = "/me/installationTemplate/{templateName}/partitionScheme";
StringBuilder sb = path(qPath, templateName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "name", name);
addBody(o, "priority", priority);
exec(qPath, "POST", sb.toString(), o);
} | java | public void installationTemplate_templateName_partitionScheme_POST(String templateName, String name, Long priority) throws IOException {
String qPath = "/me/installationTemplate/{templateName}/partitionScheme";
StringBuilder sb = path(qPath, templateName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "name", name);
addBody(o, "priority", priority);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"installationTemplate_templateName_partitionScheme_POST",
"(",
"String",
"templateName",
",",
"String",
"name",
",",
"Long",
"priority",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/installationTemplate/{templateName}/partitionScheme\"",
... | Add a scheme of partition
REST: POST /me/installationTemplate/{templateName}/partitionScheme
@param priority [required] on a reinstall, if a partitioning scheme is not specified, the one with the higher priority will be used by default, among all the compatible partitioning schemes (given the underlying hardware specifications)
@param name [required] name of this partitioning scheme
@param templateName [required] This template name | [
"Add",
"a",
"scheme",
"of",
"partition"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L3491-L3498 |
redkale/redkale | src/org/redkale/net/AsyncConnection.java | AsyncConnection.createTCP | public static CompletableFuture<AsyncConnection> createTCP(final ObjectPool<ByteBuffer> bufferPool, final AsynchronousChannelGroup group, final SSLContext sslContext,
final SocketAddress address, final int readTimeoutSeconds, final int writeTimeoutSeconds) {
return createTCP(bufferPool, bufferPool, group, sslContext, address, readTimeoutSeconds, writeTimeoutSeconds);
} | java | public static CompletableFuture<AsyncConnection> createTCP(final ObjectPool<ByteBuffer> bufferPool, final AsynchronousChannelGroup group, final SSLContext sslContext,
final SocketAddress address, final int readTimeoutSeconds, final int writeTimeoutSeconds) {
return createTCP(bufferPool, bufferPool, group, sslContext, address, readTimeoutSeconds, writeTimeoutSeconds);
} | [
"public",
"static",
"CompletableFuture",
"<",
"AsyncConnection",
">",
"createTCP",
"(",
"final",
"ObjectPool",
"<",
"ByteBuffer",
">",
"bufferPool",
",",
"final",
"AsynchronousChannelGroup",
"group",
",",
"final",
"SSLContext",
"sslContext",
",",
"final",
"SocketAddre... | 创建TCP协议客户端连接
@param bufferPool ByteBuffer对象池
@param address 连接点子
@param sslContext SSLContext
@param group 连接AsynchronousChannelGroup
@param readTimeoutSeconds 读取超时秒数
@param writeTimeoutSeconds 写入超时秒数
@return 连接CompletableFuture | [
"创建TCP协议客户端连接"
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/net/AsyncConnection.java#L276-L279 |
cycorp/api-suite | core-api/src/main/java/com/cyc/kb/exception/InvalidNameException.java | InvalidNameException.fromThrowable | public static InvalidNameException fromThrowable(String message, Throwable cause) {
return (cause instanceof InvalidNameException && Objects.equals(message, cause.getMessage()))
? (InvalidNameException) cause
: new InvalidNameException(message, cause);
} | java | public static InvalidNameException fromThrowable(String message, Throwable cause) {
return (cause instanceof InvalidNameException && Objects.equals(message, cause.getMessage()))
? (InvalidNameException) cause
: new InvalidNameException(message, cause);
} | [
"public",
"static",
"InvalidNameException",
"fromThrowable",
"(",
"String",
"message",
",",
"Throwable",
"cause",
")",
"{",
"return",
"(",
"cause",
"instanceof",
"InvalidNameException",
"&&",
"Objects",
".",
"equals",
"(",
"message",
",",
"cause",
".",
"getMessage... | Converts a Throwable to a InvalidNameException with the specified detail message. If the
Throwable is a InvalidNameException and if the Throwable's message is identical to the
one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
a new InvalidNameException with the detail message.
@param cause the Throwable to convert
@param message the specified detail message
@return a InvalidNameException | [
"Converts",
"a",
"Throwable",
"to",
"a",
"InvalidNameException",
"with",
"the",
"specified",
"detail",
"message",
".",
"If",
"the",
"Throwable",
"is",
"a",
"InvalidNameException",
"and",
"if",
"the",
"Throwable",
"s",
"message",
"is",
"identical",
"to",
"the",
... | train | https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/exception/InvalidNameException.java#L64-L68 |
cojen/Cojen | src/main/java/org/cojen/classfile/ClassFile.java | ClassFile.addInnerClass | public ClassFile addInnerClass(String fullInnerClassName, String innerClassName,
String superClassName) {
if (fullInnerClassName == null) {
if (innerClassName == null) {
fullInnerClassName = mClassName + '$' + (++mAnonymousInnerClassCount);
} else {
fullInnerClassName = mClassName + '$' + innerClassName;
}
}
ClassFile inner = new ClassFile(fullInnerClassName, superClassName);
Modifiers modifiers = inner.getModifiers().toPrivate(true).toStatic(true);
inner.setModifiers(modifiers);
inner.mInnerClassName = innerClassName;
inner.mOuterClass = this;
if (mInnerClasses == null) {
mInnerClasses = new ArrayList<ClassFile>();
}
mInnerClasses.add(inner);
// Record the inner class in this, the outer class.
if (mInnerClassesAttr == null) {
addAttribute(new InnerClassesAttr(mCp));
}
// TODO: Anonymous inner classes and method scoped classes do not have
// an outer class listed.
mInnerClassesAttr.addInnerClass(fullInnerClassName, mClassName,
innerClassName, modifiers);
// Record the inner class in itself.
inner.addAttribute(new InnerClassesAttr(inner.getConstantPool()));
inner.mInnerClassesAttr.addInnerClass(fullInnerClassName, mClassName,
innerClassName, modifiers);
return inner;
} | java | public ClassFile addInnerClass(String fullInnerClassName, String innerClassName,
String superClassName) {
if (fullInnerClassName == null) {
if (innerClassName == null) {
fullInnerClassName = mClassName + '$' + (++mAnonymousInnerClassCount);
} else {
fullInnerClassName = mClassName + '$' + innerClassName;
}
}
ClassFile inner = new ClassFile(fullInnerClassName, superClassName);
Modifiers modifiers = inner.getModifiers().toPrivate(true).toStatic(true);
inner.setModifiers(modifiers);
inner.mInnerClassName = innerClassName;
inner.mOuterClass = this;
if (mInnerClasses == null) {
mInnerClasses = new ArrayList<ClassFile>();
}
mInnerClasses.add(inner);
// Record the inner class in this, the outer class.
if (mInnerClassesAttr == null) {
addAttribute(new InnerClassesAttr(mCp));
}
// TODO: Anonymous inner classes and method scoped classes do not have
// an outer class listed.
mInnerClassesAttr.addInnerClass(fullInnerClassName, mClassName,
innerClassName, modifiers);
// Record the inner class in itself.
inner.addAttribute(new InnerClassesAttr(inner.getConstantPool()));
inner.mInnerClassesAttr.addInnerClass(fullInnerClassName, mClassName,
innerClassName, modifiers);
return inner;
} | [
"public",
"ClassFile",
"addInnerClass",
"(",
"String",
"fullInnerClassName",
",",
"String",
"innerClassName",
",",
"String",
"superClassName",
")",
"{",
"if",
"(",
"fullInnerClassName",
"==",
"null",
")",
"{",
"if",
"(",
"innerClassName",
"==",
"null",
")",
"{",... | Add an inner class to this class. By default, inner classes are private
static.
@param fullInnerClassName Optional full inner class name.
@param innerClassName Optional short inner class name.
@param superClassName Full super class name. | [
"Add",
"an",
"inner",
"class",
"to",
"this",
"class",
".",
"By",
"default",
"inner",
"classes",
"are",
"private",
"static",
"."
] | train | https://github.com/cojen/Cojen/blob/ddee9a0fde83870b97e0ed04c58270aa665f3a62/src/main/java/org/cojen/classfile/ClassFile.java#L862-L901 |
Faylixe/googlecodejam-client | src/main/java/fr/faylixe/googlecodejam/client/executor/HttpRequestExecutor.java | HttpRequestExecutor.buildDataPart | public static Part buildDataPart(final String name, final String data) {
final ByteArrayContent content = new ByteArrayContent(null, data.getBytes());
final Part part = new Part(content);
final HttpHeaders headers = new HttpHeaders();
final String disposition = String.format(Request.DATA_CONTENT_DISPOSITION, name);
headers.set(Request.CONTENT_DISPOSITION, disposition);
part.setHeaders(headers);
return part;
} | java | public static Part buildDataPart(final String name, final String data) {
final ByteArrayContent content = new ByteArrayContent(null, data.getBytes());
final Part part = new Part(content);
final HttpHeaders headers = new HttpHeaders();
final String disposition = String.format(Request.DATA_CONTENT_DISPOSITION, name);
headers.set(Request.CONTENT_DISPOSITION, disposition);
part.setHeaders(headers);
return part;
} | [
"public",
"static",
"Part",
"buildDataPart",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"data",
")",
"{",
"final",
"ByteArrayContent",
"content",
"=",
"new",
"ByteArrayContent",
"(",
"null",
",",
"data",
".",
"getBytes",
"(",
")",
")",
";",
"f... | Static factory method that creates a {@link Part} which contains
simple form data.
@param name Name of the POST data to create part for.
@param data Value of the POST data to create part for.
@return Created data part. | [
"Static",
"factory",
"method",
"that",
"creates",
"a",
"{",
"@link",
"Part",
"}",
"which",
"contains",
"simple",
"form",
"data",
"."
] | train | https://github.com/Faylixe/googlecodejam-client/blob/84a5fed4e049dca48994dc3f70213976aaff4bd3/src/main/java/fr/faylixe/googlecodejam/client/executor/HttpRequestExecutor.java#L124-L132 |
RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java | ImmutableRoaringBitmap.contains | public boolean contains(ImmutableRoaringBitmap subset) {
if(subset.getCardinality() > getCardinality()) {
return false;
}
final int length1 = this.highLowContainer.size();
final int length2 = subset.highLowContainer.size();
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = this.highLowContainer.getKeyAtIndex(pos1);
final short s2 = subset.highLowContainer.getKeyAtIndex(pos2);
if (s1 == s2) {
MappeableContainer c1 = this.highLowContainer.getContainerAtIndex(pos1);
MappeableContainer c2 = subset.highLowContainer.getContainerAtIndex(pos2);
if(!c1.contains(c2)) {
return false;
}
++pos1;
++pos2;
} else if (compareUnsigned(s1, s2) > 0) {
return false;
} else {
pos1 = subset.highLowContainer.advanceUntil(s2, pos1);
}
}
return pos2 == length2;
} | java | public boolean contains(ImmutableRoaringBitmap subset) {
if(subset.getCardinality() > getCardinality()) {
return false;
}
final int length1 = this.highLowContainer.size();
final int length2 = subset.highLowContainer.size();
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = this.highLowContainer.getKeyAtIndex(pos1);
final short s2 = subset.highLowContainer.getKeyAtIndex(pos2);
if (s1 == s2) {
MappeableContainer c1 = this.highLowContainer.getContainerAtIndex(pos1);
MappeableContainer c2 = subset.highLowContainer.getContainerAtIndex(pos2);
if(!c1.contains(c2)) {
return false;
}
++pos1;
++pos2;
} else if (compareUnsigned(s1, s2) > 0) {
return false;
} else {
pos1 = subset.highLowContainer.advanceUntil(s2, pos1);
}
}
return pos2 == length2;
} | [
"public",
"boolean",
"contains",
"(",
"ImmutableRoaringBitmap",
"subset",
")",
"{",
"if",
"(",
"subset",
".",
"getCardinality",
"(",
")",
">",
"getCardinality",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"length1",
"=",
"this",
".",
... | Checks whether the parameter is a subset of this RoaringBitmap or not
@param subset the potential subset
@return true if the parameter is a subset of this RoaringBitmap | [
"Checks",
"whether",
"the",
"parameter",
"is",
"a",
"subset",
"of",
"this",
"RoaringBitmap",
"or",
"not"
] | train | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java#L1043-L1068 |
sagiegurari/fax4j | src/main/java/org/fax4j/common/AbstractLogger.java | AbstractLogger.formatLogMessage | protected String formatLogMessage(LogLevel level,Object[] message,Throwable throwable)
{
//get text
String messageText=this.format(message);
String throwableText=this.format(throwable);
//init buffer
StringBuilder buffer=new StringBuilder();
//append prefix
buffer.append("[fax4j][");
buffer.append(level.getName());
buffer.append("] ");
if(messageText!=null)
{
buffer.append(messageText);
if(throwableText!=null)
{
buffer.append(Logger.SYSTEM_EOL);
buffer.append(throwableText);
}
}
else if(throwableText!=null)
{
buffer.append(throwableText);
}
//get text
String text=buffer.toString();
return text;
} | java | protected String formatLogMessage(LogLevel level,Object[] message,Throwable throwable)
{
//get text
String messageText=this.format(message);
String throwableText=this.format(throwable);
//init buffer
StringBuilder buffer=new StringBuilder();
//append prefix
buffer.append("[fax4j][");
buffer.append(level.getName());
buffer.append("] ");
if(messageText!=null)
{
buffer.append(messageText);
if(throwableText!=null)
{
buffer.append(Logger.SYSTEM_EOL);
buffer.append(throwableText);
}
}
else if(throwableText!=null)
{
buffer.append(throwableText);
}
//get text
String text=buffer.toString();
return text;
} | [
"protected",
"String",
"formatLogMessage",
"(",
"LogLevel",
"level",
",",
"Object",
"[",
"]",
"message",
",",
"Throwable",
"throwable",
")",
"{",
"//get text",
"String",
"messageText",
"=",
"this",
".",
"format",
"(",
"message",
")",
";",
"String",
"throwableT... | Converts the provided data to string.
@param level
The log level
@param message
The message parts (may be null)
@param throwable
The throwable (may be null)
@return The string | [
"Converts",
"the",
"provided",
"data",
"to",
"string",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L40-L73 |
structr/structr | structr-core/src/main/java/org/structr/module/JarConfigurationProvider.java | JarConfigurationProvider.findNearestMatchingRelationClass | private Class findNearestMatchingRelationClass(final String sourceTypeName, final String relType, final String targetTypeName) {
final Class sourceType = getNodeEntityClass(sourceTypeName);
final Class targetType = getNodeEntityClass(targetTypeName);
final Map<Integer, Class> candidates = new TreeMap<>();
for (final Class candidate : getRelationClassCandidatesForRelType(relType)) {
final Relation rel = instantiate(candidate);
final int distance = getDistance(rel.getSourceType(), sourceType, -1) + getDistance(rel.getTargetType(), targetType, -1);
if (distance >= 2000) {
candidates.put(distance - 2000, candidate);
}
}
if (candidates.isEmpty()) {
return null;
} else {
final Entry<Integer, Class> candidateEntry = candidates.entrySet().iterator().next();
final Class c = candidateEntry.getValue();
combinedTypeRelationClassCache.put(getCombinedType(sourceTypeName, relType, targetTypeName), c);
return c;
}
} | java | private Class findNearestMatchingRelationClass(final String sourceTypeName, final String relType, final String targetTypeName) {
final Class sourceType = getNodeEntityClass(sourceTypeName);
final Class targetType = getNodeEntityClass(targetTypeName);
final Map<Integer, Class> candidates = new TreeMap<>();
for (final Class candidate : getRelationClassCandidatesForRelType(relType)) {
final Relation rel = instantiate(candidate);
final int distance = getDistance(rel.getSourceType(), sourceType, -1) + getDistance(rel.getTargetType(), targetType, -1);
if (distance >= 2000) {
candidates.put(distance - 2000, candidate);
}
}
if (candidates.isEmpty()) {
return null;
} else {
final Entry<Integer, Class> candidateEntry = candidates.entrySet().iterator().next();
final Class c = candidateEntry.getValue();
combinedTypeRelationClassCache.put(getCombinedType(sourceTypeName, relType, targetTypeName), c);
return c;
}
} | [
"private",
"Class",
"findNearestMatchingRelationClass",
"(",
"final",
"String",
"sourceTypeName",
",",
"final",
"String",
"relType",
",",
"final",
"String",
"targetTypeName",
")",
"{",
"final",
"Class",
"sourceType",
"=",
"getNodeEntityClass",
"(",
"sourceTypeName",
"... | Find the most specialized relation class matching the given
parameters.
If no direct match is found (source and target type are equal), we
count the levels of inheritance, including interfaces.
@param sourceTypeName
@param relType
@param targetTypeName
@param rel
@param candidate
@return class | [
"Find",
"the",
"most",
"specialized",
"relation",
"class",
"matching",
"the",
"given",
"parameters",
"."
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/module/JarConfigurationProvider.java#L381-L410 |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/uistate/UIStateRegistry.java | UIStateRegistry.getCastedState | @Nullable
public <T> T getCastedState (@Nullable final ObjectType aOT, @Nullable final String sStateID)
{
final IHasUIState aObject = getState (aOT, sStateID);
if (aObject == null)
return null;
// Special handling for UI state wrapper to retrieve the contained object
if (aObject instanceof UIStateWrapper <?>)
return ((UIStateWrapper <?>) aObject).<T> getCastedObject ();
// Regular cast
return GenericReflection.uncheckedCast (aObject);
} | java | @Nullable
public <T> T getCastedState (@Nullable final ObjectType aOT, @Nullable final String sStateID)
{
final IHasUIState aObject = getState (aOT, sStateID);
if (aObject == null)
return null;
// Special handling for UI state wrapper to retrieve the contained object
if (aObject instanceof UIStateWrapper <?>)
return ((UIStateWrapper <?>) aObject).<T> getCastedObject ();
// Regular cast
return GenericReflection.uncheckedCast (aObject);
} | [
"@",
"Nullable",
"public",
"<",
"T",
">",
"T",
"getCastedState",
"(",
"@",
"Nullable",
"final",
"ObjectType",
"aOT",
",",
"@",
"Nullable",
"final",
"String",
"sStateID",
")",
"{",
"final",
"IHasUIState",
"aObject",
"=",
"getState",
"(",
"aOT",
",",
"sState... | Get the state object in the specified type. If the saved state is a
{@link UIStateWrapper} instance, the contained value is returned!
@param aOT
The ObjectType to be resolved. May be <code>null</code>.
@param sStateID
The state ID to be resolved.
@return <code>null</code> if no such object was found.
@param <T>
Return type | [
"Get",
"the",
"state",
"object",
"in",
"the",
"specified",
"type",
".",
"If",
"the",
"saved",
"state",
"is",
"a",
"{",
"@link",
"UIStateWrapper",
"}",
"instance",
"the",
"contained",
"value",
"is",
"returned!"
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/uistate/UIStateRegistry.java#L129-L142 |
beangle/beangle3 | commons/model/src/main/java/org/beangle/commons/transfer/excel/ExcelItemReader.java | ExcelItemReader.readDescription | public String[] readDescription() {
if (workbook.getNumberOfSheets() < 1) {
return new String[0];
} else {
HSSFSheet sheet = workbook.getSheetAt(0);
return readLine(sheet, headIndex);
}
} | java | public String[] readDescription() {
if (workbook.getNumberOfSheets() < 1) {
return new String[0];
} else {
HSSFSheet sheet = workbook.getSheetAt(0);
return readLine(sheet, headIndex);
}
} | [
"public",
"String",
"[",
"]",
"readDescription",
"(",
")",
"{",
"if",
"(",
"workbook",
".",
"getNumberOfSheets",
"(",
")",
"<",
"1",
")",
"{",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"HSSFSheet",
"sheet",
"=",
"workbook",
"."... | 描述放在第一行
@return an array of {@link java.lang.String} objects. | [
"描述放在第一行"
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/transfer/excel/ExcelItemReader.java#L155-L162 |
jaxio/celerio | celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java | RelationCollisionUtil.getInverseOneToOneNamer | public Namer getInverseOneToOneNamer(Attribute fromAttribute, Namer fromEntityNamer) {
Namer result = getInverseOneToOneNamerFromConf(fromAttribute.getColumnConfig(), fromEntityNamer);
if (result == null) {
result = fromEntityNamer;
}
return result;
} | java | public Namer getInverseOneToOneNamer(Attribute fromAttribute, Namer fromEntityNamer) {
Namer result = getInverseOneToOneNamerFromConf(fromAttribute.getColumnConfig(), fromEntityNamer);
if (result == null) {
result = fromEntityNamer;
}
return result;
} | [
"public",
"Namer",
"getInverseOneToOneNamer",
"(",
"Attribute",
"fromAttribute",
",",
"Namer",
"fromEntityNamer",
")",
"{",
"Namer",
"result",
"=",
"getInverseOneToOneNamerFromConf",
"(",
"fromAttribute",
".",
"getColumnConfig",
"(",
")",
",",
"fromEntityNamer",
")",
... | Compute the namer for the Java field marked by @OneToOne (inverse side of the relation)
@param fromAttribute the fk column config
@param fromEntityNamer | [
"Compute",
"the",
"namer",
"for",
"the",
"Java",
"field",
"marked",
"by",
"@OneToOne",
"(",
"inverse",
"side",
"of",
"the",
"relation",
")"
] | train | https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java#L159-L167 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/internal/yaml/YamlUtil.java | YamlUtil.asScalar | public static YamlScalar asScalar(YamlNode node) {
if (node != null && !(node instanceof YamlScalar)) {
String nodeName = node.nodeName();
throw new YamlException(String.format("Child %s is not a scalar, it's actual type is %s", nodeName, node.getClass()));
}
return (YamlScalar) node;
} | java | public static YamlScalar asScalar(YamlNode node) {
if (node != null && !(node instanceof YamlScalar)) {
String nodeName = node.nodeName();
throw new YamlException(String.format("Child %s is not a scalar, it's actual type is %s", nodeName, node.getClass()));
}
return (YamlScalar) node;
} | [
"public",
"static",
"YamlScalar",
"asScalar",
"(",
"YamlNode",
"node",
")",
"{",
"if",
"(",
"node",
"!=",
"null",
"&&",
"!",
"(",
"node",
"instanceof",
"YamlScalar",
")",
")",
"{",
"String",
"nodeName",
"=",
"node",
".",
"nodeName",
"(",
")",
";",
"thr... | Takes a generic {@link YamlNode} instance and returns it casted to
{@link YamlScalar} if the type of the node is a descendant of
{@link YamlScalar}.
@param node The generic node to cast
@return the casted scalar
@throws YamlException if the provided node is not a scalar | [
"Takes",
"a",
"generic",
"{",
"@link",
"YamlNode",
"}",
"instance",
"and",
"returns",
"it",
"casted",
"to",
"{",
"@link",
"YamlScalar",
"}",
"if",
"the",
"type",
"of",
"the",
"node",
"is",
"a",
"descendant",
"of",
"{",
"@link",
"YamlScalar",
"}",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/yaml/YamlUtil.java#L77-L84 |
Activiti/Activiti | activiti-bpmn-layout/src/main/java/org/activiti/bpmn/BPMNLayout.java | BPMNLayout.moveNode | protected void moveNode(TreeNode node, double dx, double dy) {
node.x += dx;
node.y += dy;
apply(node, null);
TreeNode child = node.child;
while (child != null) {
moveNode(child, dx, dy);
child = child.next;
}
} | java | protected void moveNode(TreeNode node, double dx, double dy) {
node.x += dx;
node.y += dy;
apply(node, null);
TreeNode child = node.child;
while (child != null) {
moveNode(child, dx, dy);
child = child.next;
}
} | [
"protected",
"void",
"moveNode",
"(",
"TreeNode",
"node",
",",
"double",
"dx",
",",
"double",
"dy",
")",
"{",
"node",
".",
"x",
"+=",
"dx",
";",
"node",
".",
"y",
"+=",
"dy",
";",
"apply",
"(",
"node",
",",
"null",
")",
";",
"TreeNode",
"child",
... | Moves the specified node and all of its children by the given amount. | [
"Moves",
"the",
"specified",
"node",
"and",
"all",
"of",
"its",
"children",
"by",
"the",
"given",
"amount",
"."
] | train | https://github.com/Activiti/Activiti/blob/82e2b2cd2083b2f734ca0efc7815389c0f2517d9/activiti-bpmn-layout/src/main/java/org/activiti/bpmn/BPMNLayout.java#L325-L336 |
protostuff/protostuff | protostuff-parser/src/main/java/io/protostuff/parser/DefaultProtoLoader.java | DefaultProtoLoader.searchFromProtoPathOnly | protected Proto searchFromProtoPathOnly(String path, Proto importer) throws Exception
{
// proto_path
File protoFile;
for (File dir : __protoLoadDirs)
{
if ((protoFile = new File(dir, path)).exists())
return loadFrom(protoFile, importer);
}
throw new IllegalStateException("Imported proto " + path +
" not found. (" + importer.getSourcePath() + ")");
} | java | protected Proto searchFromProtoPathOnly(String path, Proto importer) throws Exception
{
// proto_path
File protoFile;
for (File dir : __protoLoadDirs)
{
if ((protoFile = new File(dir, path)).exists())
return loadFrom(protoFile, importer);
}
throw new IllegalStateException("Imported proto " + path +
" not found. (" + importer.getSourcePath() + ")");
} | [
"protected",
"Proto",
"searchFromProtoPathOnly",
"(",
"String",
"path",
",",
"Proto",
"importer",
")",
"throws",
"Exception",
"{",
"// proto_path\r",
"File",
"protoFile",
";",
"for",
"(",
"File",
"dir",
":",
"__protoLoadDirs",
")",
"{",
"if",
"(",
"(",
"protoF... | Search from proto_path only. For full protoc compatibility, use this.
<p>
<pre>
Enable via:
-Dproto_path=$path -Dproto_search_strategy=1
</pre> | [
"Search",
"from",
"proto_path",
"only",
".",
"For",
"full",
"protoc",
"compatibility",
"use",
"this",
".",
"<p",
">"
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-parser/src/main/java/io/protostuff/parser/DefaultProtoLoader.java#L127-L139 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java | JournalCreator.purgeDatastream | public Date[] purgeDatastream(Context context,
String pid,
String datastreamID,
Date startDT,
Date endDT,
String logMessage) throws ServerException {
try {
CreatorJournalEntry cje =
new CreatorJournalEntry(METHOD_PURGE_DATASTREAM, context);
cje.addArgument(ARGUMENT_NAME_PID, pid);
cje.addArgument(ARGUMENT_NAME_DS_ID, datastreamID);
cje.addArgument(ARGUMENT_NAME_START_DATE, startDT);
cje.addArgument(ARGUMENT_NAME_END_DATE, endDT);
cje.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage);
return (Date[]) cje.invokeAndClose(delegate, writer);
} catch (JournalException e) {
throw new GeneralException("Problem creating the Journal", e);
}
} | java | public Date[] purgeDatastream(Context context,
String pid,
String datastreamID,
Date startDT,
Date endDT,
String logMessage) throws ServerException {
try {
CreatorJournalEntry cje =
new CreatorJournalEntry(METHOD_PURGE_DATASTREAM, context);
cje.addArgument(ARGUMENT_NAME_PID, pid);
cje.addArgument(ARGUMENT_NAME_DS_ID, datastreamID);
cje.addArgument(ARGUMENT_NAME_START_DATE, startDT);
cje.addArgument(ARGUMENT_NAME_END_DATE, endDT);
cje.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage);
return (Date[]) cje.invokeAndClose(delegate, writer);
} catch (JournalException e) {
throw new GeneralException("Problem creating the Journal", e);
}
} | [
"public",
"Date",
"[",
"]",
"purgeDatastream",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"datastreamID",
",",
"Date",
"startDT",
",",
"Date",
"endDT",
",",
"String",
"logMessage",
")",
"throws",
"ServerException",
"{",
"try",
"{",
"Crea... | Create a journal entry, add the arguments, and invoke the method. | [
"Create",
"a",
"journal",
"entry",
"add",
"the",
"arguments",
"and",
"invoke",
"the",
"method",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java#L322-L340 |
sculptor/sculptor | sculptor-framework/sculptor-framework-main/src/main/java/org/sculptor/framework/accessimpl/jpa/JpaHelper.java | JpaHelper.toSeparatedString | public static String toSeparatedString(List<?> values, String separator, String prefix) {
StringBuilder result = new StringBuilder();
for (Object each : values) {
if (each == null) {
continue;
}
if (result.length() > 0) {
result.append(separator);
}
if (prefix != null) {
result.append(String.valueOf(each));
} else {
result.append(prefix + String.valueOf(each));
}
}
return result.toString();
} | java | public static String toSeparatedString(List<?> values, String separator, String prefix) {
StringBuilder result = new StringBuilder();
for (Object each : values) {
if (each == null) {
continue;
}
if (result.length() > 0) {
result.append(separator);
}
if (prefix != null) {
result.append(String.valueOf(each));
} else {
result.append(prefix + String.valueOf(each));
}
}
return result.toString();
} | [
"public",
"static",
"String",
"toSeparatedString",
"(",
"List",
"<",
"?",
">",
"values",
",",
"String",
"separator",
",",
"String",
"prefix",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Object",
"each",
":"... | build a single String from a List of objects with a given separator and prefix
@param values
@param separator
@param prefix
@return | [
"build",
"a",
"single",
"String",
"from",
"a",
"List",
"of",
"objects",
"with",
"a",
"given",
"separator",
"and",
"prefix"
] | train | https://github.com/sculptor/sculptor/blob/38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5/sculptor-framework/sculptor-framework-main/src/main/java/org/sculptor/framework/accessimpl/jpa/JpaHelper.java#L297-L313 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/nephele/instance/cluster/ClusterManager.java | ClusterManager.canBeAccommodated | private int canBeAccommodated(int sourceTypeIndex, int targetTypeIndex) {
if (sourceTypeIndex >= this.availableInstanceTypes.length
|| targetTypeIndex >= this.availableInstanceTypes.length) {
LOG.error("Cannot determine number of instance accomodations: invalid index");
return 0;
}
return this.instanceAccommodationMatrix[targetTypeIndex][sourceTypeIndex];
} | java | private int canBeAccommodated(int sourceTypeIndex, int targetTypeIndex) {
if (sourceTypeIndex >= this.availableInstanceTypes.length
|| targetTypeIndex >= this.availableInstanceTypes.length) {
LOG.error("Cannot determine number of instance accomodations: invalid index");
return 0;
}
return this.instanceAccommodationMatrix[targetTypeIndex][sourceTypeIndex];
} | [
"private",
"int",
"canBeAccommodated",
"(",
"int",
"sourceTypeIndex",
",",
"int",
"targetTypeIndex",
")",
"{",
"if",
"(",
"sourceTypeIndex",
">=",
"this",
".",
"availableInstanceTypes",
".",
"length",
"||",
"targetTypeIndex",
">=",
"this",
".",
"availableInstanceTyp... | Returns how many times the instance type stored at index <code>sourceTypeIndex</code> can be accommodated inside
the instance type stored at index <code>targetTypeIndex</code> in the list of available instance types.
@param sourceTypeIndex
the index of the source instance type in the list of available instance types
@param targetTypeIndex
the index of the target instance type in the list of available instance types
@return the number of times the source type instance can be accommodated inside the target instance | [
"Returns",
"how",
"many",
"times",
"the",
"instance",
"type",
"stored",
"at",
"index",
"<code",
">",
"sourceTypeIndex<",
"/",
"code",
">",
"can",
"be",
"accommodated",
"inside",
"the",
"instance",
"type",
"stored",
"at",
"index",
"<code",
">",
"targetTypeIndex... | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/instance/cluster/ClusterManager.java#L902-L911 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java | HashtableOnDisk.findEntry | private HashtableEntry findEntry(Object key, int hashcode, int retrieveMode, boolean checkExpired, long current, int tableid)
throws IOException,
EOFException,
FileManagerException,
ClassNotFoundException,
HashtableOnDiskException {
long previous = 0;
long next = 0;
int hash = 0;
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
while (current != 0) {
if (hash == hashcode) { // hash the same?
//
// Need to finish collision resolution and maybe return the object
//
HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, checkExpired, tableid, key, null); //493877
if (entry != null) { // 493877 if entry is NOT null, the entry is found.
return entry;
}
}
collisions++;
//
// Try for next object in bucket
//
previous = current;
current = next;
if (current != 0) { // optimize - don't read if we know we can't use it
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
}
}
//
// If we fall through we did not find it
//
return null;
} | java | private HashtableEntry findEntry(Object key, int hashcode, int retrieveMode, boolean checkExpired, long current, int tableid)
throws IOException,
EOFException,
FileManagerException,
ClassNotFoundException,
HashtableOnDiskException {
long previous = 0;
long next = 0;
int hash = 0;
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
while (current != 0) {
if (hash == hashcode) { // hash the same?
//
// Need to finish collision resolution and maybe return the object
//
HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, checkExpired, tableid, key, null); //493877
if (entry != null) { // 493877 if entry is NOT null, the entry is found.
return entry;
}
}
collisions++;
//
// Try for next object in bucket
//
previous = current;
current = next;
if (current != 0) { // optimize - don't read if we know we can't use it
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
}
}
//
// If we fall through we did not find it
//
return null;
} | [
"private",
"HashtableEntry",
"findEntry",
"(",
"Object",
"key",
",",
"int",
"hashcode",
",",
"int",
"retrieveMode",
",",
"boolean",
"checkExpired",
",",
"long",
"current",
",",
"int",
"tableid",
")",
"throws",
"IOException",
",",
"EOFException",
",",
"FileManage... | ************************************************************************
Search disk for the indicated entry and return it and its
predecessor if any.
*********************************************************************** | [
"************************************************************************",
"Search",
"disk",
"for",
"the",
"indicated",
"entry",
"and",
"return",
"it",
"and",
"its",
"predecessor",
"if",
"any",
".",
"***********************************************************************"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java#L2198-L2244 |
citiususc/hipster | hipster-examples/src/main/java/es/usc/citius/hipster/examples/problem/NPuzzle.java | NPuzzle.getPrettyPath | public static String getPrettyPath(List<Puzzle> path, int size) {
// Print each row of all states
StringBuffer output = new StringBuffer();
for (int y = 0; y < size; y++) {
String row = "";
for (Puzzle state : path) {
int[][] board = state.getMatrixBoard();
row += "| ";
for (int x = 0; x < size; x++) {
row += board[y][x] + " ";
}
row += "| ";
}
row += "\n";
output.append(row);
}
return output.toString();
} | java | public static String getPrettyPath(List<Puzzle> path, int size) {
// Print each row of all states
StringBuffer output = new StringBuffer();
for (int y = 0; y < size; y++) {
String row = "";
for (Puzzle state : path) {
int[][] board = state.getMatrixBoard();
row += "| ";
for (int x = 0; x < size; x++) {
row += board[y][x] + " ";
}
row += "| ";
}
row += "\n";
output.append(row);
}
return output.toString();
} | [
"public",
"static",
"String",
"getPrettyPath",
"(",
"List",
"<",
"Puzzle",
">",
"path",
",",
"int",
"size",
")",
"{",
"// Print each row of all states",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"y",
"=",
"0",
... | Prints a search path in a readable form.
@param path List of puzzle states of the path.
@param size Size of the puzzle state (8 for 8-puzzle)
@return String representing all the transitions from initial to goal. | [
"Prints",
"a",
"search",
"path",
"in",
"a",
"readable",
"form",
"."
] | train | https://github.com/citiususc/hipster/blob/9ab1236abb833a27641ae73ba9ca890d5c17598e/hipster-examples/src/main/java/es/usc/citius/hipster/examples/problem/NPuzzle.java#L40-L57 |
xvik/dropwizard-guicey | src/main/java/ru/vyarus/dropwizard/guice/module/installer/feature/web/util/WebUtils.java | WebUtils.getFilterName | public static String getFilterName(final WebFilter filter, final Class<? extends Filter> type) {
final String name = Strings.emptyToNull(filter.filterName());
return name != null ? name : generateName(type, "filter");
} | java | public static String getFilterName(final WebFilter filter, final Class<? extends Filter> type) {
final String name = Strings.emptyToNull(filter.filterName());
return name != null ? name : generateName(type, "filter");
} | [
"public",
"static",
"String",
"getFilterName",
"(",
"final",
"WebFilter",
"filter",
",",
"final",
"Class",
"<",
"?",
"extends",
"Filter",
">",
"type",
")",
"{",
"final",
"String",
"name",
"=",
"Strings",
".",
"emptyToNull",
"(",
"filter",
".",
"filterName",
... | When filter name not set in annotation, name generates as: . (dot) at the beginning to indicate
generated name, followed by lower-cased class name. If class ends with "filter" then it will be cut off.
For example, for class "MyCoolFilter" generated name will be ".mycool".
@param filter filter annotation
@param type filter type
@return filter name or generated name if name not provided | [
"When",
"filter",
"name",
"not",
"set",
"in",
"annotation",
"name",
"generates",
"as",
":",
".",
"(",
"dot",
")",
"at",
"the",
"beginning",
"to",
"indicate",
"generated",
"name",
"followed",
"by",
"lower",
"-",
"cased",
"class",
"name",
".",
"If",
"class... | train | https://github.com/xvik/dropwizard-guicey/blob/dd39ad77283555be21f606d5ebf0f11207a733d4/src/main/java/ru/vyarus/dropwizard/guice/module/installer/feature/web/util/WebUtils.java#L31-L34 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ras.instrument/src/com/ibm/ws/ras/instrument/internal/bci/AbstractRasMethodAdapter.java | AbstractRasMethodAdapter.visitParameterAnnotation | @Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
AnnotationVisitor av = super.visitParameterAnnotation(parameter, desc, visible);
Set<Type> parameterAnnotations = observedParameterAnnotations.get(parameter);
if (parameterAnnotations == null) {
parameterAnnotations = new HashSet<Type>();
observedParameterAnnotations.put(parameter, parameterAnnotations);
}
parameterAnnotations.add(Type.getType(desc));
return av;
} | java | @Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
AnnotationVisitor av = super.visitParameterAnnotation(parameter, desc, visible);
Set<Type> parameterAnnotations = observedParameterAnnotations.get(parameter);
if (parameterAnnotations == null) {
parameterAnnotations = new HashSet<Type>();
observedParameterAnnotations.put(parameter, parameterAnnotations);
}
parameterAnnotations.add(Type.getType(desc));
return av;
} | [
"@",
"Override",
"public",
"AnnotationVisitor",
"visitParameterAnnotation",
"(",
"int",
"parameter",
",",
"String",
"desc",
",",
"boolean",
"visible",
")",
"{",
"AnnotationVisitor",
"av",
"=",
"super",
".",
"visitParameterAnnotation",
"(",
"parameter",
",",
"desc",
... | Visit the method parameter annotations looking for the supported RAS
annotations. The visitors are only used when a {@code MethodInfo} model
object was not provided during construction.
@param desc
the annotation descriptor
@param visible
true if the annotation is a runtime visible annotation | [
"Visit",
"the",
"method",
"parameter",
"annotations",
"looking",
"for",
"the",
"supported",
"RAS",
"annotations",
".",
"The",
"visitors",
"are",
"only",
"used",
"when",
"a",
"{",
"@code",
"MethodInfo",
"}",
"model",
"object",
"was",
"not",
"provided",
"during"... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ras.instrument/src/com/ibm/ws/ras/instrument/internal/bci/AbstractRasMethodAdapter.java#L353-L363 |
google/j2objc | jre_emul/android/platform/libcore/json/src/main/java/org/json/JSONObject.java | JSONObject.put | public JSONObject put(String name, Object value) throws JSONException {
if (value == null) {
nameValuePairs.remove(name);
return this;
}
if (value instanceof Number) {
// deviate from the original by checking all Numbers, not just floats & doubles
JSON.checkDouble(((Number) value).doubleValue());
}
nameValuePairs.put(checkName(name), value);
return this;
} | java | public JSONObject put(String name, Object value) throws JSONException {
if (value == null) {
nameValuePairs.remove(name);
return this;
}
if (value instanceof Number) {
// deviate from the original by checking all Numbers, not just floats & doubles
JSON.checkDouble(((Number) value).doubleValue());
}
nameValuePairs.put(checkName(name), value);
return this;
} | [
"public",
"JSONObject",
"put",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"nameValuePairs",
".",
"remove",
"(",
"name",
")",
";",
"return",
"this",
";",
"}",
"if",
"("... | Maps {@code name} to {@code value}, clobbering any existing name/value
mapping with the same name. If the value is {@code null}, any existing
mapping for {@code name} is removed.
@param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
Integer, Long, Double, {@link #NULL}, or {@code null}. May not be
{@link Double#isNaN() NaNs} or {@link Double#isInfinite()
infinities}.
@return this object. | [
"Maps",
"{",
"@code",
"name",
"}",
"to",
"{",
"@code",
"value",
"}",
"clobbering",
"any",
"existing",
"name",
"/",
"value",
"mapping",
"with",
"the",
"same",
"name",
".",
"If",
"the",
"value",
"is",
"{",
"@code",
"null",
"}",
"any",
"existing",
"mappin... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/json/src/main/java/org/json/JSONObject.java#L255-L266 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.moveToTrash | public static void moveToTrash(FileSystem fs, Path path) throws IOException {
Trash trash = new Trash(fs, new Configuration());
trash.moveToTrash(path);
} | java | public static void moveToTrash(FileSystem fs, Path path) throws IOException {
Trash trash = new Trash(fs, new Configuration());
trash.moveToTrash(path);
} | [
"public",
"static",
"void",
"moveToTrash",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"Trash",
"trash",
"=",
"new",
"Trash",
"(",
"fs",
",",
"new",
"Configuration",
"(",
")",
")",
";",
"trash",
".",
"moveToTrash",
"(... | Moves the object to the filesystem trash according to the file system policy.
@param fs FileSystem object
@param path Path to the object to be moved to trash.
@throws IOException | [
"Moves",
"the",
"object",
"to",
"the",
"filesystem",
"trash",
"according",
"to",
"the",
"file",
"system",
"policy",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L211-L214 |
dadoonet/elasticsearch-beyonder | src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java | IndexElasticsearchUpdater.isIndexExist | public static boolean isIndexExist(RestClient client, String index) throws Exception {
Response response = client.performRequest(new Request("HEAD", "/" + index));
return response.getStatusLine().getStatusCode() == 200;
} | java | public static boolean isIndexExist(RestClient client, String index) throws Exception {
Response response = client.performRequest(new Request("HEAD", "/" + index));
return response.getStatusLine().getStatusCode() == 200;
} | [
"public",
"static",
"boolean",
"isIndexExist",
"(",
"RestClient",
"client",
",",
"String",
"index",
")",
"throws",
"Exception",
"{",
"Response",
"response",
"=",
"client",
".",
"performRequest",
"(",
"new",
"Request",
"(",
"\"HEAD\"",
",",
"\"/\"",
"+",
"index... | Check if an index already exists
@param client Elasticsearch client
@param index Index name
@return true if index already exists
@throws Exception if the elasticsearch API call is failing | [
"Check",
"if",
"an",
"index",
"already",
"exists"
] | train | https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L331-L334 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxCollection.java | BoxCollection.getAllCollections | public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) {
return new Iterable<BoxCollection.Info>() {
public Iterator<BoxCollection.Info> iterator() {
URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL());
return new BoxCollectionIterator(api, url);
}
};
} | java | public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) {
return new Iterable<BoxCollection.Info>() {
public Iterator<BoxCollection.Info> iterator() {
URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL());
return new BoxCollectionIterator(api, url);
}
};
} | [
"public",
"static",
"Iterable",
"<",
"BoxCollection",
".",
"Info",
">",
"getAllCollections",
"(",
"final",
"BoxAPIConnection",
"api",
")",
"{",
"return",
"new",
"Iterable",
"<",
"BoxCollection",
".",
"Info",
">",
"(",
")",
"{",
"public",
"Iterator",
"<",
"Bo... | Gets an iterable of all the collections for the given user.
@param api the API connection to be used when retrieving the collections.
@return an iterable containing info about all the collections. | [
"Gets",
"an",
"iterable",
"of",
"all",
"the",
"collections",
"for",
"the",
"given",
"user",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L44-L51 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java | FormatUtil.appendSpace | public static StringBuilder appendSpace(StringBuilder buf, int spaces) {
for(int i = spaces; i > 0; i -= SPACEPADDING.length) {
buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length);
}
return buf;
} | java | public static StringBuilder appendSpace(StringBuilder buf, int spaces) {
for(int i = spaces; i > 0; i -= SPACEPADDING.length) {
buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length);
}
return buf;
} | [
"public",
"static",
"StringBuilder",
"appendSpace",
"(",
"StringBuilder",
"buf",
",",
"int",
"spaces",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"spaces",
";",
"i",
">",
"0",
";",
"i",
"-=",
"SPACEPADDING",
".",
"length",
")",
"{",
"buf",
".",
"append",
... | Append whitespace to a buffer.
@param buf Buffer to append to
@param spaces Number of spaces to append.
@return Buffer | [
"Append",
"whitespace",
"to",
"a",
"buffer",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L989-L994 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.flattenPaging | public static <T> Paging<T> flattenPaging(Collection<Paging<T>> collectionOfPaging,
Comparator<T> sorter, BooleanExpression<T> filter)
{
if (collectionOfPaging == null || collectionOfPaging.isEmpty())
return null;
PageCriteria pageCriteria = collectionOfPaging.iterator().next().getPageCriteria();
return flattenPaging(collectionOfPaging, pageCriteria, sorter, filter);
} | java | public static <T> Paging<T> flattenPaging(Collection<Paging<T>> collectionOfPaging,
Comparator<T> sorter, BooleanExpression<T> filter)
{
if (collectionOfPaging == null || collectionOfPaging.isEmpty())
return null;
PageCriteria pageCriteria = collectionOfPaging.iterator().next().getPageCriteria();
return flattenPaging(collectionOfPaging, pageCriteria, sorter, filter);
} | [
"public",
"static",
"<",
"T",
">",
"Paging",
"<",
"T",
">",
"flattenPaging",
"(",
"Collection",
"<",
"Paging",
"<",
"T",
">",
">",
"collectionOfPaging",
",",
"Comparator",
"<",
"T",
">",
"sorter",
",",
"BooleanExpression",
"<",
"T",
">",
"filter",
")",
... | Aggregates multiple collections into a single paging collection
@param collectionOfPaging
the collection paging that need to be flatten
@param sorter
optional comparable for sorting
@param filter
optional filter, if filter.
@param <T>
the type class
@return the flatten collections into a single collection | [
"Aggregates",
"multiple",
"collections",
"into",
"a",
"single",
"paging",
"collection"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L206-L214 |
alkacon/opencms-core | src/org/opencms/widgets/CmsCalendarWidget.java | CmsCalendarWidget.calendarIncludes | public static String calendarIncludes(Locale locale, String style) {
StringBuffer result = new StringBuffer(512);
String calendarPath = CmsWorkplace.getSkinUri() + "components/js_calendar/";
if (CmsStringUtil.isEmpty(style)) {
style = "system";
}
result.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
result.append(calendarPath);
result.append("calendar-");
result.append(style);
result.append(".css\">\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("calendar.js\"></script>\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("lang/calendar-");
result.append(getLanguageSuffix(locale.getLanguage()));
result.append(".js\"></script>\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("calendar-setup.js\"></script>\n");
return result.toString();
} | java | public static String calendarIncludes(Locale locale, String style) {
StringBuffer result = new StringBuffer(512);
String calendarPath = CmsWorkplace.getSkinUri() + "components/js_calendar/";
if (CmsStringUtil.isEmpty(style)) {
style = "system";
}
result.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
result.append(calendarPath);
result.append("calendar-");
result.append(style);
result.append(".css\">\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("calendar.js\"></script>\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("lang/calendar-");
result.append(getLanguageSuffix(locale.getLanguage()));
result.append(".js\"></script>\n");
result.append("<script type=\"text/javascript\" src=\"");
result.append(calendarPath);
result.append("calendar-setup.js\"></script>\n");
return result.toString();
} | [
"public",
"static",
"String",
"calendarIncludes",
"(",
"Locale",
"locale",
",",
"String",
"style",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"512",
")",
";",
"String",
"calendarPath",
"=",
"CmsWorkplace",
".",
"getSkinUri",
"(",
")",... | Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.<p>
@param locale the locale to use for the calendar
@param style the name of the used calendar style, e.g. "system", "blue"
@return the necessary HTML code for the js and stylesheet includes | [
"Creates",
"the",
"HTML",
"JavaScript",
"and",
"stylesheet",
"includes",
"required",
"by",
"the",
"calendar",
"for",
"the",
"head",
"of",
"the",
"page",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/CmsCalendarWidget.java#L104-L128 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/databinding/datagrid/AbstractDataGridHtmlTag.java | AbstractDataGridHtmlTag.applyIndexedTagId | protected final void applyIndexedTagId(AbstractHtmlState state, String tagId)
throws JspException {
state.id = indexTagId(generateTagId(tagId));
} | java | protected final void applyIndexedTagId(AbstractHtmlState state, String tagId)
throws JspException {
state.id = indexTagId(generateTagId(tagId));
} | [
"protected",
"final",
"void",
"applyIndexedTagId",
"(",
"AbstractHtmlState",
"state",
",",
"String",
"tagId",
")",
"throws",
"JspException",
"{",
"state",
".",
"id",
"=",
"indexTagId",
"(",
"generateTagId",
"(",
"tagId",
")",
")",
";",
"}"
] | Create an indexed tag identifier given a state object and a base tag identifier. The <code>tagId</code>
will have the index of the current item in the data grid attached as a suffix to the
the given base identifier.
@param state the {@link AbstractHtmlState} upon which the tag identifier will be set once created
@param tagId the base tag identifier name
@throws JspException | [
"Create",
"an",
"indexed",
"tag",
"identifier",
"given",
"a",
"state",
"object",
"and",
"a",
"base",
"tag",
"identifier",
".",
"The",
"<code",
">",
"tagId<",
"/",
"code",
">",
"will",
"have",
"the",
"index",
"of",
"the",
"current",
"item",
"in",
"the",
... | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/databinding/datagrid/AbstractDataGridHtmlTag.java#L68-L71 |
JodaOrg/joda-beans | src/main/java/org/joda/beans/gen/PropertyData.java | PropertyData.resolveToStringStyle | public void resolveToStringStyle(File file, int lineIndex) {
if (toStringStyle.equals("smart")) {
toStringStyle = (bean.isImmutable() ? "field" : "getter");
}
if (toStringStyle.equals("omit") ||
toStringStyle.equals("getter") ||
toStringStyle.equals("field")) {
return;
}
throw new BeanCodeGenException("Invalid toString style: " + toStringStyle +
" in " + getBean().getTypeRaw() + "." + getPropertyName(), file, lineIndex);
} | java | public void resolveToStringStyle(File file, int lineIndex) {
if (toStringStyle.equals("smart")) {
toStringStyle = (bean.isImmutable() ? "field" : "getter");
}
if (toStringStyle.equals("omit") ||
toStringStyle.equals("getter") ||
toStringStyle.equals("field")) {
return;
}
throw new BeanCodeGenException("Invalid toString style: " + toStringStyle +
" in " + getBean().getTypeRaw() + "." + getPropertyName(), file, lineIndex);
} | [
"public",
"void",
"resolveToStringStyle",
"(",
"File",
"file",
",",
"int",
"lineIndex",
")",
"{",
"if",
"(",
"toStringStyle",
".",
"equals",
"(",
"\"smart\"",
")",
")",
"{",
"toStringStyle",
"=",
"(",
"bean",
".",
"isImmutable",
"(",
")",
"?",
"\"field\"",... | Resolves the toString generator.
@param file the file
@param lineIndex the line index | [
"Resolves",
"the",
"toString",
"generator",
"."
] | train | https://github.com/JodaOrg/joda-beans/blob/f07dbe42947150b23a173f35984c6ab33c5529bf/src/main/java/org/joda/beans/gen/PropertyData.java#L487-L498 |
Netflix/zuul | zuul-core/src/main/java/com/netflix/zuul/context/SessionContext.java | SessionContext.addFilterExecutionSummary | public void addFilterExecutionSummary(String name, String status, long time) {
StringBuilder sb = getFilterExecutionSummary();
if (sb.length() > 0) sb.append(", ");
sb.append(name).append('[').append(status).append(']').append('[').append(time).append("ms]");
} | java | public void addFilterExecutionSummary(String name, String status, long time) {
StringBuilder sb = getFilterExecutionSummary();
if (sb.length() > 0) sb.append(", ");
sb.append(name).append('[').append(status).append(']').append('[').append(time).append("ms]");
} | [
"public",
"void",
"addFilterExecutionSummary",
"(",
"String",
"name",
",",
"String",
"status",
",",
"long",
"time",
")",
"{",
"StringBuilder",
"sb",
"=",
"getFilterExecutionSummary",
"(",
")",
";",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
... | appends filter name and status to the filter execution history for the
current request | [
"appends",
"filter",
"name",
"and",
"status",
"to",
"the",
"filter",
"execution",
"history",
"for",
"the",
"current",
"request"
] | train | https://github.com/Netflix/zuul/blob/01bc777cf05e3522d37c9ed902ae13eb38a19692/zuul-core/src/main/java/com/netflix/zuul/context/SessionContext.java#L305-L309 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java | FlowController.getDataSource | protected DataSource getDataSource( HttpServletRequest request, String key )
{
// Return the requested data source instance
return ( DataSource ) getServletContext().getAttribute( key + getModuleConfig().getPrefix() );
} | java | protected DataSource getDataSource( HttpServletRequest request, String key )
{
// Return the requested data source instance
return ( DataSource ) getServletContext().getAttribute( key + getModuleConfig().getPrefix() );
} | [
"protected",
"DataSource",
"getDataSource",
"(",
"HttpServletRequest",
"request",
",",
"String",
"key",
")",
"{",
"// Return the requested data source instance",
"return",
"(",
"DataSource",
")",
"getServletContext",
"(",
")",
".",
"getAttribute",
"(",
"key",
"+",
"ge... | Return the specified data source for the current Struts module.
@param request The servlet request we are processing
@param key The key specified in the
<code><message-resources></code> element for the
requested bundle | [
"Return",
"the",
"specified",
"data",
"source",
"for",
"the",
"current",
"Struts",
"module",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java#L1596-L1600 |
atomix/copycat | server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java | AbstractAppender.buildAppendRequest | protected AppendRequest buildAppendRequest(MemberState member, long lastIndex) {
// If the log is empty then send an empty commit.
// If the next index hasn't yet been set then we send an empty commit first.
// If the next index is greater than the last index then send an empty commit.
// If the member failed to respond to recent communication send an empty commit. This
// helps avoid doing expensive work until we can ascertain the member is back up.
if (context.getLog().isEmpty() || member.getNextIndex() > lastIndex || member.getFailureCount() > 0) {
return buildAppendEmptyRequest(member);
} else {
return buildAppendEntriesRequest(member, lastIndex);
}
} | java | protected AppendRequest buildAppendRequest(MemberState member, long lastIndex) {
// If the log is empty then send an empty commit.
// If the next index hasn't yet been set then we send an empty commit first.
// If the next index is greater than the last index then send an empty commit.
// If the member failed to respond to recent communication send an empty commit. This
// helps avoid doing expensive work until we can ascertain the member is back up.
if (context.getLog().isEmpty() || member.getNextIndex() > lastIndex || member.getFailureCount() > 0) {
return buildAppendEmptyRequest(member);
} else {
return buildAppendEntriesRequest(member, lastIndex);
}
} | [
"protected",
"AppendRequest",
"buildAppendRequest",
"(",
"MemberState",
"member",
",",
"long",
"lastIndex",
")",
"{",
"// If the log is empty then send an empty commit.",
"// If the next index hasn't yet been set then we send an empty commit first.",
"// If the next index is greater than t... | Builds an append request.
@param member The member to which to send the request.
@return The append request. | [
"Builds",
"an",
"append",
"request",
"."
] | train | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/AbstractAppender.java#L61-L72 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/opengl/CursorLoader.java | CursorLoader.getAnimatedCursor | public Cursor getAnimatedCursor(String ref,int x,int y, int width, int height, int[] cursorDelays) throws IOException, LWJGLException {
IntBuffer cursorDelaysBuffer = ByteBuffer.allocateDirect(cursorDelays.length*4).order(ByteOrder.nativeOrder()).asIntBuffer();
for (int i=0;i<cursorDelays.length;i++) {
cursorDelaysBuffer.put(cursorDelays[i]);
}
cursorDelaysBuffer.flip();
LoadableImageData imageData = new TGAImageData();
ByteBuffer buf = imageData.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
return new Cursor(width, height, x, y, cursorDelays.length, buf.asIntBuffer(), cursorDelaysBuffer);
} | java | public Cursor getAnimatedCursor(String ref,int x,int y, int width, int height, int[] cursorDelays) throws IOException, LWJGLException {
IntBuffer cursorDelaysBuffer = ByteBuffer.allocateDirect(cursorDelays.length*4).order(ByteOrder.nativeOrder()).asIntBuffer();
for (int i=0;i<cursorDelays.length;i++) {
cursorDelaysBuffer.put(cursorDelays[i]);
}
cursorDelaysBuffer.flip();
LoadableImageData imageData = new TGAImageData();
ByteBuffer buf = imageData.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
return new Cursor(width, height, x, y, cursorDelays.length, buf.asIntBuffer(), cursorDelaysBuffer);
} | [
"public",
"Cursor",
"getAnimatedCursor",
"(",
"String",
"ref",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
",",
"int",
"[",
"]",
"cursorDelays",
")",
"throws",
"IOException",
",",
"LWJGLException",
"{",
"IntBuffer",
"cursor... | Get a cursor based on a image reference on the classpath. The image
is assumed to be a set/strip of cursor animation frames running from top to
bottom.
@param ref The reference to the image to be loaded
@param x The x-coordinate of the cursor hotspot (left -> right)
@param y The y-coordinate of the cursor hotspot (bottom -> top)
@param width The x width of the cursor
@param height The y height of the cursor
@param cursorDelays image delays between changing frames in animation
@return The created cursor
@throws IOException Indicates a failure to load the image
@throws LWJGLException Indicates a failure to create the hardware cursor | [
"Get",
"a",
"cursor",
"based",
"on",
"a",
"image",
"reference",
"on",
"the",
"classpath",
".",
"The",
"image",
"is",
"assumed",
"to",
"be",
"a",
"set",
"/",
"strip",
"of",
"cursor",
"animation",
"frames",
"running",
"from",
"top",
"to",
"bottom",
"."
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/CursorLoader.java#L171-L182 |
drtrang/spring-boot-autoconfigure | src/main/java/com/github/trang/autoconfigure/mybatis/SqlMapper.java | SqlMapper.selectOne | public <T> T selectOne(String sql, Object value, Class<T> resultType) {
List<T> list = selectList(sql, value, resultType);
return getOne(list);
} | java | public <T> T selectOne(String sql, Object value, Class<T> resultType) {
List<T> list = selectList(sql, value, resultType);
return getOne(list);
} | [
"public",
"<",
"T",
">",
"T",
"selectOne",
"(",
"String",
"sql",
",",
"Object",
"value",
",",
"Class",
"<",
"T",
">",
"resultType",
")",
"{",
"List",
"<",
"T",
">",
"list",
"=",
"selectList",
"(",
"sql",
",",
"value",
",",
"resultType",
")",
";",
... | 查询返回一个结果,多个结果时抛出异常
@param sql 执行的sql
@param value 参数
@param resultType 返回的结果类型
@param <T> 泛型类型
@return result | [
"查询返回一个结果,多个结果时抛出异常"
] | train | https://github.com/drtrang/spring-boot-autoconfigure/blob/6c9aa6352c22d3eb44f1edf93e89e8442d3f3efa/src/main/java/com/github/trang/autoconfigure/mybatis/SqlMapper.java#L103-L106 |
ahome-it/lienzo-core | src/main/java/com/ait/lienzo/shared/core/types/Color.java | Color.toBrowserRGB | public static final String toBrowserRGB(final int r, final int g, final int b)
{
return "rgb(" + fixRGB(r) + "," + fixRGB(g) + "," + fixRGB(b) + ")";
} | java | public static final String toBrowserRGB(final int r, final int g, final int b)
{
return "rgb(" + fixRGB(r) + "," + fixRGB(g) + "," + fixRGB(b) + ")";
} | [
"public",
"static",
"final",
"String",
"toBrowserRGB",
"(",
"final",
"int",
"r",
",",
"final",
"int",
"g",
",",
"final",
"int",
"b",
")",
"{",
"return",
"\"rgb(\"",
"+",
"fixRGB",
"(",
"r",
")",
"+",
"\",\"",
"+",
"fixRGB",
"(",
"g",
")",
"+",
"\",... | Converts RGB integer values to a browser-compliance rgb format.
@param r int between 0 and 255
@param g int between 0 and 255
@param b int between 0 and 255
@return String e.g. "rgb(12,34,255)" | [
"Converts",
"RGB",
"integer",
"values",
"to",
"a",
"browser",
"-",
"compliance",
"rgb",
"format",
"."
] | train | https://github.com/ahome-it/lienzo-core/blob/8e03723700dec366f77064d12fb8676d8cd6be99/src/main/java/com/ait/lienzo/shared/core/types/Color.java#L192-L195 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/jboss/logging/Logger.java | Logger.errorf | public void errorf(String format, Object... params) {
doLogf(Level.ERROR, FQCN, format, params, null);
} | java | public void errorf(String format, Object... params) {
doLogf(Level.ERROR, FQCN, format, params, null);
} | [
"public",
"void",
"errorf",
"(",
"String",
"format",
",",
"Object",
"...",
"params",
")",
"{",
"doLogf",
"(",
"Level",
".",
"ERROR",
",",
"FQCN",
",",
"format",
",",
"params",
",",
"null",
")",
";",
"}"
] | Issue a formatted log message with a level of ERROR.
@param format the format string as per {@link String#format(String, Object...)} or resource bundle key therefor
@param params the parameters | [
"Issue",
"a",
"formatted",
"log",
"message",
"with",
"a",
"level",
"of",
"ERROR",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/jboss/logging/Logger.java#L1666-L1668 |
roboconf/roboconf-platform | core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java | DockerUtils.deleteImageIfItExists | public static void deleteImageIfItExists( String imageId, DockerClient dockerClient ) {
if( imageId != null ) {
List<Image> images = dockerClient.listImagesCmd().exec();
if( findImageById( imageId, images ) != null )
dockerClient.removeImageCmd( imageId ).withForce( true ).exec();
}
} | java | public static void deleteImageIfItExists( String imageId, DockerClient dockerClient ) {
if( imageId != null ) {
List<Image> images = dockerClient.listImagesCmd().exec();
if( findImageById( imageId, images ) != null )
dockerClient.removeImageCmd( imageId ).withForce( true ).exec();
}
} | [
"public",
"static",
"void",
"deleteImageIfItExists",
"(",
"String",
"imageId",
",",
"DockerClient",
"dockerClient",
")",
"{",
"if",
"(",
"imageId",
"!=",
"null",
")",
"{",
"List",
"<",
"Image",
">",
"images",
"=",
"dockerClient",
".",
"listImagesCmd",
"(",
"... | Deletes a Docker image if it exists.
@param imageId the image ID (not null)
@param dockerClient a Docker client | [
"Deletes",
"a",
"Docker",
"image",
"if",
"it",
"exists",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L102-L109 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/Runtime.java | Runtime.changedPropertyValue | public static void changedPropertyValue (String name, String value) {
if (tc.isEntryEnabled()) SibTr.entry(tc, "changedPropertyValue");
if (value == null) value = "null"; // Ensure that the new value is non-null (here we're only using for a message insert)
if (!value.equals(seenProperties.put(name,value)))
{
// We haven't seen the property before or it's changed, so issue the message
SibTr.info(tc, "RUNTIME_CWSIU0001", new Object[] {name,value}); //220097.0
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "changedPropertyValue");
} | java | public static void changedPropertyValue (String name, String value) {
if (tc.isEntryEnabled()) SibTr.entry(tc, "changedPropertyValue");
if (value == null) value = "null"; // Ensure that the new value is non-null (here we're only using for a message insert)
if (!value.equals(seenProperties.put(name,value)))
{
// We haven't seen the property before or it's changed, so issue the message
SibTr.info(tc, "RUNTIME_CWSIU0001", new Object[] {name,value}); //220097.0
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "changedPropertyValue");
} | [
"public",
"static",
"void",
"changedPropertyValue",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"changedPropertyValue\"",
")",
";",
"if",
"(",
"v... | This method should be called each time a SIB property value is assigned a
none default value. An informational message is output for serviceability
reasons so that it is obvious that a property value has been changed.
@param name the name of the property that has been changed
@param value the new value assigned to the changed property | [
"This",
"method",
"should",
"be",
"called",
"each",
"time",
"a",
"SIB",
"property",
"value",
"is",
"assigned",
"a",
"none",
"default",
"value",
".",
"An",
"informational",
"message",
"is",
"output",
"for",
"serviceability",
"reasons",
"so",
"that",
"it",
"is... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/Runtime.java#L39-L51 |
Bearded-Hen/Android-Bootstrap | AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapProgressBar.java | BootstrapProgressBar.createRoundedBitmap | private static Bitmap createRoundedBitmap(Bitmap bitmap, float cornerRadius, boolean roundRight, boolean roundLeft) {
Bitmap roundedBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), ARGB_8888);
Canvas canvas = new Canvas(roundedBitmap);
final Paint paint = new Paint();
final Rect frame = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
// final Rect frameLeft = new Rect(0, 0, bitmap.getWidth() /2, bitmap.getHeight());
// final Rect frameRight = new Rect(bitmap.getWidth() /2, bitmap.getHeight(), bitmap.getWidth(), bitmap.getHeight());
final Rect leftRect = new Rect(0, 0, bitmap.getWidth() / 2, bitmap.getHeight());
final Rect rightRect = new Rect(bitmap.getWidth() / 2, 0, bitmap.getWidth(), bitmap.getHeight());
// prepare canvas for transfer
paint.setAntiAlias(true);
paint.setColor(0xFFFFFFFF);
paint.setStyle(Paint.Style.FILL);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawRoundRect(new RectF(frame), cornerRadius, cornerRadius, paint);
if (!roundLeft){
canvas.drawRect(leftRect, paint);
}
if (!roundRight){
canvas.drawRect(rightRect, paint);
}
// draw bitmap
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, frame, frame, paint);
return roundedBitmap;
} | java | private static Bitmap createRoundedBitmap(Bitmap bitmap, float cornerRadius, boolean roundRight, boolean roundLeft) {
Bitmap roundedBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), ARGB_8888);
Canvas canvas = new Canvas(roundedBitmap);
final Paint paint = new Paint();
final Rect frame = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
// final Rect frameLeft = new Rect(0, 0, bitmap.getWidth() /2, bitmap.getHeight());
// final Rect frameRight = new Rect(bitmap.getWidth() /2, bitmap.getHeight(), bitmap.getWidth(), bitmap.getHeight());
final Rect leftRect = new Rect(0, 0, bitmap.getWidth() / 2, bitmap.getHeight());
final Rect rightRect = new Rect(bitmap.getWidth() / 2, 0, bitmap.getWidth(), bitmap.getHeight());
// prepare canvas for transfer
paint.setAntiAlias(true);
paint.setColor(0xFFFFFFFF);
paint.setStyle(Paint.Style.FILL);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawRoundRect(new RectF(frame), cornerRadius, cornerRadius, paint);
if (!roundLeft){
canvas.drawRect(leftRect, paint);
}
if (!roundRight){
canvas.drawRect(rightRect, paint);
}
// draw bitmap
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, frame, frame, paint);
return roundedBitmap;
} | [
"private",
"static",
"Bitmap",
"createRoundedBitmap",
"(",
"Bitmap",
"bitmap",
",",
"float",
"cornerRadius",
",",
"boolean",
"roundRight",
",",
"boolean",
"roundLeft",
")",
"{",
"Bitmap",
"roundedBitmap",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"bitmap",
".",
"... | Creates a rounded bitmap with transparent corners, from a square bitmap.
See <a href="http://stackoverflow.com/questions/4028270">StackOverflow</a>
@param bitmap the original bitmap
@param cornerRadius the radius of the corners
@param roundRight if you should round the corners on the right, note that if set to true and cornerRadius == 0 it will create a square
@param roundLeft if you should round the corners on the right, note that if set to true and cornerRadius == 0 it will create a square
@return a rounded bitmap | [
"Creates",
"a",
"rounded",
"bitmap",
"with",
"transparent",
"corners",
"from",
"a",
"square",
"bitmap",
".",
"See",
"<a",
"href",
"=",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"4028270",
">",
"StackOverflow<",
"/",
"a",
">"
] | train | https://github.com/Bearded-Hen/Android-Bootstrap/blob/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapProgressBar.java#L413-L446 |
haifengl/smile | core/src/main/java/smile/association/ARM.java | ARM.learn | private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int size, Node node, double confidence) {
long n = 0;
if (node.children == null) {
return n;
}
for (int i = 0; i < size; i++) {
if (node.children[i] != null) {
int[] newItemset = FPGrowth.insert(itemset, node.children[i].id);
// Generate ARs for current large itemset
n += learn(out, list, newItemset, node.children[i].support, confidence);
// Continue generation process
n += learn(out, list, newItemset, i, node.children[i], confidence);
}
}
return n;
} | java | private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int size, Node node, double confidence) {
long n = 0;
if (node.children == null) {
return n;
}
for (int i = 0; i < size; i++) {
if (node.children[i] != null) {
int[] newItemset = FPGrowth.insert(itemset, node.children[i].id);
// Generate ARs for current large itemset
n += learn(out, list, newItemset, node.children[i].support, confidence);
// Continue generation process
n += learn(out, list, newItemset, i, node.children[i], confidence);
}
}
return n;
} | [
"private",
"long",
"learn",
"(",
"PrintStream",
"out",
",",
"List",
"<",
"AssociationRule",
">",
"list",
",",
"int",
"[",
"]",
"itemset",
",",
"int",
"size",
",",
"Node",
"node",
",",
"double",
"confidence",
")",
"{",
"long",
"n",
"=",
"0",
";",
"if"... | Generates association rules from a T-tree.
@param itemset the label for a T-tree node as generated sofar.
@param size the size of the current array level in the T-tree.
@param node the current node in the T-tree.
@param confidence the confidence threshold for association rules. | [
"Generates",
"association",
"rules",
"from",
"a",
"T",
"-",
"tree",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L146-L163 |
OpenLiberty/open-liberty | dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/modelresolver/impl/AbstractPropertyResolver.java | AbstractPropertyResolver.substituteProperties | public B substituteProperties(final B b, final Properties submittedProps) {
return this.substituteProperties(b, submittedProps, null);
} | java | public B substituteProperties(final B b, final Properties submittedProps) {
return this.substituteProperties(b, submittedProps, null);
} | [
"public",
"B",
"substituteProperties",
"(",
"final",
"B",
"b",
",",
"final",
"Properties",
"submittedProps",
")",
"{",
"return",
"this",
".",
"substituteProperties",
"(",
"b",
",",
"submittedProps",
",",
"null",
")",
";",
"}"
] | /*
Convenience method that is the same as calling substituteProperties(job,
submittedProps, null) | [
"/",
"*",
"Convenience",
"method",
"that",
"is",
"the",
"same",
"as",
"calling",
"substituteProperties",
"(",
"job",
"submittedProps",
"null",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/modelresolver/impl/AbstractPropertyResolver.java#L50-L54 |
dropwizard/dropwizard | dropwizard-json-logging/src/main/java/io/dropwizard/logging/json/layout/MapBuilder.java | MapBuilder.addNumber | public MapBuilder addNumber(String fieldName, boolean include, @Nullable Number number) {
if (include && number != null) {
map.put(getFieldName(fieldName), number);
}
return this;
} | java | public MapBuilder addNumber(String fieldName, boolean include, @Nullable Number number) {
if (include && number != null) {
map.put(getFieldName(fieldName), number);
}
return this;
} | [
"public",
"MapBuilder",
"addNumber",
"(",
"String",
"fieldName",
",",
"boolean",
"include",
",",
"@",
"Nullable",
"Number",
"number",
")",
"{",
"if",
"(",
"include",
"&&",
"number",
"!=",
"null",
")",
"{",
"map",
".",
"put",
"(",
"getFieldName",
"(",
"fi... | Adds the number to the provided map under the provided field name if it's should be included. | [
"Adds",
"the",
"number",
"to",
"the",
"provided",
"map",
"under",
"the",
"provided",
"field",
"name",
"if",
"it",
"s",
"should",
"be",
"included",
"."
] | train | https://github.com/dropwizard/dropwizard/blob/7ee09a410476b9681e8072ab684788bb440877bd/dropwizard-json-logging/src/main/java/io/dropwizard/logging/json/layout/MapBuilder.java#L66-L71 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICULocaleService.java | ICULocaleService.registerObject | public Factory registerObject(Object obj, ULocale locale) {
return registerObject(obj, locale, LocaleKey.KIND_ANY, true);
} | java | public Factory registerObject(Object obj, ULocale locale) {
return registerObject(obj, locale, LocaleKey.KIND_ANY, true);
} | [
"public",
"Factory",
"registerObject",
"(",
"Object",
"obj",
",",
"ULocale",
"locale",
")",
"{",
"return",
"registerObject",
"(",
"obj",
",",
"locale",
",",
"LocaleKey",
".",
"KIND_ANY",
",",
"true",
")",
";",
"}"
] | Convenience override for callers using locales. This calls
registerObject(Object, ULocale, int kind, boolean visible)
passing KIND_ANY for the kind, and true for the visibility. | [
"Convenience",
"override",
"for",
"callers",
"using",
"locales",
".",
"This",
"calls",
"registerObject",
"(",
"Object",
"ULocale",
"int",
"kind",
"boolean",
"visible",
")",
"passing",
"KIND_ANY",
"for",
"the",
"kind",
"and",
"true",
"for",
"the",
"visibility",
... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICULocaleService.java#L93-L95 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java | SVGMorph.addStep | public void addStep(Diagram diagram) {
if (diagram.getFigureCount() != figures.size()) {
throw new RuntimeException("Mismatched diagrams, missing ids");
}
for (int i=0;i<diagram.getFigureCount();i++) {
Figure figure = diagram.getFigure(i);
String id = figure.getData().getMetaData();
for (int j=0;j<figures.size();j++) {
Figure existing = (Figure) figures.get(j);
if (existing.getData().getMetaData().equals(id)) {
MorphShape morph = (MorphShape) existing.getShape();
morph.addShape(figure.getShape());
break;
}
}
}
} | java | public void addStep(Diagram diagram) {
if (diagram.getFigureCount() != figures.size()) {
throw new RuntimeException("Mismatched diagrams, missing ids");
}
for (int i=0;i<diagram.getFigureCount();i++) {
Figure figure = diagram.getFigure(i);
String id = figure.getData().getMetaData();
for (int j=0;j<figures.size();j++) {
Figure existing = (Figure) figures.get(j);
if (existing.getData().getMetaData().equals(id)) {
MorphShape morph = (MorphShape) existing.getShape();
morph.addShape(figure.getShape());
break;
}
}
}
} | [
"public",
"void",
"addStep",
"(",
"Diagram",
"diagram",
")",
"{",
"if",
"(",
"diagram",
".",
"getFigureCount",
"(",
")",
"!=",
"figures",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Mismatched diagrams, missing ids\"",
")",
"... | Add a subsquent step to the morphing
@param diagram The diagram to add as the next step in the morph | [
"Add",
"a",
"subsquent",
"step",
"to",
"the",
"morphing"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java#L37-L54 |
paypal/SeLion | client/src/main/java/com/paypal/selion/platform/html/DatePicker.java | DatePicker.setDate | public void setDate(int year, int month, int day) {
Calendar to = Calendar.getInstance();
to.set(year, month, day);
setDate(to);
} | java | public void setDate(int year, int month, int day) {
Calendar to = Calendar.getInstance();
to.set(year, month, day);
setDate(to);
} | [
"public",
"void",
"setDate",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"day",
")",
"{",
"Calendar",
"to",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"to",
".",
"set",
"(",
"year",
",",
"month",
",",
"day",
")",
";",
"setDate",
... | This function set the date on the DatePicker using the year, month and day provided. <b>Note:</b> month is
0-based (January - 0)
@param year
The full year.
@param month
The month. (0-based, 0 for January)
@param day
The day of the month. | [
"This",
"function",
"set",
"the",
"date",
"on",
"the",
"DatePicker",
"using",
"the",
"year",
"month",
"and",
"day",
"provided",
".",
"<b",
">",
"Note",
":",
"<",
"/",
"b",
">",
"month",
"is",
"0",
"-",
"based",
"(",
"January",
"-",
"0",
")"
] | train | https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/client/src/main/java/com/paypal/selion/platform/html/DatePicker.java#L255-L259 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java | WordVectorSerializer.writeWordVectors | @Deprecated
public static void writeWordVectors(@NonNull Word2Vec vec, @NonNull BufferedWriter writer) throws IOException {
int words = 0;
String str = vec.getVocab().numWords() + " " + vec.getLayerSize() + " " + vec.getVocab().totalNumberOfDocs();
log.debug("Saving header: {}", str);
writer.write(str + "\n");
for (String word : vec.vocab().words()) {
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
INDArray wordVector = vec.getWordVectorMatrix(word);
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(" ");
}
}
sb.append("\n");
writer.write(sb.toString());
words++;
}
try {
writer.flush();
} catch (Exception e) {
}
log.info("Wrote " + words + " with size of " + vec.lookupTable().layerSize());
} | java | @Deprecated
public static void writeWordVectors(@NonNull Word2Vec vec, @NonNull BufferedWriter writer) throws IOException {
int words = 0;
String str = vec.getVocab().numWords() + " " + vec.getLayerSize() + " " + vec.getVocab().totalNumberOfDocs();
log.debug("Saving header: {}", str);
writer.write(str + "\n");
for (String word : vec.vocab().words()) {
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
INDArray wordVector = vec.getWordVectorMatrix(word);
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(" ");
}
}
sb.append("\n");
writer.write(sb.toString());
words++;
}
try {
writer.flush();
} catch (Exception e) {
}
log.info("Wrote " + words + " with size of " + vec.lookupTable().layerSize());
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"writeWordVectors",
"(",
"@",
"NonNull",
"Word2Vec",
"vec",
",",
"@",
"NonNull",
"BufferedWriter",
"writer",
")",
"throws",
"IOException",
"{",
"int",
"words",
"=",
"0",
";",
"String",
"str",
"=",
"vec",
".",
... | Writes the word vectors to the given BufferedWriter. Note that this assumes an in memory cache.
BufferedWriter can be writer to local file, or hdfs file, or any compatible to java target.
@param vec the word2vec to write
@param writer - BufferedWriter, where all data should be written to
the path to write
@throws IOException | [
"Writes",
"the",
"word",
"vectors",
"to",
"the",
"given",
"BufferedWriter",
".",
"Note",
"that",
"this",
"assumes",
"an",
"in",
"memory",
"cache",
".",
"BufferedWriter",
"can",
"be",
"writer",
"to",
"local",
"file",
"or",
"hdfs",
"file",
"or",
"any",
"comp... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java#L1527-L1559 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.putLastRefreshDate | public static void putLastRefreshDate(Bundle bundle, Date value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
putDate(bundle, LAST_REFRESH_DATE_KEY, value);
} | java | public static void putLastRefreshDate(Bundle bundle, Date value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
putDate(bundle, LAST_REFRESH_DATE_KEY, value);
} | [
"public",
"static",
"void",
"putLastRefreshDate",
"(",
"Bundle",
"bundle",
",",
"Date",
"value",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"putDat... | Puts the last refresh date into a Bundle.
@param bundle
A Bundle in which the last refresh date should be stored.
@param value
The Date representing the last refresh date, or null.
@throws NullPointerException if the passed in Bundle or date value are null | [
"Puts",
"the",
"last",
"refresh",
"date",
"into",
"a",
"Bundle",
"."
] | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L357-L361 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/parameters/Parameters.java | Parameters.getIntegerList | public List<Integer> getIntegerList(final String param) {
return getList(param, new StringToInteger(),
new AlwaysValid<Integer>(), "integer");
} | java | public List<Integer> getIntegerList(final String param) {
return getList(param, new StringToInteger(),
new AlwaysValid<Integer>(), "integer");
} | [
"public",
"List",
"<",
"Integer",
">",
"getIntegerList",
"(",
"final",
"String",
"param",
")",
"{",
"return",
"getList",
"(",
"param",
",",
"new",
"StringToInteger",
"(",
")",
",",
"new",
"AlwaysValid",
"<",
"Integer",
">",
"(",
")",
",",
"\"integer\"",
... | Gets a parameter whose value is a (possibly empty) list of integers. | [
"Gets",
"a",
"parameter",
"whose",
"value",
"is",
"a",
"(",
"possibly",
"empty",
")",
"list",
"of",
"integers",
"."
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/parameters/Parameters.java#L604-L607 |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/DateUtilities.java | DateUtilities.getDateForHour | private static long getDateForHour(long dt, TimeZone tz, int hour, int dayoffset)
{
Calendar c = getCalendar(tz);
c.setTimeInMillis(dt);
int dd = c.get(Calendar.DAY_OF_MONTH);
int mm = c.get(Calendar.MONTH);
int yy = c.get(Calendar.YEAR);
c.set(yy, mm, dd, hour, 0, 0);
c.set(Calendar.MILLISECOND, 0);
if(dayoffset != 0)
c.add(Calendar.DAY_OF_MONTH, dayoffset);
return c.getTimeInMillis();
} | java | private static long getDateForHour(long dt, TimeZone tz, int hour, int dayoffset)
{
Calendar c = getCalendar(tz);
c.setTimeInMillis(dt);
int dd = c.get(Calendar.DAY_OF_MONTH);
int mm = c.get(Calendar.MONTH);
int yy = c.get(Calendar.YEAR);
c.set(yy, mm, dd, hour, 0, 0);
c.set(Calendar.MILLISECOND, 0);
if(dayoffset != 0)
c.add(Calendar.DAY_OF_MONTH, dayoffset);
return c.getTimeInMillis();
} | [
"private",
"static",
"long",
"getDateForHour",
"(",
"long",
"dt",
",",
"TimeZone",
"tz",
",",
"int",
"hour",
",",
"int",
"dayoffset",
")",
"{",
"Calendar",
"c",
"=",
"getCalendar",
"(",
"tz",
")",
";",
"c",
".",
"setTimeInMillis",
"(",
"dt",
")",
";",
... | Returns the date for the given hour.
@param dt The date to be checked
@param tz The timezone associated with the date
@param hour The hour to be checked
@param dayoffset The day of the month to offset
@return The date for the given hour | [
"Returns",
"the",
"date",
"for",
"the",
"given",
"hour",
"."
] | train | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L175-L187 |
xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java | XsdAsmUtils.writeClassToFile | static void writeClassToFile(String className, ClassWriter classWriter, String apiName){
classWriter.visitEnd();
byte[] constructedClass = classWriter.toByteArray();
try (FileOutputStream os = new FileOutputStream(new File(getFinalPathPart(className, apiName)))){
os.write(constructedClass);
} catch (IOException e) {
throw new AsmException("Exception while writing generated classes to the .class files.", e);
}
} | java | static void writeClassToFile(String className, ClassWriter classWriter, String apiName){
classWriter.visitEnd();
byte[] constructedClass = classWriter.toByteArray();
try (FileOutputStream os = new FileOutputStream(new File(getFinalPathPart(className, apiName)))){
os.write(constructedClass);
} catch (IOException e) {
throw new AsmException("Exception while writing generated classes to the .class files.", e);
}
} | [
"static",
"void",
"writeClassToFile",
"(",
"String",
"className",
",",
"ClassWriter",
"classWriter",
",",
"String",
"apiName",
")",
"{",
"classWriter",
".",
"visitEnd",
"(",
")",
";",
"byte",
"[",
"]",
"constructedClass",
"=",
"classWriter",
".",
"toByteArray",
... | Writes a given class to a .class file.
@param className The class name, needed to name the file.
@param classWriter The classWriter, which contains all the class information. | [
"Writes",
"a",
"given",
"class",
"to",
"a",
".",
"class",
"file",
"."
] | train | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L223-L233 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/URLClassPath.java | URLClassPath.lookupClass | public JavaClass lookupClass(String className) throws ClassNotFoundException {
if (classesThatCantBeFound.contains(className)) {
throw new ClassNotFoundException("Error while looking for class " + className + ": class not found");
}
String resourceName = className.replace('.', '/') + ".class";
InputStream in = null;
boolean parsedClass = false;
try {
in = getInputStreamForResource(resourceName);
if (in == null) {
classesThatCantBeFound.add(className);
throw new ClassNotFoundException("Error while looking for class " + className + ": class not found");
}
ClassParser classParser = new ClassParser(in, resourceName);
JavaClass javaClass = classParser.parse();
parsedClass = true;
return javaClass;
} catch (IOException e) {
classesThatCantBeFound.add(className);
throw new ClassNotFoundException("IOException while looking for class " + className, e);
} finally {
if (in != null && !parsedClass) {
try {
in.close();
} catch (IOException ignore) {
// Ignore
}
}
}
} | java | public JavaClass lookupClass(String className) throws ClassNotFoundException {
if (classesThatCantBeFound.contains(className)) {
throw new ClassNotFoundException("Error while looking for class " + className + ": class not found");
}
String resourceName = className.replace('.', '/') + ".class";
InputStream in = null;
boolean parsedClass = false;
try {
in = getInputStreamForResource(resourceName);
if (in == null) {
classesThatCantBeFound.add(className);
throw new ClassNotFoundException("Error while looking for class " + className + ": class not found");
}
ClassParser classParser = new ClassParser(in, resourceName);
JavaClass javaClass = classParser.parse();
parsedClass = true;
return javaClass;
} catch (IOException e) {
classesThatCantBeFound.add(className);
throw new ClassNotFoundException("IOException while looking for class " + className, e);
} finally {
if (in != null && !parsedClass) {
try {
in.close();
} catch (IOException ignore) {
// Ignore
}
}
}
} | [
"public",
"JavaClass",
"lookupClass",
"(",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"classesThatCantBeFound",
".",
"contains",
"(",
"className",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"\"Error while looking... | Look up a class from the classpath.
@param className
name of class to look up
@return the JavaClass object for the class
@throws ClassNotFoundException
if the class couldn't be found | [
"Look",
"up",
"a",
"class",
"from",
"the",
"classpath",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/URLClassPath.java#L412-L445 |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java | DomXmlEnsure.ensureChildElement | public static void ensureChildElement(DomXmlElement parentElement, DomXmlElement childElement) {
Node parent = childElement.unwrap().getParentNode();
if (parent == null || !parentElement.unwrap().isEqualNode(parent)) {
throw LOG.elementIsNotChildOfThisElement(childElement, parentElement);
}
} | java | public static void ensureChildElement(DomXmlElement parentElement, DomXmlElement childElement) {
Node parent = childElement.unwrap().getParentNode();
if (parent == null || !parentElement.unwrap().isEqualNode(parent)) {
throw LOG.elementIsNotChildOfThisElement(childElement, parentElement);
}
} | [
"public",
"static",
"void",
"ensureChildElement",
"(",
"DomXmlElement",
"parentElement",
",",
"DomXmlElement",
"childElement",
")",
"{",
"Node",
"parent",
"=",
"childElement",
".",
"unwrap",
"(",
")",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"parent",
"... | Ensures that the element is child element of the parent element.
@param parentElement the parent xml dom element
@param childElement the child element
@throws SpinXmlElementException if the element is not child of the parent element | [
"Ensures",
"that",
"the",
"element",
"is",
"child",
"element",
"of",
"the",
"parent",
"element",
"."
] | train | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java#L46-L51 |
groundupworks/wings | wings/src/main/java/com/groundupworks/wings/core/WingsService.java | WingsService.startWakefulService | public static void startWakefulService(Context context) {
acquireWakeLock(context);
context.startService(new Intent(context, WingsService.class));
} | java | public static void startWakefulService(Context context) {
acquireWakeLock(context);
context.startService(new Intent(context, WingsService.class));
} | [
"public",
"static",
"void",
"startWakefulService",
"(",
"Context",
"context",
")",
"{",
"acquireWakeLock",
"(",
"context",
")",
";",
"context",
".",
"startService",
"(",
"new",
"Intent",
"(",
"context",
",",
"WingsService",
".",
"class",
")",
")",
";",
"}"
] | Starts this {@link IntentService}, ensuring the device does not sleep before the service is started or during
{@link #onHandleIntent(Intent)}.
@param context the {@link Context}. | [
"Starts",
"this",
"{",
"@link",
"IntentService",
"}",
"ensuring",
"the",
"device",
"does",
"not",
"sleep",
"before",
"the",
"service",
"is",
"started",
"or",
"during",
"{",
"@link",
"#onHandleIntent",
"(",
"Intent",
")",
"}",
"."
] | train | https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/core/WingsService.java#L259-L262 |
joniles/mpxj | src/main/java/net/sf/mpxj/Task.java | Task.setEnterpriseNumber | public void setEnterpriseNumber(int index, Number value)
{
set(selectField(TaskFieldLists.ENTERPRISE_NUMBER, index), value);
} | java | public void setEnterpriseNumber(int index, Number value)
{
set(selectField(TaskFieldLists.ENTERPRISE_NUMBER, index), value);
} | [
"public",
"void",
"setEnterpriseNumber",
"(",
"int",
"index",
",",
"Number",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"ENTERPRISE_NUMBER",
",",
"index",
")",
",",
"value",
")",
";",
"}"
] | Set an enterprise field value.
@param index field index
@param value field value | [
"Set",
"an",
"enterprise",
"field",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3925-L3928 |
lucmoreau/ProvToolbox | prov-model/src/main/java/org/openprovenance/prov/model/ProvFactory.java | ProvFactory.newWasEndedBy | public WasEndedBy newWasEndedBy(QualifiedName id, QualifiedName activity, QualifiedName trigger, QualifiedName ender, XMLGregorianCalendar time, Collection<Attribute> attributes) {
WasEndedBy res=newWasEndedBy(id,activity,trigger);
res.setTime(time);
res.setEnder(ender);
setAttributes(res, attributes);
return res;
} | java | public WasEndedBy newWasEndedBy(QualifiedName id, QualifiedName activity, QualifiedName trigger, QualifiedName ender, XMLGregorianCalendar time, Collection<Attribute> attributes) {
WasEndedBy res=newWasEndedBy(id,activity,trigger);
res.setTime(time);
res.setEnder(ender);
setAttributes(res, attributes);
return res;
} | [
"public",
"WasEndedBy",
"newWasEndedBy",
"(",
"QualifiedName",
"id",
",",
"QualifiedName",
"activity",
",",
"QualifiedName",
"trigger",
",",
"QualifiedName",
"ender",
",",
"XMLGregorianCalendar",
"time",
",",
"Collection",
"<",
"Attribute",
">",
"attributes",
")",
"... | /* (non-Javadoc)
@see org.openprovenance.prov.model.ModelConstructor#newWasEndedBy(org.openprovenance.model.QualifiedName, org.openprovenance.model.QualifiedName, org.openprovenance.model.QualifiedName, org.openprovenance.model.QualifiedName, javax.xml.datatype.XMLGregorianCalendar, java.util.Collection) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | train | https://github.com/lucmoreau/ProvToolbox/blob/f865952868ffb69432937b08728c86bebbe4678a/prov-model/src/main/java/org/openprovenance/prov/model/ProvFactory.java#L1270-L1276 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/HFClient.java | HFClient.loadChannelFromConfig | public Channel loadChannelFromConfig(String channelName, NetworkConfig networkConfig,
NetworkConfig.NetworkConfigAddPeerHandler networkConfigAddPeerHandler,
NetworkConfig.NetworkConfigAddOrdererHandler networkConfigAddOrdererHandler) throws InvalidArgumentException, NetworkConfigurationException {
clientCheck();
// Sanity checks
if (channelName == null || channelName.isEmpty()) {
throw new InvalidArgumentException("channelName must be specified");
}
if (networkConfig == null) {
throw new InvalidArgumentException("networkConfig must be specified");
}
if (null == networkConfigAddPeerHandler) {
throw new InvalidArgumentException("networkConfigAddPeerHandler is null.");
}
if (null == networkConfigAddOrdererHandler) {
throw new InvalidArgumentException("networkConfigAddOrdererHandler is null.");
}
if (channels.containsKey(channelName)) {
throw new InvalidArgumentException(format("Channel with name %s already exists", channelName));
}
return networkConfig.loadChannel(this, channelName, networkConfigAddPeerHandler, networkConfigAddOrdererHandler);
} | java | public Channel loadChannelFromConfig(String channelName, NetworkConfig networkConfig,
NetworkConfig.NetworkConfigAddPeerHandler networkConfigAddPeerHandler,
NetworkConfig.NetworkConfigAddOrdererHandler networkConfigAddOrdererHandler) throws InvalidArgumentException, NetworkConfigurationException {
clientCheck();
// Sanity checks
if (channelName == null || channelName.isEmpty()) {
throw new InvalidArgumentException("channelName must be specified");
}
if (networkConfig == null) {
throw new InvalidArgumentException("networkConfig must be specified");
}
if (null == networkConfigAddPeerHandler) {
throw new InvalidArgumentException("networkConfigAddPeerHandler is null.");
}
if (null == networkConfigAddOrdererHandler) {
throw new InvalidArgumentException("networkConfigAddOrdererHandler is null.");
}
if (channels.containsKey(channelName)) {
throw new InvalidArgumentException(format("Channel with name %s already exists", channelName));
}
return networkConfig.loadChannel(this, channelName, networkConfigAddPeerHandler, networkConfigAddOrdererHandler);
} | [
"public",
"Channel",
"loadChannelFromConfig",
"(",
"String",
"channelName",
",",
"NetworkConfig",
"networkConfig",
",",
"NetworkConfig",
".",
"NetworkConfigAddPeerHandler",
"networkConfigAddPeerHandler",
",",
"NetworkConfig",
".",
"NetworkConfigAddOrdererHandler",
"networkConfigA... | Configures a channel based on information loaded from a Network Config file.
Note that it is up to the caller to initialize the returned channel.
@param channelName The name of the channel to be configured
@param networkConfig The network configuration to use to configure the channel
@param networkConfigAddPeerHandler A handler that will create and add peers to the channel.
@param networkConfigAddOrdererHandler A handler that will create orderers and add orderers to the channel.
@return The configured channel, or null if the channel is not defined in the configuration
@throws InvalidArgumentException | [
"Configures",
"a",
"channel",
"based",
"on",
"information",
"loaded",
"from",
"a",
"Network",
"Config",
"file",
".",
"Note",
"that",
"it",
"is",
"up",
"to",
"the",
"caller",
"to",
"initialize",
"the",
"returned",
"channel",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/HFClient.java#L165-L192 |
aequologica/geppaequo | geppaequo-core/src/main/java/net/aequologica/neo/geppaequo/auth/MethodUtils.java | MethodUtils.getObjectTransformationCost | private static float getObjectTransformationCost(Class<?> srcClass, Class<?> destClass) {
float cost = 0.0f;
while (srcClass != null && !destClass.equals(srcClass)) {
if (destClass.isPrimitive()) {
Class<?> destClassWrapperClazz = getPrimitiveWrapper(destClass);
if (destClassWrapperClazz != null && destClassWrapperClazz.equals(srcClass)) {
cost += 0.25f;
break;
}
}
if (destClass.isInterface() && isAssignmentCompatible(destClass,srcClass)) {
// slight penalty for interface match.
// we still want an exact match to override an interface match, but
// an interface match should override anything where we have to get a
// superclass.
cost += 0.25f;
break;
}
cost++;
srcClass = srcClass.getSuperclass();
}
/*
* If the destination class is null, we've travelled all the way up to
* an Object match. We'll penalize this by adding 1.5 to the cost.
*/
if (srcClass == null) {
cost += 1.5f;
}
return cost;
} | java | private static float getObjectTransformationCost(Class<?> srcClass, Class<?> destClass) {
float cost = 0.0f;
while (srcClass != null && !destClass.equals(srcClass)) {
if (destClass.isPrimitive()) {
Class<?> destClassWrapperClazz = getPrimitiveWrapper(destClass);
if (destClassWrapperClazz != null && destClassWrapperClazz.equals(srcClass)) {
cost += 0.25f;
break;
}
}
if (destClass.isInterface() && isAssignmentCompatible(destClass,srcClass)) {
// slight penalty for interface match.
// we still want an exact match to override an interface match, but
// an interface match should override anything where we have to get a
// superclass.
cost += 0.25f;
break;
}
cost++;
srcClass = srcClass.getSuperclass();
}
/*
* If the destination class is null, we've travelled all the way up to
* an Object match. We'll penalize this by adding 1.5 to the cost.
*/
if (srcClass == null) {
cost += 1.5f;
}
return cost;
} | [
"private",
"static",
"float",
"getObjectTransformationCost",
"(",
"Class",
"<",
"?",
">",
"srcClass",
",",
"Class",
"<",
"?",
">",
"destClass",
")",
"{",
"float",
"cost",
"=",
"0.0f",
";",
"while",
"(",
"srcClass",
"!=",
"null",
"&&",
"!",
"destClass",
"... | Gets the number of steps required needed to turn the source class into the
destination class. This represents the number of steps in the object hierarchy
graph.
@param srcClass The source class
@param destClass The destination class
@return The cost of transforming an object | [
"Gets",
"the",
"number",
"of",
"steps",
"required",
"needed",
"to",
"turn",
"the",
"source",
"class",
"into",
"the",
"destination",
"class",
".",
"This",
"represents",
"the",
"number",
"of",
"steps",
"in",
"the",
"object",
"hierarchy",
"graph",
"."
] | train | https://github.com/aequologica/geppaequo/blob/b72e5f6356535fd045a931f8c544d4a8ea6e35a2/geppaequo-core/src/main/java/net/aequologica/neo/geppaequo/auth/MethodUtils.java#L1124-L1155 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.writeGroup | public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsException {
CmsGroup oldGroup = readGroup(dbc, group.getName());
m_monitor.uncacheGroup(oldGroup);
getUserDriver(dbc).writeGroup(dbc, group);
m_monitor.cacheGroup(group);
if (!dbc.getProjectId().isNullUUID()) {
// group modified event is not needed
return;
}
// fire group modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_GROUP_ID, group.getId().toString());
eventData.put(I_CmsEventListener.KEY_GROUP_NAME, oldGroup.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_GROUP_MODIFIED_ACTION_WRITE);
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_GROUP_MODIFIED, eventData));
} | java | public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsException {
CmsGroup oldGroup = readGroup(dbc, group.getName());
m_monitor.uncacheGroup(oldGroup);
getUserDriver(dbc).writeGroup(dbc, group);
m_monitor.cacheGroup(group);
if (!dbc.getProjectId().isNullUUID()) {
// group modified event is not needed
return;
}
// fire group modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_GROUP_ID, group.getId().toString());
eventData.put(I_CmsEventListener.KEY_GROUP_NAME, oldGroup.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_GROUP_MODIFIED_ACTION_WRITE);
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_GROUP_MODIFIED, eventData));
} | [
"public",
"void",
"writeGroup",
"(",
"CmsDbContext",
"dbc",
",",
"CmsGroup",
"group",
")",
"throws",
"CmsException",
"{",
"CmsGroup",
"oldGroup",
"=",
"readGroup",
"(",
"dbc",
",",
"group",
".",
"getName",
"(",
")",
")",
";",
"m_monitor",
".",
"uncacheGroup"... | Writes an already existing group.<p>
The group id has to be a valid OpenCms group id.<br>
The group with the given id will be completely overridden
by the given data.<p>
@param dbc the current database context
@param group the group that should be written
@throws CmsException if operation was not successful | [
"Writes",
"an",
"already",
"existing",
"group",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L9842-L9859 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.setRow | public Matrix4d setRow(int row, Vector4dc src) throws IndexOutOfBoundsException {
switch (row) {
case 0:
this.m00 = src.x();
this.m10 = src.y();
this.m20 = src.z();
this.m30 = src.w();
break;
case 1:
this.m01 = src.x();
this.m11 = src.y();
this.m21 = src.z();
this.m31 = src.w();
break;
case 2:
this.m02 = src.x();
this.m12 = src.y();
this.m22 = src.z();
this.m32 = src.w();
break;
case 3:
this.m03 = src.x();
this.m13 = src.y();
this.m23 = src.z();
this.m33 = src.w();
break;
default:
throw new IndexOutOfBoundsException();
}
properties = 0;
return this;
} | java | public Matrix4d setRow(int row, Vector4dc src) throws IndexOutOfBoundsException {
switch (row) {
case 0:
this.m00 = src.x();
this.m10 = src.y();
this.m20 = src.z();
this.m30 = src.w();
break;
case 1:
this.m01 = src.x();
this.m11 = src.y();
this.m21 = src.z();
this.m31 = src.w();
break;
case 2:
this.m02 = src.x();
this.m12 = src.y();
this.m22 = src.z();
this.m32 = src.w();
break;
case 3:
this.m03 = src.x();
this.m13 = src.y();
this.m23 = src.z();
this.m33 = src.w();
break;
default:
throw new IndexOutOfBoundsException();
}
properties = 0;
return this;
} | [
"public",
"Matrix4d",
"setRow",
"(",
"int",
"row",
",",
"Vector4dc",
"src",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"switch",
"(",
"row",
")",
"{",
"case",
"0",
":",
"this",
".",
"m00",
"=",
"src",
".",
"x",
"(",
")",
";",
"this",
".",
"m10"... | Set the row at the given <code>row</code> index, starting with <code>0</code>.
@param row
the row index in <code>[0..3]</code>
@param src
the row components to set
@return this
@throws IndexOutOfBoundsException if <code>row</code> is not in <code>[0..3]</code> | [
"Set",
"the",
"row",
"at",
"the",
"given",
"<code",
">",
"row<",
"/",
"code",
">",
"index",
"starting",
"with",
"<code",
">",
"0<",
"/",
"code",
">",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L8637-L8668 |
haifengl/smile | core/src/main/java/smile/association/ARM.java | ARM.learn | public long learn(double confidence, PrintStream out) {
long n = 0;
ttree = fim.buildTotalSupportTree();
for (int i = 0; i < ttree.root.children.length; i++) {
if (ttree.root.children[i] != null) {
int[] itemset = {ttree.root.children[i].id};
n += learn(out, null, itemset, i, ttree.root.children[i], confidence);
}
}
return n;
} | java | public long learn(double confidence, PrintStream out) {
long n = 0;
ttree = fim.buildTotalSupportTree();
for (int i = 0; i < ttree.root.children.length; i++) {
if (ttree.root.children[i] != null) {
int[] itemset = {ttree.root.children[i].id};
n += learn(out, null, itemset, i, ttree.root.children[i], confidence);
}
}
return n;
} | [
"public",
"long",
"learn",
"(",
"double",
"confidence",
",",
"PrintStream",
"out",
")",
"{",
"long",
"n",
"=",
"0",
";",
"ttree",
"=",
"fim",
".",
"buildTotalSupportTree",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ttree",
"."... | Mines the association rules. The discovered rules will be printed out
to the provided stream.
@param confidence the confidence threshold for association rules.
@return the number of discovered association rules. | [
"Mines",
"the",
"association",
"rules",
".",
"The",
"discovered",
"rules",
"will",
"be",
"printed",
"out",
"to",
"the",
"provided",
"stream",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L111-L121 |
roboconf/roboconf-platform | miscellaneous/roboconf-maven-plugin/src/main/java/net/roboconf/maven/MavenPluginUtils.java | MavenPluginUtils.formatErrors | public static StringBuilder formatErrors( Collection<? extends RoboconfError> errors, Log log ) {
StringBuilder result = new StringBuilder();
for( Map.Entry<RoboconfError,String> entry : RoboconfErrorHelpers.formatErrors( errors, null, true ).entrySet()) {
if( entry.getKey().getErrorCode().getLevel() == ErrorLevel.WARNING )
log.warn( entry.getValue());
else
log.error( entry.getValue());
result.append( entry.getValue());
result.append( "\n" );
}
return result;
} | java | public static StringBuilder formatErrors( Collection<? extends RoboconfError> errors, Log log ) {
StringBuilder result = new StringBuilder();
for( Map.Entry<RoboconfError,String> entry : RoboconfErrorHelpers.formatErrors( errors, null, true ).entrySet()) {
if( entry.getKey().getErrorCode().getLevel() == ErrorLevel.WARNING )
log.warn( entry.getValue());
else
log.error( entry.getValue());
result.append( entry.getValue());
result.append( "\n" );
}
return result;
} | [
"public",
"static",
"StringBuilder",
"formatErrors",
"(",
"Collection",
"<",
"?",
"extends",
"RoboconfError",
">",
"errors",
",",
"Log",
"log",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
... | Formats a Roboconf errors and outputs it in the logs.
@param error an error
@param log the Maven logger
@return a string builder with the output | [
"Formats",
"a",
"Roboconf",
"errors",
"and",
"outputs",
"it",
"in",
"the",
"logs",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-maven-plugin/src/main/java/net/roboconf/maven/MavenPluginUtils.java#L56-L70 |
Alluxio/alluxio | underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoClient.java | KodoClient.getObject | public InputStream getObject(String key, long startPos, long endPos, long contentLength)
throws IOException {
String baseUrl = String.format("http://%s/%s", mDownloadHost, key);
String privateUrl = mAuth.privateDownloadUrl(baseUrl);
URL url = new URL(privateUrl);
String objectUrl = String.format("http://%s/%s?%s", mEndPoint, key, url.getQuery());
Request request = new Request.Builder().url(objectUrl)
.addHeader("Range",
"bytes=" + String.valueOf(startPos) + "-"
+ String.valueOf(endPos < contentLength ? endPos - 1 : contentLength - 1))
.addHeader("Host", mDownloadHost).get().build();
Response response = mOkHttpClient.newCall(request).execute();
if (response.code() == HttpStatus.SC_NOT_FOUND) {
throw new NotFoundException("Qiniu kodo: " + response.message());
}
if (response.code() != 200 && response.code() != 206) {
throw new IOException(String.format("Qiniu kodo:get object failed errcode:%d,errmsg:%s",
response.code(), response.message()));
}
return response.body().byteStream();
} | java | public InputStream getObject(String key, long startPos, long endPos, long contentLength)
throws IOException {
String baseUrl = String.format("http://%s/%s", mDownloadHost, key);
String privateUrl = mAuth.privateDownloadUrl(baseUrl);
URL url = new URL(privateUrl);
String objectUrl = String.format("http://%s/%s?%s", mEndPoint, key, url.getQuery());
Request request = new Request.Builder().url(objectUrl)
.addHeader("Range",
"bytes=" + String.valueOf(startPos) + "-"
+ String.valueOf(endPos < contentLength ? endPos - 1 : contentLength - 1))
.addHeader("Host", mDownloadHost).get().build();
Response response = mOkHttpClient.newCall(request).execute();
if (response.code() == HttpStatus.SC_NOT_FOUND) {
throw new NotFoundException("Qiniu kodo: " + response.message());
}
if (response.code() != 200 && response.code() != 206) {
throw new IOException(String.format("Qiniu kodo:get object failed errcode:%d,errmsg:%s",
response.code(), response.message()));
}
return response.body().byteStream();
} | [
"public",
"InputStream",
"getObject",
"(",
"String",
"key",
",",
"long",
"startPos",
",",
"long",
"endPos",
",",
"long",
"contentLength",
")",
"throws",
"IOException",
"{",
"String",
"baseUrl",
"=",
"String",
".",
"format",
"(",
"\"http://%s/%s\"",
",",
"mDown... | Gets object from Qiniu kodo. All requests are authenticated by default,default expires 3600s We
use okhttp as our HTTP client and support two main parameters in the external adjustment, MAX
request and timeout time.
@param key object key
@param startPos start index for object
@param endPos end index for object
@return inputstream
@param contentLength object file size
@throws IOException | [
"Gets",
"object",
"from",
"Qiniu",
"kodo",
".",
"All",
"requests",
"are",
"authenticated",
"by",
"default,default",
"expires",
"3600s",
"We",
"use",
"okhttp",
"as",
"our",
"HTTP",
"client",
"and",
"support",
"two",
"main",
"parameters",
"in",
"the",
"external"... | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoClient.java#L106-L126 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/clustering/criterion/BaseFunction.java | BaseFunction.subtractedMagnitude | protected static double subtractedMagnitude(DoubleVector c, DoubleVector v) {
return Math.sqrt(subtractedMagnitudeSqrd(c, v));
} | java | protected static double subtractedMagnitude(DoubleVector c, DoubleVector v) {
return Math.sqrt(subtractedMagnitudeSqrd(c, v));
} | [
"protected",
"static",
"double",
"subtractedMagnitude",
"(",
"DoubleVector",
"c",
",",
"DoubleVector",
"v",
")",
"{",
"return",
"Math",
".",
"sqrt",
"(",
"subtractedMagnitudeSqrd",
"(",
"c",
",",
"v",
")",
")",
";",
"}"
] | Returns the magnitude of {@code c} as if {@code v} was added to the the
vector. We do this because it would be more costly, garbage collection
wise, to create a new vector for each alternate cluster and * vector. | [
"Returns",
"the",
"magnitude",
"of",
"{"
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/clustering/criterion/BaseFunction.java#L414-L416 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java | ArrayUtil.resizeArrayIfDifferent | public static Object resizeArrayIfDifferent(Object source, int newsize) {
int oldsize = Array.getLength(source);
if (oldsize == newsize) {
return source;
}
Object newarray =
Array.newInstance(source.getClass().getComponentType(), newsize);
if (oldsize < newsize) {
newsize = oldsize;
}
System.arraycopy(source, 0, newarray, 0, newsize);
return newarray;
} | java | public static Object resizeArrayIfDifferent(Object source, int newsize) {
int oldsize = Array.getLength(source);
if (oldsize == newsize) {
return source;
}
Object newarray =
Array.newInstance(source.getClass().getComponentType(), newsize);
if (oldsize < newsize) {
newsize = oldsize;
}
System.arraycopy(source, 0, newarray, 0, newsize);
return newarray;
} | [
"public",
"static",
"Object",
"resizeArrayIfDifferent",
"(",
"Object",
"source",
",",
"int",
"newsize",
")",
"{",
"int",
"oldsize",
"=",
"Array",
".",
"getLength",
"(",
"source",
")",
";",
"if",
"(",
"oldsize",
"==",
"newsize",
")",
"{",
"return",
"source"... | Returns the given array if newsize is the same as existing.
Returns a new array of given size, containing as many elements of
the original array as it can hold. | [
"Returns",
"the",
"given",
"array",
"if",
"newsize",
"is",
"the",
"same",
"as",
"existing",
".",
"Returns",
"a",
"new",
"array",
"of",
"given",
"size",
"containing",
"as",
"many",
"elements",
"of",
"the",
"original",
"array",
"as",
"it",
"can",
"hold",
"... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L869-L887 |
derari/cthul | strings/src/main/java/org/cthul/strings/format/pattern/PatternAlignmentBase.java | PatternAlignmentBase.toRegex | protected int toRegex(PatternAPI regex, Locale locale, String flags, char padding, int width, int precision, String formatString, int position) {
throw new UnsupportedOperationException("Explicit width matching not supported.");
} | java | protected int toRegex(PatternAPI regex, Locale locale, String flags, char padding, int width, int precision, String formatString, int position) {
throw new UnsupportedOperationException("Explicit width matching not supported.");
} | [
"protected",
"int",
"toRegex",
"(",
"PatternAPI",
"regex",
",",
"Locale",
"locale",
",",
"String",
"flags",
",",
"char",
"padding",
",",
"int",
"width",
",",
"int",
"precision",
",",
"String",
"formatString",
",",
"int",
"position",
")",
"{",
"throw",
"new... | Appends a pattern to {@code pattern} that will be parsed into a value.
If {@code with} is non-negative, it specifies the exact number of
characters the pattern should consume.
@param regex
@param locale
@param flags
@param padding
@param width
@param precision
@param formatString
@param position
@return | [
"Appends",
"a",
"pattern",
"to",
"{"
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/format/pattern/PatternAlignmentBase.java#L140-L142 |
buschmais/extended-objects | impl/src/main/java/com/buschmais/xo/impl/AbstractInstanceManager.java | AbstractInstanceManager.readInstance | @Override
public <T> T readInstance(DatastoreType datastoreType) {
return getInstance(datastoreType, TransactionalCache.Mode.READ);
} | java | @Override
public <T> T readInstance(DatastoreType datastoreType) {
return getInstance(datastoreType, TransactionalCache.Mode.READ);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"readInstance",
"(",
"DatastoreType",
"datastoreType",
")",
"{",
"return",
"getInstance",
"(",
"datastoreType",
",",
"TransactionalCache",
".",
"Mode",
".",
"READ",
")",
";",
"}"
] | Return the proxy instance which corresponds to the given datastore type for
reading.
@param datastoreType
The datastore type.
@param <T>
The instance type.
@return The instance. | [
"Return",
"the",
"proxy",
"instance",
"which",
"corresponds",
"to",
"the",
"given",
"datastore",
"type",
"for",
"reading",
"."
] | train | https://github.com/buschmais/extended-objects/blob/186431e81f3d8d26c511cfe1143dee59b03c2e7a/impl/src/main/java/com/buschmais/xo/impl/AbstractInstanceManager.java#L54-L57 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/FileUpdateMonitor.java | FileUpdateMonitor.scanForUpdates | @Override
public void scanForUpdates(Collection<File> created, Collection<File> modified, Collection<File> deleted) {
if (monitoredFile.isFile()) {
if (performScan(monitoredFile)) {
if (exists) { // If file previously existed, it was modified
addToList(modified, monitoredFile);
} else {
exists = true;
addToList(created, monitoredFile);
}
}
} else {
if (exists) {
addToList(deleted, monitoredFile);
exists = false;
monitoredTime = 0;
monitoredSize = 0;
}
}
} | java | @Override
public void scanForUpdates(Collection<File> created, Collection<File> modified, Collection<File> deleted) {
if (monitoredFile.isFile()) {
if (performScan(monitoredFile)) {
if (exists) { // If file previously existed, it was modified
addToList(modified, monitoredFile);
} else {
exists = true;
addToList(created, monitoredFile);
}
}
} else {
if (exists) {
addToList(deleted, monitoredFile);
exists = false;
monitoredTime = 0;
monitoredSize = 0;
}
}
} | [
"@",
"Override",
"public",
"void",
"scanForUpdates",
"(",
"Collection",
"<",
"File",
">",
"created",
",",
"Collection",
"<",
"File",
">",
"modified",
",",
"Collection",
"<",
"File",
">",
"deleted",
")",
"{",
"if",
"(",
"monitoredFile",
".",
"isFile",
"(",
... | {@inheritDoc}
<p>
FileUpdateMonitor:
If the file being monitored is deleted, the File will be added to the
deleted list, and a {@link ResourceUpdateMonitor} will be returned.
If the file being monitored is changed, the File will be added to the modified
list. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/FileUpdateMonitor.java#L61-L80 |
demidenko05/beigesoft-bcommon | src/main/java/org/beigesoft/service/SrvI18n.java | SrvI18n.getMsg | @Override
public final String getMsg(final String pKey, final String pLang) {
try {
ResourceBundle mb = messagesMap.get(pLang);
if (mb != null) {
return mb.getString(pKey);
} else {
return getMsg(pKey);
}
} catch (Exception e) {
return "[" + pKey + "]-" + pLang;
}
} | java | @Override
public final String getMsg(final String pKey, final String pLang) {
try {
ResourceBundle mb = messagesMap.get(pLang);
if (mb != null) {
return mb.getString(pKey);
} else {
return getMsg(pKey);
}
} catch (Exception e) {
return "[" + pKey + "]-" + pLang;
}
} | [
"@",
"Override",
"public",
"final",
"String",
"getMsg",
"(",
"final",
"String",
"pKey",
",",
"final",
"String",
"pLang",
")",
"{",
"try",
"{",
"ResourceBundle",
"mb",
"=",
"messagesMap",
".",
"get",
"(",
"pLang",
")",
";",
"if",
"(",
"mb",
"!=",
"null"... | <p>Evaluate message by given key for given language.</p>
@param pKey key of message
@param pLang e.g. "en", "ru", etc. | [
"<p",
">",
"Evaluate",
"message",
"by",
"given",
"key",
"for",
"given",
"language",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/demidenko05/beigesoft-bcommon/blob/bb446822b4fc9b5a6a8cd3cc98d0b3d83d718daf/src/main/java/org/beigesoft/service/SrvI18n.java#L145-L157 |
ops4j/org.ops4j.pax.web | pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/Activator.java | Activator.trackServletContextHelper | private void trackServletContextHelper(final BundleContext bundleContext, ExtendedHttpServiceRuntime httpServiceRuntime) {
final ServiceTracker<ServletContextHelper, ServletContextHelperElement> servletContextHelperTracker =
ServletContextHelperTracker.createTracker(extenderContext, bundleContext, httpServiceRuntime);
servletContextHelperTracker.open();
trackers.add(0, servletContextHelperTracker);
} | java | private void trackServletContextHelper(final BundleContext bundleContext, ExtendedHttpServiceRuntime httpServiceRuntime) {
final ServiceTracker<ServletContextHelper, ServletContextHelperElement> servletContextHelperTracker =
ServletContextHelperTracker.createTracker(extenderContext, bundleContext, httpServiceRuntime);
servletContextHelperTracker.open();
trackers.add(0, servletContextHelperTracker);
} | [
"private",
"void",
"trackServletContextHelper",
"(",
"final",
"BundleContext",
"bundleContext",
",",
"ExtendedHttpServiceRuntime",
"httpServiceRuntime",
")",
"{",
"final",
"ServiceTracker",
"<",
"ServletContextHelper",
",",
"ServletContextHelperElement",
">",
"servletContextHel... | Track servlets.
@param bundleContext the BundleContext associated with this bundle
@param httpServiceRuntime | [
"Track",
"servlets",
"."
] | 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/Activator.java#L163-L170 |
fabiomaffioletti/jsondoc | jsondoc-springmvc/src/main/java/org/jsondoc/springmvc/scanner/builder/SpringPathVariableBuilder.java | SpringPathVariableBuilder.mergeApiPathParamDoc | private static void mergeApiPathParamDoc(ApiPathParam apiPathParam, ApiParamDoc apiParamDoc) {
if (apiPathParam != null) {
if (apiParamDoc.getName().trim().isEmpty()) {
apiParamDoc.setName(apiPathParam.name());
}
apiParamDoc.setDescription(apiPathParam.description());
apiParamDoc.setAllowedvalues(apiPathParam.allowedvalues());
apiParamDoc.setFormat(apiPathParam.format());
}
} | java | private static void mergeApiPathParamDoc(ApiPathParam apiPathParam, ApiParamDoc apiParamDoc) {
if (apiPathParam != null) {
if (apiParamDoc.getName().trim().isEmpty()) {
apiParamDoc.setName(apiPathParam.name());
}
apiParamDoc.setDescription(apiPathParam.description());
apiParamDoc.setAllowedvalues(apiPathParam.allowedvalues());
apiParamDoc.setFormat(apiPathParam.format());
}
} | [
"private",
"static",
"void",
"mergeApiPathParamDoc",
"(",
"ApiPathParam",
"apiPathParam",
",",
"ApiParamDoc",
"apiParamDoc",
")",
"{",
"if",
"(",
"apiPathParam",
"!=",
"null",
")",
"{",
"if",
"(",
"apiParamDoc",
".",
"getName",
"(",
")",
".",
"trim",
"(",
")... | Available properties that can be overridden: name, description,
allowedvalues, format. Name is overridden only if it's empty in the
apiParamDoc argument. Description, format and allowedvalues are copied in
any case.
@param apiPathParam
@param apiParamDoc | [
"Available",
"properties",
"that",
"can",
"be",
"overridden",
":",
"name",
"description",
"allowedvalues",
"format",
".",
"Name",
"is",
"overridden",
"only",
"if",
"it",
"s",
"empty",
"in",
"the",
"apiParamDoc",
"argument",
".",
"Description",
"format",
"and",
... | train | https://github.com/fabiomaffioletti/jsondoc/blob/26bf413c236e7c3b66f534c2451b157783c1f45e/jsondoc-springmvc/src/main/java/org/jsondoc/springmvc/scanner/builder/SpringPathVariableBuilder.java#L56-L65 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/parser/lexparser/MLEDependencyGrammar.java | MLEDependencyGrammar.treeToDependencyHelper | protected static EndHead treeToDependencyHelper(Tree tree, List<IntDependency> depList, int loc, Index<String> wordIndex, Index<String> tagIndex) {
// try {
// PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out,"GB18030"),true);
// tree.pennPrint(pw);
// }
// catch (UnsupportedEncodingException e) {}
if (tree.isLeaf() || tree.isPreTerminal()) {
EndHead tempEndHead = new EndHead();
tempEndHead.head = loc;
tempEndHead.end = loc + 1;
return tempEndHead;
}
Tree[] kids = tree.children();
if (kids.length == 1) {
return treeToDependencyHelper(kids[0], depList, loc, wordIndex, tagIndex);
}
EndHead tempEndHead = treeToDependencyHelper(kids[0], depList, loc, wordIndex, tagIndex);
int lHead = tempEndHead.head;
int split = tempEndHead.end;
tempEndHead = treeToDependencyHelper(kids[1], depList, tempEndHead.end, wordIndex, tagIndex);
int end = tempEndHead.end;
int rHead = tempEndHead.head;
String hTag = ((HasTag) tree.label()).tag();
String lTag = ((HasTag) kids[0].label()).tag();
String rTag = ((HasTag) kids[1].label()).tag();
String hWord = ((HasWord) tree.label()).word();
String lWord = ((HasWord) kids[0].label()).word();
String rWord = ((HasWord) kids[1].label()).word();
boolean leftHeaded = hWord.equals(lWord);
String aTag = (leftHeaded ? rTag : lTag);
String aWord = (leftHeaded ? rWord : lWord);
int hT = tagIndex.indexOf(hTag);
int aT = tagIndex.indexOf(aTag);
int hW = (wordIndex.contains(hWord) ? wordIndex.indexOf(hWord) : wordIndex.indexOf(Lexicon.UNKNOWN_WORD));
int aW = (wordIndex.contains(aWord) ? wordIndex.indexOf(aWord) : wordIndex.indexOf(Lexicon.UNKNOWN_WORD));
int head = (leftHeaded ? lHead : rHead);
int arg = (leftHeaded ? rHead : lHead);
IntDependency dependency = new IntDependency(hW, hT, aW, aT, leftHeaded, (leftHeaded ? split - head - 1 : head - split));
depList.add(dependency);
IntDependency stopL = new IntDependency(aW, aT, STOP_WORD_INT, STOP_TAG_INT, false, (leftHeaded ? arg - split : arg - loc));
depList.add(stopL);
IntDependency stopR = new IntDependency(aW, aT, STOP_WORD_INT, STOP_TAG_INT, true, (leftHeaded ? end - arg - 1 : split - arg - 1));
depList.add(stopR);
//System.out.println("Adding: "+dependency+" at "+tree.label());
tempEndHead.head = head;
return tempEndHead;
} | java | protected static EndHead treeToDependencyHelper(Tree tree, List<IntDependency> depList, int loc, Index<String> wordIndex, Index<String> tagIndex) {
// try {
// PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out,"GB18030"),true);
// tree.pennPrint(pw);
// }
// catch (UnsupportedEncodingException e) {}
if (tree.isLeaf() || tree.isPreTerminal()) {
EndHead tempEndHead = new EndHead();
tempEndHead.head = loc;
tempEndHead.end = loc + 1;
return tempEndHead;
}
Tree[] kids = tree.children();
if (kids.length == 1) {
return treeToDependencyHelper(kids[0], depList, loc, wordIndex, tagIndex);
}
EndHead tempEndHead = treeToDependencyHelper(kids[0], depList, loc, wordIndex, tagIndex);
int lHead = tempEndHead.head;
int split = tempEndHead.end;
tempEndHead = treeToDependencyHelper(kids[1], depList, tempEndHead.end, wordIndex, tagIndex);
int end = tempEndHead.end;
int rHead = tempEndHead.head;
String hTag = ((HasTag) tree.label()).tag();
String lTag = ((HasTag) kids[0].label()).tag();
String rTag = ((HasTag) kids[1].label()).tag();
String hWord = ((HasWord) tree.label()).word();
String lWord = ((HasWord) kids[0].label()).word();
String rWord = ((HasWord) kids[1].label()).word();
boolean leftHeaded = hWord.equals(lWord);
String aTag = (leftHeaded ? rTag : lTag);
String aWord = (leftHeaded ? rWord : lWord);
int hT = tagIndex.indexOf(hTag);
int aT = tagIndex.indexOf(aTag);
int hW = (wordIndex.contains(hWord) ? wordIndex.indexOf(hWord) : wordIndex.indexOf(Lexicon.UNKNOWN_WORD));
int aW = (wordIndex.contains(aWord) ? wordIndex.indexOf(aWord) : wordIndex.indexOf(Lexicon.UNKNOWN_WORD));
int head = (leftHeaded ? lHead : rHead);
int arg = (leftHeaded ? rHead : lHead);
IntDependency dependency = new IntDependency(hW, hT, aW, aT, leftHeaded, (leftHeaded ? split - head - 1 : head - split));
depList.add(dependency);
IntDependency stopL = new IntDependency(aW, aT, STOP_WORD_INT, STOP_TAG_INT, false, (leftHeaded ? arg - split : arg - loc));
depList.add(stopL);
IntDependency stopR = new IntDependency(aW, aT, STOP_WORD_INT, STOP_TAG_INT, true, (leftHeaded ? end - arg - 1 : split - arg - 1));
depList.add(stopR);
//System.out.println("Adding: "+dependency+" at "+tree.label());
tempEndHead.head = head;
return tempEndHead;
} | [
"protected",
"static",
"EndHead",
"treeToDependencyHelper",
"(",
"Tree",
"tree",
",",
"List",
"<",
"IntDependency",
">",
"depList",
",",
"int",
"loc",
",",
"Index",
"<",
"String",
">",
"wordIndex",
",",
"Index",
"<",
"String",
">",
"tagIndex",
")",
"{",
"/... | Adds dependencies to list depList. These are in terms of the original
tag set not the reduced (projected) tag set. | [
"Adds",
"dependencies",
"to",
"list",
"depList",
".",
"These",
"are",
"in",
"terms",
"of",
"the",
"original",
"tag",
"set",
"not",
"the",
"reduced",
"(",
"projected",
")",
"tag",
"set",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/parser/lexparser/MLEDependencyGrammar.java#L123-L170 |
census-instrumentation/opencensus-java | benchmarks/src/jmh/java/io/opencensus/benchmarks/tags/TagsBenchmarksUtil.java | TagsBenchmarksUtil.createTagContext | @VisibleForTesting
public static TagContext createTagContext(TagContextBuilder tagsBuilder, int numTags) {
for (int i = 0; i < numTags; i++) {
tagsBuilder.put(TAG_KEYS.get(i), TAG_VALUES.get(i), UNLIMITED_PROPAGATION);
}
return tagsBuilder.build();
} | java | @VisibleForTesting
public static TagContext createTagContext(TagContextBuilder tagsBuilder, int numTags) {
for (int i = 0; i < numTags; i++) {
tagsBuilder.put(TAG_KEYS.get(i), TAG_VALUES.get(i), UNLIMITED_PROPAGATION);
}
return tagsBuilder.build();
} | [
"@",
"VisibleForTesting",
"public",
"static",
"TagContext",
"createTagContext",
"(",
"TagContextBuilder",
"tagsBuilder",
",",
"int",
"numTags",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numTags",
";",
"i",
"++",
")",
"{",
"tagsBuilder",
"... | Adds 'numTags' tags to 'tagsBuilder' and returns the associated tag context. | [
"Adds",
"numTags",
"tags",
"to",
"tagsBuilder",
"and",
"returns",
"the",
"associated",
"tag",
"context",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/benchmarks/src/jmh/java/io/opencensus/benchmarks/tags/TagsBenchmarksUtil.java#L98-L104 |
fflewddur/hola | src/main/java/net/straylightlabs/hola/sd/Query.java | Query.createFor | @SuppressWarnings("unused")
public static Query createFor(Service service, Domain domain) {
return new Query(service, domain, BROWSING_TIMEOUT);
} | java | @SuppressWarnings("unused")
public static Query createFor(Service service, Domain domain) {
return new Query(service, domain, BROWSING_TIMEOUT);
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"static",
"Query",
"createFor",
"(",
"Service",
"service",
",",
"Domain",
"domain",
")",
"{",
"return",
"new",
"Query",
"(",
"service",
",",
"domain",
",",
"BROWSING_TIMEOUT",
")",
";",
"}"
] | Create a Query for the given Service and Domain.
@param service service to search for
@param domain domain to search on
@return a new Query object | [
"Create",
"a",
"Query",
"for",
"the",
"given",
"Service",
"and",
"Domain",
"."
] | train | https://github.com/fflewddur/hola/blob/08d9b9f3b807fd447181a5c1122f117a950db848/src/main/java/net/straylightlabs/hola/sd/Query.java#L82-L85 |
nemerosa/ontrack | ontrack-model/src/main/java/net/nemerosa/ontrack/model/structure/ValidationStampRunView.java | ValidationStampRunView.hasValidationStamp | public boolean hasValidationStamp(String name, String status) {
return (StringUtils.equals(name, getValidationStamp().getName()))
&& isRun()
&& (
StringUtils.isBlank(status)
|| StringUtils.equals(status, getLastStatus().getStatusID().getId())
);
} | java | public boolean hasValidationStamp(String name, String status) {
return (StringUtils.equals(name, getValidationStamp().getName()))
&& isRun()
&& (
StringUtils.isBlank(status)
|| StringUtils.equals(status, getLastStatus().getStatusID().getId())
);
} | [
"public",
"boolean",
"hasValidationStamp",
"(",
"String",
"name",
",",
"String",
"status",
")",
"{",
"return",
"(",
"StringUtils",
".",
"equals",
"(",
"name",
",",
"getValidationStamp",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"&&",
"isRun",
"(",
")... | Checks if the validation run view has the given validation stamp with the given status. | [
"Checks",
"if",
"the",
"validation",
"run",
"view",
"has",
"the",
"given",
"validation",
"stamp",
"with",
"the",
"given",
"status",
"."
] | train | https://github.com/nemerosa/ontrack/blob/37b0874cbf387b58aba95cd3c1bc3b15e11bc913/ontrack-model/src/main/java/net/nemerosa/ontrack/model/structure/ValidationStampRunView.java#L52-L59 |
graphql-java/graphql-java | src/main/java/graphql/Assert.java | Assert.assertValidName | public static String assertValidName(String name) {
if (name != null && !name.isEmpty() && name.matches("[_A-Za-z][_0-9A-Za-z]*")) {
return name;
}
throw new AssertException(String.format(invalidNameErrorMessage, name));
} | java | public static String assertValidName(String name) {
if (name != null && !name.isEmpty() && name.matches("[_A-Za-z][_0-9A-Za-z]*")) {
return name;
}
throw new AssertException(String.format(invalidNameErrorMessage, name));
} | [
"public",
"static",
"String",
"assertValidName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"!",
"name",
".",
"isEmpty",
"(",
")",
"&&",
"name",
".",
"matches",
"(",
"\"[_A-Za-z][_0-9A-Za-z]*\"",
")",
")",
"{",
"return",
"nam... | Validates that the Lexical token name matches the current spec.
currently non null, non empty,
@param name - the name to be validated.
@return the name if valid, or AssertException if invalid. | [
"Validates",
"that",
"the",
"Lexical",
"token",
"name",
"matches",
"the",
"current",
"spec",
".",
"currently",
"non",
"null",
"non",
"empty"
] | train | https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/Assert.java#L96-L101 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormat.java | DateTimeFormat.createDateTimeFormatter | private static DateTimeFormatter createDateTimeFormatter(int dateStyle, int timeStyle){
int type = DATETIME;
if (dateStyle == NONE) {
type = TIME;
} else if (timeStyle == NONE) {
type = DATE;
}
StyleFormatter llf = new StyleFormatter(dateStyle, timeStyle, type);
return new DateTimeFormatter(llf, llf);
} | java | private static DateTimeFormatter createDateTimeFormatter(int dateStyle, int timeStyle){
int type = DATETIME;
if (dateStyle == NONE) {
type = TIME;
} else if (timeStyle == NONE) {
type = DATE;
}
StyleFormatter llf = new StyleFormatter(dateStyle, timeStyle, type);
return new DateTimeFormatter(llf, llf);
} | [
"private",
"static",
"DateTimeFormatter",
"createDateTimeFormatter",
"(",
"int",
"dateStyle",
",",
"int",
"timeStyle",
")",
"{",
"int",
"type",
"=",
"DATETIME",
";",
"if",
"(",
"dateStyle",
"==",
"NONE",
")",
"{",
"type",
"=",
"TIME",
";",
"}",
"else",
"if... | Creates a formatter for the specified style.
@param dateStyle the date style
@param timeStyle the time style
@return the formatter | [
"Creates",
"a",
"formatter",
"for",
"the",
"specified",
"style",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L752-L761 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java | RequestParameters.put | public void put(String name, String value) {
List<String> list = new ArrayList<>();
list.add(value);
getMap().put(name, list);
} | java | public void put(String name, String value) {
List<String> list = new ArrayList<>();
list.add(value);
getMap().put(name, list);
} | [
"public",
"void",
"put",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"list",
".",
"add",
"(",
"value",
")",
";",
"getMap",
"(",
")",
".",
"put",
"(",
... | Set a parameter to a single value.
@param name the parameter name
@param value the value of the parameter | [
"Set",
"a",
"parameter",
"to",
"a",
"single",
"value",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java#L48-L52 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.escapeXml10Minimal | public static void escapeXml10Minimal(final String text, final Writer writer)
throws IOException {
escapeXml(text, writer, XmlEscapeSymbols.XML10_SYMBOLS,
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA,
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT);
} | java | public static void escapeXml10Minimal(final String text, final Writer writer)
throws IOException {
escapeXml(text, writer, XmlEscapeSymbols.XML10_SYMBOLS,
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA,
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT);
} | [
"public",
"static",
"void",
"escapeXml10Minimal",
"(",
"final",
"String",
"text",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"escapeXml",
"(",
"text",
",",
"writer",
",",
"XmlEscapeSymbols",
".",
"XML10_SYMBOLS",
",",
"XmlEscapeType",
"... | <p>
Perform an XML 1.0 level 1 (only markup-significant chars) <strong>escape</strong> operation
on a <tt>String</tt> input, writing results to a <tt>Writer</tt>.
</p>
<p>
<em>Level 1</em> means this method will only escape the five markup-significant characters which
are <em>predefined</em> as Character Entity References in XML:
<tt><</tt>, <tt>></tt>, <tt>&</tt>, <tt>"</tt> and <tt>'</tt>.
</p>
<p>
This method calls {@link #escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel)} with the following
preconfigured values:
</p>
<ul>
<li><tt>type</tt>:
{@link org.unbescape.xml.XmlEscapeType#CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA}</li>
<li><tt>level</tt>:
{@link org.unbescape.xml.XmlEscapeLevel#LEVEL_1_ONLY_MARKUP_SIGNIFICANT}</li>
</ul>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"an",
"XML",
"1",
".",
"0",
"level",
"1",
"(",
"only",
"markup",
"-",
"significant",
"chars",
")",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
"writing",... | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L695-L700 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTableUtil.java | VoltTableUtil.toCSV | public static Pair<Integer,byte[]> toCSV(
VoltTable vt,
ArrayList<VoltType> columns,
char delimiter,
char fullDelimiters[],
int lastNumCharacters) throws IOException {
StringWriter sw = new StringWriter((int)(lastNumCharacters * 1.2));
CSVWriter writer;
if (fullDelimiters != null) {
writer = new CSVWriter(sw,
fullDelimiters[0], fullDelimiters[1], fullDelimiters[2], String.valueOf(fullDelimiters[3]));
}
else if (delimiter == ',') {
// CSV
writer = new CSVWriter(sw, delimiter);
} else {
// TSV
writer = CSVWriter.getStrictTSVWriter(sw);
}
toCSVWriter(writer, vt, columns);
String csvString = sw.toString();
return Pair.of(csvString.length(), csvString.getBytes(com.google_voltpatches.common.base.Charsets.UTF_8));
} | java | public static Pair<Integer,byte[]> toCSV(
VoltTable vt,
ArrayList<VoltType> columns,
char delimiter,
char fullDelimiters[],
int lastNumCharacters) throws IOException {
StringWriter sw = new StringWriter((int)(lastNumCharacters * 1.2));
CSVWriter writer;
if (fullDelimiters != null) {
writer = new CSVWriter(sw,
fullDelimiters[0], fullDelimiters[1], fullDelimiters[2], String.valueOf(fullDelimiters[3]));
}
else if (delimiter == ',') {
// CSV
writer = new CSVWriter(sw, delimiter);
} else {
// TSV
writer = CSVWriter.getStrictTSVWriter(sw);
}
toCSVWriter(writer, vt, columns);
String csvString = sw.toString();
return Pair.of(csvString.length(), csvString.getBytes(com.google_voltpatches.common.base.Charsets.UTF_8));
} | [
"public",
"static",
"Pair",
"<",
"Integer",
",",
"byte",
"[",
"]",
">",
"toCSV",
"(",
"VoltTable",
"vt",
",",
"ArrayList",
"<",
"VoltType",
">",
"columns",
",",
"char",
"delimiter",
",",
"char",
"fullDelimiters",
"[",
"]",
",",
"int",
"lastNumCharacters",
... | /*
Returns the number of characters generated and the csv data
in UTF-8 encoding. | [
"/",
"*",
"Returns",
"the",
"number",
"of",
"characters",
"generated",
"and",
"the",
"csv",
"data",
"in",
"UTF",
"-",
"8",
"encoding",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTableUtil.java#L166-L188 |
jbundle/jbundle | base/model/src/main/java/org/jbundle/base/model/Resources.java | Resources.init | public void init(ResourceBundle resourceBundle, String strResourceName, boolean bReturnKeyOnMissing)
{
m_resourceBundle = resourceBundle;
m_strResourceName = strResourceName;
m_bReturnKeyOnMissing = bReturnKeyOnMissing;
} | java | public void init(ResourceBundle resourceBundle, String strResourceName, boolean bReturnKeyOnMissing)
{
m_resourceBundle = resourceBundle;
m_strResourceName = strResourceName;
m_bReturnKeyOnMissing = bReturnKeyOnMissing;
} | [
"public",
"void",
"init",
"(",
"ResourceBundle",
"resourceBundle",
",",
"String",
"strResourceName",
",",
"boolean",
"bReturnKeyOnMissing",
")",
"{",
"m_resourceBundle",
"=",
"resourceBundle",
";",
"m_strResourceName",
"=",
"strResourceName",
";",
"m_bReturnKeyOnMissing",... | Constuctor.
@param resourceBundle The resource bundle to do lookups in.
@param strResourceName The name of this resource.
@param bReturnKeyOnMissing Return the key if it is not in the resource bundle. | [
"Constuctor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/model/src/main/java/org/jbundle/base/model/Resources.java#L60-L65 |
ontop/ontop | mapping/sql/native/src/main/java/it/unibz/inf/ontop/spec/mapping/parser/impl/OntopNativeMappingParser.java | OntopNativeMappingParser.parse | @Override
public SQLPPMapping parse(File file) throws InvalidMappingException, DuplicateMappingException, MappingIOException {
checkFile(file);
try (Reader reader = new FileReader(file)) {
return load(reader, specificationFactory, ppMappingFactory, file.getName());
} catch (IOException e) {
throw new MappingIOException(e);
}
} | java | @Override
public SQLPPMapping parse(File file) throws InvalidMappingException, DuplicateMappingException, MappingIOException {
checkFile(file);
try (Reader reader = new FileReader(file)) {
return load(reader, specificationFactory, ppMappingFactory, file.getName());
} catch (IOException e) {
throw new MappingIOException(e);
}
} | [
"@",
"Override",
"public",
"SQLPPMapping",
"parse",
"(",
"File",
"file",
")",
"throws",
"InvalidMappingException",
",",
"DuplicateMappingException",
",",
"MappingIOException",
"{",
"checkFile",
"(",
"file",
")",
";",
"try",
"(",
"Reader",
"reader",
"=",
"new",
"... | Parsing is not done at construction time because our dependency
injection framework (Guice) does not manage exceptions nicely. | [
"Parsing",
"is",
"not",
"done",
"at",
"construction",
"time",
"because",
"our",
"dependency",
"injection",
"framework",
"(",
"Guice",
")",
"does",
"not",
"manage",
"exceptions",
"nicely",
"."
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/mapping/sql/native/src/main/java/it/unibz/inf/ontop/spec/mapping/parser/impl/OntopNativeMappingParser.java#L111-L119 |
libgdx/gdx-ai | gdx-ai/src/com/badlogic/gdx/ai/msg/PriorityQueue.java | PriorityQueue.siftDown | @SuppressWarnings("unchecked")
private void siftDown (int k, E x) {
int half = size >>> 1; // loop while a non-leaf
while (k < half) {
int child = (k << 1) + 1; // assume left child is least
E c = (E)queue[child];
int right = child + 1;
if (right < size && c.compareTo((E)queue[right]) > 0) c = (E)queue[child = right];
if (x.compareTo(c) <= 0) break;
queue[k] = c;
k = child;
}
queue[k] = x;
} | java | @SuppressWarnings("unchecked")
private void siftDown (int k, E x) {
int half = size >>> 1; // loop while a non-leaf
while (k < half) {
int child = (k << 1) + 1; // assume left child is least
E c = (E)queue[child];
int right = child + 1;
if (right < size && c.compareTo((E)queue[right]) > 0) c = (E)queue[child = right];
if (x.compareTo(c) <= 0) break;
queue[k] = c;
k = child;
}
queue[k] = x;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"siftDown",
"(",
"int",
"k",
",",
"E",
"x",
")",
"{",
"int",
"half",
"=",
"size",
">>>",
"1",
";",
"// loop while a non-leaf",
"while",
"(",
"k",
"<",
"half",
")",
"{",
"int",
"chil... | Inserts item x at position k, maintaining heap invariant by demoting x down the tree repeatedly until it is less than or
equal to its children or is a leaf.
@param k the position to fill
@param x the item to insert | [
"Inserts",
"item",
"x",
"at",
"position",
"k",
"maintaining",
"heap",
"invariant",
"by",
"demoting",
"x",
"down",
"the",
"tree",
"repeatedly",
"until",
"it",
"is",
"less",
"than",
"or",
"equal",
"to",
"its",
"children",
"or",
"is",
"a",
"leaf",
"."
] | train | https://github.com/libgdx/gdx-ai/blob/2d1523a97193a45e18e11a4837c6800d08f177c5/gdx-ai/src/com/badlogic/gdx/ai/msg/PriorityQueue.java#L186-L199 |
OpenLiberty/open-liberty | dev/com.ibm.ws.cloudant/src/com/ibm/ws/cloudant/internal/CloudantService.java | CloudantService.getCloudantClient | public Object getCloudantClient(int resAuth, List<? extends ResourceInfo.Property> loginPropertyList) throws Exception {
AuthData containerAuthData = null;
if (resAuth == ResourceInfo.AUTH_CONTAINER) {
containerAuthData = getContainerAuthData(loginPropertyList);
}
String userName = containerAuthData == null ? (String) props.get(USERNAME) : containerAuthData.getUserName();
String password = null;
if (containerAuthData == null) {
SerializableProtectedString protectedPwd = (SerializableProtectedString) props.get(PASSWORD);
if (protectedPwd != null) {
password = String.valueOf(protectedPwd.getChars());
password = PasswordUtil.getCryptoAlgorithm(password) == null ? password : PasswordUtil.decode(password);
}
} else
password = String.valueOf(containerAuthData.getPassword());
final ClientKey key = new ClientKey(null, userName, password);
return clients.get(key);
} | java | public Object getCloudantClient(int resAuth, List<? extends ResourceInfo.Property> loginPropertyList) throws Exception {
AuthData containerAuthData = null;
if (resAuth == ResourceInfo.AUTH_CONTAINER) {
containerAuthData = getContainerAuthData(loginPropertyList);
}
String userName = containerAuthData == null ? (String) props.get(USERNAME) : containerAuthData.getUserName();
String password = null;
if (containerAuthData == null) {
SerializableProtectedString protectedPwd = (SerializableProtectedString) props.get(PASSWORD);
if (protectedPwd != null) {
password = String.valueOf(protectedPwd.getChars());
password = PasswordUtil.getCryptoAlgorithm(password) == null ? password : PasswordUtil.decode(password);
}
} else
password = String.valueOf(containerAuthData.getPassword());
final ClientKey key = new ClientKey(null, userName, password);
return clients.get(key);
} | [
"public",
"Object",
"getCloudantClient",
"(",
"int",
"resAuth",
",",
"List",
"<",
"?",
"extends",
"ResourceInfo",
".",
"Property",
">",
"loginPropertyList",
")",
"throws",
"Exception",
"{",
"AuthData",
"containerAuthData",
"=",
"null",
";",
"if",
"(",
"resAuth",... | Return the cloudant client object used for a particular username and password
@param resAuth
@param loginPropertyList
@return CloudantClient object
@throws Exception | [
"Return",
"the",
"cloudant",
"client",
"object",
"used",
"for",
"a",
"particular",
"username",
"and",
"password"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cloudant/src/com/ibm/ws/cloudant/internal/CloudantService.java#L618-L637 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/orders/OrderItemUrl.java | OrderItemUrl.getOrderItemViaLineIdUrl | public static MozuUrl getOrderItemViaLineIdUrl(Boolean draft, Integer lineId, String orderId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/items/{lineId}?draft={draft}&responseFields={responseFields}");
formatter.formatUrl("draft", draft);
formatter.formatUrl("lineId", lineId);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getOrderItemViaLineIdUrl(Boolean draft, Integer lineId, String orderId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/items/{lineId}?draft={draft}&responseFields={responseFields}");
formatter.formatUrl("draft", draft);
formatter.formatUrl("lineId", lineId);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getOrderItemViaLineIdUrl",
"(",
"Boolean",
"draft",
",",
"Integer",
"lineId",
",",
"String",
"orderId",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/orders/{or... | Get Resource Url for GetOrderItemViaLineId
@param draft If true, retrieve the draft version of the order, which might include uncommitted changes to the order or its components.
@param lineId The specific line id that's associated with the order item.
@param orderId Unique identifier of the order.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetOrderItemViaLineId"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/orders/OrderItemUrl.java#L24-L32 |
BradleyWood/Software-Quality-Test-Framework | sqtf-core/src/main/java/org/sqtf/assertions/Assert.java | Assert.assertEquals | public static void assertEquals(float expected, float actual, float delta) {
assertEquals(expected, actual, delta, "Expected " + expected + " +- " + delta + " but got " + actual);
} | java | public static void assertEquals(float expected, float actual, float delta) {
assertEquals(expected, actual, delta, "Expected " + expected + " +- " + delta + " but got " + actual);
} | [
"public",
"static",
"void",
"assertEquals",
"(",
"float",
"expected",
",",
"float",
"actual",
",",
"float",
"delta",
")",
"{",
"assertEquals",
"(",
"expected",
",",
"actual",
",",
"delta",
",",
"\"Expected \"",
"+",
"expected",
"+",
"\" +- \"",
"+",
"delta",... | Asserts that the two floats are equal. If they are not
the test will fail
@param expected The expected value
@param actual The actual value
@param delta The maximum amount that expected and actual values may deviate by | [
"Asserts",
"that",
"the",
"two",
"floats",
"are",
"equal",
".",
"If",
"they",
"are",
"not",
"the",
"test",
"will",
"fail"
] | train | https://github.com/BradleyWood/Software-Quality-Test-Framework/blob/010dea3bfc8e025a4304ab9ef4a213c1adcb1aa0/sqtf-core/src/main/java/org/sqtf/assertions/Assert.java#L125-L127 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/tree/GISTreeSetUtil.java | GISTreeSetUtil.addInside | static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>>
boolean addInside(AbstractGISTreeSet<P, N> tree,
N insertionNode,
P element,
GISTreeSetNodeFactory<P, N> builder) {
return addInside(tree, insertionNode, element, builder, true);
} | java | static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>>
boolean addInside(AbstractGISTreeSet<P, N> tree,
N insertionNode,
P element,
GISTreeSetNodeFactory<P, N> builder) {
return addInside(tree, insertionNode, element, builder, true);
} | [
"static",
"<",
"P",
"extends",
"GISPrimitive",
",",
"N",
"extends",
"AbstractGISTreeSetNode",
"<",
"P",
",",
"N",
">",
">",
"boolean",
"addInside",
"(",
"AbstractGISTreeSet",
"<",
"P",
",",
"N",
">",
"tree",
",",
"N",
"insertionNode",
",",
"P",
"element",
... | Add the given element inside the given node (or one of its children).
@param <P> is the type of the primitives.
@param <N> is the type of the nodes.
@param tree is the tree to update.
@param insertionNode the receiving node.
@param element the element to insert.
@param builder is the node factory.
@return success state. | [
"Add",
"the",
"given",
"element",
"inside",
"the",
"given",
"node",
"(",
"or",
"one",
"of",
"its",
"children",
")",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/tree/GISTreeSetUtil.java#L157-L163 |
JM-Lab/utils-elasticsearch | src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchSearchAndCount.java | JMElasticsearchSearchAndCount.searchAllWithTargetCount | public SearchResponse searchAllWithTargetCount(String index, String type) {
return searchAllWithTargetCount(index, type, null, null);
} | java | public SearchResponse searchAllWithTargetCount(String index, String type) {
return searchAllWithTargetCount(index, type, null, null);
} | [
"public",
"SearchResponse",
"searchAllWithTargetCount",
"(",
"String",
"index",
",",
"String",
"type",
")",
"{",
"return",
"searchAllWithTargetCount",
"(",
"index",
",",
"type",
",",
"null",
",",
"null",
")",
";",
"}"
] | Search all with target count search response.
@param index the index
@param type the type
@return the search response | [
"Search",
"all",
"with",
"target",
"count",
"search",
"response",
"."
] | train | https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchSearchAndCount.java#L676-L678 |
Waikato/moa | moa/src/main/java/moa/gui/GUIDefaults.java | GUIDefaults.get | public static String get(String property, String defaultValue) {
return PROPERTIES.getProperty(property, defaultValue);
} | java | public static String get(String property, String defaultValue) {
return PROPERTIES.getProperty(property, defaultValue);
} | [
"public",
"static",
"String",
"get",
"(",
"String",
"property",
",",
"String",
"defaultValue",
")",
"{",
"return",
"PROPERTIES",
".",
"getProperty",
"(",
"property",
",",
"defaultValue",
")",
";",
"}"
] | returns the value for the specified property, if non-existent then the
default value.
@param property the property to retrieve the value for
@param defaultValue the default value for the property
@return the value of the specified property | [
"returns",
"the",
"value",
"for",
"the",
"specified",
"property",
"if",
"non",
"-",
"existent",
"then",
"the",
"default",
"value",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/gui/GUIDefaults.java#L69-L71 |
threerings/nenya | core/src/main/java/com/threerings/miso/client/SceneBlock.java | SceneBlock.update | protected void update (Map<Integer, SceneBlock> blocks)
{
boolean recover = false;
// link up to our neighbors
for (int ii = 0; ii < DX.length; ii++) {
SceneBlock neigh = blocks.get(neighborKey(DX[ii], DY[ii]));
if (neigh != _neighbors[ii]) {
_neighbors[ii] = neigh;
// if we're linking up to a neighbor for the first time;
// we need to recalculate our coverage
recover = recover || (neigh != null);
// Log.info(this + " was introduced to " + neigh + ".");
}
}
// if we need to regenerate the set of tiles covered by our
// objects, do so
if (recover) {
for (SceneObject _object : _objects) {
setCovered(blocks, _object);
}
}
} | java | protected void update (Map<Integer, SceneBlock> blocks)
{
boolean recover = false;
// link up to our neighbors
for (int ii = 0; ii < DX.length; ii++) {
SceneBlock neigh = blocks.get(neighborKey(DX[ii], DY[ii]));
if (neigh != _neighbors[ii]) {
_neighbors[ii] = neigh;
// if we're linking up to a neighbor for the first time;
// we need to recalculate our coverage
recover = recover || (neigh != null);
// Log.info(this + " was introduced to " + neigh + ".");
}
}
// if we need to regenerate the set of tiles covered by our
// objects, do so
if (recover) {
for (SceneObject _object : _objects) {
setCovered(blocks, _object);
}
}
} | [
"protected",
"void",
"update",
"(",
"Map",
"<",
"Integer",
",",
"SceneBlock",
">",
"blocks",
")",
"{",
"boolean",
"recover",
"=",
"false",
";",
"// link up to our neighbors",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"DX",
".",
"length",
";",
... | Links this block to its neighbors; informs neighboring blocks of
object coverage. | [
"Links",
"this",
"block",
"to",
"its",
"neighbors",
";",
"informs",
"neighboring",
"blocks",
"of",
"object",
"coverage",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/SceneBlock.java#L513-L536 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryLockManager.java | RepositoryLockManager.cleanLocks | Set<String> cleanLocks( JcrSession session ) throws RepositoryException {
Set<String> lockTokens = session.lockManager().lockTokens();
List<ModeShapeLock> locks = null;
for (ModeShapeLock lock : locksByNodeKey.values()) {
if (lock.isSessionScoped() && lockTokens.contains(lock.getLockToken())) {
if (locks == null) locks = new LinkedList<ModeShapeLock>();
locks.add(lock);
}
}
Set<String> cleanedTokens = null;
if (locks != null) {
cleanedTokens = new HashSet<>(locks.size());
// clear the locks which have been unlocked
unlock(session, locks);
for (ModeShapeLock lock : locks) {
locksByNodeKey.remove(lock.getLockedNodeKey());
cleanedTokens.add(lock.getLockToken());
}
}
return cleanedTokens != null ? cleanedTokens : Collections.<String>emptySet();
} | java | Set<String> cleanLocks( JcrSession session ) throws RepositoryException {
Set<String> lockTokens = session.lockManager().lockTokens();
List<ModeShapeLock> locks = null;
for (ModeShapeLock lock : locksByNodeKey.values()) {
if (lock.isSessionScoped() && lockTokens.contains(lock.getLockToken())) {
if (locks == null) locks = new LinkedList<ModeShapeLock>();
locks.add(lock);
}
}
Set<String> cleanedTokens = null;
if (locks != null) {
cleanedTokens = new HashSet<>(locks.size());
// clear the locks which have been unlocked
unlock(session, locks);
for (ModeShapeLock lock : locks) {
locksByNodeKey.remove(lock.getLockedNodeKey());
cleanedTokens.add(lock.getLockToken());
}
}
return cleanedTokens != null ? cleanedTokens : Collections.<String>emptySet();
} | [
"Set",
"<",
"String",
">",
"cleanLocks",
"(",
"JcrSession",
"session",
")",
"throws",
"RepositoryException",
"{",
"Set",
"<",
"String",
">",
"lockTokens",
"=",
"session",
".",
"lockManager",
"(",
")",
".",
"lockTokens",
"(",
")",
";",
"List",
"<",
"ModeSha... | Unlocks all locks corresponding to the tokens held by the supplied session.
@param session the session on behalf of which the lock operation is being performed
@return a {@link Set} of the lock tokens that have been cleaned (removed from the system area and the corresponding nodes
unlocked)
@throws RepositoryException if the session is not live | [
"Unlocks",
"all",
"locks",
"corresponding",
"to",
"the",
"tokens",
"held",
"by",
"the",
"supplied",
"session",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryLockManager.java#L493-L514 |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/progress/ProgressionUtil.java | ProgressionUtil.setValue | public static void setValue(Progression model, int value) {
if (model != null && value > model.getValue()) {
model.setValue(value);
}
} | java | public static void setValue(Progression model, int value) {
if (model != null && value > model.getValue()) {
model.setValue(value);
}
} | [
"public",
"static",
"void",
"setValue",
"(",
"Progression",
"model",
",",
"int",
"value",
")",
"{",
"if",
"(",
"model",
"!=",
"null",
"&&",
"value",
">",
"model",
".",
"getValue",
"(",
")",
")",
"{",
"model",
".",
"setValue",
"(",
"value",
")",
";",
... | Set the value of the given task progression,
if not <code>null</code>.
The value must be greater than the current progression value.
@param model is the progression to change
@param value is the value to add to the progression value. | [
"Set",
"the",
"value",
"of",
"the",
"given",
"task",
"progression",
"if",
"not",
"<code",
">",
"null<",
"/",
"code",
">",
".",
"The",
"value",
"must",
"be",
"greater",
"than",
"the",
"current",
"progression",
"value",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/progress/ProgressionUtil.java#L313-L317 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/ComputationGraph.java | ComputationGraph.outputSingle | public INDArray outputSingle(boolean train, boolean clearInputs, INDArray... input){
if (numOutputArrays != 1) {
throw new IllegalStateException(
"Cannot use outputSingle with ComputationGraph that does not have exactly 1 output. nOutputs: "
+ numOutputArrays);
}
return output(train, clearInputs, input)[0];
} | java | public INDArray outputSingle(boolean train, boolean clearInputs, INDArray... input){
if (numOutputArrays != 1) {
throw new IllegalStateException(
"Cannot use outputSingle with ComputationGraph that does not have exactly 1 output. nOutputs: "
+ numOutputArrays);
}
return output(train, clearInputs, input)[0];
} | [
"public",
"INDArray",
"outputSingle",
"(",
"boolean",
"train",
",",
"boolean",
"clearInputs",
",",
"INDArray",
"...",
"input",
")",
"{",
"if",
"(",
"numOutputArrays",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot use outputSingle wit... | Identical to {@link #outputSingle(boolean, boolean, INDArray...)} but has the option of not clearing the input
arrays (useful when later backpropagating external errors). Most users should use {@link #outputSingle(boolean, INDArray...)}
in preference to this method. | [
"Identical",
"to",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/ComputationGraph.java#L1765-L1772 |
mediathekview/MServer | src/main/java/mServer/crawler/sender/base/UrlUtils.java | UrlUtils.addProtocolIfMissing | public static String addProtocolIfMissing(final String aUrl, final String aProtocol) {
if (aUrl != null && aUrl.startsWith("//")) {
return aProtocol + aUrl;
}
return aUrl;
} | java | public static String addProtocolIfMissing(final String aUrl, final String aProtocol) {
if (aUrl != null && aUrl.startsWith("//")) {
return aProtocol + aUrl;
}
return aUrl;
} | [
"public",
"static",
"String",
"addProtocolIfMissing",
"(",
"final",
"String",
"aUrl",
",",
"final",
"String",
"aProtocol",
")",
"{",
"if",
"(",
"aUrl",
"!=",
"null",
"&&",
"aUrl",
".",
"startsWith",
"(",
"\"//\"",
")",
")",
"{",
"return",
"aProtocol",
"+",... | adds the protocol if missing.
@param aUrl the url to check
@param aProtocol the protocol to add
@return the url including the protocol | [
"adds",
"the",
"protocol",
"if",
"missing",
"."
] | train | https://github.com/mediathekview/MServer/blob/ba8d03e6a1a303db3807a1327f553f1decd30388/src/main/java/mServer/crawler/sender/base/UrlUtils.java#L52-L58 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java | GrailsDomainBinder.bindProperty | protected void bindProperty(PersistentProperty grailsProperty, Property prop, InFlightMetadataCollector mappings) {
// set the property name
prop.setName(grailsProperty.getName());
if (isBidirectionalManyToOneWithListMapping(grailsProperty, prop)) {
prop.setInsertable(false);
prop.setUpdateable(false);
} else {
prop.setInsertable(getInsertableness(grailsProperty));
prop.setUpdateable(getUpdateableness(grailsProperty));
}
AccessType accessType = AccessType.getAccessStrategy(
grailsProperty.getMapping().getMappedForm().getAccessType()
);
if(accessType == AccessType.FIELD) {
EntityReflector.PropertyReader reader = grailsProperty.getReader();
Method getter = reader != null ? reader.getter() : null;
if(getter != null && getter.getAnnotation(Traits.Implemented.class) != null) {
prop.setPropertyAccessorName(TraitPropertyAccessStrategy.class.getName());
}
else {
prop.setPropertyAccessorName( accessType.getType() );
}
}
else {
prop.setPropertyAccessorName( accessType.getType() );
}
prop.setOptional(grailsProperty.isNullable());
setCascadeBehaviour(grailsProperty, prop);
// lazy to true
final boolean isToOne = grailsProperty instanceof ToOne && !(grailsProperty instanceof Embedded);
PersistentEntity propertyOwner = grailsProperty.getOwner();
boolean isLazyable = isToOne ||
!(grailsProperty instanceof Association) && !grailsProperty.equals(propertyOwner.getIdentity());
if (isLazyable) {
final boolean isLazy = getLaziness(grailsProperty);
prop.setLazy(isLazy);
if (isLazy && isToOne && !(PersistentAttributeInterceptable.class.isAssignableFrom(propertyOwner.getJavaClass()))) {
// handleLazyProxy(propertyOwner, grailsProperty);
}
}
} | java | protected void bindProperty(PersistentProperty grailsProperty, Property prop, InFlightMetadataCollector mappings) {
// set the property name
prop.setName(grailsProperty.getName());
if (isBidirectionalManyToOneWithListMapping(grailsProperty, prop)) {
prop.setInsertable(false);
prop.setUpdateable(false);
} else {
prop.setInsertable(getInsertableness(grailsProperty));
prop.setUpdateable(getUpdateableness(grailsProperty));
}
AccessType accessType = AccessType.getAccessStrategy(
grailsProperty.getMapping().getMappedForm().getAccessType()
);
if(accessType == AccessType.FIELD) {
EntityReflector.PropertyReader reader = grailsProperty.getReader();
Method getter = reader != null ? reader.getter() : null;
if(getter != null && getter.getAnnotation(Traits.Implemented.class) != null) {
prop.setPropertyAccessorName(TraitPropertyAccessStrategy.class.getName());
}
else {
prop.setPropertyAccessorName( accessType.getType() );
}
}
else {
prop.setPropertyAccessorName( accessType.getType() );
}
prop.setOptional(grailsProperty.isNullable());
setCascadeBehaviour(grailsProperty, prop);
// lazy to true
final boolean isToOne = grailsProperty instanceof ToOne && !(grailsProperty instanceof Embedded);
PersistentEntity propertyOwner = grailsProperty.getOwner();
boolean isLazyable = isToOne ||
!(grailsProperty instanceof Association) && !grailsProperty.equals(propertyOwner.getIdentity());
if (isLazyable) {
final boolean isLazy = getLaziness(grailsProperty);
prop.setLazy(isLazy);
if (isLazy && isToOne && !(PersistentAttributeInterceptable.class.isAssignableFrom(propertyOwner.getJavaClass()))) {
// handleLazyProxy(propertyOwner, grailsProperty);
}
}
} | [
"protected",
"void",
"bindProperty",
"(",
"PersistentProperty",
"grailsProperty",
",",
"Property",
"prop",
",",
"InFlightMetadataCollector",
"mappings",
")",
"{",
"// set the property name",
"prop",
".",
"setName",
"(",
"grailsProperty",
".",
"getName",
"(",
")",
")",... | Binds a property to Hibernate runtime meta model. Deals with cascade strategy based on the Grails domain model
@param grailsProperty The grails property instance
@param prop The Hibernate property
@param mappings The Hibernate mappings | [
"Binds",
"a",
"property",
"to",
"Hibernate",
"runtime",
"meta",
"model",
".",
"Deals",
"with",
"cascade",
"strategy",
"based",
"on",
"the",
"Grails",
"domain",
"model"
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java#L2626-L2674 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.