repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
netplex/json-smart-v2
|
accessors-smart/src/main/java/net/minidev/asm/ASMUtil.java
|
ASMUtil.getAccessors
|
static public Accessor[] getAccessors(Class<?> type, FieldFilter filter) {
"""
Extract all Accessor for the field of the given class.
@param type
@return all Accessor available
"""
Class<?> nextClass = type;
HashMap<String, Accessor> map = new HashMap<String, Accessor>();
if (filter == null)
filter = BasicFiledFilter.SINGLETON;
while (nextClass != Object.class) {
Field[] declaredFields = nextClass.getDeclaredFields();
for (Field field : declaredFields) {
String fn = field.getName();
if (map.containsKey(fn))
continue;
Accessor acc = new Accessor(nextClass, field, filter);
if (!acc.isUsable())
continue;
map.put(fn, acc);
}
nextClass = nextClass.getSuperclass();
}
return map.values().toArray(new Accessor[map.size()]);
}
|
java
|
static public Accessor[] getAccessors(Class<?> type, FieldFilter filter) {
Class<?> nextClass = type;
HashMap<String, Accessor> map = new HashMap<String, Accessor>();
if (filter == null)
filter = BasicFiledFilter.SINGLETON;
while (nextClass != Object.class) {
Field[] declaredFields = nextClass.getDeclaredFields();
for (Field field : declaredFields) {
String fn = field.getName();
if (map.containsKey(fn))
continue;
Accessor acc = new Accessor(nextClass, field, filter);
if (!acc.isUsable())
continue;
map.put(fn, acc);
}
nextClass = nextClass.getSuperclass();
}
return map.values().toArray(new Accessor[map.size()]);
}
|
[
"static",
"public",
"Accessor",
"[",
"]",
"getAccessors",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"FieldFilter",
"filter",
")",
"{",
"Class",
"<",
"?",
">",
"nextClass",
"=",
"type",
";",
"HashMap",
"<",
"String",
",",
"Accessor",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Accessor",
">",
"(",
")",
";",
"if",
"(",
"filter",
"==",
"null",
")",
"filter",
"=",
"BasicFiledFilter",
".",
"SINGLETON",
";",
"while",
"(",
"nextClass",
"!=",
"Object",
".",
"class",
")",
"{",
"Field",
"[",
"]",
"declaredFields",
"=",
"nextClass",
".",
"getDeclaredFields",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"declaredFields",
")",
"{",
"String",
"fn",
"=",
"field",
".",
"getName",
"(",
")",
";",
"if",
"(",
"map",
".",
"containsKey",
"(",
"fn",
")",
")",
"continue",
";",
"Accessor",
"acc",
"=",
"new",
"Accessor",
"(",
"nextClass",
",",
"field",
",",
"filter",
")",
";",
"if",
"(",
"!",
"acc",
".",
"isUsable",
"(",
")",
")",
"continue",
";",
"map",
".",
"put",
"(",
"fn",
",",
"acc",
")",
";",
"}",
"nextClass",
"=",
"nextClass",
".",
"getSuperclass",
"(",
")",
";",
"}",
"return",
"map",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"new",
"Accessor",
"[",
"map",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Extract all Accessor for the field of the given class.
@param type
@return all Accessor available
|
[
"Extract",
"all",
"Accessor",
"for",
"the",
"field",
"of",
"the",
"given",
"class",
"."
] |
train
|
https://github.com/netplex/json-smart-v2/blob/bfb3daef039e22a7bbff5f76bf14ea23330cd70e/accessors-smart/src/main/java/net/minidev/asm/ASMUtil.java#L48-L68
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java
|
AbstractHibernateDao.countBySql
|
public long countBySql(String fullSql, Object[] paramValues, Type[] paramTypes) {
"""
Get the count of all records in database
@param fullSql
@param paramValues
@param paramTypes
@return the count
"""
Session session = this.getCurrentSession();
Query query = session.createSQLQuery(fullSql);
setupQuery(query, paramValues, paramTypes, null, null);
return ((Number)query.uniqueResult()).longValue();
}
|
java
|
public long countBySql(String fullSql, Object[] paramValues, Type[] paramTypes){
Session session = this.getCurrentSession();
Query query = session.createSQLQuery(fullSql);
setupQuery(query, paramValues, paramTypes, null, null);
return ((Number)query.uniqueResult()).longValue();
}
|
[
"public",
"long",
"countBySql",
"(",
"String",
"fullSql",
",",
"Object",
"[",
"]",
"paramValues",
",",
"Type",
"[",
"]",
"paramTypes",
")",
"{",
"Session",
"session",
"=",
"this",
".",
"getCurrentSession",
"(",
")",
";",
"Query",
"query",
"=",
"session",
".",
"createSQLQuery",
"(",
"fullSql",
")",
";",
"setupQuery",
"(",
"query",
",",
"paramValues",
",",
"paramTypes",
",",
"null",
",",
"null",
")",
";",
"return",
"(",
"(",
"Number",
")",
"query",
".",
"uniqueResult",
"(",
")",
")",
".",
"longValue",
"(",
")",
";",
"}"
] |
Get the count of all records in database
@param fullSql
@param paramValues
@param paramTypes
@return the count
|
[
"Get",
"the",
"count",
"of",
"all",
"records",
"in",
"database"
] |
train
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java#L362-L367
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/DefaultCommandManager.java
|
DefaultCommandManager.createCommandGroup
|
@Override
public CommandGroup createCommandGroup(String groupId, List<? extends AbstractCommand> members) {
"""
Create a command group which holds all the given members.
@param groupId the id to configure the group.
@param members members to add to the group.
@return a {@link CommandGroup} which contains all the members.
"""
return createCommandGroup(groupId, members.toArray(), false, null);
}
|
java
|
@Override
public CommandGroup createCommandGroup(String groupId, List<? extends AbstractCommand> members) {
return createCommandGroup(groupId, members.toArray(), false, null);
}
|
[
"@",
"Override",
"public",
"CommandGroup",
"createCommandGroup",
"(",
"String",
"groupId",
",",
"List",
"<",
"?",
"extends",
"AbstractCommand",
">",
"members",
")",
"{",
"return",
"createCommandGroup",
"(",
"groupId",
",",
"members",
".",
"toArray",
"(",
")",
",",
"false",
",",
"null",
")",
";",
"}"
] |
Create a command group which holds all the given members.
@param groupId the id to configure the group.
@param members members to add to the group.
@return a {@link CommandGroup} which contains all the members.
|
[
"Create",
"a",
"command",
"group",
"which",
"holds",
"all",
"the",
"given",
"members",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/DefaultCommandManager.java#L304-L307
|
baidubce/bce-sdk-java
|
src/main/java/com/baidubce/services/lss/LssClient.java
|
LssClient.pauseAppStream
|
public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) {
"""
Pause your app stream by app name and stream name
@param request The request object containing all parameters for pausing app session.
@return the response
"""
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
internalRequest.addParameter(PAUSE, null);
return invokeHttpClient(internalRequest, PauseAppStreamResponse.class);
}
|
java
|
public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
internalRequest.addParameter(PAUSE, null);
return invokeHttpClient(internalRequest, PauseAppStreamResponse.class);
}
|
[
"public",
"PauseAppStreamResponse",
"pauseAppStream",
"(",
"PauseAppStreamRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getApp",
"(",
")",
",",
"\"The parameter app should NOT be null or empty string.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getStream",
"(",
")",
",",
"\"The parameter stream should NOT be null or empty string.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"PUT",
",",
"request",
",",
"LIVE_APP",
",",
"request",
".",
"getApp",
"(",
")",
",",
"LIVE_SESSION",
",",
"request",
".",
"getStream",
"(",
")",
")",
";",
"internalRequest",
".",
"addParameter",
"(",
"PAUSE",
",",
"null",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"PauseAppStreamResponse",
".",
"class",
")",
";",
"}"
] |
Pause your app stream by app name and stream name
@param request The request object containing all parameters for pausing app session.
@return the response
|
[
"Pause",
"your",
"app",
"stream",
"by",
"app",
"name",
"and",
"stream",
"name"
] |
train
|
https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L920-L928
|
JOML-CI/JOML
|
src/org/joml/Quaternionf.java
|
Quaternionf.rotateTo
|
public Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) {
"""
Apply a rotation to <code>this</code> that rotates the <code>fromDir</code> vector to point along <code>toDir</code>.
<p>
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
<p>
If <code>Q</code> is <code>this</code> quaternion and <code>R</code> the quaternion representing the
specified rotation, then the new quaternion will be <code>Q * R</code>. So when transforming a
vector <code>v</code> with the new quaternion by using <code>Q * R * v</code>, the
rotation added by this method will be applied first!
@see #rotateTo(float, float, float, float, float, float, Quaternionf)
@param fromDirX
the x-coordinate of the direction to rotate into the destination direction
@param fromDirY
the y-coordinate of the direction to rotate into the destination direction
@param fromDirZ
the z-coordinate of the direction to rotate into the destination direction
@param toDirX
the x-coordinate of the direction to rotate to
@param toDirY
the y-coordinate of the direction to rotate to
@param toDirZ
the z-coordinate of the direction to rotate to
@return this
"""
return rotateTo(fromDirX, fromDirY, fromDirZ, toDirX, toDirY, toDirZ, this);
}
|
java
|
public Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) {
return rotateTo(fromDirX, fromDirY, fromDirZ, toDirX, toDirY, toDirZ, this);
}
|
[
"public",
"Quaternionf",
"rotateTo",
"(",
"float",
"fromDirX",
",",
"float",
"fromDirY",
",",
"float",
"fromDirZ",
",",
"float",
"toDirX",
",",
"float",
"toDirY",
",",
"float",
"toDirZ",
")",
"{",
"return",
"rotateTo",
"(",
"fromDirX",
",",
"fromDirY",
",",
"fromDirZ",
",",
"toDirX",
",",
"toDirY",
",",
"toDirZ",
",",
"this",
")",
";",
"}"
] |
Apply a rotation to <code>this</code> that rotates the <code>fromDir</code> vector to point along <code>toDir</code>.
<p>
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
<p>
If <code>Q</code> is <code>this</code> quaternion and <code>R</code> the quaternion representing the
specified rotation, then the new quaternion will be <code>Q * R</code>. So when transforming a
vector <code>v</code> with the new quaternion by using <code>Q * R * v</code>, the
rotation added by this method will be applied first!
@see #rotateTo(float, float, float, float, float, float, Quaternionf)
@param fromDirX
the x-coordinate of the direction to rotate into the destination direction
@param fromDirY
the y-coordinate of the direction to rotate into the destination direction
@param fromDirZ
the z-coordinate of the direction to rotate into the destination direction
@param toDirX
the x-coordinate of the direction to rotate to
@param toDirY
the y-coordinate of the direction to rotate to
@param toDirZ
the z-coordinate of the direction to rotate to
@return this
|
[
"Apply",
"a",
"rotation",
"to",
"<code",
">",
"this<",
"/",
"code",
">",
"that",
"rotates",
"the",
"<code",
">",
"fromDir<",
"/",
"code",
">",
"vector",
"to",
"point",
"along",
"<code",
">",
"toDir<",
"/",
"code",
">",
".",
"<p",
">",
"Since",
"there",
"can",
"be",
"multiple",
"possible",
"rotations",
"this",
"method",
"chooses",
"the",
"one",
"with",
"the",
"shortest",
"arc",
".",
"<p",
">",
"If",
"<code",
">",
"Q<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"quaternion",
"and",
"<code",
">",
"R<",
"/",
"code",
">",
"the",
"quaternion",
"representing",
"the",
"specified",
"rotation",
"then",
"the",
"new",
"quaternion",
"will",
"be",
"<code",
">",
"Q",
"*",
"R<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"quaternion",
"by",
"using",
"<code",
">",
"Q",
"*",
"R",
"*",
"v<",
"/",
"code",
">",
"the",
"rotation",
"added",
"by",
"this",
"method",
"will",
"be",
"applied",
"first!"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Quaternionf.java#L2324-L2326
|
kaazing/gateway
|
transport/ws/src/main/java/org/kaazing/gateway/transport/ws/bridge/filter/WsFrameEncodingSupport.java
|
WsFrameEncodingSupport.doEncode
|
public static IoBufferEx doEncode(IoBufferAllocatorEx<?> allocator, int flags, WsMessage message, int maskValue) {
"""
Encode WebSocket message as a single frame, with the provided masking value applied.
"""
final boolean mask = true;
IoBufferEx ioBuf = getBytes(allocator, flags, message);
ByteBuffer buf = ioBuf.buf();
boolean fin = message.isFin();
int remaining = buf.remaining();
int offset = 2 + (mask ? 4 : 0) + calculateLengthSize(remaining);
ByteBuffer b = allocator.allocate(offset + remaining, flags);
int start = b.position();
byte b1 = (byte) (fin ? 0x80 : 0x00);
byte b2 = (byte) (mask ? 0x80 : 0x00);
b1 = doEncodeOpcode(b1, message);
b2 |= lenBits(remaining);
b.put(b1).put(b2);
doEncodeLength(b, remaining);
if (mask) {
b.putInt(maskValue);
}
if ( mask ) {
WsFrameUtils.xor(buf, b, maskValue);
}
// reset buffer position after write in case of reuse
// (KG-8125) if shared, duplicate to ensure we don't affect other threads
if (ioBuf.isShared()) {
b.put(buf.duplicate());
}
else {
int bufPos = buf.position();
b.put(buf);
buf.position(bufPos);
}
b.limit(b.position());
b.position(start);
return allocator.wrap(b, flags);
}
|
java
|
public static IoBufferEx doEncode(IoBufferAllocatorEx<?> allocator, int flags, WsMessage message, int maskValue) {
final boolean mask = true;
IoBufferEx ioBuf = getBytes(allocator, flags, message);
ByteBuffer buf = ioBuf.buf();
boolean fin = message.isFin();
int remaining = buf.remaining();
int offset = 2 + (mask ? 4 : 0) + calculateLengthSize(remaining);
ByteBuffer b = allocator.allocate(offset + remaining, flags);
int start = b.position();
byte b1 = (byte) (fin ? 0x80 : 0x00);
byte b2 = (byte) (mask ? 0x80 : 0x00);
b1 = doEncodeOpcode(b1, message);
b2 |= lenBits(remaining);
b.put(b1).put(b2);
doEncodeLength(b, remaining);
if (mask) {
b.putInt(maskValue);
}
if ( mask ) {
WsFrameUtils.xor(buf, b, maskValue);
}
// reset buffer position after write in case of reuse
// (KG-8125) if shared, duplicate to ensure we don't affect other threads
if (ioBuf.isShared()) {
b.put(buf.duplicate());
}
else {
int bufPos = buf.position();
b.put(buf);
buf.position(bufPos);
}
b.limit(b.position());
b.position(start);
return allocator.wrap(b, flags);
}
|
[
"public",
"static",
"IoBufferEx",
"doEncode",
"(",
"IoBufferAllocatorEx",
"<",
"?",
">",
"allocator",
",",
"int",
"flags",
",",
"WsMessage",
"message",
",",
"int",
"maskValue",
")",
"{",
"final",
"boolean",
"mask",
"=",
"true",
";",
"IoBufferEx",
"ioBuf",
"=",
"getBytes",
"(",
"allocator",
",",
"flags",
",",
"message",
")",
";",
"ByteBuffer",
"buf",
"=",
"ioBuf",
".",
"buf",
"(",
")",
";",
"boolean",
"fin",
"=",
"message",
".",
"isFin",
"(",
")",
";",
"int",
"remaining",
"=",
"buf",
".",
"remaining",
"(",
")",
";",
"int",
"offset",
"=",
"2",
"+",
"(",
"mask",
"?",
"4",
":",
"0",
")",
"+",
"calculateLengthSize",
"(",
"remaining",
")",
";",
"ByteBuffer",
"b",
"=",
"allocator",
".",
"allocate",
"(",
"offset",
"+",
"remaining",
",",
"flags",
")",
";",
"int",
"start",
"=",
"b",
".",
"position",
"(",
")",
";",
"byte",
"b1",
"=",
"(",
"byte",
")",
"(",
"fin",
"?",
"0x80",
":",
"0x00",
")",
";",
"byte",
"b2",
"=",
"(",
"byte",
")",
"(",
"mask",
"?",
"0x80",
":",
"0x00",
")",
";",
"b1",
"=",
"doEncodeOpcode",
"(",
"b1",
",",
"message",
")",
";",
"b2",
"|=",
"lenBits",
"(",
"remaining",
")",
";",
"b",
".",
"put",
"(",
"b1",
")",
".",
"put",
"(",
"b2",
")",
";",
"doEncodeLength",
"(",
"b",
",",
"remaining",
")",
";",
"if",
"(",
"mask",
")",
"{",
"b",
".",
"putInt",
"(",
"maskValue",
")",
";",
"}",
"if",
"(",
"mask",
")",
"{",
"WsFrameUtils",
".",
"xor",
"(",
"buf",
",",
"b",
",",
"maskValue",
")",
";",
"}",
"// reset buffer position after write in case of reuse",
"// (KG-8125) if shared, duplicate to ensure we don't affect other threads",
"if",
"(",
"ioBuf",
".",
"isShared",
"(",
")",
")",
"{",
"b",
".",
"put",
"(",
"buf",
".",
"duplicate",
"(",
")",
")",
";",
"}",
"else",
"{",
"int",
"bufPos",
"=",
"buf",
".",
"position",
"(",
")",
";",
"b",
".",
"put",
"(",
"buf",
")",
";",
"buf",
".",
"position",
"(",
"bufPos",
")",
";",
"}",
"b",
".",
"limit",
"(",
"b",
".",
"position",
"(",
")",
")",
";",
"b",
".",
"position",
"(",
"start",
")",
";",
"return",
"allocator",
".",
"wrap",
"(",
"b",
",",
"flags",
")",
";",
"}"
] |
Encode WebSocket message as a single frame, with the provided masking value applied.
|
[
"Encode",
"WebSocket",
"message",
"as",
"a",
"single",
"frame",
"with",
"the",
"provided",
"masking",
"value",
"applied",
"."
] |
train
|
https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/transport/ws/src/main/java/org/kaazing/gateway/transport/ws/bridge/filter/WsFrameEncodingSupport.java#L35-L80
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/implementation/PredictionsImpl.java
|
PredictionsImpl.resolveWithServiceResponseAsync
|
public Observable<ServiceResponse<LuisResult>> resolveWithServiceResponseAsync(String appId, String query, ResolveOptionalParameter resolveOptionalParameter) {
"""
Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters.
@param appId The LUIS application ID (Guid).
@param query The utterance to predict.
@param resolveOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LuisResult object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (query == null) {
throw new IllegalArgumentException("Parameter query is required and cannot be null.");
}
final Double timezoneOffset = resolveOptionalParameter != null ? resolveOptionalParameter.timezoneOffset() : null;
final Boolean verbose = resolveOptionalParameter != null ? resolveOptionalParameter.verbose() : null;
final Boolean staging = resolveOptionalParameter != null ? resolveOptionalParameter.staging() : null;
final Boolean spellCheck = resolveOptionalParameter != null ? resolveOptionalParameter.spellCheck() : null;
final String bingSpellCheckSubscriptionKey = resolveOptionalParameter != null ? resolveOptionalParameter.bingSpellCheckSubscriptionKey() : null;
final Boolean log = resolveOptionalParameter != null ? resolveOptionalParameter.log() : null;
return resolveWithServiceResponseAsync(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log);
}
|
java
|
public Observable<ServiceResponse<LuisResult>> resolveWithServiceResponseAsync(String appId, String query, ResolveOptionalParameter resolveOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (query == null) {
throw new IllegalArgumentException("Parameter query is required and cannot be null.");
}
final Double timezoneOffset = resolveOptionalParameter != null ? resolveOptionalParameter.timezoneOffset() : null;
final Boolean verbose = resolveOptionalParameter != null ? resolveOptionalParameter.verbose() : null;
final Boolean staging = resolveOptionalParameter != null ? resolveOptionalParameter.staging() : null;
final Boolean spellCheck = resolveOptionalParameter != null ? resolveOptionalParameter.spellCheck() : null;
final String bingSpellCheckSubscriptionKey = resolveOptionalParameter != null ? resolveOptionalParameter.bingSpellCheckSubscriptionKey() : null;
final Boolean log = resolveOptionalParameter != null ? resolveOptionalParameter.log() : null;
return resolveWithServiceResponseAsync(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log);
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"LuisResult",
">",
">",
"resolveWithServiceResponseAsync",
"(",
"String",
"appId",
",",
"String",
"query",
",",
"ResolveOptionalParameter",
"resolveOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"query",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter query is required and cannot be null.\"",
")",
";",
"}",
"final",
"Double",
"timezoneOffset",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"timezoneOffset",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"verbose",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"verbose",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"staging",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"staging",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"spellCheck",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"spellCheck",
"(",
")",
":",
"null",
";",
"final",
"String",
"bingSpellCheckSubscriptionKey",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"bingSpellCheckSubscriptionKey",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"log",
"=",
"resolveOptionalParameter",
"!=",
"null",
"?",
"resolveOptionalParameter",
".",
"log",
"(",
")",
":",
"null",
";",
"return",
"resolveWithServiceResponseAsync",
"(",
"appId",
",",
"query",
",",
"timezoneOffset",
",",
"verbose",
",",
"staging",
",",
"spellCheck",
",",
"bingSpellCheckSubscriptionKey",
",",
"log",
")",
";",
"}"
] |
Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters.
@param appId The LUIS application ID (Guid).
@param query The utterance to predict.
@param resolveOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LuisResult object
|
[
"Gets",
"predictions",
"for",
"a",
"given",
"utterance",
"in",
"the",
"form",
"of",
"intents",
"and",
"entities",
".",
"The",
"current",
"maximum",
"query",
"size",
"is",
"500",
"characters",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/implementation/PredictionsImpl.java#L122-L140
|
ManfredTremmel/gwt-bean-validators
|
mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/CreditCardNumberValidator.java
|
CreditCardNumberValidator.isValid
|
@Override
public final boolean isValid(final String pvalue, final ConstraintValidatorContext pcontext) {
"""
{@inheritDoc} check if given string is a valid mail.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext)
"""
if (StringUtils.isEmpty(pvalue)) {
return true;
}
if (pvalue.length() > LENGTH_CREDIT_CARDNUMBER) {
// credit card number is to long, but that's handled by size annotation
return true;
}
return CHECK_CREDIT_CARD.isValid(pvalue);
}
|
java
|
@Override
public final boolean isValid(final String pvalue, final ConstraintValidatorContext pcontext) {
if (StringUtils.isEmpty(pvalue)) {
return true;
}
if (pvalue.length() > LENGTH_CREDIT_CARDNUMBER) {
// credit card number is to long, but that's handled by size annotation
return true;
}
return CHECK_CREDIT_CARD.isValid(pvalue);
}
|
[
"@",
"Override",
"public",
"final",
"boolean",
"isValid",
"(",
"final",
"String",
"pvalue",
",",
"final",
"ConstraintValidatorContext",
"pcontext",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"pvalue",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"pvalue",
".",
"length",
"(",
")",
">",
"LENGTH_CREDIT_CARDNUMBER",
")",
"{",
"// credit card number is to long, but that's handled by size annotation",
"return",
"true",
";",
"}",
"return",
"CHECK_CREDIT_CARD",
".",
"isValid",
"(",
"pvalue",
")",
";",
"}"
] |
{@inheritDoc} check if given string is a valid mail.
@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext)
|
[
"{",
"@inheritDoc",
"}",
"check",
"if",
"given",
"string",
"is",
"a",
"valid",
"mail",
"."
] |
train
|
https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/impl/CreditCardNumberValidator.java#L59-L69
|
elastic/elasticsearch-hadoop
|
mr/src/main/java/org/elasticsearch/hadoop/mr/security/TokenUtil.java
|
TokenUtil.obtainAndCache
|
public static void obtainAndCache(RestClient client, User user) throws IOException {
"""
Obtain an authentication token for the given user and add it to the
user's credentials.
@param client The Elasticsearch client
@param user The user for obtaining and storing the token
@throws IOException If making a remote call to the authentication service fails
"""
EsToken token = obtainEsToken(client, user);
if (token == null) {
throw new IOException("No token returned for user " + user.getKerberosPrincipal().getName());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Obtained token " + EsTokenIdentifier.KIND_NAME + " for user " +
user.getKerberosPrincipal().getName());
}
user.addEsToken(token);
}
|
java
|
public static void obtainAndCache(RestClient client, User user) throws IOException {
EsToken token = obtainEsToken(client, user);
if (token == null) {
throw new IOException("No token returned for user " + user.getKerberosPrincipal().getName());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Obtained token " + EsTokenIdentifier.KIND_NAME + " for user " +
user.getKerberosPrincipal().getName());
}
user.addEsToken(token);
}
|
[
"public",
"static",
"void",
"obtainAndCache",
"(",
"RestClient",
"client",
",",
"User",
"user",
")",
"throws",
"IOException",
"{",
"EsToken",
"token",
"=",
"obtainEsToken",
"(",
"client",
",",
"user",
")",
";",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"No token returned for user \"",
"+",
"user",
".",
"getKerberosPrincipal",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Obtained token \"",
"+",
"EsTokenIdentifier",
".",
"KIND_NAME",
"+",
"\" for user \"",
"+",
"user",
".",
"getKerberosPrincipal",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"user",
".",
"addEsToken",
"(",
"token",
")",
";",
"}"
] |
Obtain an authentication token for the given user and add it to the
user's credentials.
@param client The Elasticsearch client
@param user The user for obtaining and storing the token
@throws IOException If making a remote call to the authentication service fails
|
[
"Obtain",
"an",
"authentication",
"token",
"for",
"the",
"given",
"user",
"and",
"add",
"it",
"to",
"the",
"user",
"s",
"credentials",
"."
] |
train
|
https://github.com/elastic/elasticsearch-hadoop/blob/f3acaba268ff96efae8eb946088c748c777c22cc/mr/src/main/java/org/elasticsearch/hadoop/mr/security/TokenUtil.java#L99-L110
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/tools/StringTools.java
|
StringTools.assureSet
|
public static void assureSet(String s, String varName) {
"""
Throw exception if the given string is null or empty or only whitespace.
"""
Objects.requireNonNull(varName);
if (isEmpty(s.trim())) {
throw new IllegalArgumentException(varName + " cannot be empty or whitespace only");
}
}
|
java
|
public static void assureSet(String s, String varName) {
Objects.requireNonNull(varName);
if (isEmpty(s.trim())) {
throw new IllegalArgumentException(varName + " cannot be empty or whitespace only");
}
}
|
[
"public",
"static",
"void",
"assureSet",
"(",
"String",
"s",
",",
"String",
"varName",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"varName",
")",
";",
"if",
"(",
"isEmpty",
"(",
"s",
".",
"trim",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"varName",
"+",
"\" cannot be empty or whitespace only\"",
")",
";",
"}",
"}"
] |
Throw exception if the given string is null or empty or only whitespace.
|
[
"Throw",
"exception",
"if",
"the",
"given",
"string",
"is",
"null",
"or",
"empty",
"or",
"only",
"whitespace",
"."
] |
train
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/tools/StringTools.java#L82-L87
|
prestodb/presto
|
presto-spi/src/main/java/com/facebook/presto/spi/function/Signature.java
|
Signature.withVariadicBound
|
public static TypeVariableConstraint withVariadicBound(String name, String variadicBound) {
"""
/*
similar to T extends MyClass<?...>, if Java supported varargs wildcards
"""
return new TypeVariableConstraint(name, false, false, variadicBound);
}
|
java
|
public static TypeVariableConstraint withVariadicBound(String name, String variadicBound)
{
return new TypeVariableConstraint(name, false, false, variadicBound);
}
|
[
"public",
"static",
"TypeVariableConstraint",
"withVariadicBound",
"(",
"String",
"name",
",",
"String",
"variadicBound",
")",
"{",
"return",
"new",
"TypeVariableConstraint",
"(",
"name",
",",
"false",
",",
"false",
",",
"variadicBound",
")",
";",
"}"
] |
/*
similar to T extends MyClass<?...>, if Java supported varargs wildcards
|
[
"/",
"*",
"similar",
"to",
"T",
"extends",
"MyClass<?",
"...",
">",
"if",
"Java",
"supported",
"varargs",
"wildcards"
] |
train
|
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-spi/src/main/java/com/facebook/presto/spi/function/Signature.java#L161-L164
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/util/internal/FileUtils.java
|
FileUtils.osSensitiveEquals
|
public static boolean osSensitiveEquals( String s1, String s2 ) {
"""
Compare two strings, with case sensitivity determined by the operating system.
@param s1 the first String to compare.
@param s2 the second String to compare.
@return <code>true</code> when:
<ul>
<li>the strings match exactly (including case), or,</li>
<li>the operating system is not case-sensitive with regard to file names, and the strings match,
ignoring case.</li>
</ul>
@see #isOSCaseSensitive()
"""
if ( OS_CASE_SENSITIVE )
{
return s1.equals( s2 );
}
else
{
return s1.equalsIgnoreCase( s2 );
}
}
|
java
|
public static boolean osSensitiveEquals( String s1, String s2 )
{
if ( OS_CASE_SENSITIVE )
{
return s1.equals( s2 );
}
else
{
return s1.equalsIgnoreCase( s2 );
}
}
|
[
"public",
"static",
"boolean",
"osSensitiveEquals",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"OS_CASE_SENSITIVE",
")",
"{",
"return",
"s1",
".",
"equals",
"(",
"s2",
")",
";",
"}",
"else",
"{",
"return",
"s1",
".",
"equalsIgnoreCase",
"(",
"s2",
")",
";",
"}",
"}"
] |
Compare two strings, with case sensitivity determined by the operating system.
@param s1 the first String to compare.
@param s2 the second String to compare.
@return <code>true</code> when:
<ul>
<li>the strings match exactly (including case), or,</li>
<li>the operating system is not case-sensitive with regard to file names, and the strings match,
ignoring case.</li>
</ul>
@see #isOSCaseSensitive()
|
[
"Compare",
"two",
"strings",
"with",
"case",
"sensitivity",
"determined",
"by",
"the",
"operating",
"system",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/util/internal/FileUtils.java#L116-L126
|
crnk-project/crnk-framework
|
crnk-core/src/main/java/io/crnk/core/engine/information/resource/ResourceInformation.java
|
ResourceInformation.absentAnySetter
|
private static boolean absentAnySetter(Method jsonAnyGetter, Method jsonAnySetter) {
"""
The resource has to have both method annotated with {@link JsonAnySetter} and {@link JsonAnyGetter} to allow
proper handling.
@return <i>true</i> if resource definition is incomplete, <i>false</i> otherwise
"""
return (jsonAnySetter == null && jsonAnyGetter != null) ||
(jsonAnySetter != null && jsonAnyGetter == null);
}
|
java
|
private static boolean absentAnySetter(Method jsonAnyGetter, Method jsonAnySetter) {
return (jsonAnySetter == null && jsonAnyGetter != null) ||
(jsonAnySetter != null && jsonAnyGetter == null);
}
|
[
"private",
"static",
"boolean",
"absentAnySetter",
"(",
"Method",
"jsonAnyGetter",
",",
"Method",
"jsonAnySetter",
")",
"{",
"return",
"(",
"jsonAnySetter",
"==",
"null",
"&&",
"jsonAnyGetter",
"!=",
"null",
")",
"||",
"(",
"jsonAnySetter",
"!=",
"null",
"&&",
"jsonAnyGetter",
"==",
"null",
")",
";",
"}"
] |
The resource has to have both method annotated with {@link JsonAnySetter} and {@link JsonAnyGetter} to allow
proper handling.
@return <i>true</i> if resource definition is incomplete, <i>false</i> otherwise
|
[
"The",
"resource",
"has",
"to",
"have",
"both",
"method",
"annotated",
"with",
"{",
"@link",
"JsonAnySetter",
"}",
"and",
"{",
"@link",
"JsonAnyGetter",
"}",
"to",
"allow",
"proper",
"handling",
"."
] |
train
|
https://github.com/crnk-project/crnk-framework/blob/2fd3ef9a991788d46fd2e83b43c8ea37cbaf8681/crnk-core/src/main/java/io/crnk/core/engine/information/resource/ResourceInformation.java#L416-L419
|
logic-ng/LogicNG
|
src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java
|
CCTotalizer.buildAMK
|
void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) {
"""
Builds an at-most-k constraint.
@param result the result
@param vars the variables
@param rhs the right-hand side
@throws IllegalArgumentException if the right hand side of the constraint was negative
"""
final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars);
this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars);
this.toCNF(cardinalityOutvars, rhs, Bound.UPPER);
assert this.cardinalityInvars.size() == 0;
for (int i = rhs; i < cardinalityOutvars.size(); i++)
this.result.addClause(cardinalityOutvars.get(i).negate());
}
|
java
|
void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) {
final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars);
this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars);
this.toCNF(cardinalityOutvars, rhs, Bound.UPPER);
assert this.cardinalityInvars.size() == 0;
for (int i = rhs; i < cardinalityOutvars.size(); i++)
this.result.addClause(cardinalityOutvars.get(i).negate());
}
|
[
"void",
"buildAMK",
"(",
"final",
"EncodingResult",
"result",
",",
"final",
"Variable",
"[",
"]",
"vars",
",",
"int",
"rhs",
")",
"{",
"final",
"LNGVector",
"<",
"Variable",
">",
"cardinalityOutvars",
"=",
"this",
".",
"initializeConstraint",
"(",
"result",
",",
"vars",
")",
";",
"this",
".",
"incData",
"=",
"new",
"CCIncrementalData",
"(",
"result",
",",
"CCConfig",
".",
"AMK_ENCODER",
".",
"TOTALIZER",
",",
"rhs",
",",
"cardinalityOutvars",
")",
";",
"this",
".",
"toCNF",
"(",
"cardinalityOutvars",
",",
"rhs",
",",
"Bound",
".",
"UPPER",
")",
";",
"assert",
"this",
".",
"cardinalityInvars",
".",
"size",
"(",
")",
"==",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"rhs",
";",
"i",
"<",
"cardinalityOutvars",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"this",
".",
"result",
".",
"addClause",
"(",
"cardinalityOutvars",
".",
"get",
"(",
"i",
")",
".",
"negate",
"(",
")",
")",
";",
"}"
] |
Builds an at-most-k constraint.
@param result the result
@param vars the variables
@param rhs the right-hand side
@throws IllegalArgumentException if the right hand side of the constraint was negative
|
[
"Builds",
"an",
"at",
"-",
"most",
"-",
"k",
"constraint",
"."
] |
train
|
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L83-L90
|
svenkubiak/mangooio
|
mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java
|
ControllerRoute.withBasicAuthentication
|
public ControllerRoute withBasicAuthentication(String username, String password, String secret) {
"""
Sets Basic HTTP authentication to all method on the given controller class
@param username The username for basic authentication in clear text
@param password The password for basic authentication in clear text
@param secret The secret used for 2FA
@return controller route instance
"""
Objects.requireNonNull(username, Required.USERNAME.toString());
Objects.requireNonNull(password, Required.PASSWORD.toString());
Objects.requireNonNull(password, Required.SECRET.toString());
this.username = username;
this.password = password;
this.secret = secret;
return this;
}
|
java
|
public ControllerRoute withBasicAuthentication(String username, String password, String secret) {
Objects.requireNonNull(username, Required.USERNAME.toString());
Objects.requireNonNull(password, Required.PASSWORD.toString());
Objects.requireNonNull(password, Required.SECRET.toString());
this.username = username;
this.password = password;
this.secret = secret;
return this;
}
|
[
"public",
"ControllerRoute",
"withBasicAuthentication",
"(",
"String",
"username",
",",
"String",
"password",
",",
"String",
"secret",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"username",
",",
"Required",
".",
"USERNAME",
".",
"toString",
"(",
")",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"password",
",",
"Required",
".",
"PASSWORD",
".",
"toString",
"(",
")",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"password",
",",
"Required",
".",
"SECRET",
".",
"toString",
"(",
")",
")",
";",
"this",
".",
"username",
"=",
"username",
";",
"this",
".",
"password",
"=",
"password",
";",
"this",
".",
"secret",
"=",
"secret",
";",
"return",
"this",
";",
"}"
] |
Sets Basic HTTP authentication to all method on the given controller class
@param username The username for basic authentication in clear text
@param password The password for basic authentication in clear text
@param secret The secret used for 2FA
@return controller route instance
|
[
"Sets",
"Basic",
"HTTP",
"authentication",
"to",
"all",
"method",
"on",
"the",
"given",
"controller",
"class"
] |
train
|
https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java#L108-L118
|
jbundle/jbundle
|
thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java
|
ThinTableModel.cacheCurrentLockedData
|
public BaseBuffer cacheCurrentLockedData(int iRowIndex, FieldList fieldList) {
"""
Get the array of changed values for the current row.
I use a standard field buffer and append all the screen items which
are not included in the field.
@param iRowIndex The row to get the data for.
@return The array of data for the currently locked row.
"""
int iColumnCount = this.getColumnCount();
if ((m_buffCurrentLockedData == null) || (m_iCurrentLockedRowIndex != iRowIndex))
m_buffCurrentLockedData = new VectorBuffer(null, BaseBuffer.ALL_FIELDS);
m_buffCurrentLockedData.fieldsToBuffer(fieldList);
for (int i = 0; i < iColumnCount; i++)
{ // Cache the non-field data
Field field = null;
if (this.getFieldInfo(i) != null)
field = this.getFieldInfo(i).getField();
if ((field != null) && (field.getRecord() != fieldList))
m_buffCurrentLockedData.addNextString(field.toString());
}
m_iCurrentLockedRowIndex = iRowIndex;
return m_buffCurrentLockedData;
}
|
java
|
public BaseBuffer cacheCurrentLockedData(int iRowIndex, FieldList fieldList)
{
int iColumnCount = this.getColumnCount();
if ((m_buffCurrentLockedData == null) || (m_iCurrentLockedRowIndex != iRowIndex))
m_buffCurrentLockedData = new VectorBuffer(null, BaseBuffer.ALL_FIELDS);
m_buffCurrentLockedData.fieldsToBuffer(fieldList);
for (int i = 0; i < iColumnCount; i++)
{ // Cache the non-field data
Field field = null;
if (this.getFieldInfo(i) != null)
field = this.getFieldInfo(i).getField();
if ((field != null) && (field.getRecord() != fieldList))
m_buffCurrentLockedData.addNextString(field.toString());
}
m_iCurrentLockedRowIndex = iRowIndex;
return m_buffCurrentLockedData;
}
|
[
"public",
"BaseBuffer",
"cacheCurrentLockedData",
"(",
"int",
"iRowIndex",
",",
"FieldList",
"fieldList",
")",
"{",
"int",
"iColumnCount",
"=",
"this",
".",
"getColumnCount",
"(",
")",
";",
"if",
"(",
"(",
"m_buffCurrentLockedData",
"==",
"null",
")",
"||",
"(",
"m_iCurrentLockedRowIndex",
"!=",
"iRowIndex",
")",
")",
"m_buffCurrentLockedData",
"=",
"new",
"VectorBuffer",
"(",
"null",
",",
"BaseBuffer",
".",
"ALL_FIELDS",
")",
";",
"m_buffCurrentLockedData",
".",
"fieldsToBuffer",
"(",
"fieldList",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"iColumnCount",
";",
"i",
"++",
")",
"{",
"// Cache the non-field data",
"Field",
"field",
"=",
"null",
";",
"if",
"(",
"this",
".",
"getFieldInfo",
"(",
"i",
")",
"!=",
"null",
")",
"field",
"=",
"this",
".",
"getFieldInfo",
"(",
"i",
")",
".",
"getField",
"(",
")",
";",
"if",
"(",
"(",
"field",
"!=",
"null",
")",
"&&",
"(",
"field",
".",
"getRecord",
"(",
")",
"!=",
"fieldList",
")",
")",
"m_buffCurrentLockedData",
".",
"addNextString",
"(",
"field",
".",
"toString",
"(",
")",
")",
";",
"}",
"m_iCurrentLockedRowIndex",
"=",
"iRowIndex",
";",
"return",
"m_buffCurrentLockedData",
";",
"}"
] |
Get the array of changed values for the current row.
I use a standard field buffer and append all the screen items which
are not included in the field.
@param iRowIndex The row to get the data for.
@return The array of data for the currently locked row.
|
[
"Get",
"the",
"array",
"of",
"changed",
"values",
"for",
"the",
"current",
"row",
".",
"I",
"use",
"a",
"standard",
"field",
"buffer",
"and",
"append",
"all",
"the",
"screen",
"items",
"which",
"are",
"not",
"included",
"in",
"the",
"field",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java#L245-L261
|
medined/d4m
|
src/main/java/com/codebits/d4m/TableManager.java
|
TableManager.addSplits
|
public void addSplits(final String tablename, final SortedSet<Text> splits) {
"""
Pre-split the Tedge and TedgeText tables.
@param tablename name of the accumulo table
@param splits set of splits to add
"""
try {
tableOperations.addSplits(tablename, splits);
} catch (TableNotFoundException e) {
throw new D4MException(String.format("Unable to find table [%s]", tablename), e);
} catch (AccumuloException | AccumuloSecurityException e) {
throw new D4MException(String.format("Unable to add splits to table [%s]", tablename), e);
}
}
|
java
|
public void addSplits(final String tablename, final SortedSet<Text> splits) {
try {
tableOperations.addSplits(tablename, splits);
} catch (TableNotFoundException e) {
throw new D4MException(String.format("Unable to find table [%s]", tablename), e);
} catch (AccumuloException | AccumuloSecurityException e) {
throw new D4MException(String.format("Unable to add splits to table [%s]", tablename), e);
}
}
|
[
"public",
"void",
"addSplits",
"(",
"final",
"String",
"tablename",
",",
"final",
"SortedSet",
"<",
"Text",
">",
"splits",
")",
"{",
"try",
"{",
"tableOperations",
".",
"addSplits",
"(",
"tablename",
",",
"splits",
")",
";",
"}",
"catch",
"(",
"TableNotFoundException",
"e",
")",
"{",
"throw",
"new",
"D4MException",
"(",
"String",
".",
"format",
"(",
"\"Unable to find table [%s]\"",
",",
"tablename",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"AccumuloException",
"|",
"AccumuloSecurityException",
"e",
")",
"{",
"throw",
"new",
"D4MException",
"(",
"String",
".",
"format",
"(",
"\"Unable to add splits to table [%s]\"",
",",
"tablename",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Pre-split the Tedge and TedgeText tables.
@param tablename name of the accumulo table
@param splits set of splits to add
|
[
"Pre",
"-",
"split",
"the",
"Tedge",
"and",
"TedgeText",
"tables",
"."
] |
train
|
https://github.com/medined/d4m/blob/b61100609fba6961f6c903fcf96b687122c5bf05/src/main/java/com/codebits/d4m/TableManager.java#L205-L213
|
mozilla/rhino
|
src/org/mozilla/javascript/NativeJavaObject.java
|
NativeJavaObject.canConvert
|
public static boolean canConvert(Object fromObj, Class<?> to) {
"""
Determine whether we can/should convert between the given type and the
desired one. This should be superceded by a conversion-cost calculation
function, but for now I'll hide behind precedent.
"""
int weight = getConversionWeight(fromObj, to);
return (weight < CONVERSION_NONE);
}
|
java
|
public static boolean canConvert(Object fromObj, Class<?> to) {
int weight = getConversionWeight(fromObj, to);
return (weight < CONVERSION_NONE);
}
|
[
"public",
"static",
"boolean",
"canConvert",
"(",
"Object",
"fromObj",
",",
"Class",
"<",
"?",
">",
"to",
")",
"{",
"int",
"weight",
"=",
"getConversionWeight",
"(",
"fromObj",
",",
"to",
")",
";",
"return",
"(",
"weight",
"<",
"CONVERSION_NONE",
")",
";",
"}"
] |
Determine whether we can/should convert between the given type and the
desired one. This should be superceded by a conversion-cost calculation
function, but for now I'll hide behind precedent.
|
[
"Determine",
"whether",
"we",
"can",
"/",
"should",
"convert",
"between",
"the",
"given",
"type",
"and",
"the",
"desired",
"one",
".",
"This",
"should",
"be",
"superceded",
"by",
"a",
"conversion",
"-",
"cost",
"calculation",
"function",
"but",
"for",
"now",
"I",
"ll",
"hide",
"behind",
"precedent",
"."
] |
train
|
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeJavaObject.java#L239-L243
|
samskivert/pythagoras
|
src/main/java/pythagoras/d/Plane.java
|
Plane.fromPointNormal
|
public Plane fromPointNormal (IVector3 pt, IVector3 normal) {
"""
Sets this plane based on a point on the plane and the plane normal.
@return a reference to the plane (for chaining).
"""
return set(normal, -normal.dot(pt));
}
|
java
|
public Plane fromPointNormal (IVector3 pt, IVector3 normal) {
return set(normal, -normal.dot(pt));
}
|
[
"public",
"Plane",
"fromPointNormal",
"(",
"IVector3",
"pt",
",",
"IVector3",
"normal",
")",
"{",
"return",
"set",
"(",
"normal",
",",
"-",
"normal",
".",
"dot",
"(",
"pt",
")",
")",
";",
"}"
] |
Sets this plane based on a point on the plane and the plane normal.
@return a reference to the plane (for chaining).
|
[
"Sets",
"this",
"plane",
"based",
"on",
"a",
"point",
"on",
"the",
"plane",
"and",
"the",
"plane",
"normal",
"."
] |
train
|
https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/Plane.java#L125-L127
|
opengeospatial/teamengine
|
teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java
|
LogUtils.generateSessionId
|
public static String generateSessionId(File logDir) {
"""
Generates a session identifier. The value corresponds to the name of a
sub-directory (session) in the root test log directory.
@return a session id string ("s0001" by default, unless the session
sub-directory already exists).
"""
int i = 1;
String session = "s0001";
while (new File(logDir, session).exists() && i < 10000) {
i++;
session = "s" + Integer.toString(10000 + i).substring(1);
}
return session;
}
|
java
|
public static String generateSessionId(File logDir) {
int i = 1;
String session = "s0001";
while (new File(logDir, session).exists() && i < 10000) {
i++;
session = "s" + Integer.toString(10000 + i).substring(1);
}
return session;
}
|
[
"public",
"static",
"String",
"generateSessionId",
"(",
"File",
"logDir",
")",
"{",
"int",
"i",
"=",
"1",
";",
"String",
"session",
"=",
"\"s0001\"",
";",
"while",
"(",
"new",
"File",
"(",
"logDir",
",",
"session",
")",
".",
"exists",
"(",
")",
"&&",
"i",
"<",
"10000",
")",
"{",
"i",
"++",
";",
"session",
"=",
"\"s\"",
"+",
"Integer",
".",
"toString",
"(",
"10000",
"+",
"i",
")",
".",
"substring",
"(",
"1",
")",
";",
"}",
"return",
"session",
";",
"}"
] |
Generates a session identifier. The value corresponds to the name of a
sub-directory (session) in the root test log directory.
@return a session id string ("s0001" by default, unless the session
sub-directory already exists).
|
[
"Generates",
"a",
"session",
"identifier",
".",
"The",
"value",
"corresponds",
"to",
"the",
"name",
"of",
"a",
"sub",
"-",
"directory",
"(",
"session",
")",
"in",
"the",
"root",
"test",
"log",
"directory",
"."
] |
train
|
https://github.com/opengeospatial/teamengine/blob/b6b890214b6784bbe19460bf753bdf28a9514bee/teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java#L421-L429
|
buschmais/extended-objects
|
impl/src/main/java/com/buschmais/xo/impl/ProxyFactory.java
|
ProxyFactory.createInstance
|
public <Instance> Instance createInstance(InvocationHandler invocationHandler, CompositeType compositeType) {
"""
Creates a proxy instance.
@param invocationHandler
The {@link java.lang.reflect.InvocationHandler}.
@param compositeType
The composite type to create an instance for.
@param <Instance>
The instance type.
@return The instance.
"""
Class<?>[] classes = compositeType.getClasses();
Constructor<?> constructor = classCache.getIfPresent(compositeType);
if (constructor == null) {
Class<?> type;
try {
type = Proxy.getProxyClass(classLoader, classes);
} catch (IllegalArgumentException e) {
throw new XOException("Cannot create proxy for " + compositeType + " of classes " + compositeType.getClasses(), e);
}
try {
constructor = type.getConstructor(new Class<?>[] { InvocationHandler.class });
} catch (NoSuchMethodException e) {
throw new XOException("Cannot find constructor for " + compositeType, e);
}
classCache.put(compositeType, constructor);
}
Instance instance;
try {
instance = (Instance) constructor.newInstance(invocationHandler);
} catch (Exception e) {
throw new XOException("Cannot create instance of " + compositeType, e);
}
return interceptorFactory.addInterceptor(instance, classes);
}
|
java
|
public <Instance> Instance createInstance(InvocationHandler invocationHandler, CompositeType compositeType) {
Class<?>[] classes = compositeType.getClasses();
Constructor<?> constructor = classCache.getIfPresent(compositeType);
if (constructor == null) {
Class<?> type;
try {
type = Proxy.getProxyClass(classLoader, classes);
} catch (IllegalArgumentException e) {
throw new XOException("Cannot create proxy for " + compositeType + " of classes " + compositeType.getClasses(), e);
}
try {
constructor = type.getConstructor(new Class<?>[] { InvocationHandler.class });
} catch (NoSuchMethodException e) {
throw new XOException("Cannot find constructor for " + compositeType, e);
}
classCache.put(compositeType, constructor);
}
Instance instance;
try {
instance = (Instance) constructor.newInstance(invocationHandler);
} catch (Exception e) {
throw new XOException("Cannot create instance of " + compositeType, e);
}
return interceptorFactory.addInterceptor(instance, classes);
}
|
[
"public",
"<",
"Instance",
">",
"Instance",
"createInstance",
"(",
"InvocationHandler",
"invocationHandler",
",",
"CompositeType",
"compositeType",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
"=",
"compositeType",
".",
"getClasses",
"(",
")",
";",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"classCache",
".",
"getIfPresent",
"(",
"compositeType",
")",
";",
"if",
"(",
"constructor",
"==",
"null",
")",
"{",
"Class",
"<",
"?",
">",
"type",
";",
"try",
"{",
"type",
"=",
"Proxy",
".",
"getProxyClass",
"(",
"classLoader",
",",
"classes",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"XOException",
"(",
"\"Cannot create proxy for \"",
"+",
"compositeType",
"+",
"\" of classes \"",
"+",
"compositeType",
".",
"getClasses",
"(",
")",
",",
"e",
")",
";",
"}",
"try",
"{",
"constructor",
"=",
"type",
".",
"getConstructor",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"InvocationHandler",
".",
"class",
"}",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"throw",
"new",
"XOException",
"(",
"\"Cannot find constructor for \"",
"+",
"compositeType",
",",
"e",
")",
";",
"}",
"classCache",
".",
"put",
"(",
"compositeType",
",",
"constructor",
")",
";",
"}",
"Instance",
"instance",
";",
"try",
"{",
"instance",
"=",
"(",
"Instance",
")",
"constructor",
".",
"newInstance",
"(",
"invocationHandler",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"XOException",
"(",
"\"Cannot create instance of \"",
"+",
"compositeType",
",",
"e",
")",
";",
"}",
"return",
"interceptorFactory",
".",
"addInterceptor",
"(",
"instance",
",",
"classes",
")",
";",
"}"
] |
Creates a proxy instance.
@param invocationHandler
The {@link java.lang.reflect.InvocationHandler}.
@param compositeType
The composite type to create an instance for.
@param <Instance>
The instance type.
@return The instance.
|
[
"Creates",
"a",
"proxy",
"instance",
"."
] |
train
|
https://github.com/buschmais/extended-objects/blob/186431e81f3d8d26c511cfe1143dee59b03c2e7a/impl/src/main/java/com/buschmais/xo/impl/ProxyFactory.java#L50-L74
|
Coveros/selenified
|
src/main/java/com/coveros/selenified/application/WaitFor.java
|
WaitFor.cookieMatches
|
public void cookieMatches(double seconds, String cookieName, String expectedCookiePattern) {
"""
Waits up to the provided wait time for a cookies with the provided name has a value matching the
expected pattern. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param cookieName the name of the cookie
@param expectedCookiePattern the expected value of the cookie
@param seconds the number of seconds to wait
"""
double end = System.currentTimeMillis() + (seconds * 1000);
while (app.is().cookiePresent(cookieName) && System.currentTimeMillis() < end) ;
if (app.is().cookiePresent(cookieName)) {
while (!app.get().cookieValue(cookieName).matches(expectedCookiePattern) && System.currentTimeMillis() < end) ;
}
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkCookieMatches(cookieName, expectedCookiePattern, seconds, timeTook);
}
|
java
|
public void cookieMatches(double seconds, String cookieName, String expectedCookiePattern) {
double end = System.currentTimeMillis() + (seconds * 1000);
while (app.is().cookiePresent(cookieName) && System.currentTimeMillis() < end) ;
if (app.is().cookiePresent(cookieName)) {
while (!app.get().cookieValue(cookieName).matches(expectedCookiePattern) && System.currentTimeMillis() < end) ;
}
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkCookieMatches(cookieName, expectedCookiePattern, seconds, timeTook);
}
|
[
"public",
"void",
"cookieMatches",
"(",
"double",
"seconds",
",",
"String",
"cookieName",
",",
"String",
"expectedCookiePattern",
")",
"{",
"double",
"end",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"(",
"seconds",
"*",
"1000",
")",
";",
"while",
"(",
"app",
".",
"is",
"(",
")",
".",
"cookiePresent",
"(",
"cookieName",
")",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"end",
")",
";",
"if",
"(",
"app",
".",
"is",
"(",
")",
".",
"cookiePresent",
"(",
"cookieName",
")",
")",
"{",
"while",
"(",
"!",
"app",
".",
"get",
"(",
")",
".",
"cookieValue",
"(",
"cookieName",
")",
".",
"matches",
"(",
"expectedCookiePattern",
")",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"end",
")",
";",
"}",
"double",
"timeTook",
"=",
"Math",
".",
"min",
"(",
"(",
"seconds",
"*",
"1000",
")",
"-",
"(",
"end",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
",",
"seconds",
"*",
"1000",
")",
"/",
"1000",
";",
"checkCookieMatches",
"(",
"cookieName",
",",
"expectedCookiePattern",
",",
"seconds",
",",
"timeTook",
")",
";",
"}"
] |
Waits up to the provided wait time for a cookies with the provided name has a value matching the
expected pattern. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param cookieName the name of the cookie
@param expectedCookiePattern the expected value of the cookie
@param seconds the number of seconds to wait
|
[
"Waits",
"up",
"to",
"the",
"provided",
"wait",
"time",
"for",
"a",
"cookies",
"with",
"the",
"provided",
"name",
"has",
"a",
"value",
"matching",
"the",
"expected",
"pattern",
".",
"This",
"information",
"will",
"be",
"logged",
"and",
"recorded",
"with",
"a",
"screenshot",
"for",
"traceability",
"and",
"added",
"debugging",
"support",
"."
] |
train
|
https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/application/WaitFor.java#L744-L752
|
weld/core
|
impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java
|
InterceptedSubclassFactory.addSpecialMethods
|
protected void addSpecialMethods(ClassFile proxyClassType, ClassMethod staticConstructor) {
"""
Adds methods requiring special implementations rather than just
delegation.
@param proxyClassType the Javassist class description for the proxy type
"""
try {
// Add special methods for interceptors
for (Method method : LifecycleMixin.class.getMethods()) {
BeanLogger.LOG.addingMethodToProxy(method);
MethodInformation methodInfo = new RuntimeMethodInformation(method);
createInterceptorBody(proxyClassType.addMethod(method), methodInfo, false, staticConstructor);
}
Method getInstanceMethod = TargetInstanceProxy.class.getMethod("weld_getTargetInstance");
Method getInstanceClassMethod = TargetInstanceProxy.class.getMethod("weld_getTargetClass");
generateGetTargetInstanceBody(proxyClassType.addMethod(getInstanceMethod));
generateGetTargetClassBody(proxyClassType.addMethod(getInstanceClassMethod));
Method setMethodHandlerMethod = ProxyObject.class.getMethod("weld_setHandler", MethodHandler.class);
generateSetMethodHandlerBody(proxyClassType.addMethod(setMethodHandlerMethod));
Method getMethodHandlerMethod = ProxyObject.class.getMethod("weld_getHandler");
generateGetMethodHandlerBody(proxyClassType.addMethod(getMethodHandlerMethod));
} catch (Exception e) {
throw new WeldException(e);
}
}
|
java
|
protected void addSpecialMethods(ClassFile proxyClassType, ClassMethod staticConstructor) {
try {
// Add special methods for interceptors
for (Method method : LifecycleMixin.class.getMethods()) {
BeanLogger.LOG.addingMethodToProxy(method);
MethodInformation methodInfo = new RuntimeMethodInformation(method);
createInterceptorBody(proxyClassType.addMethod(method), methodInfo, false, staticConstructor);
}
Method getInstanceMethod = TargetInstanceProxy.class.getMethod("weld_getTargetInstance");
Method getInstanceClassMethod = TargetInstanceProxy.class.getMethod("weld_getTargetClass");
generateGetTargetInstanceBody(proxyClassType.addMethod(getInstanceMethod));
generateGetTargetClassBody(proxyClassType.addMethod(getInstanceClassMethod));
Method setMethodHandlerMethod = ProxyObject.class.getMethod("weld_setHandler", MethodHandler.class);
generateSetMethodHandlerBody(proxyClassType.addMethod(setMethodHandlerMethod));
Method getMethodHandlerMethod = ProxyObject.class.getMethod("weld_getHandler");
generateGetMethodHandlerBody(proxyClassType.addMethod(getMethodHandlerMethod));
} catch (Exception e) {
throw new WeldException(e);
}
}
|
[
"protected",
"void",
"addSpecialMethods",
"(",
"ClassFile",
"proxyClassType",
",",
"ClassMethod",
"staticConstructor",
")",
"{",
"try",
"{",
"// Add special methods for interceptors",
"for",
"(",
"Method",
"method",
":",
"LifecycleMixin",
".",
"class",
".",
"getMethods",
"(",
")",
")",
"{",
"BeanLogger",
".",
"LOG",
".",
"addingMethodToProxy",
"(",
"method",
")",
";",
"MethodInformation",
"methodInfo",
"=",
"new",
"RuntimeMethodInformation",
"(",
"method",
")",
";",
"createInterceptorBody",
"(",
"proxyClassType",
".",
"addMethod",
"(",
"method",
")",
",",
"methodInfo",
",",
"false",
",",
"staticConstructor",
")",
";",
"}",
"Method",
"getInstanceMethod",
"=",
"TargetInstanceProxy",
".",
"class",
".",
"getMethod",
"(",
"\"weld_getTargetInstance\"",
")",
";",
"Method",
"getInstanceClassMethod",
"=",
"TargetInstanceProxy",
".",
"class",
".",
"getMethod",
"(",
"\"weld_getTargetClass\"",
")",
";",
"generateGetTargetInstanceBody",
"(",
"proxyClassType",
".",
"addMethod",
"(",
"getInstanceMethod",
")",
")",
";",
"generateGetTargetClassBody",
"(",
"proxyClassType",
".",
"addMethod",
"(",
"getInstanceClassMethod",
")",
")",
";",
"Method",
"setMethodHandlerMethod",
"=",
"ProxyObject",
".",
"class",
".",
"getMethod",
"(",
"\"weld_setHandler\"",
",",
"MethodHandler",
".",
"class",
")",
";",
"generateSetMethodHandlerBody",
"(",
"proxyClassType",
".",
"addMethod",
"(",
"setMethodHandlerMethod",
")",
")",
";",
"Method",
"getMethodHandlerMethod",
"=",
"ProxyObject",
".",
"class",
".",
"getMethod",
"(",
"\"weld_getHandler\"",
")",
";",
"generateGetMethodHandlerBody",
"(",
"proxyClassType",
".",
"addMethod",
"(",
"getMethodHandlerMethod",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"WeldException",
"(",
"e",
")",
";",
"}",
"}"
] |
Adds methods requiring special implementations rather than just
delegation.
@param proxyClassType the Javassist class description for the proxy type
|
[
"Adds",
"methods",
"requiring",
"special",
"implementations",
"rather",
"than",
"just",
"delegation",
"."
] |
train
|
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java#L472-L493
|
facebookarchive/hadoop-20
|
src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java
|
FairScheduler.mergeJobs
|
private void mergeJobs (LinkedList<JobInProgress> jobsToReinsert, TaskType taskType) {
"""
reinsert a set of jobs into the sorted jobs for a given type (MAP/REDUCE)
the re-insertion happens in place.
we are exploiting the property that the jobs being inserted will most likely end
up at the head of the sorted list and not require a lot comparisons
"""
LinkedList<JobInProgress> sortedJobs = (taskType == TaskType.MAP) ?
sortedJobsByMapNeed : sortedJobsByReduceNeed;
Comparator<JobInProgress> comparator = (taskType == TaskType.MAP) ?
mapComparator : reduceComparator;
// for each job to be reinserted
for(JobInProgress jobToReinsert: jobsToReinsert) {
// look at existing jobs in the sorted list starting with the head
boolean reinserted = false;
ListIterator<JobInProgress> iter = sortedJobs.listIterator(0);
while (iter.hasNext()) {
JobInProgress job = iter.next();
if (comparator.compare(jobToReinsert, job) < 0) {
// found the point of insertion, move the iterator back one step
iter.previous();
// now we are positioned before the job we compared against
// insert it before this job
iter.add(jobToReinsert);
reinserted = true;
break;
}
}
if (!reinserted) {
sortedJobs.add(jobToReinsert);
}
}
}
|
java
|
private void mergeJobs (LinkedList<JobInProgress> jobsToReinsert, TaskType taskType) {
LinkedList<JobInProgress> sortedJobs = (taskType == TaskType.MAP) ?
sortedJobsByMapNeed : sortedJobsByReduceNeed;
Comparator<JobInProgress> comparator = (taskType == TaskType.MAP) ?
mapComparator : reduceComparator;
// for each job to be reinserted
for(JobInProgress jobToReinsert: jobsToReinsert) {
// look at existing jobs in the sorted list starting with the head
boolean reinserted = false;
ListIterator<JobInProgress> iter = sortedJobs.listIterator(0);
while (iter.hasNext()) {
JobInProgress job = iter.next();
if (comparator.compare(jobToReinsert, job) < 0) {
// found the point of insertion, move the iterator back one step
iter.previous();
// now we are positioned before the job we compared against
// insert it before this job
iter.add(jobToReinsert);
reinserted = true;
break;
}
}
if (!reinserted) {
sortedJobs.add(jobToReinsert);
}
}
}
|
[
"private",
"void",
"mergeJobs",
"(",
"LinkedList",
"<",
"JobInProgress",
">",
"jobsToReinsert",
",",
"TaskType",
"taskType",
")",
"{",
"LinkedList",
"<",
"JobInProgress",
">",
"sortedJobs",
"=",
"(",
"taskType",
"==",
"TaskType",
".",
"MAP",
")",
"?",
"sortedJobsByMapNeed",
":",
"sortedJobsByReduceNeed",
";",
"Comparator",
"<",
"JobInProgress",
">",
"comparator",
"=",
"(",
"taskType",
"==",
"TaskType",
".",
"MAP",
")",
"?",
"mapComparator",
":",
"reduceComparator",
";",
"// for each job to be reinserted",
"for",
"(",
"JobInProgress",
"jobToReinsert",
":",
"jobsToReinsert",
")",
"{",
"// look at existing jobs in the sorted list starting with the head",
"boolean",
"reinserted",
"=",
"false",
";",
"ListIterator",
"<",
"JobInProgress",
">",
"iter",
"=",
"sortedJobs",
".",
"listIterator",
"(",
"0",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"JobInProgress",
"job",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"comparator",
".",
"compare",
"(",
"jobToReinsert",
",",
"job",
")",
"<",
"0",
")",
"{",
"// found the point of insertion, move the iterator back one step",
"iter",
".",
"previous",
"(",
")",
";",
"// now we are positioned before the job we compared against",
"// insert it before this job",
"iter",
".",
"add",
"(",
"jobToReinsert",
")",
";",
"reinserted",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"reinserted",
")",
"{",
"sortedJobs",
".",
"add",
"(",
"jobToReinsert",
")",
";",
"}",
"}",
"}"
] |
reinsert a set of jobs into the sorted jobs for a given type (MAP/REDUCE)
the re-insertion happens in place.
we are exploiting the property that the jobs being inserted will most likely end
up at the head of the sorted list and not require a lot comparisons
|
[
"reinsert",
"a",
"set",
"of",
"jobs",
"into",
"the",
"sorted",
"jobs",
"for",
"a",
"given",
"type",
"(",
"MAP",
"/",
"REDUCE",
")",
"the",
"re",
"-",
"insertion",
"happens",
"in",
"place",
".",
"we",
"are",
"exploiting",
"the",
"property",
"that",
"the",
"jobs",
"being",
"inserted",
"will",
"most",
"likely",
"end",
"up",
"at",
"the",
"head",
"of",
"the",
"sorted",
"list",
"and",
"not",
"require",
"a",
"lot",
"comparisons"
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java#L829-L857
|
stephanenicolas/afterburner
|
afterburner-library/src/main/java/com/github/stephanenicolas/afterburner/AfterBurner.java
|
AfterBurner.beforeOverrideMethod
|
public void beforeOverrideMethod(CtClass targetClass, String targetMethodName, String body) throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
"""
Add/Inserts java instructions into a given override method of a given class. Before the overriden method call.
@param targetClass the class to inject code into.
@param targetMethodName the method to inject code into. Body will be injected right before the call to super.<targetName>.
@param body the instructions of java to be injected.
@throws CannotCompileException if the source contained in insertableMethod can't be compiled.
@throws AfterBurnerImpossibleException if something else goes wrong, wraps other exceptions.
"""
InsertableMethod insertableMethod = new InsertableMethodBuilder(this, signatureExtractor).insertIntoClass(targetClass).beforeOverrideMethod(targetMethodName).withBody(body).createInsertableMethod();
addOrInsertMethod(insertableMethod);
}
|
java
|
public void beforeOverrideMethod(CtClass targetClass, String targetMethodName, String body) throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
InsertableMethod insertableMethod = new InsertableMethodBuilder(this, signatureExtractor).insertIntoClass(targetClass).beforeOverrideMethod(targetMethodName).withBody(body).createInsertableMethod();
addOrInsertMethod(insertableMethod);
}
|
[
"public",
"void",
"beforeOverrideMethod",
"(",
"CtClass",
"targetClass",
",",
"String",
"targetMethodName",
",",
"String",
"body",
")",
"throws",
"CannotCompileException",
",",
"AfterBurnerImpossibleException",
",",
"NotFoundException",
"{",
"InsertableMethod",
"insertableMethod",
"=",
"new",
"InsertableMethodBuilder",
"(",
"this",
",",
"signatureExtractor",
")",
".",
"insertIntoClass",
"(",
"targetClass",
")",
".",
"beforeOverrideMethod",
"(",
"targetMethodName",
")",
".",
"withBody",
"(",
"body",
")",
".",
"createInsertableMethod",
"(",
")",
";",
"addOrInsertMethod",
"(",
"insertableMethod",
")",
";",
"}"
] |
Add/Inserts java instructions into a given override method of a given class. Before the overriden method call.
@param targetClass the class to inject code into.
@param targetMethodName the method to inject code into. Body will be injected right before the call to super.<targetName>.
@param body the instructions of java to be injected.
@throws CannotCompileException if the source contained in insertableMethod can't be compiled.
@throws AfterBurnerImpossibleException if something else goes wrong, wraps other exceptions.
|
[
"Add",
"/",
"Inserts",
"java",
"instructions",
"into",
"a",
"given",
"override",
"method",
"of",
"a",
"given",
"class",
".",
"Before",
"the",
"overriden",
"method",
"call",
"."
] |
train
|
https://github.com/stephanenicolas/afterburner/blob/b126d70e063895b036b6ac47e39e582439f58d12/afterburner-library/src/main/java/com/github/stephanenicolas/afterburner/AfterBurner.java#L69-L72
|
jillesvangurp/jsonj
|
src/main/java/com/github/jsonj/tools/JsonBuilder.java
|
JsonBuilder.put
|
public @Nonnull JsonBuilder put(String key, String s) {
"""
Add a string value to the object.
@param key key
@param s value
@return the builder
"""
object.put(key, primitive(s));
return this;
}
|
java
|
public @Nonnull JsonBuilder put(String key, String s) {
object.put(key, primitive(s));
return this;
}
|
[
"public",
"@",
"Nonnull",
"JsonBuilder",
"put",
"(",
"String",
"key",
",",
"String",
"s",
")",
"{",
"object",
".",
"put",
"(",
"key",
",",
"primitive",
"(",
"s",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add a string value to the object.
@param key key
@param s value
@return the builder
|
[
"Add",
"a",
"string",
"value",
"to",
"the",
"object",
"."
] |
train
|
https://github.com/jillesvangurp/jsonj/blob/1da0c44c5bdb60c0cd806c48d2da5a8a75bf84af/src/main/java/com/github/jsonj/tools/JsonBuilder.java#L88-L91
|
buschmais/jqa-maven3-plugin
|
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java
|
MavenProjectScannerPlugin.scanPath
|
private <F extends FileDescriptor> void scanPath(MavenProjectDirectoryDescriptor projectDescriptor, String path, Scope scope, Scanner scanner) {
"""
Scan a given path and add it to
{@link MavenProjectDirectoryDescriptor#getContains()}.
@param projectDescriptor
The maven project descriptor.
@param path
The path.
@param scope
The scope.
@param scanner
The scanner.
"""
File file = new File(path);
if (!file.exists()) {
LOGGER.debug(file.getAbsolutePath() + " does not exist, skipping.");
} else {
F fileDescriptor = scanFile(projectDescriptor, file, path, scope, scanner);
if (fileDescriptor != null) {
projectDescriptor.getContains().add(fileDescriptor);
}
}
}
|
java
|
private <F extends FileDescriptor> void scanPath(MavenProjectDirectoryDescriptor projectDescriptor, String path, Scope scope, Scanner scanner) {
File file = new File(path);
if (!file.exists()) {
LOGGER.debug(file.getAbsolutePath() + " does not exist, skipping.");
} else {
F fileDescriptor = scanFile(projectDescriptor, file, path, scope, scanner);
if (fileDescriptor != null) {
projectDescriptor.getContains().add(fileDescriptor);
}
}
}
|
[
"private",
"<",
"F",
"extends",
"FileDescriptor",
">",
"void",
"scanPath",
"(",
"MavenProjectDirectoryDescriptor",
"projectDescriptor",
",",
"String",
"path",
",",
"Scope",
"scope",
",",
"Scanner",
"scanner",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" does not exist, skipping.\"",
")",
";",
"}",
"else",
"{",
"F",
"fileDescriptor",
"=",
"scanFile",
"(",
"projectDescriptor",
",",
"file",
",",
"path",
",",
"scope",
",",
"scanner",
")",
";",
"if",
"(",
"fileDescriptor",
"!=",
"null",
")",
"{",
"projectDescriptor",
".",
"getContains",
"(",
")",
".",
"add",
"(",
"fileDescriptor",
")",
";",
"}",
"}",
"}"
] |
Scan a given path and add it to
{@link MavenProjectDirectoryDescriptor#getContains()}.
@param projectDescriptor
The maven project descriptor.
@param path
The path.
@param scope
The scope.
@param scanner
The scanner.
|
[
"Scan",
"a",
"given",
"path",
"and",
"add",
"it",
"to",
"{",
"@link",
"MavenProjectDirectoryDescriptor#getContains",
"()",
"}",
"."
] |
train
|
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenProjectScannerPlugin.java#L330-L340
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/SimpleGroupMember.java
|
SimpleGroupMember.findButton
|
protected AbstractButton findButton(AbstractCommand attachedCommand, List buttons) {
"""
Searches the given list of {@link AbstractButton}s for one that is not an instance of a
{@link JMenuItem} and has the given command attached to it. If found, the button will be
removed from the list.
@param attachedCommand The command that we are checking to see if it attached to any item in the list.
@param abstractButtons The collection of {@link AbstractButton}s that will be checked to
see if they have the given command attached to them. May be null or empty.
@return The element from the list that the given command is attached to, or null if no
such element could be found.
"""
if (buttons == null) {
return null;
}
for (Iterator it = buttons.iterator(); it.hasNext();) {
AbstractButton button = (AbstractButton)it.next();
if (!(button instanceof JMenuItem) && attachedCommand.isAttached(button)) {
it.remove();
return button;
}
}
return null;
}
|
java
|
protected AbstractButton findButton(AbstractCommand attachedCommand, List buttons) {
if (buttons == null) {
return null;
}
for (Iterator it = buttons.iterator(); it.hasNext();) {
AbstractButton button = (AbstractButton)it.next();
if (!(button instanceof JMenuItem) && attachedCommand.isAttached(button)) {
it.remove();
return button;
}
}
return null;
}
|
[
"protected",
"AbstractButton",
"findButton",
"(",
"AbstractCommand",
"attachedCommand",
",",
"List",
"buttons",
")",
"{",
"if",
"(",
"buttons",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Iterator",
"it",
"=",
"buttons",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"AbstractButton",
"button",
"=",
"(",
"AbstractButton",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"(",
"button",
"instanceof",
"JMenuItem",
")",
"&&",
"attachedCommand",
".",
"isAttached",
"(",
"button",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"return",
"button",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Searches the given list of {@link AbstractButton}s for one that is not an instance of a
{@link JMenuItem} and has the given command attached to it. If found, the button will be
removed from the list.
@param attachedCommand The command that we are checking to see if it attached to any item in the list.
@param abstractButtons The collection of {@link AbstractButton}s that will be checked to
see if they have the given command attached to them. May be null or empty.
@return The element from the list that the given command is attached to, or null if no
such element could be found.
|
[
"Searches",
"the",
"given",
"list",
"of",
"{",
"@link",
"AbstractButton",
"}",
"s",
"for",
"one",
"that",
"is",
"not",
"an",
"instance",
"of",
"a",
"{",
"@link",
"JMenuItem",
"}",
"and",
"has",
"the",
"given",
"command",
"attached",
"to",
"it",
".",
"If",
"found",
"the",
"button",
"will",
"be",
"removed",
"from",
"the",
"list",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/SimpleGroupMember.java#L164-L178
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfStructureTreeRoot.java
|
PdfStructureTreeRoot.mapRole
|
public void mapRole(PdfName used, PdfName standard) {
"""
Maps the user tags to the standard tags. The mapping will allow a standard application to make some sense of the tagged
document whatever the user tags may be.
@param used the user tag
@param standard the standard tag
"""
PdfDictionary rm = (PdfDictionary)get(PdfName.ROLEMAP);
if (rm == null) {
rm = new PdfDictionary();
put(PdfName.ROLEMAP, rm);
}
rm.put(used, standard);
}
|
java
|
public void mapRole(PdfName used, PdfName standard) {
PdfDictionary rm = (PdfDictionary)get(PdfName.ROLEMAP);
if (rm == null) {
rm = new PdfDictionary();
put(PdfName.ROLEMAP, rm);
}
rm.put(used, standard);
}
|
[
"public",
"void",
"mapRole",
"(",
"PdfName",
"used",
",",
"PdfName",
"standard",
")",
"{",
"PdfDictionary",
"rm",
"=",
"(",
"PdfDictionary",
")",
"get",
"(",
"PdfName",
".",
"ROLEMAP",
")",
";",
"if",
"(",
"rm",
"==",
"null",
")",
"{",
"rm",
"=",
"new",
"PdfDictionary",
"(",
")",
";",
"put",
"(",
"PdfName",
".",
"ROLEMAP",
",",
"rm",
")",
";",
"}",
"rm",
".",
"put",
"(",
"used",
",",
"standard",
")",
";",
"}"
] |
Maps the user tags to the standard tags. The mapping will allow a standard application to make some sense of the tagged
document whatever the user tags may be.
@param used the user tag
@param standard the standard tag
|
[
"Maps",
"the",
"user",
"tags",
"to",
"the",
"standard",
"tags",
".",
"The",
"mapping",
"will",
"allow",
"a",
"standard",
"application",
"to",
"make",
"some",
"sense",
"of",
"the",
"tagged",
"document",
"whatever",
"the",
"user",
"tags",
"may",
"be",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStructureTreeRoot.java#L84-L91
|
facebookarchive/hadoop-20
|
src/core/org/apache/hadoop/conf/ClientConfigurationUtil.java
|
ClientConfigurationUtil.getInstance
|
public static ClientConfiguration getInstance(URI uri, Configuration conf) {
"""
Retrieves the implementation for {@link ClientConfiguration}. The
expectation is that either this will be specified in the default
configuration or it will be specified in the configuration of the client
via command line options and environment variables.
@param conf
the configuration for the client
@param uri
the URI for the filesystem
@return
"""
Class<? extends ClientConfiguration> clazz = conf.getClass("fs." + uri.getScheme()
+ ".client.configuration.impl",
DefaultClientConfiguration.class, ClientConfiguration.class);
ClientConfiguration clientConf = classCache.get(clazz);
if (clientConf == null) {
clientConf = (ClientConfiguration) ReflectionUtils.newInstance(clazz,
null);
classCache.put(clazz, clientConf);
}
return clientConf;
}
|
java
|
public static ClientConfiguration getInstance(URI uri, Configuration conf) {
Class<? extends ClientConfiguration> clazz = conf.getClass("fs." + uri.getScheme()
+ ".client.configuration.impl",
DefaultClientConfiguration.class, ClientConfiguration.class);
ClientConfiguration clientConf = classCache.get(clazz);
if (clientConf == null) {
clientConf = (ClientConfiguration) ReflectionUtils.newInstance(clazz,
null);
classCache.put(clazz, clientConf);
}
return clientConf;
}
|
[
"public",
"static",
"ClientConfiguration",
"getInstance",
"(",
"URI",
"uri",
",",
"Configuration",
"conf",
")",
"{",
"Class",
"<",
"?",
"extends",
"ClientConfiguration",
">",
"clazz",
"=",
"conf",
".",
"getClass",
"(",
"\"fs.\"",
"+",
"uri",
".",
"getScheme",
"(",
")",
"+",
"\".client.configuration.impl\"",
",",
"DefaultClientConfiguration",
".",
"class",
",",
"ClientConfiguration",
".",
"class",
")",
";",
"ClientConfiguration",
"clientConf",
"=",
"classCache",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"clientConf",
"==",
"null",
")",
"{",
"clientConf",
"=",
"(",
"ClientConfiguration",
")",
"ReflectionUtils",
".",
"newInstance",
"(",
"clazz",
",",
"null",
")",
";",
"classCache",
".",
"put",
"(",
"clazz",
",",
"clientConf",
")",
";",
"}",
"return",
"clientConf",
";",
"}"
] |
Retrieves the implementation for {@link ClientConfiguration}. The
expectation is that either this will be specified in the default
configuration or it will be specified in the configuration of the client
via command line options and environment variables.
@param conf
the configuration for the client
@param uri
the URI for the filesystem
@return
|
[
"Retrieves",
"the",
"implementation",
"for",
"{",
"@link",
"ClientConfiguration",
"}",
".",
"The",
"expectation",
"is",
"that",
"either",
"this",
"will",
"be",
"specified",
"in",
"the",
"default",
"configuration",
"or",
"it",
"will",
"be",
"specified",
"in",
"the",
"configuration",
"of",
"the",
"client",
"via",
"command",
"line",
"options",
"and",
"environment",
"variables",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/conf/ClientConfigurationUtil.java#L40-L51
|
j256/simplejmx
|
src/main/java/com/j256/simplejmx/client/JmxClient.java
|
JmxClient.getOperationInfo
|
public MBeanOperationInfo getOperationInfo(ObjectName name, String oper) throws JMException {
"""
Return an array of the operations associated with the bean name.
"""
checkClientConnected();
MBeanInfo mbeanInfo;
try {
mbeanInfo = mbeanConn.getMBeanInfo(name);
} catch (Exception e) {
throw createJmException("Problems getting bean information from " + name, e);
}
for (MBeanOperationInfo info : mbeanInfo.getOperations()) {
if (oper.equals(info.getName())) {
return info;
}
}
return null;
}
|
java
|
public MBeanOperationInfo getOperationInfo(ObjectName name, String oper) throws JMException {
checkClientConnected();
MBeanInfo mbeanInfo;
try {
mbeanInfo = mbeanConn.getMBeanInfo(name);
} catch (Exception e) {
throw createJmException("Problems getting bean information from " + name, e);
}
for (MBeanOperationInfo info : mbeanInfo.getOperations()) {
if (oper.equals(info.getName())) {
return info;
}
}
return null;
}
|
[
"public",
"MBeanOperationInfo",
"getOperationInfo",
"(",
"ObjectName",
"name",
",",
"String",
"oper",
")",
"throws",
"JMException",
"{",
"checkClientConnected",
"(",
")",
";",
"MBeanInfo",
"mbeanInfo",
";",
"try",
"{",
"mbeanInfo",
"=",
"mbeanConn",
".",
"getMBeanInfo",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"createJmException",
"(",
"\"Problems getting bean information from \"",
"+",
"name",
",",
"e",
")",
";",
"}",
"for",
"(",
"MBeanOperationInfo",
"info",
":",
"mbeanInfo",
".",
"getOperations",
"(",
")",
")",
"{",
"if",
"(",
"oper",
".",
"equals",
"(",
"info",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"info",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Return an array of the operations associated with the bean name.
|
[
"Return",
"an",
"array",
"of",
"the",
"operations",
"associated",
"with",
"the",
"bean",
"name",
"."
] |
train
|
https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L286-L300
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileSystemUtils.java
|
FileSystemUtils.persistAndWait
|
public static void persistAndWait(final FileSystem fs, final AlluxioURI uri)
throws FileDoesNotExistException, IOException, AlluxioException, TimeoutException,
InterruptedException {
"""
Convenience method for {@code #persistAndWait(fs, uri, -1)}. i.e. wait for an indefinite period
of time to persist. This will block for an indefinite period of time if the path is never
persisted. Use with care.
@param fs {@link FileSystem} to carry out Alluxio operations
@param uri the uri of the file to persist
"""
persistAndWait(fs, uri, -1);
}
|
java
|
public static void persistAndWait(final FileSystem fs, final AlluxioURI uri)
throws FileDoesNotExistException, IOException, AlluxioException, TimeoutException,
InterruptedException {
persistAndWait(fs, uri, -1);
}
|
[
"public",
"static",
"void",
"persistAndWait",
"(",
"final",
"FileSystem",
"fs",
",",
"final",
"AlluxioURI",
"uri",
")",
"throws",
"FileDoesNotExistException",
",",
"IOException",
",",
"AlluxioException",
",",
"TimeoutException",
",",
"InterruptedException",
"{",
"persistAndWait",
"(",
"fs",
",",
"uri",
",",
"-",
"1",
")",
";",
"}"
] |
Convenience method for {@code #persistAndWait(fs, uri, -1)}. i.e. wait for an indefinite period
of time to persist. This will block for an indefinite period of time if the path is never
persisted. Use with care.
@param fs {@link FileSystem} to carry out Alluxio operations
@param uri the uri of the file to persist
|
[
"Convenience",
"method",
"for",
"{",
"@code",
"#persistAndWait",
"(",
"fs",
"uri",
"-",
"1",
")",
"}",
".",
"i",
".",
"e",
".",
"wait",
"for",
"an",
"indefinite",
"period",
"of",
"time",
"to",
"persist",
".",
"This",
"will",
"block",
"for",
"an",
"indefinite",
"period",
"of",
"time",
"if",
"the",
"path",
"is",
"never",
"persisted",
".",
"Use",
"with",
"care",
"."
] |
train
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileSystemUtils.java#L134-L138
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java
|
PhaseOneApplication.processFiles
|
private void processFiles(File[] files) {
"""
Starts phase one compilation from {@link File XBEL files}.
@param files the {@link File XBEL files} to compile
"""
phaseOutput(format("=== %s ===", getApplicationName()));
phaseOutput(format("Compiling %d BEL Document(s)", files.length));
boolean pedantic = withPedantic();
boolean verbose = withVerbose();
int validated = 0;
for (int i = 1; i <= files.length; i++) {
File file = files[i - 1];
if (verbose) {
phaseOutput("Compiling " + i + " of " + files.length
+ " BEL Document(s)");
}
// validate document
Document document = stage1(file);
if (document == null) {
if (pedantic) {
bail(VALIDATION_FAILURE);
}
continue;
}
validated++;
// run stages 2 - 7
runCommonStages(pedantic, document);
}
if (validated == 0) {
bail(NO_VALID_DOCUMENTS);
}
}
|
java
|
private void processFiles(File[] files) {
phaseOutput(format("=== %s ===", getApplicationName()));
phaseOutput(format("Compiling %d BEL Document(s)", files.length));
boolean pedantic = withPedantic();
boolean verbose = withVerbose();
int validated = 0;
for (int i = 1; i <= files.length; i++) {
File file = files[i - 1];
if (verbose) {
phaseOutput("Compiling " + i + " of " + files.length
+ " BEL Document(s)");
}
// validate document
Document document = stage1(file);
if (document == null) {
if (pedantic) {
bail(VALIDATION_FAILURE);
}
continue;
}
validated++;
// run stages 2 - 7
runCommonStages(pedantic, document);
}
if (validated == 0) {
bail(NO_VALID_DOCUMENTS);
}
}
|
[
"private",
"void",
"processFiles",
"(",
"File",
"[",
"]",
"files",
")",
"{",
"phaseOutput",
"(",
"format",
"(",
"\"=== %s ===\"",
",",
"getApplicationName",
"(",
")",
")",
")",
";",
"phaseOutput",
"(",
"format",
"(",
"\"Compiling %d BEL Document(s)\"",
",",
"files",
".",
"length",
")",
")",
";",
"boolean",
"pedantic",
"=",
"withPedantic",
"(",
")",
";",
"boolean",
"verbose",
"=",
"withVerbose",
"(",
")",
";",
"int",
"validated",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"File",
"file",
"=",
"files",
"[",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"verbose",
")",
"{",
"phaseOutput",
"(",
"\"Compiling \"",
"+",
"i",
"+",
"\" of \"",
"+",
"files",
".",
"length",
"+",
"\" BEL Document(s)\"",
")",
";",
"}",
"// validate document",
"Document",
"document",
"=",
"stage1",
"(",
"file",
")",
";",
"if",
"(",
"document",
"==",
"null",
")",
"{",
"if",
"(",
"pedantic",
")",
"{",
"bail",
"(",
"VALIDATION_FAILURE",
")",
";",
"}",
"continue",
";",
"}",
"validated",
"++",
";",
"// run stages 2 - 7",
"runCommonStages",
"(",
"pedantic",
",",
"document",
")",
";",
"}",
"if",
"(",
"validated",
"==",
"0",
")",
"{",
"bail",
"(",
"NO_VALID_DOCUMENTS",
")",
";",
"}",
"}"
] |
Starts phase one compilation from {@link File XBEL files}.
@param files the {@link File XBEL files} to compile
|
[
"Starts",
"phase",
"one",
"compilation",
"from",
"{",
"@link",
"File",
"XBEL",
"files",
"}",
"."
] |
train
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseOneApplication.java#L260-L294
|
haifengl/smile
|
math/src/main/java/smile/sort/SortUtils.java
|
SortUtils.siftUp
|
public static <T extends Comparable<? super T>> void siftUp(T[] arr, int k) {
"""
To restore the max-heap condition when a node's priority is increased.
We move up the heap, exchaning the node at position k with its parent
(at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or
until we reach the top of the heap.
"""
while (k > 1 && arr[k/2].compareTo(arr[k]) < 0) {
swap(arr, k, k/2);
k = k/2;
}
}
|
java
|
public static <T extends Comparable<? super T>> void siftUp(T[] arr, int k) {
while (k > 1 && arr[k/2].compareTo(arr[k]) < 0) {
swap(arr, k, k/2);
k = k/2;
}
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"siftUp",
"(",
"T",
"[",
"]",
"arr",
",",
"int",
"k",
")",
"{",
"while",
"(",
"k",
">",
"1",
"&&",
"arr",
"[",
"k",
"/",
"2",
"]",
".",
"compareTo",
"(",
"arr",
"[",
"k",
"]",
")",
"<",
"0",
")",
"{",
"swap",
"(",
"arr",
",",
"k",
",",
"k",
"/",
"2",
")",
";",
"k",
"=",
"k",
"/",
"2",
";",
"}",
"}"
] |
To restore the max-heap condition when a node's priority is increased.
We move up the heap, exchaning the node at position k with its parent
(at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or
until we reach the top of the heap.
|
[
"To",
"restore",
"the",
"max",
"-",
"heap",
"condition",
"when",
"a",
"node",
"s",
"priority",
"is",
"increased",
".",
"We",
"move",
"up",
"the",
"heap",
"exchaning",
"the",
"node",
"at",
"position",
"k",
"with",
"its",
"parent",
"(",
"at",
"postion",
"k",
"/",
"2",
")",
"if",
"necessary",
"continuing",
"as",
"long",
"as",
"a",
"[",
"k",
"/",
"2",
"]",
"<",
";",
"a",
"[",
"k",
"]",
"or",
"until",
"we",
"reach",
"the",
"top",
"of",
"the",
"heap",
"."
] |
train
|
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/sort/SortUtils.java#L114-L119
|
mozilla/rhino
|
src/org/mozilla/javascript/IRFactory.java
|
IRFactory.createLoopNode
|
private Scope createLoopNode(Node loopLabel, int lineno) {
"""
Create loop node. The code generator will later call
createWhile|createDoWhile|createFor|createForIn
to finish loop generation.
"""
Scope result = createScopeNode(Token.LOOP, lineno);
if (loopLabel != null) {
((Jump)loopLabel).setLoop(result);
}
return result;
}
|
java
|
private Scope createLoopNode(Node loopLabel, int lineno) {
Scope result = createScopeNode(Token.LOOP, lineno);
if (loopLabel != null) {
((Jump)loopLabel).setLoop(result);
}
return result;
}
|
[
"private",
"Scope",
"createLoopNode",
"(",
"Node",
"loopLabel",
",",
"int",
"lineno",
")",
"{",
"Scope",
"result",
"=",
"createScopeNode",
"(",
"Token",
".",
"LOOP",
",",
"lineno",
")",
";",
"if",
"(",
"loopLabel",
"!=",
"null",
")",
"{",
"(",
"(",
"Jump",
")",
"loopLabel",
")",
".",
"setLoop",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Create loop node. The code generator will later call
createWhile|createDoWhile|createFor|createForIn
to finish loop generation.
|
[
"Create",
"loop",
"node",
".",
"The",
"code",
"generator",
"will",
"later",
"call",
"createWhile|createDoWhile|createFor|createForIn",
"to",
"finish",
"loop",
"generation",
"."
] |
train
|
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/IRFactory.java#L1508-L1514
|
landawn/AbacusUtil
|
src/com/landawn/abacus/android/util/SQLiteExecutor.java
|
SQLiteExecutor.query
|
@SafeVarargs
public final DataSet query(Class<?> targetClass, String sql, Object... parameters) {
"""
Find the records from database with the specified <code>sql, parameters</code> and return the result set.
@param targetClass an entity class with getter/setter methods.
@param sql set <code>offset</code> and <code>limit</code> in sql with format:
<li><code>SELECT * FROM account where id = ? LIMIT <i>offsetValue</i>, <i>limitValue</i></code></li>
<br>or limit only:</br>
<li><code>SELECT * FROM account where id = ? LIMIT <i>limitValue</i></code></li>
@param parameters A Object Array/List, and Map/Entity with getter/setter methods for parameterized sql with named parameters
@return
"""
return query(targetClass, sql, 0, Integer.MAX_VALUE, parameters);
}
|
java
|
@SafeVarargs
public final DataSet query(Class<?> targetClass, String sql, Object... parameters) {
return query(targetClass, sql, 0, Integer.MAX_VALUE, parameters);
}
|
[
"@",
"SafeVarargs",
"public",
"final",
"DataSet",
"query",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"sql",
",",
"Object",
"...",
"parameters",
")",
"{",
"return",
"query",
"(",
"targetClass",
",",
"sql",
",",
"0",
",",
"Integer",
".",
"MAX_VALUE",
",",
"parameters",
")",
";",
"}"
] |
Find the records from database with the specified <code>sql, parameters</code> and return the result set.
@param targetClass an entity class with getter/setter methods.
@param sql set <code>offset</code> and <code>limit</code> in sql with format:
<li><code>SELECT * FROM account where id = ? LIMIT <i>offsetValue</i>, <i>limitValue</i></code></li>
<br>or limit only:</br>
<li><code>SELECT * FROM account where id = ? LIMIT <i>limitValue</i></code></li>
@param parameters A Object Array/List, and Map/Entity with getter/setter methods for parameterized sql with named parameters
@return
|
[
"Find",
"the",
"records",
"from",
"database",
"with",
"the",
"specified",
"<code",
">",
"sql",
"parameters<",
"/",
"code",
">",
"and",
"return",
"the",
"result",
"set",
"."
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/android/util/SQLiteExecutor.java#L2002-L2005
|
ldapchai/ldapchai
|
src/main/java/com/novell/ldapchai/util/SearchHelper.java
|
SearchHelper.setFilterExists
|
public void setFilterExists( final String attributeName ) {
"""
Set up an exists filter for attribute name. Consider the following example.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Value</b></td></tr>
<tr><td>givenName</td></tr>
</table>
<p><i>Result</i></p>
<code>(givenName=*)</code>
@param attributeName A valid attribute name
"""
final StringBuilder sb = new StringBuilder();
sb.append( "(" );
sb.append( new FilterSequence( attributeName, "*", FilterSequence.MatchingRuleEnum.EQUALS ) );
sb.append( ")" );
this.filter = sb.toString();
}
|
java
|
public void setFilterExists( final String attributeName )
{
final StringBuilder sb = new StringBuilder();
sb.append( "(" );
sb.append( new FilterSequence( attributeName, "*", FilterSequence.MatchingRuleEnum.EQUALS ) );
sb.append( ")" );
this.filter = sb.toString();
}
|
[
"public",
"void",
"setFilterExists",
"(",
"final",
"String",
"attributeName",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"(\"",
")",
";",
"sb",
".",
"append",
"(",
"new",
"FilterSequence",
"(",
"attributeName",
",",
"\"*\"",
",",
"FilterSequence",
".",
"MatchingRuleEnum",
".",
"EQUALS",
")",
")",
";",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"this",
".",
"filter",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Set up an exists filter for attribute name. Consider the following example.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Value</b></td></tr>
<tr><td>givenName</td></tr>
</table>
<p><i>Result</i></p>
<code>(givenName=*)</code>
@param attributeName A valid attribute name
|
[
"Set",
"up",
"an",
"exists",
"filter",
"for",
"attribute",
"name",
".",
"Consider",
"the",
"following",
"example",
"."
] |
train
|
https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/SearchHelper.java#L523-L530
|
craftercms/core
|
src/main/java/org/craftercms/core/processors/impl/TextMetaDataCollectionExtractingProcessor.java
|
TextMetaDataCollectionExtractingProcessor.process
|
@Override
public Item process(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException {
"""
For every XPath query provided in {@code metaDataNodesXPathQueries}, a list of nodes is selected and for each
one of these nodes its text value is extracted and added to a list that is later put in the item's properties.
"""
for (String xpathQuery : metaDataNodesXPathQueries) {
List<String> metaDataValues = item.queryDescriptorValues(xpathQuery);
if (CollectionUtils.isNotEmpty(metaDataValues)) {
item.setProperty(xpathQuery, metaDataValues);
}
}
return item;
}
|
java
|
@Override
public Item process(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException {
for (String xpathQuery : metaDataNodesXPathQueries) {
List<String> metaDataValues = item.queryDescriptorValues(xpathQuery);
if (CollectionUtils.isNotEmpty(metaDataValues)) {
item.setProperty(xpathQuery, metaDataValues);
}
}
return item;
}
|
[
"@",
"Override",
"public",
"Item",
"process",
"(",
"Context",
"context",
",",
"CachingOptions",
"cachingOptions",
",",
"Item",
"item",
")",
"throws",
"ItemProcessingException",
"{",
"for",
"(",
"String",
"xpathQuery",
":",
"metaDataNodesXPathQueries",
")",
"{",
"List",
"<",
"String",
">",
"metaDataValues",
"=",
"item",
".",
"queryDescriptorValues",
"(",
"xpathQuery",
")",
";",
"if",
"(",
"CollectionUtils",
".",
"isNotEmpty",
"(",
"metaDataValues",
")",
")",
"{",
"item",
".",
"setProperty",
"(",
"xpathQuery",
",",
"metaDataValues",
")",
";",
"}",
"}",
"return",
"item",
";",
"}"
] |
For every XPath query provided in {@code metaDataNodesXPathQueries}, a list of nodes is selected and for each
one of these nodes its text value is extracted and added to a list that is later put in the item's properties.
|
[
"For",
"every",
"XPath",
"query",
"provided",
"in",
"{"
] |
train
|
https://github.com/craftercms/core/blob/d3ec74d669d3f8cfcf995177615d5f126edfa237/src/main/java/org/craftercms/core/processors/impl/TextMetaDataCollectionExtractingProcessor.java#L55-L65
|
google/error-prone
|
core/src/main/java/com/google/errorprone/bugpatterns/RestrictedApiChecker.java
|
RestrictedApiChecker.matchAnnotation
|
@Override
public Description matchAnnotation(AnnotationTree tree, VisitorState state) {
"""
Validates a {@code @RestrictedApi} annotation and that the declared restriction makes sense.
<p>The other match functions in this class check the <em>usages</em> of a restricted API.
"""
// TODO(bangert): Validate all the fields
if (!ASTHelpers.getSymbol(tree).toString().equals(RestrictedApi.class.getName())) {
return Description.NO_MATCH;
}
// TODO(bangert): make a more elegant API to get the annotation within an annotation tree.
// Maybe find the declared object and get annotations on that...
AnnotationMirror restrictedApi = ASTHelpers.getAnnotationMirror(tree);
if (restrictedApi == null) {
return Description.NO_MATCH;
}
return Description.NO_MATCH;
}
|
java
|
@Override
public Description matchAnnotation(AnnotationTree tree, VisitorState state) {
// TODO(bangert): Validate all the fields
if (!ASTHelpers.getSymbol(tree).toString().equals(RestrictedApi.class.getName())) {
return Description.NO_MATCH;
}
// TODO(bangert): make a more elegant API to get the annotation within an annotation tree.
// Maybe find the declared object and get annotations on that...
AnnotationMirror restrictedApi = ASTHelpers.getAnnotationMirror(tree);
if (restrictedApi == null) {
return Description.NO_MATCH;
}
return Description.NO_MATCH;
}
|
[
"@",
"Override",
"public",
"Description",
"matchAnnotation",
"(",
"AnnotationTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"// TODO(bangert): Validate all the fields",
"if",
"(",
"!",
"ASTHelpers",
".",
"getSymbol",
"(",
"tree",
")",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"RestrictedApi",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"Description",
".",
"NO_MATCH",
";",
"}",
"// TODO(bangert): make a more elegant API to get the annotation within an annotation tree.",
"// Maybe find the declared object and get annotations on that...",
"AnnotationMirror",
"restrictedApi",
"=",
"ASTHelpers",
".",
"getAnnotationMirror",
"(",
"tree",
")",
";",
"if",
"(",
"restrictedApi",
"==",
"null",
")",
"{",
"return",
"Description",
".",
"NO_MATCH",
";",
"}",
"return",
"Description",
".",
"NO_MATCH",
";",
"}"
] |
Validates a {@code @RestrictedApi} annotation and that the declared restriction makes sense.
<p>The other match functions in this class check the <em>usages</em> of a restricted API.
|
[
"Validates",
"a",
"{",
"@code",
"@RestrictedApi",
"}",
"annotation",
"and",
"that",
"the",
"declared",
"restriction",
"makes",
"sense",
"."
] |
train
|
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/RestrictedApiChecker.java#L59-L72
|
moparisthebest/beehive
|
beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/NewDefaultObjectResultSetMapper.java
|
NewDefaultObjectResultSetMapper.mapToResultType
|
@SuppressWarnings( {
"""
Map the ResultSet to the method's return type. The object type returned is defined by the return type of the method.
@param context A ControlBeanContext instance, see Beehive controls javadoc for additional information
@param m Method assoicated with this call.
@param rs Result set to map.
@param cal A Calendar instance for time/date value resolution.
@return The Object resulting from the ResultSet
""""unchecked"})
public Object mapToResultType(ControlBeanContext context, Method m, ResultSet rs, Calendar cal) {
final Type type = m.getGenericReturnType();
// todo: is genericArray: false correct here? good enough I guess...
return toType(rs, m.getReturnType(), type instanceof ParameterizedType ? (ParameterizedType) type : null, false, context.getMethodPropertySet(m, JdbcControl.SQL.class).arrayMaxLength(), cal);
}
|
java
|
@SuppressWarnings({"unchecked"})
public Object mapToResultType(ControlBeanContext context, Method m, ResultSet rs, Calendar cal) {
final Type type = m.getGenericReturnType();
// todo: is genericArray: false correct here? good enough I guess...
return toType(rs, m.getReturnType(), type instanceof ParameterizedType ? (ParameterizedType) type : null, false, context.getMethodPropertySet(m, JdbcControl.SQL.class).arrayMaxLength(), cal);
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"Object",
"mapToResultType",
"(",
"ControlBeanContext",
"context",
",",
"Method",
"m",
",",
"ResultSet",
"rs",
",",
"Calendar",
"cal",
")",
"{",
"final",
"Type",
"type",
"=",
"m",
".",
"getGenericReturnType",
"(",
")",
";",
"// todo: is genericArray: false correct here? good enough I guess...",
"return",
"toType",
"(",
"rs",
",",
"m",
".",
"getReturnType",
"(",
")",
",",
"type",
"instanceof",
"ParameterizedType",
"?",
"(",
"ParameterizedType",
")",
"type",
":",
"null",
",",
"false",
",",
"context",
".",
"getMethodPropertySet",
"(",
"m",
",",
"JdbcControl",
".",
"SQL",
".",
"class",
")",
".",
"arrayMaxLength",
"(",
")",
",",
"cal",
")",
";",
"}"
] |
Map the ResultSet to the method's return type. The object type returned is defined by the return type of the method.
@param context A ControlBeanContext instance, see Beehive controls javadoc for additional information
@param m Method assoicated with this call.
@param rs Result set to map.
@param cal A Calendar instance for time/date value resolution.
@return The Object resulting from the ResultSet
|
[
"Map",
"the",
"ResultSet",
"to",
"the",
"method",
"s",
"return",
"type",
".",
"The",
"object",
"type",
"returned",
"is",
"defined",
"by",
"the",
"return",
"type",
"of",
"the",
"method",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/NewDefaultObjectResultSetMapper.java#L28-L33
|
CloudSlang/cs-actions
|
cs-vmware/src/main/java/io/cloudslang/content/vmware/connection/helpers/MoRefHandler.java
|
MoRefHandler.containerViewByType
|
private RetrieveResult containerViewByType(final ManagedObjectReference container,
final String morefType,
final RetrieveOptions retrieveOptions,
final String... morefProperties
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
"""
Returns the raw RetrieveResult object for the provided container filtered on properties list
@param container - container to look in
@param morefType - type to filter for
@param morefProperties - properties to include
@return com.vmware.vim25.RetrieveResult for this query
@throws RuntimeFaultFaultMsg
@throws InvalidPropertyFaultMsg
"""
PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(container, morefType, morefProperties);
return containerViewByType(retrieveOptions, propertyFilterSpecs);
}
|
java
|
private RetrieveResult containerViewByType(final ManagedObjectReference container,
final String morefType,
final RetrieveOptions retrieveOptions,
final String... morefProperties
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(container, morefType, morefProperties);
return containerViewByType(retrieveOptions, propertyFilterSpecs);
}
|
[
"private",
"RetrieveResult",
"containerViewByType",
"(",
"final",
"ManagedObjectReference",
"container",
",",
"final",
"String",
"morefType",
",",
"final",
"RetrieveOptions",
"retrieveOptions",
",",
"final",
"String",
"...",
"morefProperties",
")",
"throws",
"RuntimeFaultFaultMsg",
",",
"InvalidPropertyFaultMsg",
"{",
"PropertyFilterSpec",
"[",
"]",
"propertyFilterSpecs",
"=",
"propertyFilterSpecs",
"(",
"container",
",",
"morefType",
",",
"morefProperties",
")",
";",
"return",
"containerViewByType",
"(",
"retrieveOptions",
",",
"propertyFilterSpecs",
")",
";",
"}"
] |
Returns the raw RetrieveResult object for the provided container filtered on properties list
@param container - container to look in
@param morefType - type to filter for
@param morefProperties - properties to include
@return com.vmware.vim25.RetrieveResult for this query
@throws RuntimeFaultFaultMsg
@throws InvalidPropertyFaultMsg
|
[
"Returns",
"the",
"raw",
"RetrieveResult",
"object",
"for",
"the",
"provided",
"container",
"filtered",
"on",
"properties",
"list"
] |
train
|
https://github.com/CloudSlang/cs-actions/blob/9a1be1e99ad88286a6c153d5f2275df6ae1a57a1/cs-vmware/src/main/java/io/cloudslang/content/vmware/connection/helpers/MoRefHandler.java#L141-L149
|
jayantk/jklol
|
src/com/jayantkrish/jklol/models/FactorGraph.java
|
FactorGraph.addVariable
|
public FactorGraph addVariable(String variableName, Variable variable) {
"""
Gets a new {@code FactorGraph} identical to this one, except with
an additional variable. The new variable is named
{@code variableName} and has type {@code variable}. Each variable
in a factor graph must have a unique name; hence {@code this}
must not already contain a variable named {@code variableName}.
"""
Preconditions.checkArgument(!getVariables().contains(variableName));
int varNum = getAllVariables().size() > 0 ? Ints.max(getAllVariables().getVariableNumsArray()) + 1 : 0;
return addVariableWithIndex(variableName, variable, varNum);
}
|
java
|
public FactorGraph addVariable(String variableName, Variable variable) {
Preconditions.checkArgument(!getVariables().contains(variableName));
int varNum = getAllVariables().size() > 0 ? Ints.max(getAllVariables().getVariableNumsArray()) + 1 : 0;
return addVariableWithIndex(variableName, variable, varNum);
}
|
[
"public",
"FactorGraph",
"addVariable",
"(",
"String",
"variableName",
",",
"Variable",
"variable",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"getVariables",
"(",
")",
".",
"contains",
"(",
"variableName",
")",
")",
";",
"int",
"varNum",
"=",
"getAllVariables",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
"?",
"Ints",
".",
"max",
"(",
"getAllVariables",
"(",
")",
".",
"getVariableNumsArray",
"(",
")",
")",
"+",
"1",
":",
"0",
";",
"return",
"addVariableWithIndex",
"(",
"variableName",
",",
"variable",
",",
"varNum",
")",
";",
"}"
] |
Gets a new {@code FactorGraph} identical to this one, except with
an additional variable. The new variable is named
{@code variableName} and has type {@code variable}. Each variable
in a factor graph must have a unique name; hence {@code this}
must not already contain a variable named {@code variableName}.
|
[
"Gets",
"a",
"new",
"{"
] |
train
|
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/models/FactorGraph.java#L457-L461
|
alkacon/opencms-core
|
src/org/opencms/i18n/CmsVfsBundleLoaderProperties.java
|
CmsVfsBundleLoaderProperties.getEncoding
|
private String getEncoding(CmsObject cms, CmsResource res) {
"""
Gets the encoding which should be used to read the properties file.<p>
@param cms the CMS context to use
@param res the resource for which we want the encoding
@return the encoding value
"""
String defaultEncoding = OpenCms.getSystemInfo().getDefaultEncoding();
try {
CmsProperty encProp = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String encoding = encProp.getValue(defaultEncoding);
return encoding;
} catch (Exception e) {
LOG.warn(e.getLocalizedMessage(), e);
return defaultEncoding;
}
}
|
java
|
private String getEncoding(CmsObject cms, CmsResource res) {
String defaultEncoding = OpenCms.getSystemInfo().getDefaultEncoding();
try {
CmsProperty encProp = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String encoding = encProp.getValue(defaultEncoding);
return encoding;
} catch (Exception e) {
LOG.warn(e.getLocalizedMessage(), e);
return defaultEncoding;
}
}
|
[
"private",
"String",
"getEncoding",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"res",
")",
"{",
"String",
"defaultEncoding",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getDefaultEncoding",
"(",
")",
";",
"try",
"{",
"CmsProperty",
"encProp",
"=",
"cms",
".",
"readPropertyObject",
"(",
"res",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_CONTENT_ENCODING",
",",
"true",
")",
";",
"String",
"encoding",
"=",
"encProp",
".",
"getValue",
"(",
"defaultEncoding",
")",
";",
"return",
"encoding",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"defaultEncoding",
";",
"}",
"}"
] |
Gets the encoding which should be used to read the properties file.<p>
@param cms the CMS context to use
@param res the resource for which we want the encoding
@return the encoding value
|
[
"Gets",
"the",
"encoding",
"which",
"should",
"be",
"used",
"to",
"read",
"the",
"properties",
"file",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/i18n/CmsVfsBundleLoaderProperties.java#L85-L96
|
wcm-io/wcm-io-handler
|
url/src/main/java/io/wcm/handler/url/suffix/SuffixParser.java
|
SuffixParser.getResource
|
public @Nullable Resource getResource(@Nullable Predicate<Resource> filter, @Nullable Resource baseResource) {
"""
Get the first item returned by {@link #getResources(Predicate, Resource)} or null if list is empty
@param filter the resource filter
@param baseResource the suffix path is relative to this resource path (null for current page's jcr:content node)
@return the first {@link Resource} or null
"""
List<Resource> suffixResources = getResources(filter, baseResource);
if (suffixResources.isEmpty()) {
return null;
}
else {
return suffixResources.get(0);
}
}
|
java
|
public @Nullable Resource getResource(@Nullable Predicate<Resource> filter, @Nullable Resource baseResource) {
List<Resource> suffixResources = getResources(filter, baseResource);
if (suffixResources.isEmpty()) {
return null;
}
else {
return suffixResources.get(0);
}
}
|
[
"public",
"@",
"Nullable",
"Resource",
"getResource",
"(",
"@",
"Nullable",
"Predicate",
"<",
"Resource",
">",
"filter",
",",
"@",
"Nullable",
"Resource",
"baseResource",
")",
"{",
"List",
"<",
"Resource",
">",
"suffixResources",
"=",
"getResources",
"(",
"filter",
",",
"baseResource",
")",
";",
"if",
"(",
"suffixResources",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"suffixResources",
".",
"get",
"(",
"0",
")",
";",
"}",
"}"
] |
Get the first item returned by {@link #getResources(Predicate, Resource)} or null if list is empty
@param filter the resource filter
@param baseResource the suffix path is relative to this resource path (null for current page's jcr:content node)
@return the first {@link Resource} or null
|
[
"Get",
"the",
"first",
"item",
"returned",
"by",
"{"
] |
train
|
https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/url/src/main/java/io/wcm/handler/url/suffix/SuffixParser.java#L218-L226
|
wellner/jcarafe
|
jcarafe-core/src/main/java/org/mitre/jcarafe/jarafe/JarafeXValidator.java
|
JarafeXValidator.generateReport
|
public void generateReport(int numFolds, java.io.File file) {
"""
/*
@param numFolds - Number of x-validation folds to use
@param file - output file for generated x-validation report
"""
evaluator.xValidateAndGenerateReport(numFolds, file);
}
|
java
|
public void generateReport(int numFolds, java.io.File file) {
evaluator.xValidateAndGenerateReport(numFolds, file);
}
|
[
"public",
"void",
"generateReport",
"(",
"int",
"numFolds",
",",
"java",
".",
"io",
".",
"File",
"file",
")",
"{",
"evaluator",
".",
"xValidateAndGenerateReport",
"(",
"numFolds",
",",
"file",
")",
";",
"}"
] |
/*
@param numFolds - Number of x-validation folds to use
@param file - output file for generated x-validation report
|
[
"/",
"*"
] |
train
|
https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/org/mitre/jcarafe/jarafe/JarafeXValidator.java#L27-L29
|
flow/commons
|
src/main/java/com/flowpowered/commons/hashing/Int10TripleHashed.java
|
Int10TripleHashed.key
|
public final int key(int x, int y, int z) {
"""
Packs given x, y, z coordinates. The coords must represent a point within a 1024 sized cuboid with the base at the (bx, by, bz)
@param x an <code>int</code> value
@param y an <code>int</code> value
@param z an <code>int</code> value
@return the packed int
"""
return (((x - bx) & 0x3FF) << 22) | (((y - by) & 0x3FF) << 11) | ((z - bz) & 0x3FF);
}
|
java
|
public final int key(int x, int y, int z) {
return (((x - bx) & 0x3FF) << 22) | (((y - by) & 0x3FF) << 11) | ((z - bz) & 0x3FF);
}
|
[
"public",
"final",
"int",
"key",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"z",
")",
"{",
"return",
"(",
"(",
"(",
"x",
"-",
"bx",
")",
"&",
"0x3FF",
")",
"<<",
"22",
")",
"|",
"(",
"(",
"(",
"y",
"-",
"by",
")",
"&",
"0x3FF",
")",
"<<",
"11",
")",
"|",
"(",
"(",
"z",
"-",
"bz",
")",
"&",
"0x3FF",
")",
";",
"}"
] |
Packs given x, y, z coordinates. The coords must represent a point within a 1024 sized cuboid with the base at the (bx, by, bz)
@param x an <code>int</code> value
@param y an <code>int</code> value
@param z an <code>int</code> value
@return the packed int
|
[
"Packs",
"given",
"x",
"y",
"z",
"coordinates",
".",
"The",
"coords",
"must",
"represent",
"a",
"point",
"within",
"a",
"1024",
"sized",
"cuboid",
"with",
"the",
"base",
"at",
"the",
"(",
"bx",
"by",
"bz",
")"
] |
train
|
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/hashing/Int10TripleHashed.java#L58-L60
|
jqm4gwt/jqm4gwt
|
library/src/main/java/com/sksamuel/jqm4gwt/toolbar/JQMHeader.java
|
JQMHeader.setRightButton
|
public JQMButton setRightButton(String text, JQMPage page) {
"""
Creates a new {@link JQMButton} with the given text and linking to the
given {@link JQMPage} and then sets that button in the right slot. Any
existing right button will be replaced.
@param text
the text for the button
@param page
the optional page for the button to link to, if null then
this button does not navigate by default
@return the created button
"""
return setRightButton(text, page, null);
}
|
java
|
public JQMButton setRightButton(String text, JQMPage page) {
return setRightButton(text, page, null);
}
|
[
"public",
"JQMButton",
"setRightButton",
"(",
"String",
"text",
",",
"JQMPage",
"page",
")",
"{",
"return",
"setRightButton",
"(",
"text",
",",
"page",
",",
"null",
")",
";",
"}"
] |
Creates a new {@link JQMButton} with the given text and linking to the
given {@link JQMPage} and then sets that button in the right slot. Any
existing right button will be replaced.
@param text
the text for the button
@param page
the optional page for the button to link to, if null then
this button does not navigate by default
@return the created button
|
[
"Creates",
"a",
"new",
"{",
"@link",
"JQMButton",
"}",
"with",
"the",
"given",
"text",
"and",
"linking",
"to",
"the",
"given",
"{",
"@link",
"JQMPage",
"}",
"and",
"then",
"sets",
"that",
"button",
"in",
"the",
"right",
"slot",
".",
"Any",
"existing",
"right",
"button",
"will",
"be",
"replaced",
"."
] |
train
|
https://github.com/jqm4gwt/jqm4gwt/blob/cf59958e9ba6d4b70f42507b2c77f10c2465085b/library/src/main/java/com/sksamuel/jqm4gwt/toolbar/JQMHeader.java#L310-L312
|
elki-project/elki
|
elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java
|
PersistentPageFile.byteArrayToPage
|
private P byteArrayToPage(byte[] array) {
"""
Reconstruct a serialized object from the specified byte array.
@param array the byte array from which the object should be reconstructed
@return a serialized object from the specified byte array
"""
try {
ByteArrayInputStream bais = new ByteArrayInputStream(array);
ObjectInputStream ois = new ObjectInputStream(bais);
int type = ois.readInt();
if(type == EMPTY_PAGE) {
return null;
}
else if(type == FILLED_PAGE) {
P page;
try {
page = pageclass.newInstance();
page.readExternal(ois);
}
catch(InstantiationException|IllegalAccessException|ClassNotFoundException e) {
throw new AbortException("Error instanciating an index page", e);
}
return page;
}
else {
throw new IllegalArgumentException("Unknown type: " + type);
}
}
catch(IOException e) {
throw new AbortException("IO Error in page file", e);
}
}
|
java
|
private P byteArrayToPage(byte[] array) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(array);
ObjectInputStream ois = new ObjectInputStream(bais);
int type = ois.readInt();
if(type == EMPTY_PAGE) {
return null;
}
else if(type == FILLED_PAGE) {
P page;
try {
page = pageclass.newInstance();
page.readExternal(ois);
}
catch(InstantiationException|IllegalAccessException|ClassNotFoundException e) {
throw new AbortException("Error instanciating an index page", e);
}
return page;
}
else {
throw new IllegalArgumentException("Unknown type: " + type);
}
}
catch(IOException e) {
throw new AbortException("IO Error in page file", e);
}
}
|
[
"private",
"P",
"byteArrayToPage",
"(",
"byte",
"[",
"]",
"array",
")",
"{",
"try",
"{",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"array",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"int",
"type",
"=",
"ois",
".",
"readInt",
"(",
")",
";",
"if",
"(",
"type",
"==",
"EMPTY_PAGE",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"FILLED_PAGE",
")",
"{",
"P",
"page",
";",
"try",
"{",
"page",
"=",
"pageclass",
".",
"newInstance",
"(",
")",
";",
"page",
".",
"readExternal",
"(",
"ois",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"AbortException",
"(",
"\"Error instanciating an index page\"",
",",
"e",
")",
";",
"}",
"return",
"page",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown type: \"",
"+",
"type",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AbortException",
"(",
"\"IO Error in page file\"",
",",
"e",
")",
";",
"}",
"}"
] |
Reconstruct a serialized object from the specified byte array.
@param array the byte array from which the object should be reconstructed
@return a serialized object from the specified byte array
|
[
"Reconstruct",
"a",
"serialized",
"object",
"from",
"the",
"specified",
"byte",
"array",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java#L211-L237
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
|
ApiOvhOrder.email_domain_new_GET
|
public ArrayList<String> email_domain_new_GET(String domain, OvhOfferEnum offer) throws IOException {
"""
Get allowed durations for 'new' option
REST: GET /order/email/domain/new
@param domain [required] Domain name which will be linked to this mx account
@param offer [required] Offer for your new mx account
@deprecated
"""
String qPath = "/order/email/domain/new";
StringBuilder sb = path(qPath);
query(sb, "domain", domain);
query(sb, "offer", offer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
}
|
java
|
public ArrayList<String> email_domain_new_GET(String domain, OvhOfferEnum offer) throws IOException {
String qPath = "/order/email/domain/new";
StringBuilder sb = path(qPath);
query(sb, "domain", domain);
query(sb, "offer", offer);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
}
|
[
"public",
"ArrayList",
"<",
"String",
">",
"email_domain_new_GET",
"(",
"String",
"domain",
",",
"OvhOfferEnum",
"offer",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/email/domain/new\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"domain\"",
",",
"domain",
")",
";",
"query",
"(",
"sb",
",",
"\"offer\"",
",",
"offer",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t1",
")",
";",
"}"
] |
Get allowed durations for 'new' option
REST: GET /order/email/domain/new
@param domain [required] Domain name which will be linked to this mx account
@param offer [required] Offer for your new mx account
@deprecated
|
[
"Get",
"allowed",
"durations",
"for",
"new",
"option"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L4143-L4150
|
gallandarakhneorg/afc
|
core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/endian/EndianNumbers.java
|
EndianNumbers.toBEFloat
|
@Pure
@Inline(value = "Float.intBitsToFloat(EndianNumbers.toBEInt($1, $2, $3, $4))",
imported = {
"""
Converting four bytes to a Big Endian float.
@param b1 the first byte.
@param b2 the second byte.
@param b3 the third byte.
@param b4 the fourth byte.
@return the conversion result
"""EndianNumbers.class})
public static float toBEFloat(int b1, int b2, int b3, int b4) {
return Float.intBitsToFloat(toBEInt(b1, b2, b3, b4));
}
|
java
|
@Pure
@Inline(value = "Float.intBitsToFloat(EndianNumbers.toBEInt($1, $2, $3, $4))",
imported = {EndianNumbers.class})
public static float toBEFloat(int b1, int b2, int b3, int b4) {
return Float.intBitsToFloat(toBEInt(b1, b2, b3, b4));
}
|
[
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"Float.intBitsToFloat(EndianNumbers.toBEInt($1, $2, $3, $4))\"",
",",
"imported",
"=",
"{",
"EndianNumbers",
".",
"class",
"}",
")",
"public",
"static",
"float",
"toBEFloat",
"(",
"int",
"b1",
",",
"int",
"b2",
",",
"int",
"b3",
",",
"int",
"b4",
")",
"{",
"return",
"Float",
".",
"intBitsToFloat",
"(",
"toBEInt",
"(",
"b1",
",",
"b2",
",",
"b3",
",",
"b4",
")",
")",
";",
"}"
] |
Converting four bytes to a Big Endian float.
@param b1 the first byte.
@param b2 the second byte.
@param b3 the third byte.
@param b4 the fourth byte.
@return the conversion result
|
[
"Converting",
"four",
"bytes",
"to",
"a",
"Big",
"Endian",
"float",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/endian/EndianNumbers.java#L197-L202
|
BorderTech/wcomponents
|
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java
|
MenuPanel.getMatch
|
private ExampleData getMatch(final WComponent node, final String name, final boolean partial) {
"""
Recursively searches the menu for a match to a WComponent with the given name.
@param node the current node in the menu being searched.
@param name the component class name to search for.
@param partial if true, perform a case-insensitive partial name search.
@return the class for the given name, or null if not found.
"""
if (node instanceof WMenuItem) {
ExampleData data = (ExampleData) ((WMenuItem) node).getActionObject();
Class<? extends WComponent> clazz = data.getExampleClass();
if (clazz.getName().equals(name) || data.getExampleName().equals(name)
|| (partial && clazz.getSimpleName().toLowerCase().contains(name.toLowerCase()))
|| (partial && data.getExampleName().toLowerCase().contains(name.toLowerCase()))) {
return data;
}
} else if (node instanceof Container) {
for (int i = 0; i < ((Container) node).getChildCount(); i++) {
ExampleData result = getMatch(((Container) node).getChildAt(i), name, partial);
if (result != null) {
return result;
}
}
}
return null;
}
|
java
|
private ExampleData getMatch(final WComponent node, final String name, final boolean partial) {
if (node instanceof WMenuItem) {
ExampleData data = (ExampleData) ((WMenuItem) node).getActionObject();
Class<? extends WComponent> clazz = data.getExampleClass();
if (clazz.getName().equals(name) || data.getExampleName().equals(name)
|| (partial && clazz.getSimpleName().toLowerCase().contains(name.toLowerCase()))
|| (partial && data.getExampleName().toLowerCase().contains(name.toLowerCase()))) {
return data;
}
} else if (node instanceof Container) {
for (int i = 0; i < ((Container) node).getChildCount(); i++) {
ExampleData result = getMatch(((Container) node).getChildAt(i), name, partial);
if (result != null) {
return result;
}
}
}
return null;
}
|
[
"private",
"ExampleData",
"getMatch",
"(",
"final",
"WComponent",
"node",
",",
"final",
"String",
"name",
",",
"final",
"boolean",
"partial",
")",
"{",
"if",
"(",
"node",
"instanceof",
"WMenuItem",
")",
"{",
"ExampleData",
"data",
"=",
"(",
"ExampleData",
")",
"(",
"(",
"WMenuItem",
")",
"node",
")",
".",
"getActionObject",
"(",
")",
";",
"Class",
"<",
"?",
"extends",
"WComponent",
">",
"clazz",
"=",
"data",
".",
"getExampleClass",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"||",
"data",
".",
"getExampleName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"||",
"(",
"partial",
"&&",
"clazz",
".",
"getSimpleName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
")",
"||",
"(",
"partial",
"&&",
"data",
".",
"getExampleName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
")",
")",
"{",
"return",
"data",
";",
"}",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"Container",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"(",
"Container",
")",
"node",
")",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"ExampleData",
"result",
"=",
"getMatch",
"(",
"(",
"(",
"Container",
")",
"node",
")",
".",
"getChildAt",
"(",
"i",
")",
",",
"name",
",",
"partial",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Recursively searches the menu for a match to a WComponent with the given name.
@param node the current node in the menu being searched.
@param name the component class name to search for.
@param partial if true, perform a case-insensitive partial name search.
@return the class for the given name, or null if not found.
|
[
"Recursively",
"searches",
"the",
"menu",
"for",
"a",
"match",
"to",
"a",
"WComponent",
"with",
"the",
"given",
"name",
"."
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L172-L194
|
ow2-chameleon/fuchsia
|
bases/knx/calimero/src/main/java/tuwien/auto/calimero/log/LogStreamWriter.java
|
LogStreamWriter.formatOutput
|
protected String formatOutput(String svc, LogLevel l, String msg, Throwable t) {
"""
Creates a formatted output string from the input parameters.
<p>
Override this method to provide a different output format.<br>
The output returned by default follows the shown format. The date/time format is
according ISO 8601 representation, extended format with decimal fraction of second
(milliseconds):<br>
"YYYY-MM-DD hh:mm:ss,sss level=<code>level.toString()</code>,
<code>logService</code>: <code>msg</code> (<code>t.getMessage()</code>)"<br>
or, if throwable is <code>null</code> or throwable-message is <code>null</code><br>
"YYYY-MM-DD hh:mm:ss,sss logService, LogLevel=<code>level.toString()</code>:
<code>msg</code>".<br>
If <code>logService</code> contains '.' in the name, only the part after the last
'.' will be used. This way names like "package.subpackage.name" are shortened to
"name". Nevertheless, if the first character after '.' is numeric, no truncation
will be done to allow e.g. IP addresses in the log service name.
@param svc name of the log service the message comes from
@param l log level of message and throwable
@param msg message to format
@param t an optional throwable object to format, might be <code>null</code>
@return the formatted output
"""
// ??? for more severe output levels, a formatting routine which
// uses (part of) the throwable stack trace would be of advantage
final StringBuffer b = new StringBuffer(150);
synchronized (c) {
c.setTimeInMillis(System.currentTimeMillis());
b.append(c.get(Calendar.YEAR));
b.append('-').append(pad2Digits(c.get(Calendar.MONTH) + 1));
b.append('-').append(pad2Digits(c.get(Calendar.DAY_OF_MONTH)));
b.append(' ').append(pad2Digits(c.get(Calendar.HOUR_OF_DAY)));
b.append(':').append(pad2Digits(c.get(Calendar.MINUTE)));
b.append(':').append(pad2Digits(c.get(Calendar.SECOND)));
final int ms = c.get(Calendar.MILLISECOND);
b.append(',');
if (ms < 99)
b.append('0');
b.append(pad2Digits(ms));
}
b.append(" level=").append(l.toString());
b.append(", ");
final int dot = svc.lastIndexOf('.') + 1;
if (dot > 0 && dot < svc.length() && Character.isDigit(svc.charAt(dot)))
b.append(svc);
else
b.append(svc.substring(dot));
b.append(": ").append(msg);
if (t != null && t.getMessage() != null)
b.append(" (").append(t.getMessage()).append(")");
return b.toString();
}
|
java
|
protected String formatOutput(String svc, LogLevel l, String msg, Throwable t)
{
// ??? for more severe output levels, a formatting routine which
// uses (part of) the throwable stack trace would be of advantage
final StringBuffer b = new StringBuffer(150);
synchronized (c) {
c.setTimeInMillis(System.currentTimeMillis());
b.append(c.get(Calendar.YEAR));
b.append('-').append(pad2Digits(c.get(Calendar.MONTH) + 1));
b.append('-').append(pad2Digits(c.get(Calendar.DAY_OF_MONTH)));
b.append(' ').append(pad2Digits(c.get(Calendar.HOUR_OF_DAY)));
b.append(':').append(pad2Digits(c.get(Calendar.MINUTE)));
b.append(':').append(pad2Digits(c.get(Calendar.SECOND)));
final int ms = c.get(Calendar.MILLISECOND);
b.append(',');
if (ms < 99)
b.append('0');
b.append(pad2Digits(ms));
}
b.append(" level=").append(l.toString());
b.append(", ");
final int dot = svc.lastIndexOf('.') + 1;
if (dot > 0 && dot < svc.length() && Character.isDigit(svc.charAt(dot)))
b.append(svc);
else
b.append(svc.substring(dot));
b.append(": ").append(msg);
if (t != null && t.getMessage() != null)
b.append(" (").append(t.getMessage()).append(")");
return b.toString();
}
|
[
"protected",
"String",
"formatOutput",
"(",
"String",
"svc",
",",
"LogLevel",
"l",
",",
"String",
"msg",
",",
"Throwable",
"t",
")",
"{",
"// ??? for more severe output levels, a formatting routine which\r",
"// uses (part of) the throwable stack trace would be of advantage\r",
"final",
"StringBuffer",
"b",
"=",
"new",
"StringBuffer",
"(",
"150",
")",
";",
"synchronized",
"(",
"c",
")",
"{",
"c",
".",
"setTimeInMillis",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"b",
".",
"append",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"pad2Digits",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
"+",
"1",
")",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"pad2Digits",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
")",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"pad2Digits",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
")",
")",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"pad2Digits",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"MINUTE",
")",
")",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"pad2Digits",
"(",
"c",
".",
"get",
"(",
"Calendar",
".",
"SECOND",
")",
")",
")",
";",
"final",
"int",
"ms",
"=",
"c",
".",
"get",
"(",
"Calendar",
".",
"MILLISECOND",
")",
";",
"b",
".",
"append",
"(",
"'",
"'",
")",
";",
"if",
"(",
"ms",
"<",
"99",
")",
"b",
".",
"append",
"(",
"'",
"'",
")",
";",
"b",
".",
"append",
"(",
"pad2Digits",
"(",
"ms",
")",
")",
";",
"}",
"b",
".",
"append",
"(",
"\" level=\"",
")",
".",
"append",
"(",
"l",
".",
"toString",
"(",
")",
")",
";",
"b",
".",
"append",
"(",
"\", \"",
")",
";",
"final",
"int",
"dot",
"=",
"svc",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
";",
"if",
"(",
"dot",
">",
"0",
"&&",
"dot",
"<",
"svc",
".",
"length",
"(",
")",
"&&",
"Character",
".",
"isDigit",
"(",
"svc",
".",
"charAt",
"(",
"dot",
")",
")",
")",
"b",
".",
"append",
"(",
"svc",
")",
";",
"else",
"b",
".",
"append",
"(",
"svc",
".",
"substring",
"(",
"dot",
")",
")",
";",
"b",
".",
"append",
"(",
"\": \"",
")",
".",
"append",
"(",
"msg",
")",
";",
"if",
"(",
"t",
"!=",
"null",
"&&",
"t",
".",
"getMessage",
"(",
")",
"!=",
"null",
")",
"b",
".",
"append",
"(",
"\" (\"",
")",
".",
"append",
"(",
"t",
".",
"getMessage",
"(",
")",
")",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"b",
".",
"toString",
"(",
")",
";",
"}"
] |
Creates a formatted output string from the input parameters.
<p>
Override this method to provide a different output format.<br>
The output returned by default follows the shown format. The date/time format is
according ISO 8601 representation, extended format with decimal fraction of second
(milliseconds):<br>
"YYYY-MM-DD hh:mm:ss,sss level=<code>level.toString()</code>,
<code>logService</code>: <code>msg</code> (<code>t.getMessage()</code>)"<br>
or, if throwable is <code>null</code> or throwable-message is <code>null</code><br>
"YYYY-MM-DD hh:mm:ss,sss logService, LogLevel=<code>level.toString()</code>:
<code>msg</code>".<br>
If <code>logService</code> contains '.' in the name, only the part after the last
'.' will be used. This way names like "package.subpackage.name" are shortened to
"name". Nevertheless, if the first character after '.' is numeric, no truncation
will be done to allow e.g. IP addresses in the log service name.
@param svc name of the log service the message comes from
@param l log level of message and throwable
@param msg message to format
@param t an optional throwable object to format, might be <code>null</code>
@return the formatted output
|
[
"Creates",
"a",
"formatted",
"output",
"string",
"from",
"the",
"input",
"parameters",
".",
"<p",
">",
"Override",
"this",
"method",
"to",
"provide",
"a",
"different",
"output",
"format",
".",
"<br",
">",
"The",
"output",
"returned",
"by",
"default",
"follows",
"the",
"shown",
"format",
".",
"The",
"date",
"/",
"time",
"format",
"is",
"according",
"ISO",
"8601",
"representation",
"extended",
"format",
"with",
"decimal",
"fraction",
"of",
"second",
"(",
"milliseconds",
")",
":",
"<br",
">",
"YYYY",
"-",
"MM",
"-",
"DD",
"hh",
":",
"mm",
":",
"ss",
"sss",
"level",
"=",
"<code",
">",
"level",
".",
"toString",
"()",
"<",
"/",
"code",
">",
"<code",
">",
"logService<",
"/",
"code",
">",
":",
"<code",
">",
"msg<",
"/",
"code",
">",
"(",
"<code",
">",
"t",
".",
"getMessage",
"()",
"<",
"/",
"code",
">",
")",
"<br",
">",
"or",
"if",
"throwable",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"or",
"throwable",
"-",
"message",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"<br",
">",
"YYYY",
"-",
"MM",
"-",
"DD",
"hh",
":",
"mm",
":",
"ss",
"sss",
"logService",
"LogLevel",
"=",
"<code",
">",
"level",
".",
"toString",
"()",
"<",
"/",
"code",
">",
":",
"<code",
">",
"msg<",
"/",
"code",
">",
".",
"<br",
">",
"If",
"<code",
">",
"logService<",
"/",
"code",
">",
"contains",
".",
"in",
"the",
"name",
"only",
"the",
"part",
"after",
"the",
"last",
".",
"will",
"be",
"used",
".",
"This",
"way",
"names",
"like",
"package",
".",
"subpackage",
".",
"name",
"are",
"shortened",
"to",
"name",
".",
"Nevertheless",
"if",
"the",
"first",
"character",
"after",
".",
"is",
"numeric",
"no",
"truncation",
"will",
"be",
"done",
"to",
"allow",
"e",
".",
"g",
".",
"IP",
"addresses",
"in",
"the",
"log",
"service",
"name",
"."
] |
train
|
https://github.com/ow2-chameleon/fuchsia/blob/4e9318eadbdeb945e529789f573b45386e619bed/bases/knx/calimero/src/main/java/tuwien/auto/calimero/log/LogStreamWriter.java#L257-L287
|
apache/flink
|
flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java
|
Configuration.getTimeDurationHelper
|
public long getTimeDurationHelper(String name, String vStr, TimeUnit unit) {
"""
Return time duration in the given time unit. Valid units are encoded in
properties as suffixes: nanoseconds (ns), microseconds (us), milliseconds
(ms), seconds (s), minutes (m), hours (h), and days (d).
@param name Property name
@param vStr The string value with time unit suffix to be converted.
@param unit Unit to convert the stored property, if it exists.
"""
vStr = vStr.trim();
vStr = StringUtils.toLowerCase(vStr);
ParsedTimeDuration vUnit = ParsedTimeDuration.unitFor(vStr);
if (null == vUnit) {
logDeprecation("No unit for " + name + "(" + vStr + ") assuming " + unit);
vUnit = ParsedTimeDuration.unitFor(unit);
} else {
vStr = vStr.substring(0, vStr.lastIndexOf(vUnit.suffix()));
}
long raw = Long.parseLong(vStr);
long converted = unit.convert(raw, vUnit.unit());
if (vUnit.unit().convert(converted, unit) < raw) {
logDeprecation("Possible loss of precision converting " + vStr
+ vUnit.suffix() + " to " + unit + " for " + name);
}
return converted;
}
|
java
|
public long getTimeDurationHelper(String name, String vStr, TimeUnit unit) {
vStr = vStr.trim();
vStr = StringUtils.toLowerCase(vStr);
ParsedTimeDuration vUnit = ParsedTimeDuration.unitFor(vStr);
if (null == vUnit) {
logDeprecation("No unit for " + name + "(" + vStr + ") assuming " + unit);
vUnit = ParsedTimeDuration.unitFor(unit);
} else {
vStr = vStr.substring(0, vStr.lastIndexOf(vUnit.suffix()));
}
long raw = Long.parseLong(vStr);
long converted = unit.convert(raw, vUnit.unit());
if (vUnit.unit().convert(converted, unit) < raw) {
logDeprecation("Possible loss of precision converting " + vStr
+ vUnit.suffix() + " to " + unit + " for " + name);
}
return converted;
}
|
[
"public",
"long",
"getTimeDurationHelper",
"(",
"String",
"name",
",",
"String",
"vStr",
",",
"TimeUnit",
"unit",
")",
"{",
"vStr",
"=",
"vStr",
".",
"trim",
"(",
")",
";",
"vStr",
"=",
"StringUtils",
".",
"toLowerCase",
"(",
"vStr",
")",
";",
"ParsedTimeDuration",
"vUnit",
"=",
"ParsedTimeDuration",
".",
"unitFor",
"(",
"vStr",
")",
";",
"if",
"(",
"null",
"==",
"vUnit",
")",
"{",
"logDeprecation",
"(",
"\"No unit for \"",
"+",
"name",
"+",
"\"(\"",
"+",
"vStr",
"+",
"\") assuming \"",
"+",
"unit",
")",
";",
"vUnit",
"=",
"ParsedTimeDuration",
".",
"unitFor",
"(",
"unit",
")",
";",
"}",
"else",
"{",
"vStr",
"=",
"vStr",
".",
"substring",
"(",
"0",
",",
"vStr",
".",
"lastIndexOf",
"(",
"vUnit",
".",
"suffix",
"(",
")",
")",
")",
";",
"}",
"long",
"raw",
"=",
"Long",
".",
"parseLong",
"(",
"vStr",
")",
";",
"long",
"converted",
"=",
"unit",
".",
"convert",
"(",
"raw",
",",
"vUnit",
".",
"unit",
"(",
")",
")",
";",
"if",
"(",
"vUnit",
".",
"unit",
"(",
")",
".",
"convert",
"(",
"converted",
",",
"unit",
")",
"<",
"raw",
")",
"{",
"logDeprecation",
"(",
"\"Possible loss of precision converting \"",
"+",
"vStr",
"+",
"vUnit",
".",
"suffix",
"(",
")",
"+",
"\" to \"",
"+",
"unit",
"+",
"\" for \"",
"+",
"name",
")",
";",
"}",
"return",
"converted",
";",
"}"
] |
Return time duration in the given time unit. Valid units are encoded in
properties as suffixes: nanoseconds (ns), microseconds (us), milliseconds
(ms), seconds (s), minutes (m), hours (h), and days (d).
@param name Property name
@param vStr The string value with time unit suffix to be converted.
@param unit Unit to convert the stored property, if it exists.
|
[
"Return",
"time",
"duration",
"in",
"the",
"given",
"time",
"unit",
".",
"Valid",
"units",
"are",
"encoded",
"in",
"properties",
"as",
"suffixes",
":",
"nanoseconds",
"(",
"ns",
")",
"microseconds",
"(",
"us",
")",
"milliseconds",
"(",
"ms",
")",
"seconds",
"(",
"s",
")",
"minutes",
"(",
"m",
")",
"hours",
"(",
"h",
")",
"and",
"days",
"(",
"d",
")",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L1688-L1706
|
hal/elemento
|
samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java
|
TodoItemElement.create
|
static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) {
"""
Don't use ApplicationElement directly as this will lead to a dependency cycle in the generated GIN code!
"""
return new Templated_TodoItemElement(application, repository);
}
|
java
|
static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) {
return new Templated_TodoItemElement(application, repository);
}
|
[
"static",
"TodoItemElement",
"create",
"(",
"Provider",
"<",
"ApplicationElement",
">",
"application",
",",
"TodoItemRepository",
"repository",
")",
"{",
"return",
"new",
"Templated_TodoItemElement",
"(",
"application",
",",
"repository",
")",
";",
"}"
] |
Don't use ApplicationElement directly as this will lead to a dependency cycle in the generated GIN code!
|
[
"Don",
"t",
"use",
"ApplicationElement",
"directly",
"as",
"this",
"will",
"lead",
"to",
"a",
"dependency",
"cycle",
"in",
"the",
"generated",
"GIN",
"code!"
] |
train
|
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java#L39-L41
|
googleads/googleads-java-lib
|
modules/ads_lib_axis/src/main/java/com/google/api/ads/common/lib/soap/axis/HttpHandler.java
|
HttpHandler.createResponseMessage
|
private Message createResponseMessage(HttpResponse httpResponse) throws IOException, AxisFault {
"""
Returns a new Axis Message based on the contents of the HTTP response.
@param httpResponse the HTTP response
@return an Axis Message for the HTTP response
@throws IOException if unable to retrieve the HTTP response's contents
@throws AxisFault if the HTTP response's status or contents indicate an unexpected error, such
as a 405.
"""
int statusCode = httpResponse.getStatusCode();
String contentType = httpResponse.getContentType();
// The conditions below duplicate the logic in CommonsHTTPSender and HTTPSender.
boolean shouldParseResponse =
(statusCode > 199 && statusCode < 300)
|| (contentType != null
&& !contentType.equals("text/html")
&& statusCode > 499
&& statusCode < 600);
// Wrap the content input stream in a notifying stream so the stream event listener will be
// notified when it is closed.
InputStream responseInputStream =
new NotifyingInputStream(httpResponse.getContent(), inputStreamEventListener);
if (!shouldParseResponse) {
// The contents are not an XML response, so throw an AxisFault with
// the HTTP status code and message details.
String statusMessage = httpResponse.getStatusMessage();
AxisFault axisFault =
new AxisFault("HTTP", "(" + statusCode + ")" + statusMessage, null, null);
axisFault.addFaultDetail(
Constants.QNAME_FAULTDETAIL_HTTPERRORCODE, String.valueOf(statusCode));
try (InputStream stream = responseInputStream) {
byte[] contentBytes = ByteStreams.toByteArray(stream);
axisFault.setFaultDetailString(
Messages.getMessage(
"return01", String.valueOf(statusCode), new String(contentBytes, UTF_8)));
}
throw axisFault;
}
// Response is an XML response. Do not consume and close the stream in this case, since that
// will happen later when the response is deserialized by Axis (as confirmed by unit tests for
// this class).
Message responseMessage =
new Message(
responseInputStream, false, contentType, httpResponse.getHeaders().getLocation());
responseMessage.setMessageType(Message.RESPONSE);
return responseMessage;
}
|
java
|
private Message createResponseMessage(HttpResponse httpResponse) throws IOException, AxisFault {
int statusCode = httpResponse.getStatusCode();
String contentType = httpResponse.getContentType();
// The conditions below duplicate the logic in CommonsHTTPSender and HTTPSender.
boolean shouldParseResponse =
(statusCode > 199 && statusCode < 300)
|| (contentType != null
&& !contentType.equals("text/html")
&& statusCode > 499
&& statusCode < 600);
// Wrap the content input stream in a notifying stream so the stream event listener will be
// notified when it is closed.
InputStream responseInputStream =
new NotifyingInputStream(httpResponse.getContent(), inputStreamEventListener);
if (!shouldParseResponse) {
// The contents are not an XML response, so throw an AxisFault with
// the HTTP status code and message details.
String statusMessage = httpResponse.getStatusMessage();
AxisFault axisFault =
new AxisFault("HTTP", "(" + statusCode + ")" + statusMessage, null, null);
axisFault.addFaultDetail(
Constants.QNAME_FAULTDETAIL_HTTPERRORCODE, String.valueOf(statusCode));
try (InputStream stream = responseInputStream) {
byte[] contentBytes = ByteStreams.toByteArray(stream);
axisFault.setFaultDetailString(
Messages.getMessage(
"return01", String.valueOf(statusCode), new String(contentBytes, UTF_8)));
}
throw axisFault;
}
// Response is an XML response. Do not consume and close the stream in this case, since that
// will happen later when the response is deserialized by Axis (as confirmed by unit tests for
// this class).
Message responseMessage =
new Message(
responseInputStream, false, contentType, httpResponse.getHeaders().getLocation());
responseMessage.setMessageType(Message.RESPONSE);
return responseMessage;
}
|
[
"private",
"Message",
"createResponseMessage",
"(",
"HttpResponse",
"httpResponse",
")",
"throws",
"IOException",
",",
"AxisFault",
"{",
"int",
"statusCode",
"=",
"httpResponse",
".",
"getStatusCode",
"(",
")",
";",
"String",
"contentType",
"=",
"httpResponse",
".",
"getContentType",
"(",
")",
";",
"// The conditions below duplicate the logic in CommonsHTTPSender and HTTPSender.",
"boolean",
"shouldParseResponse",
"=",
"(",
"statusCode",
">",
"199",
"&&",
"statusCode",
"<",
"300",
")",
"||",
"(",
"contentType",
"!=",
"null",
"&&",
"!",
"contentType",
".",
"equals",
"(",
"\"text/html\"",
")",
"&&",
"statusCode",
">",
"499",
"&&",
"statusCode",
"<",
"600",
")",
";",
"// Wrap the content input stream in a notifying stream so the stream event listener will be",
"// notified when it is closed.",
"InputStream",
"responseInputStream",
"=",
"new",
"NotifyingInputStream",
"(",
"httpResponse",
".",
"getContent",
"(",
")",
",",
"inputStreamEventListener",
")",
";",
"if",
"(",
"!",
"shouldParseResponse",
")",
"{",
"// The contents are not an XML response, so throw an AxisFault with",
"// the HTTP status code and message details.",
"String",
"statusMessage",
"=",
"httpResponse",
".",
"getStatusMessage",
"(",
")",
";",
"AxisFault",
"axisFault",
"=",
"new",
"AxisFault",
"(",
"\"HTTP\"",
",",
"\"(\"",
"+",
"statusCode",
"+",
"\")\"",
"+",
"statusMessage",
",",
"null",
",",
"null",
")",
";",
"axisFault",
".",
"addFaultDetail",
"(",
"Constants",
".",
"QNAME_FAULTDETAIL_HTTPERRORCODE",
",",
"String",
".",
"valueOf",
"(",
"statusCode",
")",
")",
";",
"try",
"(",
"InputStream",
"stream",
"=",
"responseInputStream",
")",
"{",
"byte",
"[",
"]",
"contentBytes",
"=",
"ByteStreams",
".",
"toByteArray",
"(",
"stream",
")",
";",
"axisFault",
".",
"setFaultDetailString",
"(",
"Messages",
".",
"getMessage",
"(",
"\"return01\"",
",",
"String",
".",
"valueOf",
"(",
"statusCode",
")",
",",
"new",
"String",
"(",
"contentBytes",
",",
"UTF_8",
")",
")",
")",
";",
"}",
"throw",
"axisFault",
";",
"}",
"// Response is an XML response. Do not consume and close the stream in this case, since that",
"// will happen later when the response is deserialized by Axis (as confirmed by unit tests for",
"// this class).",
"Message",
"responseMessage",
"=",
"new",
"Message",
"(",
"responseInputStream",
",",
"false",
",",
"contentType",
",",
"httpResponse",
".",
"getHeaders",
"(",
")",
".",
"getLocation",
"(",
")",
")",
";",
"responseMessage",
".",
"setMessageType",
"(",
"Message",
".",
"RESPONSE",
")",
";",
"return",
"responseMessage",
";",
"}"
] |
Returns a new Axis Message based on the contents of the HTTP response.
@param httpResponse the HTTP response
@return an Axis Message for the HTTP response
@throws IOException if unable to retrieve the HTTP response's contents
@throws AxisFault if the HTTP response's status or contents indicate an unexpected error, such
as a 405.
|
[
"Returns",
"a",
"new",
"Axis",
"Message",
"based",
"on",
"the",
"contents",
"of",
"the",
"HTTP",
"response",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib_axis/src/main/java/com/google/api/ads/common/lib/soap/axis/HttpHandler.java#L190-L228
|
acromusashi/acromusashi-stream
|
src/main/java/acromusashi/stream/bean/FieldExtractor.java
|
FieldExtractor.extractKeyHead
|
public static String extractKeyHead(String key, String delimeter) {
"""
Extract the value of keyHead.
@param key is used to get string.
@param delimeter key delimeter
@return the value of keyHead .
"""
int index = key.indexOf(delimeter);
if (index == -1)
{
return key;
}
String result = key.substring(0, index);
return result;
}
|
java
|
public static String extractKeyHead(String key, String delimeter)
{
int index = key.indexOf(delimeter);
if (index == -1)
{
return key;
}
String result = key.substring(0, index);
return result;
}
|
[
"public",
"static",
"String",
"extractKeyHead",
"(",
"String",
"key",
",",
"String",
"delimeter",
")",
"{",
"int",
"index",
"=",
"key",
".",
"indexOf",
"(",
"delimeter",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"key",
";",
"}",
"String",
"result",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"return",
"result",
";",
"}"
] |
Extract the value of keyHead.
@param key is used to get string.
@param delimeter key delimeter
@return the value of keyHead .
|
[
"Extract",
"the",
"value",
"of",
"keyHead",
"."
] |
train
|
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bean/FieldExtractor.java#L87-L97
|
JOML-CI/JOML
|
src/org/joml/Matrix4f.java
|
Matrix4f.setOrthoSymmetric
|
public Matrix4f setOrthoSymmetric(float width, float height, float zNear, float zFar, boolean zZeroToOne) {
"""
Set this matrix to be a symmetric orthographic projection transformation for a right-handed coordinate system using the given NDC z range.
<p>
This method is equivalent to calling {@link #setOrtho(float, float, float, float, float, float, boolean) setOrtho()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
In order to apply the symmetric orthographic projection to an already existing transformation,
use {@link #orthoSymmetric(float, float, float, float, boolean) orthoSymmetric()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #orthoSymmetric(float, float, float, float, boolean)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this
"""
if ((properties & PROPERTY_IDENTITY) == 0)
MemUtil.INSTANCE.identity(this);
this._m00(2.0f / width);
this._m11(2.0f / height);
this._m22((zZeroToOne ? 1.0f : 2.0f) / (zNear - zFar));
this._m32((zZeroToOne ? zNear : (zFar + zNear)) / (zNear - zFar));
_properties(PROPERTY_AFFINE);
return this;
}
|
java
|
public Matrix4f setOrthoSymmetric(float width, float height, float zNear, float zFar, boolean zZeroToOne) {
if ((properties & PROPERTY_IDENTITY) == 0)
MemUtil.INSTANCE.identity(this);
this._m00(2.0f / width);
this._m11(2.0f / height);
this._m22((zZeroToOne ? 1.0f : 2.0f) / (zNear - zFar));
this._m32((zZeroToOne ? zNear : (zFar + zNear)) / (zNear - zFar));
_properties(PROPERTY_AFFINE);
return this;
}
|
[
"public",
"Matrix4f",
"setOrthoSymmetric",
"(",
"float",
"width",
",",
"float",
"height",
",",
"float",
"zNear",
",",
"float",
"zFar",
",",
"boolean",
"zZeroToOne",
")",
"{",
"if",
"(",
"(",
"properties",
"&",
"PROPERTY_IDENTITY",
")",
"==",
"0",
")",
"MemUtil",
".",
"INSTANCE",
".",
"identity",
"(",
"this",
")",
";",
"this",
".",
"_m00",
"(",
"2.0f",
"/",
"width",
")",
";",
"this",
".",
"_m11",
"(",
"2.0f",
"/",
"height",
")",
";",
"this",
".",
"_m22",
"(",
"(",
"zZeroToOne",
"?",
"1.0f",
":",
"2.0f",
")",
"/",
"(",
"zNear",
"-",
"zFar",
")",
")",
";",
"this",
".",
"_m32",
"(",
"(",
"zZeroToOne",
"?",
"zNear",
":",
"(",
"zFar",
"+",
"zNear",
")",
")",
"/",
"(",
"zNear",
"-",
"zFar",
")",
")",
";",
"_properties",
"(",
"PROPERTY_AFFINE",
")",
";",
"return",
"this",
";",
"}"
] |
Set this matrix to be a symmetric orthographic projection transformation for a right-handed coordinate system using the given NDC z range.
<p>
This method is equivalent to calling {@link #setOrtho(float, float, float, float, float, float, boolean) setOrtho()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
In order to apply the symmetric orthographic projection to an already existing transformation,
use {@link #orthoSymmetric(float, float, float, float, boolean) orthoSymmetric()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #orthoSymmetric(float, float, float, float, boolean)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this
|
[
"Set",
"this",
"matrix",
"to",
"be",
"a",
"symmetric",
"orthographic",
"projection",
"transformation",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"using",
"the",
"given",
"NDC",
"z",
"range",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
"{",
"@link",
"#setOrtho",
"(",
"float",
"float",
"float",
"float",
"float",
"float",
"boolean",
")",
"setOrtho",
"()",
"}",
"with",
"<code",
">",
"left",
"=",
"-",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"right",
"=",
"+",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"bottom",
"=",
"-",
"height",
"/",
"2<",
"/",
"code",
">",
"and",
"<code",
">",
"top",
"=",
"+",
"height",
"/",
"2<",
"/",
"code",
">",
".",
"<p",
">",
"In",
"order",
"to",
"apply",
"the",
"symmetric",
"orthographic",
"projection",
"to",
"an",
"already",
"existing",
"transformation",
"use",
"{",
"@link",
"#orthoSymmetric",
"(",
"float",
"float",
"float",
"float",
"boolean",
")",
"orthoSymmetric",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca",
"/",
"opengl",
"/",
"gl_projectionmatrix",
".",
"html#ortho",
">",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca<",
"/",
"a",
">"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L7668-L7677
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
|
DefaultGroovyMethods.intdiv
|
public static Number intdiv(Character left, Number right) {
"""
Integer Divide a Character by a Number. The ordinal value of the Character
is used in the division (the ordinal value is the unicode
value which for simple character sets is the ASCII value).
@param left a Character
@param right a Number
@return a Number (an Integer) resulting from the integer division operation
@since 1.0
"""
return intdiv(Integer.valueOf(left), right);
}
|
java
|
public static Number intdiv(Character left, Number right) {
return intdiv(Integer.valueOf(left), right);
}
|
[
"public",
"static",
"Number",
"intdiv",
"(",
"Character",
"left",
",",
"Number",
"right",
")",
"{",
"return",
"intdiv",
"(",
"Integer",
".",
"valueOf",
"(",
"left",
")",
",",
"right",
")",
";",
"}"
] |
Integer Divide a Character by a Number. The ordinal value of the Character
is used in the division (the ordinal value is the unicode
value which for simple character sets is the ASCII value).
@param left a Character
@param right a Number
@return a Number (an Integer) resulting from the integer division operation
@since 1.0
|
[
"Integer",
"Divide",
"a",
"Character",
"by",
"a",
"Number",
".",
"The",
"ordinal",
"value",
"of",
"the",
"Character",
"is",
"used",
"in",
"the",
"division",
"(",
"the",
"ordinal",
"value",
"is",
"the",
"unicode",
"value",
"which",
"for",
"simple",
"character",
"sets",
"is",
"the",
"ASCII",
"value",
")",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15394-L15396
|
Mozu/mozu-java
|
mozu-java-core/src/main/java/com/mozu/api/urls/platform/ApplicationUrl.java
|
ApplicationUrl.getPackageFileMetadataUrl
|
public static MozuUrl getPackageFileMetadataUrl(String applicationKey, String filepath, String responseFields) {
"""
Get Resource Url for GetPackageFileMetadata
@param applicationKey The application key uniquely identifies the developer namespace, application ID, version, and package in Dev Center. The format is {Dev Account namespace}.{Application ID}.{Application Version}.{Package name}.
@param filepath Represents the file name and location.
@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
"""
UrlFormatter formatter = new UrlFormatter("/api/platform/developer/packages/{applicationKey}/filemetadata/{filepath}?responseFields={responseFields}");
formatter.formatUrl("applicationKey", applicationKey);
formatter.formatUrl("filepath", filepath);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.HOME_POD) ;
}
|
java
|
public static MozuUrl getPackageFileMetadataUrl(String applicationKey, String filepath, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/developer/packages/{applicationKey}/filemetadata/{filepath}?responseFields={responseFields}");
formatter.formatUrl("applicationKey", applicationKey);
formatter.formatUrl("filepath", filepath);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.HOME_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"getPackageFileMetadataUrl",
"(",
"String",
"applicationKey",
",",
"String",
"filepath",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/platform/developer/packages/{applicationKey}/filemetadata/{filepath}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"applicationKey\"",
",",
"applicationKey",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"filepath\"",
",",
"filepath",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"HOME_POD",
")",
";",
"}"
] |
Get Resource Url for GetPackageFileMetadata
@param applicationKey The application key uniquely identifies the developer namespace, application ID, version, and package in Dev Center. The format is {Dev Account namespace}.{Application ID}.{Application Version}.{Package name}.
@param filepath Represents the file name and location.
@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",
"GetPackageFileMetadata"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/platform/ApplicationUrl.java#L51-L58
|
liuyukuai/commons
|
commons-core/src/main/java/com/itxiaoer/commons/core/beans/ProcessUtils.java
|
ProcessUtils.process
|
public static <T, R> R process(Class<R> clazz, T src, BiConsumer<R, T> biConsumer) {
"""
拷贝单个对象
@param clazz 目标类型
@param src 原对象
@param biConsumer 回调函数
@param <T> 原数据类型
@param <R> 目标数据类型
@return 目标对象
"""
if (Objects.isNull(clazz)) {
throw new IllegalArgumentException("the clazz argument must be not null");
}
if (Objects.isNull(src)) {
log.warn("the src argument must be not null, return null. ");
return null;
}
try {
R r = clazz.newInstance();
processObject(r, src, biConsumer);
return r;
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
|
java
|
public static <T, R> R process(Class<R> clazz, T src, BiConsumer<R, T> biConsumer) {
if (Objects.isNull(clazz)) {
throw new IllegalArgumentException("the clazz argument must be not null");
}
if (Objects.isNull(src)) {
log.warn("the src argument must be not null, return null. ");
return null;
}
try {
R r = clazz.newInstance();
processObject(r, src, biConsumer);
return r;
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"R",
"process",
"(",
"Class",
"<",
"R",
">",
"clazz",
",",
"T",
"src",
",",
"BiConsumer",
"<",
"R",
",",
"T",
">",
"biConsumer",
")",
"{",
"if",
"(",
"Objects",
".",
"isNull",
"(",
"clazz",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"the clazz argument must be not null\"",
")",
";",
"}",
"if",
"(",
"Objects",
".",
"isNull",
"(",
"src",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"the src argument must be not null, return null. \"",
")",
";",
"return",
"null",
";",
"}",
"try",
"{",
"R",
"r",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"processObject",
"(",
"r",
",",
"src",
",",
"biConsumer",
")",
";",
"return",
"r",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
拷贝单个对象
@param clazz 目标类型
@param src 原对象
@param biConsumer 回调函数
@param <T> 原数据类型
@param <R> 目标数据类型
@return 目标对象
|
[
"拷贝单个对象"
] |
train
|
https://github.com/liuyukuai/commons/blob/ba67eddb542446b12f419f1866dbaa82e47fbf35/commons-core/src/main/java/com/itxiaoer/commons/core/beans/ProcessUtils.java#L90-L105
|
kotcrab/vis-ui
|
ui/src/main/java/com/kotcrab/vis/ui/widget/VisWindow.java
|
VisWindow.addCloseButton
|
public void addCloseButton () {
"""
Adds close button to window, next to window title. After pressing that button, {@link #close()} is called. If nothing
else was added to title table, and current title alignment is center then the title will be automatically centered.
"""
Label titleLabel = getTitleLabel();
Table titleTable = getTitleTable();
VisImageButton closeButton = new VisImageButton("close-window");
titleTable.add(closeButton).padRight(-getPadRight() + 0.7f);
closeButton.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
close();
}
});
closeButton.addListener(new ClickListener() {
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
event.cancel();
return true;
}
});
if (titleLabel.getLabelAlign() == Align.center && titleTable.getChildren().size == 2)
titleTable.getCell(titleLabel).padLeft(closeButton.getWidth() * 2);
}
|
java
|
public void addCloseButton () {
Label titleLabel = getTitleLabel();
Table titleTable = getTitleTable();
VisImageButton closeButton = new VisImageButton("close-window");
titleTable.add(closeButton).padRight(-getPadRight() + 0.7f);
closeButton.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
close();
}
});
closeButton.addListener(new ClickListener() {
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
event.cancel();
return true;
}
});
if (titleLabel.getLabelAlign() == Align.center && titleTable.getChildren().size == 2)
titleTable.getCell(titleLabel).padLeft(closeButton.getWidth() * 2);
}
|
[
"public",
"void",
"addCloseButton",
"(",
")",
"{",
"Label",
"titleLabel",
"=",
"getTitleLabel",
"(",
")",
";",
"Table",
"titleTable",
"=",
"getTitleTable",
"(",
")",
";",
"VisImageButton",
"closeButton",
"=",
"new",
"VisImageButton",
"(",
"\"close-window\"",
")",
";",
"titleTable",
".",
"add",
"(",
"closeButton",
")",
".",
"padRight",
"(",
"-",
"getPadRight",
"(",
")",
"+",
"0.7f",
")",
";",
"closeButton",
".",
"addListener",
"(",
"new",
"ChangeListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"changed",
"(",
"ChangeEvent",
"event",
",",
"Actor",
"actor",
")",
"{",
"close",
"(",
")",
";",
"}",
"}",
")",
";",
"closeButton",
".",
"addListener",
"(",
"new",
"ClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"touchDown",
"(",
"InputEvent",
"event",
",",
"float",
"x",
",",
"float",
"y",
",",
"int",
"pointer",
",",
"int",
"button",
")",
"{",
"event",
".",
"cancel",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"titleLabel",
".",
"getLabelAlign",
"(",
")",
"==",
"Align",
".",
"center",
"&&",
"titleTable",
".",
"getChildren",
"(",
")",
".",
"size",
"==",
"2",
")",
"titleTable",
".",
"getCell",
"(",
"titleLabel",
")",
".",
"padLeft",
"(",
"closeButton",
".",
"getWidth",
"(",
")",
"*",
"2",
")",
";",
"}"
] |
Adds close button to window, next to window title. After pressing that button, {@link #close()} is called. If nothing
else was added to title table, and current title alignment is center then the title will be automatically centered.
|
[
"Adds",
"close",
"button",
"to",
"window",
"next",
"to",
"window",
"title",
".",
"After",
"pressing",
"that",
"button",
"{"
] |
train
|
https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/widget/VisWindow.java#L169-L191
|
classgraph/classgraph
|
src/main/java/nonapi/io/github/classgraph/utils/ReflectionUtils.java
|
ReflectionUtils.invokeStaticMethod
|
public static Object invokeStaticMethod(final Class<?> cls, final String methodName,
final boolean throwException) throws IllegalArgumentException {
"""
Invoke the named static method. If an exception is thrown while trying to call the method, and throwException
is true, then IllegalArgumentException is thrown wrapping the cause, otherwise this will return null. If
passed a null class reference, returns null unless throwException is true, then throws
IllegalArgumentException.
@param cls
The class.
@param methodName
The method name.
@param throwException
Whether to throw an exception on failure.
@return The result of the method invocation.
@throws IllegalArgumentException
If the method could not be invoked.
"""
if (cls == null || methodName == null) {
if (throwException) {
throw new NullPointerException();
} else {
return null;
}
}
return invokeMethod(cls, null, methodName, false, null, null, throwException);
}
|
java
|
public static Object invokeStaticMethod(final Class<?> cls, final String methodName,
final boolean throwException) throws IllegalArgumentException {
if (cls == null || methodName == null) {
if (throwException) {
throw new NullPointerException();
} else {
return null;
}
}
return invokeMethod(cls, null, methodName, false, null, null, throwException);
}
|
[
"public",
"static",
"Object",
"invokeStaticMethod",
"(",
"final",
"Class",
"<",
"?",
">",
"cls",
",",
"final",
"String",
"methodName",
",",
"final",
"boolean",
"throwException",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"cls",
"==",
"null",
"||",
"methodName",
"==",
"null",
")",
"{",
"if",
"(",
"throwException",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"invokeMethod",
"(",
"cls",
",",
"null",
",",
"methodName",
",",
"false",
",",
"null",
",",
"null",
",",
"throwException",
")",
";",
"}"
] |
Invoke the named static method. If an exception is thrown while trying to call the method, and throwException
is true, then IllegalArgumentException is thrown wrapping the cause, otherwise this will return null. If
passed a null class reference, returns null unless throwException is true, then throws
IllegalArgumentException.
@param cls
The class.
@param methodName
The method name.
@param throwException
Whether to throw an exception on failure.
@return The result of the method invocation.
@throws IllegalArgumentException
If the method could not be invoked.
|
[
"Invoke",
"the",
"named",
"static",
"method",
".",
"If",
"an",
"exception",
"is",
"thrown",
"while",
"trying",
"to",
"call",
"the",
"method",
"and",
"throwException",
"is",
"true",
"then",
"IllegalArgumentException",
"is",
"thrown",
"wrapping",
"the",
"cause",
"otherwise",
"this",
"will",
"return",
"null",
".",
"If",
"passed",
"a",
"null",
"class",
"reference",
"returns",
"null",
"unless",
"throwException",
"is",
"true",
"then",
"throws",
"IllegalArgumentException",
"."
] |
train
|
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/ReflectionUtils.java#L352-L362
|
geomajas/geomajas-project-client-gwt2
|
impl/src/main/java/org/geomajas/gwt2/client/service/TileService.java
|
TileService.getWorldBoundsForTile
|
public static Bbox getWorldBoundsForTile(TileConfiguration tileConfiguration, TileCode tileCode) {
"""
Given a tile for a layer, what are the tiles bounds in world space.
@param tileConfiguration The basic tile configuration.
@param tileCode The tile code.
@return The tile bounds in map CRS.
"""
double resolution = tileConfiguration.getResolution(tileCode.getTileLevel());
double worldTileWidth = tileConfiguration.getTileWidth() * resolution;
double worldTileHeight = tileConfiguration.getTileHeight() * resolution;
double x = tileConfiguration.getTileOrigin().getX() + tileCode.getX() * worldTileWidth;
double y = tileConfiguration.getTileOrigin().getY() + tileCode.getY() * worldTileHeight;
return new Bbox(x, y, worldTileWidth, worldTileHeight);
}
|
java
|
public static Bbox getWorldBoundsForTile(TileConfiguration tileConfiguration, TileCode tileCode) {
double resolution = tileConfiguration.getResolution(tileCode.getTileLevel());
double worldTileWidth = tileConfiguration.getTileWidth() * resolution;
double worldTileHeight = tileConfiguration.getTileHeight() * resolution;
double x = tileConfiguration.getTileOrigin().getX() + tileCode.getX() * worldTileWidth;
double y = tileConfiguration.getTileOrigin().getY() + tileCode.getY() * worldTileHeight;
return new Bbox(x, y, worldTileWidth, worldTileHeight);
}
|
[
"public",
"static",
"Bbox",
"getWorldBoundsForTile",
"(",
"TileConfiguration",
"tileConfiguration",
",",
"TileCode",
"tileCode",
")",
"{",
"double",
"resolution",
"=",
"tileConfiguration",
".",
"getResolution",
"(",
"tileCode",
".",
"getTileLevel",
"(",
")",
")",
";",
"double",
"worldTileWidth",
"=",
"tileConfiguration",
".",
"getTileWidth",
"(",
")",
"*",
"resolution",
";",
"double",
"worldTileHeight",
"=",
"tileConfiguration",
".",
"getTileHeight",
"(",
")",
"*",
"resolution",
";",
"double",
"x",
"=",
"tileConfiguration",
".",
"getTileOrigin",
"(",
")",
".",
"getX",
"(",
")",
"+",
"tileCode",
".",
"getX",
"(",
")",
"*",
"worldTileWidth",
";",
"double",
"y",
"=",
"tileConfiguration",
".",
"getTileOrigin",
"(",
")",
".",
"getY",
"(",
")",
"+",
"tileCode",
".",
"getY",
"(",
")",
"*",
"worldTileHeight",
";",
"return",
"new",
"Bbox",
"(",
"x",
",",
"y",
",",
"worldTileWidth",
",",
"worldTileHeight",
")",
";",
"}"
] |
Given a tile for a layer, what are the tiles bounds in world space.
@param tileConfiguration The basic tile configuration.
@param tileCode The tile code.
@return The tile bounds in map CRS.
|
[
"Given",
"a",
"tile",
"for",
"a",
"layer",
"what",
"are",
"the",
"tiles",
"bounds",
"in",
"world",
"space",
"."
] |
train
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/service/TileService.java#L83-L91
|
killbill/killbill
|
invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java
|
DefaultInvoiceDao.getInvoicesTags
|
private List<Tag> getInvoicesTags(final InternalTenantContext context) {
"""
PERF: fetch tags once. See also https://github.com/killbill/killbill/issues/720.
"""
return tagInternalApi.getTagsForAccountType(ObjectType.INVOICE, false, context);
}
|
java
|
private List<Tag> getInvoicesTags(final InternalTenantContext context) {
return tagInternalApi.getTagsForAccountType(ObjectType.INVOICE, false, context);
}
|
[
"private",
"List",
"<",
"Tag",
">",
"getInvoicesTags",
"(",
"final",
"InternalTenantContext",
"context",
")",
"{",
"return",
"tagInternalApi",
".",
"getTagsForAccountType",
"(",
"ObjectType",
".",
"INVOICE",
",",
"false",
",",
"context",
")",
";",
"}"
] |
PERF: fetch tags once. See also https://github.com/killbill/killbill/issues/720.
|
[
"PERF",
":",
"fetch",
"tags",
"once",
".",
"See",
"also",
"https",
":",
"//",
"github",
".",
"com",
"/",
"killbill",
"/",
"killbill",
"/",
"issues",
"/",
"720",
"."
] |
train
|
https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java#L1385-L1387
|
Gant/Gant
|
src/main/groovy/org/codehaus/gant/ant/Gant.java
|
Gant.addAlmostAll
|
private void addAlmostAll(final Project newProject, final Project oldProject) {
"""
Russel Winder rehacked the code provided by Eric Van Dewoestine.
"""
final Hashtable<String,Object> properties = oldProject.getProperties();
final Enumeration<String> e = properties.keys();
while (e.hasMoreElements()) {
final String key = e.nextElement();
if (!(MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key))) {
if (newProject.getProperty(key) == null) { newProject.setNewProperty(key, (String)properties.get(key)); }
}
}
}
|
java
|
private void addAlmostAll(final Project newProject, final Project oldProject) {
final Hashtable<String,Object> properties = oldProject.getProperties();
final Enumeration<String> e = properties.keys();
while (e.hasMoreElements()) {
final String key = e.nextElement();
if (!(MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key))) {
if (newProject.getProperty(key) == null) { newProject.setNewProperty(key, (String)properties.get(key)); }
}
}
}
|
[
"private",
"void",
"addAlmostAll",
"(",
"final",
"Project",
"newProject",
",",
"final",
"Project",
"oldProject",
")",
"{",
"final",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"oldProject",
".",
"getProperties",
"(",
")",
";",
"final",
"Enumeration",
"<",
"String",
">",
"e",
"=",
"properties",
".",
"keys",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"e",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"!",
"(",
"MagicNames",
".",
"PROJECT_BASEDIR",
".",
"equals",
"(",
"key",
")",
"||",
"MagicNames",
".",
"ANT_FILE",
".",
"equals",
"(",
"key",
")",
")",
")",
"{",
"if",
"(",
"newProject",
".",
"getProperty",
"(",
"key",
")",
"==",
"null",
")",
"{",
"newProject",
".",
"setNewProperty",
"(",
"key",
",",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Russel Winder rehacked the code provided by Eric Van Dewoestine.
|
[
"Russel",
"Winder",
"rehacked",
"the",
"code",
"provided",
"by",
"Eric",
"Van",
"Dewoestine",
"."
] |
train
|
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/ant/Gant.java#L204-L213
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.logging/src/com/ibm/ws/logging/internal/impl/LoggingConfigUtils.java
|
LoggingConfigUtils.getDelegate
|
public static <T> T getDelegate(Class<T> delegateClass, String className, String defaultDelegateClass) {
"""
Create a delegate instance of the specified (or default) delegate class.
@param delegate Specifically configured delegate class
@param defaultDelegateClass Default delegate class
@return constructed delegate instance
"""
if (className == null)
className = defaultDelegateClass;
try {
return Class.forName(className).asSubclass(delegateClass).newInstance();
} catch (Throwable e) {
System.err.println("Unable to locate configured delegate: " + delegateClass + ", " + e);
}
return null;
}
|
java
|
public static <T> T getDelegate(Class<T> delegateClass, String className, String defaultDelegateClass) {
if (className == null)
className = defaultDelegateClass;
try {
return Class.forName(className).asSubclass(delegateClass).newInstance();
} catch (Throwable e) {
System.err.println("Unable to locate configured delegate: " + delegateClass + ", " + e);
}
return null;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getDelegate",
"(",
"Class",
"<",
"T",
">",
"delegateClass",
",",
"String",
"className",
",",
"String",
"defaultDelegateClass",
")",
"{",
"if",
"(",
"className",
"==",
"null",
")",
"className",
"=",
"defaultDelegateClass",
";",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"className",
")",
".",
"asSubclass",
"(",
"delegateClass",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Unable to locate configured delegate: \"",
"+",
"delegateClass",
"+",
"\", \"",
"+",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Create a delegate instance of the specified (or default) delegate class.
@param delegate Specifically configured delegate class
@param defaultDelegateClass Default delegate class
@return constructed delegate instance
|
[
"Create",
"a",
"delegate",
"instance",
"of",
"the",
"specified",
"(",
"or",
"default",
")",
"delegate",
"class",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging/src/com/ibm/ws/logging/internal/impl/LoggingConfigUtils.java#L194-L204
|
khuxtable/seaglass
|
src/main/java/com/seaglasslookandfeel/painter/TitlePaneIconifyButtonPainter.java
|
TitlePaneIconifyButtonPainter.paintMinimizeEnabled
|
private void paintMinimizeEnabled(Graphics2D g, JComponent c, int width, int height) {
"""
Paint the foreground minimized button enabled state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
"""
iconifyPainter.paintEnabled(g, c, width, height);
}
|
java
|
private void paintMinimizeEnabled(Graphics2D g, JComponent c, int width, int height) {
iconifyPainter.paintEnabled(g, c, width, height);
}
|
[
"private",
"void",
"paintMinimizeEnabled",
"(",
"Graphics2D",
"g",
",",
"JComponent",
"c",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"iconifyPainter",
".",
"paintEnabled",
"(",
"g",
",",
"c",
",",
"width",
",",
"height",
")",
";",
"}"
] |
Paint the foreground minimized button enabled state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
|
[
"Paint",
"the",
"foreground",
"minimized",
"button",
"enabled",
"state",
"."
] |
train
|
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/TitlePaneIconifyButtonPainter.java#L171-L173
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/io/watch/WatchMonitor.java
|
WatchMonitor.createAll
|
public static WatchMonitor createAll(String path, Watcher watcher) {
"""
创建并初始化监听,监听所有事件
@param path 路径
@param watcher {@link Watcher}
@return {@link WatchMonitor}
"""
return createAll(Paths.get(path), watcher);
}
|
java
|
public static WatchMonitor createAll(String path, Watcher watcher){
return createAll(Paths.get(path), watcher);
}
|
[
"public",
"static",
"WatchMonitor",
"createAll",
"(",
"String",
"path",
",",
"Watcher",
"watcher",
")",
"{",
"return",
"createAll",
"(",
"Paths",
".",
"get",
"(",
"path",
")",
",",
"watcher",
")",
";",
"}"
] |
创建并初始化监听,监听所有事件
@param path 路径
@param watcher {@link Watcher}
@return {@link WatchMonitor}
|
[
"创建并初始化监听,监听所有事件"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/watch/WatchMonitor.java#L228-L230
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/AbstractWarningsParser.java
|
AbstractWarningsParser.createWarning
|
public Warning createWarning(final String fileName, final int start, final String message) {
"""
Creates a new instance of {@link Warning} using the parser's group as
warning type. No category will be set.
@param fileName
the name of the file
@param start
the first line of the line range
@param message
the message of the warning
@return the warning
"""
return createWarning(fileName, start, StringUtils.EMPTY, message);
}
|
java
|
public Warning createWarning(final String fileName, final int start, final String message) {
return createWarning(fileName, start, StringUtils.EMPTY, message);
}
|
[
"public",
"Warning",
"createWarning",
"(",
"final",
"String",
"fileName",
",",
"final",
"int",
"start",
",",
"final",
"String",
"message",
")",
"{",
"return",
"createWarning",
"(",
"fileName",
",",
"start",
",",
"StringUtils",
".",
"EMPTY",
",",
"message",
")",
";",
"}"
] |
Creates a new instance of {@link Warning} using the parser's group as
warning type. No category will be set.
@param fileName
the name of the file
@param start
the first line of the line range
@param message
the message of the warning
@return the warning
|
[
"Creates",
"a",
"new",
"instance",
"of",
"{",
"@link",
"Warning",
"}",
"using",
"the",
"parser",
"s",
"group",
"as",
"warning",
"type",
".",
"No",
"category",
"will",
"be",
"set",
"."
] |
train
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/AbstractWarningsParser.java#L206-L208
|
aws/aws-sdk-java
|
aws-java-sdk-devicefarm/src/main/java/com/amazonaws/services/devicefarm/model/AccountSettings.java
|
AccountSettings.withUnmeteredRemoteAccessDevices
|
public AccountSettings withUnmeteredRemoteAccessDevices(java.util.Map<String, Integer> unmeteredRemoteAccessDevices) {
"""
<p>
Returns the unmetered remote access devices you have purchased or want to purchase.
</p>
@param unmeteredRemoteAccessDevices
Returns the unmetered remote access devices you have purchased or want to purchase.
@return Returns a reference to this object so that method calls can be chained together.
"""
setUnmeteredRemoteAccessDevices(unmeteredRemoteAccessDevices);
return this;
}
|
java
|
public AccountSettings withUnmeteredRemoteAccessDevices(java.util.Map<String, Integer> unmeteredRemoteAccessDevices) {
setUnmeteredRemoteAccessDevices(unmeteredRemoteAccessDevices);
return this;
}
|
[
"public",
"AccountSettings",
"withUnmeteredRemoteAccessDevices",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"Integer",
">",
"unmeteredRemoteAccessDevices",
")",
"{",
"setUnmeteredRemoteAccessDevices",
"(",
"unmeteredRemoteAccessDevices",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
Returns the unmetered remote access devices you have purchased or want to purchase.
</p>
@param unmeteredRemoteAccessDevices
Returns the unmetered remote access devices you have purchased or want to purchase.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"Returns",
"the",
"unmetered",
"remote",
"access",
"devices",
"you",
"have",
"purchased",
"or",
"want",
"to",
"purchase",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-devicefarm/src/main/java/com/amazonaws/services/devicefarm/model/AccountSettings.java#L224-L227
|
Azure/azure-sdk-for-java
|
labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentsInner.java
|
EnvironmentsInner.update
|
public EnvironmentInner update(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String environmentName, EnvironmentFragment environment) {
"""
Modify properties of environments.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentName The name of the environment.
@param environment Represents an environment instance
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the EnvironmentInner object if successful.
"""
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).toBlocking().single().body();
}
|
java
|
public EnvironmentInner update(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String environmentName, EnvironmentFragment environment) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).toBlocking().single().body();
}
|
[
"public",
"EnvironmentInner",
"update",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"String",
"environmentSettingName",
",",
"String",
"environmentName",
",",
"EnvironmentFragment",
"environment",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"environmentSettingName",
",",
"environmentName",
",",
"environment",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Modify properties of environments.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentName The name of the environment.
@param environment Represents an environment instance
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the EnvironmentInner object if successful.
|
[
"Modify",
"properties",
"of",
"environments",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentsInner.java#L959-L961
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
|
KernelResolverRepository.getCachedFeature
|
private ProvisioningFeatureDefinition getCachedFeature(String featureName) {
"""
Get a feature by name, but without going and checking the remote repository if we don't know about it
@see #getFeature(String)
"""
List<ProvisioningFeatureDefinition> featureList = symbolicNameToFeature.get(featureName);
if (featureList == null) {
featureName = publicNameToSymbolicName.get(featureName.toLowerCase());
if (featureName != null) {
featureList = symbolicNameToFeature.get(featureName);
}
}
if (featureList == null || featureList.isEmpty()) {
return null;
}
return getPreferredVersion(featureName, featureList);
}
|
java
|
private ProvisioningFeatureDefinition getCachedFeature(String featureName) {
List<ProvisioningFeatureDefinition> featureList = symbolicNameToFeature.get(featureName);
if (featureList == null) {
featureName = publicNameToSymbolicName.get(featureName.toLowerCase());
if (featureName != null) {
featureList = symbolicNameToFeature.get(featureName);
}
}
if (featureList == null || featureList.isEmpty()) {
return null;
}
return getPreferredVersion(featureName, featureList);
}
|
[
"private",
"ProvisioningFeatureDefinition",
"getCachedFeature",
"(",
"String",
"featureName",
")",
"{",
"List",
"<",
"ProvisioningFeatureDefinition",
">",
"featureList",
"=",
"symbolicNameToFeature",
".",
"get",
"(",
"featureName",
")",
";",
"if",
"(",
"featureList",
"==",
"null",
")",
"{",
"featureName",
"=",
"publicNameToSymbolicName",
".",
"get",
"(",
"featureName",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"featureName",
"!=",
"null",
")",
"{",
"featureList",
"=",
"symbolicNameToFeature",
".",
"get",
"(",
"featureName",
")",
";",
"}",
"}",
"if",
"(",
"featureList",
"==",
"null",
"||",
"featureList",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"getPreferredVersion",
"(",
"featureName",
",",
"featureList",
")",
";",
"}"
] |
Get a feature by name, but without going and checking the remote repository if we don't know about it
@see #getFeature(String)
|
[
"Get",
"a",
"feature",
"by",
"name",
"but",
"without",
"going",
"and",
"checking",
"the",
"remote",
"repository",
"if",
"we",
"don",
"t",
"know",
"about",
"it"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java#L188-L203
|
google/j2objc
|
jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java
|
BigDecimal.divideAndRound
|
private static BigDecimal divideAndRound(long ldividend, long ldivisor, int scale, int roundingMode,
int preferredScale) {
"""
Internally used for division operation for division {@code long} by
{@code long}.
The returned {@code BigDecimal} object is the quotient whose scale is set
to the passed in scale. If the remainder is not zero, it will be rounded
based on the passed in roundingMode. Also, if the remainder is zero and
the last parameter, i.e. preferredScale is NOT equal to scale, the
trailing zeros of the result is stripped to match the preferredScale.
"""
int qsign; // quotient sign
long q = ldividend / ldivisor; // store quotient in long
if (roundingMode == ROUND_DOWN && scale == preferredScale)
return valueOf(q, scale);
long r = ldividend % ldivisor; // store remainder in long
qsign = ((ldividend < 0) == (ldivisor < 0)) ? 1 : -1;
if (r != 0) {
boolean increment = needIncrement(ldivisor, roundingMode, qsign, q, r);
return valueOf((increment ? q + qsign : q), scale);
} else {
if (preferredScale != scale)
return createAndStripZerosToMatchScale(q, scale, preferredScale);
else
return valueOf(q, scale);
}
}
|
java
|
private static BigDecimal divideAndRound(long ldividend, long ldivisor, int scale, int roundingMode,
int preferredScale) {
int qsign; // quotient sign
long q = ldividend / ldivisor; // store quotient in long
if (roundingMode == ROUND_DOWN && scale == preferredScale)
return valueOf(q, scale);
long r = ldividend % ldivisor; // store remainder in long
qsign = ((ldividend < 0) == (ldivisor < 0)) ? 1 : -1;
if (r != 0) {
boolean increment = needIncrement(ldivisor, roundingMode, qsign, q, r);
return valueOf((increment ? q + qsign : q), scale);
} else {
if (preferredScale != scale)
return createAndStripZerosToMatchScale(q, scale, preferredScale);
else
return valueOf(q, scale);
}
}
|
[
"private",
"static",
"BigDecimal",
"divideAndRound",
"(",
"long",
"ldividend",
",",
"long",
"ldivisor",
",",
"int",
"scale",
",",
"int",
"roundingMode",
",",
"int",
"preferredScale",
")",
"{",
"int",
"qsign",
";",
"// quotient sign",
"long",
"q",
"=",
"ldividend",
"/",
"ldivisor",
";",
"// store quotient in long",
"if",
"(",
"roundingMode",
"==",
"ROUND_DOWN",
"&&",
"scale",
"==",
"preferredScale",
")",
"return",
"valueOf",
"(",
"q",
",",
"scale",
")",
";",
"long",
"r",
"=",
"ldividend",
"%",
"ldivisor",
";",
"// store remainder in long",
"qsign",
"=",
"(",
"(",
"ldividend",
"<",
"0",
")",
"==",
"(",
"ldivisor",
"<",
"0",
")",
")",
"?",
"1",
":",
"-",
"1",
";",
"if",
"(",
"r",
"!=",
"0",
")",
"{",
"boolean",
"increment",
"=",
"needIncrement",
"(",
"ldivisor",
",",
"roundingMode",
",",
"qsign",
",",
"q",
",",
"r",
")",
";",
"return",
"valueOf",
"(",
"(",
"increment",
"?",
"q",
"+",
"qsign",
":",
"q",
")",
",",
"scale",
")",
";",
"}",
"else",
"{",
"if",
"(",
"preferredScale",
"!=",
"scale",
")",
"return",
"createAndStripZerosToMatchScale",
"(",
"q",
",",
"scale",
",",
"preferredScale",
")",
";",
"else",
"return",
"valueOf",
"(",
"q",
",",
"scale",
")",
";",
"}",
"}"
] |
Internally used for division operation for division {@code long} by
{@code long}.
The returned {@code BigDecimal} object is the quotient whose scale is set
to the passed in scale. If the remainder is not zero, it will be rounded
based on the passed in roundingMode. Also, if the remainder is zero and
the last parameter, i.e. preferredScale is NOT equal to scale, the
trailing zeros of the result is stripped to match the preferredScale.
|
[
"Internally",
"used",
"for",
"division",
"operation",
"for",
"division",
"{"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java#L4104-L4122
|
osglworks/java-mvc
|
src/main/java/org/osgl/mvc/result/NotModified.java
|
NotModified.of
|
public static NotModified of(String etag, Object... args) {
"""
Returns a static NotModified instance which when calling on
{@link #etag()} method, will return whatever stored in the
{@link #payload} thread local.
<p>
Before return the static instance, the specified etag will
be stored into the {@link #payload} thread local
@param etag the etag
@param args the args used to populate the etag
@return a static instance
"""
touchPayload().message(etag, args);
return _INSTANCE;
}
|
java
|
public static NotModified of(String etag, Object... args) {
touchPayload().message(etag, args);
return _INSTANCE;
}
|
[
"public",
"static",
"NotModified",
"of",
"(",
"String",
"etag",
",",
"Object",
"...",
"args",
")",
"{",
"touchPayload",
"(",
")",
".",
"message",
"(",
"etag",
",",
"args",
")",
";",
"return",
"_INSTANCE",
";",
"}"
] |
Returns a static NotModified instance which when calling on
{@link #etag()} method, will return whatever stored in the
{@link #payload} thread local.
<p>
Before return the static instance, the specified etag will
be stored into the {@link #payload} thread local
@param etag the etag
@param args the args used to populate the etag
@return a static instance
|
[
"Returns",
"a",
"static",
"NotModified",
"instance",
"which",
"when",
"calling",
"on",
"{",
"@link",
"#etag",
"()",
"}",
"method",
"will",
"return",
"whatever",
"stored",
"in",
"the",
"{",
"@link",
"#payload",
"}",
"thread",
"local",
".",
"<p",
">",
"Before",
"return",
"the",
"static",
"instance",
"the",
"specified",
"etag",
"will",
"be",
"stored",
"into",
"the",
"{",
"@link",
"#payload",
"}",
"thread",
"local"
] |
train
|
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/NotModified.java#L111-L114
|
ModeShape/modeshape
|
modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java
|
Query.orderedBy
|
public Query orderedBy( List<Ordering> orderings ) {
"""
Create a copy of this query, but one whose results should be ordered by the supplied orderings.
@param orderings the result ordering specification that should be used; never null
@return the copy of the query that uses the supplied ordering; never null
"""
return new Query(source, constraint, orderings, columns, getLimits(), distinct);
}
|
java
|
public Query orderedBy( List<Ordering> orderings ) {
return new Query(source, constraint, orderings, columns, getLimits(), distinct);
}
|
[
"public",
"Query",
"orderedBy",
"(",
"List",
"<",
"Ordering",
">",
"orderings",
")",
"{",
"return",
"new",
"Query",
"(",
"source",
",",
"constraint",
",",
"orderings",
",",
"columns",
",",
"getLimits",
"(",
")",
",",
"distinct",
")",
";",
"}"
] |
Create a copy of this query, but one whose results should be ordered by the supplied orderings.
@param orderings the result ordering specification that should be used; never null
@return the copy of the query that uses the supplied ordering; never null
|
[
"Create",
"a",
"copy",
"of",
"this",
"query",
"but",
"one",
"whose",
"results",
"should",
"be",
"ordered",
"by",
"the",
"supplied",
"orderings",
"."
] |
train
|
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java#L187-L189
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/outbound/HttpOutboundServiceContextImpl.java
|
HttpOutboundServiceContextImpl.getRawResponseBodyBuffer
|
@Override
public VirtualConnection getRawResponseBodyBuffer(InterChannelCallback callback, boolean bForce) throws BodyCompleteException {
"""
Retrieve the next buffer of the body asynchronously. This will avoid any
body modifications, such as decompression or removal of chunked-encoding
markers.
<p>
If the read can be performed immediately, then a VirtualConnection will be returned and the provided callback will not be used. If the read is being done asychronously, then
null will be returned and the callback used when complete. The force input flag allows the caller to force the asynchronous read to always occur, and thus the callback to
always be used.
<p>
The caller is responsible for releasing these buffers when finished with them as the HTTP Channel keeps no reference to them.
@param callback
@param bForce
@return VirtualConnection
@throws BodyCompleteException
-- if the entire body has already been read
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "getRawResponseBodyBuffer(async)");
}
setRawBody(true);
VirtualConnection vc = getResponseBodyBuffer(callback, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "getRawResponseBodyBuffer(async): " + vc);
}
return vc;
}
|
java
|
@Override
public VirtualConnection getRawResponseBodyBuffer(InterChannelCallback callback, boolean bForce) throws BodyCompleteException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "getRawResponseBodyBuffer(async)");
}
setRawBody(true);
VirtualConnection vc = getResponseBodyBuffer(callback, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "getRawResponseBodyBuffer(async): " + vc);
}
return vc;
}
|
[
"@",
"Override",
"public",
"VirtualConnection",
"getRawResponseBodyBuffer",
"(",
"InterChannelCallback",
"callback",
",",
"boolean",
"bForce",
")",
"throws",
"BodyCompleteException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"getRawResponseBodyBuffer(async)\"",
")",
";",
"}",
"setRawBody",
"(",
"true",
")",
";",
"VirtualConnection",
"vc",
"=",
"getResponseBodyBuffer",
"(",
"callback",
",",
"bForce",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"getRawResponseBodyBuffer(async): \"",
"+",
"vc",
")",
";",
"}",
"return",
"vc",
";",
"}"
] |
Retrieve the next buffer of the body asynchronously. This will avoid any
body modifications, such as decompression or removal of chunked-encoding
markers.
<p>
If the read can be performed immediately, then a VirtualConnection will be returned and the provided callback will not be used. If the read is being done asychronously, then
null will be returned and the callback used when complete. The force input flag allows the caller to force the asynchronous read to always occur, and thus the callback to
always be used.
<p>
The caller is responsible for releasing these buffers when finished with them as the HTTP Channel keeps no reference to them.
@param callback
@param bForce
@return VirtualConnection
@throws BodyCompleteException
-- if the entire body has already been read
|
[
"Retrieve",
"the",
"next",
"buffer",
"of",
"the",
"body",
"asynchronously",
".",
"This",
"will",
"avoid",
"any",
"body",
"modifications",
"such",
"as",
"decompression",
"or",
"removal",
"of",
"chunked",
"-",
"encoding",
"markers",
".",
"<p",
">",
"If",
"the",
"read",
"can",
"be",
"performed",
"immediately",
"then",
"a",
"VirtualConnection",
"will",
"be",
"returned",
"and",
"the",
"provided",
"callback",
"will",
"not",
"be",
"used",
".",
"If",
"the",
"read",
"is",
"being",
"done",
"asychronously",
"then",
"null",
"will",
"be",
"returned",
"and",
"the",
"callback",
"used",
"when",
"complete",
".",
"The",
"force",
"input",
"flag",
"allows",
"the",
"caller",
"to",
"force",
"the",
"asynchronous",
"read",
"to",
"always",
"occur",
"and",
"thus",
"the",
"callback",
"to",
"always",
"be",
"used",
".",
"<p",
">",
"The",
"caller",
"is",
"responsible",
"for",
"releasing",
"these",
"buffers",
"when",
"finished",
"with",
"them",
"as",
"the",
"HTTP",
"Channel",
"keeps",
"no",
"reference",
"to",
"them",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/outbound/HttpOutboundServiceContextImpl.java#L2179-L2190
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTotalTime
|
private long getTotalTime(ProjectCalendarDateRanges exception, Date date, boolean after) {
"""
Retrieves the amount of time represented by a calendar exception
before or after an intersection point.
@param exception calendar exception
@param date intersection time
@param after true to report time after intersection, false to report time before
@return length of time in milliseconds
"""
long currentTime = DateHelper.getCanonicalTime(date).getTime();
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd(), currentTime, after);
}
return (total);
}
|
java
|
private long getTotalTime(ProjectCalendarDateRanges exception, Date date, boolean after)
{
long currentTime = DateHelper.getCanonicalTime(date).getTime();
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd(), currentTime, after);
}
return (total);
}
|
[
"private",
"long",
"getTotalTime",
"(",
"ProjectCalendarDateRanges",
"exception",
",",
"Date",
"date",
",",
"boolean",
"after",
")",
"{",
"long",
"currentTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"date",
")",
".",
"getTime",
"(",
")",
";",
"long",
"total",
"=",
"0",
";",
"for",
"(",
"DateRange",
"range",
":",
"exception",
")",
"{",
"total",
"+=",
"getTime",
"(",
"range",
".",
"getStart",
"(",
")",
",",
"range",
".",
"getEnd",
"(",
")",
",",
"currentTime",
",",
"after",
")",
";",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
Retrieves the amount of time represented by a calendar exception
before or after an intersection point.
@param exception calendar exception
@param date intersection time
@param after true to report time after intersection, false to report time before
@return length of time in milliseconds
|
[
"Retrieves",
"the",
"amount",
"of",
"time",
"represented",
"by",
"a",
"calendar",
"exception",
"before",
"or",
"after",
"an",
"intersection",
"point",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1423-L1432
|
Red5/red5-io
|
src/main/java/org/red5/io/utils/Stax2DomBuilder.java
|
Stax2DomBuilder.build
|
public Document build(XMLStreamReader r) throws ParserConfigurationException, XMLStreamException {
"""
This method will create a {@link org.w3c.dom.Document} instance using the default JAXP mechanism and populate using the given StAX stream reader.
@param r
Stream reader from which input is read.
@return <code>Document</code> - DOM document object.
@throws ParserConfigurationException
if parse is not configured
@throws XMLStreamException
If the reader threw such exception (to indicate a parsing or I/O problem)
"""
return build(r, DocumentBuilderFactory.newInstance().newDocumentBuilder());
}
|
java
|
public Document build(XMLStreamReader r) throws ParserConfigurationException, XMLStreamException {
return build(r, DocumentBuilderFactory.newInstance().newDocumentBuilder());
}
|
[
"public",
"Document",
"build",
"(",
"XMLStreamReader",
"r",
")",
"throws",
"ParserConfigurationException",
",",
"XMLStreamException",
"{",
"return",
"build",
"(",
"r",
",",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
".",
"newDocumentBuilder",
"(",
")",
")",
";",
"}"
] |
This method will create a {@link org.w3c.dom.Document} instance using the default JAXP mechanism and populate using the given StAX stream reader.
@param r
Stream reader from which input is read.
@return <code>Document</code> - DOM document object.
@throws ParserConfigurationException
if parse is not configured
@throws XMLStreamException
If the reader threw such exception (to indicate a parsing or I/O problem)
|
[
"This",
"method",
"will",
"create",
"a",
"{",
"@link",
"org",
".",
"w3c",
".",
"dom",
".",
"Document",
"}",
"instance",
"using",
"the",
"default",
"JAXP",
"mechanism",
"and",
"populate",
"using",
"the",
"given",
"StAX",
"stream",
"reader",
"."
] |
train
|
https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/utils/Stax2DomBuilder.java#L86-L88
|
stackify/stackify-api-java
|
src/main/java/com/stackify/api/common/lang/Throwables.java
|
Throwables.toErrorItemMessage
|
private static String toErrorItemMessage(final String logMessage, final String throwableMessage) {
"""
Constructs the error item message from the log message and the throwable's message
@param logMessage The log message (can be null)
@param throwableMessage The throwable's message (can be null)
@return The error item message
"""
StringBuilder sb = new StringBuilder();
if ((throwableMessage != null) && (!throwableMessage.isEmpty())) {
sb.append(throwableMessage);
if ((logMessage != null) && (!logMessage.isEmpty())) {
sb.append(" (");
sb.append(logMessage);
sb.append(")");
}
} else {
sb.append(logMessage);
}
return sb.toString();
}
|
java
|
private static String toErrorItemMessage(final String logMessage, final String throwableMessage) {
StringBuilder sb = new StringBuilder();
if ((throwableMessage != null) && (!throwableMessage.isEmpty())) {
sb.append(throwableMessage);
if ((logMessage != null) && (!logMessage.isEmpty())) {
sb.append(" (");
sb.append(logMessage);
sb.append(")");
}
} else {
sb.append(logMessage);
}
return sb.toString();
}
|
[
"private",
"static",
"String",
"toErrorItemMessage",
"(",
"final",
"String",
"logMessage",
",",
"final",
"String",
"throwableMessage",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"(",
"throwableMessage",
"!=",
"null",
")",
"&&",
"(",
"!",
"throwableMessage",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"sb",
".",
"append",
"(",
"throwableMessage",
")",
";",
"if",
"(",
"(",
"logMessage",
"!=",
"null",
")",
"&&",
"(",
"!",
"logMessage",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\" (\"",
")",
";",
"sb",
".",
"append",
"(",
"logMessage",
")",
";",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"logMessage",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Constructs the error item message from the log message and the throwable's message
@param logMessage The log message (can be null)
@param throwableMessage The throwable's message (can be null)
@return The error item message
|
[
"Constructs",
"the",
"error",
"item",
"message",
"from",
"the",
"log",
"message",
"and",
"the",
"throwable",
"s",
"message"
] |
train
|
https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/lang/Throwables.java#L139-L156
|
EdwardRaff/JSAT
|
JSAT/src/jsat/classifiers/linear/StochasticMultinomialLogisticRegression.java
|
StochasticMultinomialLogisticRegression.setInitialLearningRate
|
public void setInitialLearningRate(double initialLearningRate) {
"""
Sets the initial learning rate to use for the first epoch. The learning
rate will decay according to the
{@link #setLearningRateDecay(jsat.math.decayrates.DecayRate) decay rate}
in use.
@param initialLearningRate the initial learning rate to use
"""
if(initialLearningRate <= 0 || Double.isInfinite(initialLearningRate) || Double.isNaN(initialLearningRate))
throw new IllegalArgumentException("Learning rate must be a positive constant, not " + initialLearningRate);
this.initialLearningRate = initialLearningRate;
}
|
java
|
public void setInitialLearningRate(double initialLearningRate)
{
if(initialLearningRate <= 0 || Double.isInfinite(initialLearningRate) || Double.isNaN(initialLearningRate))
throw new IllegalArgumentException("Learning rate must be a positive constant, not " + initialLearningRate);
this.initialLearningRate = initialLearningRate;
}
|
[
"public",
"void",
"setInitialLearningRate",
"(",
"double",
"initialLearningRate",
")",
"{",
"if",
"(",
"initialLearningRate",
"<=",
"0",
"||",
"Double",
".",
"isInfinite",
"(",
"initialLearningRate",
")",
"||",
"Double",
".",
"isNaN",
"(",
"initialLearningRate",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Learning rate must be a positive constant, not \"",
"+",
"initialLearningRate",
")",
";",
"this",
".",
"initialLearningRate",
"=",
"initialLearningRate",
";",
"}"
] |
Sets the initial learning rate to use for the first epoch. The learning
rate will decay according to the
{@link #setLearningRateDecay(jsat.math.decayrates.DecayRate) decay rate}
in use.
@param initialLearningRate the initial learning rate to use
|
[
"Sets",
"the",
"initial",
"learning",
"rate",
"to",
"use",
"for",
"the",
"first",
"epoch",
".",
"The",
"learning",
"rate",
"will",
"decay",
"according",
"to",
"the",
"{",
"@link",
"#setLearningRateDecay",
"(",
"jsat",
".",
"math",
".",
"decayrates",
".",
"DecayRate",
")",
"decay",
"rate",
"}",
"in",
"use",
"."
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/StochasticMultinomialLogisticRegression.java#L363-L368
|
apache/flink
|
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java
|
SegmentsUtil.copyToBytes
|
public static byte[] copyToBytes(MemorySegment[] segments, int offset, int numBytes) {
"""
Copy segments to a new byte[].
@param segments Source segments.
@param offset Source segments offset.
@param numBytes the number bytes to copy.
"""
return copyToBytes(segments, offset, new byte[numBytes], 0, numBytes);
}
|
java
|
public static byte[] copyToBytes(MemorySegment[] segments, int offset, int numBytes) {
return copyToBytes(segments, offset, new byte[numBytes], 0, numBytes);
}
|
[
"public",
"static",
"byte",
"[",
"]",
"copyToBytes",
"(",
"MemorySegment",
"[",
"]",
"segments",
",",
"int",
"offset",
",",
"int",
"numBytes",
")",
"{",
"return",
"copyToBytes",
"(",
"segments",
",",
"offset",
",",
"new",
"byte",
"[",
"numBytes",
"]",
",",
"0",
",",
"numBytes",
")",
";",
"}"
] |
Copy segments to a new byte[].
@param segments Source segments.
@param offset Source segments offset.
@param numBytes the number bytes to copy.
|
[
"Copy",
"segments",
"to",
"a",
"new",
"byte",
"[]",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java#L105-L107
|
qos-ch/slf4j
|
slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java
|
JavassistHelper.parameterNameFor
|
static String parameterNameFor(CtBehavior method, LocalVariableAttribute locals, int i) {
"""
Determine the name of parameter with index i in the given method. Use the
locals attributes about local variables from the classfile. Note: This is
still work in progress.
@param method
@param locals
@param i
@return the name of the parameter if available or a number if not.
"""
if (locals == null) {
return Integer.toString(i + 1);
}
int modifiers = method.getModifiers();
int j = i;
if (Modifier.isSynchronized(modifiers)) {
// skip object to synchronize upon.
j++;
// System.err.println("Synchronized");
}
if (Modifier.isStatic(modifiers) == false) {
// skip "this"
j++;
// System.err.println("Instance");
}
String variableName = locals.variableName(j);
// if (variableName.equals("this")) {
// System.err.println("'this' returned as a parameter name for "
// + method.getName() + " index " + j
// +
// ", names are probably shifted. Please submit source for class in slf4j bugreport");
// }
return variableName;
}
|
java
|
static String parameterNameFor(CtBehavior method, LocalVariableAttribute locals, int i) {
if (locals == null) {
return Integer.toString(i + 1);
}
int modifiers = method.getModifiers();
int j = i;
if (Modifier.isSynchronized(modifiers)) {
// skip object to synchronize upon.
j++;
// System.err.println("Synchronized");
}
if (Modifier.isStatic(modifiers) == false) {
// skip "this"
j++;
// System.err.println("Instance");
}
String variableName = locals.variableName(j);
// if (variableName.equals("this")) {
// System.err.println("'this' returned as a parameter name for "
// + method.getName() + " index " + j
// +
// ", names are probably shifted. Please submit source for class in slf4j bugreport");
// }
return variableName;
}
|
[
"static",
"String",
"parameterNameFor",
"(",
"CtBehavior",
"method",
",",
"LocalVariableAttribute",
"locals",
",",
"int",
"i",
")",
"{",
"if",
"(",
"locals",
"==",
"null",
")",
"{",
"return",
"Integer",
".",
"toString",
"(",
"i",
"+",
"1",
")",
";",
"}",
"int",
"modifiers",
"=",
"method",
".",
"getModifiers",
"(",
")",
";",
"int",
"j",
"=",
"i",
";",
"if",
"(",
"Modifier",
".",
"isSynchronized",
"(",
"modifiers",
")",
")",
"{",
"// skip object to synchronize upon.",
"j",
"++",
";",
"// System.err.println(\"Synchronized\");",
"}",
"if",
"(",
"Modifier",
".",
"isStatic",
"(",
"modifiers",
")",
"==",
"false",
")",
"{",
"// skip \"this\"",
"j",
"++",
";",
"// System.err.println(\"Instance\");",
"}",
"String",
"variableName",
"=",
"locals",
".",
"variableName",
"(",
"j",
")",
";",
"// if (variableName.equals(\"this\")) {",
"// System.err.println(\"'this' returned as a parameter name for \"",
"// + method.getName() + \" index \" + j",
"// +",
"// \", names are probably shifted. Please submit source for class in slf4j bugreport\");",
"// }",
"return",
"variableName",
";",
"}"
] |
Determine the name of parameter with index i in the given method. Use the
locals attributes about local variables from the classfile. Note: This is
still work in progress.
@param method
@param locals
@param i
@return the name of the parameter if available or a number if not.
|
[
"Determine",
"the",
"name",
"of",
"parameter",
"with",
"index",
"i",
"in",
"the",
"given",
"method",
".",
"Use",
"the",
"locals",
"attributes",
"about",
"local",
"variables",
"from",
"the",
"classfile",
".",
"Note",
":",
"This",
"is",
"still",
"work",
"in",
"progress",
"."
] |
train
|
https://github.com/qos-ch/slf4j/blob/905443f39fadd88a8dd2c467e44affd8cb072a4d/slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java#L157-L185
|
j256/ormlite-android
|
src/main/java/com/j256/ormlite/android/apptools/OrmLiteConfigUtil.java
|
OrmLiteConfigUtil.writeConfigFile
|
public static void writeConfigFile(OutputStream outputStream, Class<?>[] classes, boolean sortClasses)
throws SQLException, IOException {
"""
Write a configuration file to an output stream with the configuration for classes.
@param sortClasses
Set to true to sort the classes and fields by name before the file is generated.
"""
if (sortClasses) {
// sort our class list to make the output more deterministic
Class<?>[] sortedClasses = new Class<?>[classes.length];
System.arraycopy(classes, 0, sortedClasses, 0, classes.length);
Arrays.sort(sortedClasses, classComparator);
classes = sortedClasses;
}
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream), 4096);
try {
writeHeader(writer);
for (Class<?> clazz : classes) {
writeConfigForTable(writer, clazz, sortClasses);
}
// NOTE: done is here because this is public
System.out.println("Done.");
} finally {
writer.close();
}
}
|
java
|
public static void writeConfigFile(OutputStream outputStream, Class<?>[] classes, boolean sortClasses)
throws SQLException, IOException {
if (sortClasses) {
// sort our class list to make the output more deterministic
Class<?>[] sortedClasses = new Class<?>[classes.length];
System.arraycopy(classes, 0, sortedClasses, 0, classes.length);
Arrays.sort(sortedClasses, classComparator);
classes = sortedClasses;
}
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream), 4096);
try {
writeHeader(writer);
for (Class<?> clazz : classes) {
writeConfigForTable(writer, clazz, sortClasses);
}
// NOTE: done is here because this is public
System.out.println("Done.");
} finally {
writer.close();
}
}
|
[
"public",
"static",
"void",
"writeConfigFile",
"(",
"OutputStream",
"outputStream",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
",",
"boolean",
"sortClasses",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"if",
"(",
"sortClasses",
")",
"{",
"// sort our class list to make the output more deterministic",
"Class",
"<",
"?",
">",
"[",
"]",
"sortedClasses",
"=",
"new",
"Class",
"<",
"?",
">",
"[",
"classes",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"classes",
",",
"0",
",",
"sortedClasses",
",",
"0",
",",
"classes",
".",
"length",
")",
";",
"Arrays",
".",
"sort",
"(",
"sortedClasses",
",",
"classComparator",
")",
";",
"classes",
"=",
"sortedClasses",
";",
"}",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"outputStream",
")",
",",
"4096",
")",
";",
"try",
"{",
"writeHeader",
"(",
"writer",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"clazz",
":",
"classes",
")",
"{",
"writeConfigForTable",
"(",
"writer",
",",
"clazz",
",",
"sortClasses",
")",
";",
"}",
"// NOTE: done is here because this is public",
"System",
".",
"out",
".",
"println",
"(",
"\"Done.\"",
")",
";",
"}",
"finally",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Write a configuration file to an output stream with the configuration for classes.
@param sortClasses
Set to true to sort the classes and fields by name before the file is generated.
|
[
"Write",
"a",
"configuration",
"file",
"to",
"an",
"output",
"stream",
"with",
"the",
"configuration",
"for",
"classes",
"."
] |
train
|
https://github.com/j256/ormlite-android/blob/e82327a868ae242f994730fe2389f79684d7bcab/src/main/java/com/j256/ormlite/android/apptools/OrmLiteConfigUtil.java#L235-L255
|
kevinherron/opc-ua-stack
|
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/Stack.java
|
Stack.releaseSharedResources
|
public static synchronized void releaseSharedResources(long timeout, TimeUnit unit) {
"""
Release shared resources, waiting at most the specified timeout for the {@link NioEventLoopGroup} to shutdown
gracefully.
@param timeout the duration of the timeout.
@param unit the unit of the timeout duration.
"""
if (EVENT_LOOP != null) {
try {
EVENT_LOOP.shutdownGracefully().await(timeout, unit);
} catch (InterruptedException e) {
LoggerFactory.getLogger(Stack.class)
.warn("Interrupted awaiting event loop shutdown.", e);
}
EVENT_LOOP = null;
}
if (SCHEDULED_EXECUTOR_SERVICE != null) {
SCHEDULED_EXECUTOR_SERVICE.shutdown();
SCHEDULED_EXECUTOR_SERVICE = null;
}
if (EXECUTOR_SERVICE != null) {
EXECUTOR_SERVICE.shutdown();
EXECUTOR_SERVICE = null;
}
if (WHEEL_TIMER != null) {
WHEEL_TIMER.stop().forEach(Timeout::cancel);
WHEEL_TIMER = null;
}
}
|
java
|
public static synchronized void releaseSharedResources(long timeout, TimeUnit unit) {
if (EVENT_LOOP != null) {
try {
EVENT_LOOP.shutdownGracefully().await(timeout, unit);
} catch (InterruptedException e) {
LoggerFactory.getLogger(Stack.class)
.warn("Interrupted awaiting event loop shutdown.", e);
}
EVENT_LOOP = null;
}
if (SCHEDULED_EXECUTOR_SERVICE != null) {
SCHEDULED_EXECUTOR_SERVICE.shutdown();
SCHEDULED_EXECUTOR_SERVICE = null;
}
if (EXECUTOR_SERVICE != null) {
EXECUTOR_SERVICE.shutdown();
EXECUTOR_SERVICE = null;
}
if (WHEEL_TIMER != null) {
WHEEL_TIMER.stop().forEach(Timeout::cancel);
WHEEL_TIMER = null;
}
}
|
[
"public",
"static",
"synchronized",
"void",
"releaseSharedResources",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"if",
"(",
"EVENT_LOOP",
"!=",
"null",
")",
"{",
"try",
"{",
"EVENT_LOOP",
".",
"shutdownGracefully",
"(",
")",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LoggerFactory",
".",
"getLogger",
"(",
"Stack",
".",
"class",
")",
".",
"warn",
"(",
"\"Interrupted awaiting event loop shutdown.\"",
",",
"e",
")",
";",
"}",
"EVENT_LOOP",
"=",
"null",
";",
"}",
"if",
"(",
"SCHEDULED_EXECUTOR_SERVICE",
"!=",
"null",
")",
"{",
"SCHEDULED_EXECUTOR_SERVICE",
".",
"shutdown",
"(",
")",
";",
"SCHEDULED_EXECUTOR_SERVICE",
"=",
"null",
";",
"}",
"if",
"(",
"EXECUTOR_SERVICE",
"!=",
"null",
")",
"{",
"EXECUTOR_SERVICE",
".",
"shutdown",
"(",
")",
";",
"EXECUTOR_SERVICE",
"=",
"null",
";",
"}",
"if",
"(",
"WHEEL_TIMER",
"!=",
"null",
")",
"{",
"WHEEL_TIMER",
".",
"stop",
"(",
")",
".",
"forEach",
"(",
"Timeout",
"::",
"cancel",
")",
";",
"WHEEL_TIMER",
"=",
"null",
";",
"}",
"}"
] |
Release shared resources, waiting at most the specified timeout for the {@link NioEventLoopGroup} to shutdown
gracefully.
@param timeout the duration of the timeout.
@param unit the unit of the timeout duration.
|
[
"Release",
"shared",
"resources",
"waiting",
"at",
"most",
"the",
"specified",
"timeout",
"for",
"the",
"{",
"@link",
"NioEventLoopGroup",
"}",
"to",
"shutdown",
"gracefully",
"."
] |
train
|
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/Stack.java#L163-L188
|
square/okhttp
|
okhttp/src/main/java/okhttp3/internal/Util.java
|
Util.discard
|
public static boolean discard(Source source, int timeout, TimeUnit timeUnit) {
"""
Attempts to exhaust {@code source}, returning true if successful. This is useful when reading a
complete source is helpful, such as when doing so completes a cache body or frees a socket
connection for reuse.
"""
try {
return skipAll(source, timeout, timeUnit);
} catch (IOException e) {
return false;
}
}
|
java
|
public static boolean discard(Source source, int timeout, TimeUnit timeUnit) {
try {
return skipAll(source, timeout, timeUnit);
} catch (IOException e) {
return false;
}
}
|
[
"public",
"static",
"boolean",
"discard",
"(",
"Source",
"source",
",",
"int",
"timeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"try",
"{",
"return",
"skipAll",
"(",
"source",
",",
"timeout",
",",
"timeUnit",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Attempts to exhaust {@code source}, returning true if successful. This is useful when reading a
complete source is helpful, such as when doing so completes a cache body or frees a socket
connection for reuse.
|
[
"Attempts",
"to",
"exhaust",
"{"
] |
train
|
https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/okhttp/src/main/java/okhttp3/internal/Util.java#L161-L167
|
Azure/azure-sdk-for-java
|
resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java
|
DeploymentsInner.beginDelete
|
public void beginDelete(String resourceGroupName, String deploymentName) {
"""
Deletes a deployment from the deployment history.
A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code.
@param resourceGroupName The name of the resource group with the deployment to delete. The name is case insensitive.
@param deploymentName The name of the deployment to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginDeleteWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().body();
}
|
java
|
public void beginDelete(String resourceGroupName, String deploymentName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().body();
}
|
[
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"deploymentName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"deploymentName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Deletes a deployment from the deployment history.
A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code.
@param resourceGroupName The name of the resource group with the deployment to delete. The name is case insensitive.
@param deploymentName The name of the deployment to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
|
[
"Deletes",
"a",
"deployment",
"from",
"the",
"deployment",
"history",
".",
"A",
"template",
"deployment",
"that",
"is",
"currently",
"running",
"cannot",
"be",
"deleted",
".",
"Deleting",
"a",
"template",
"deployment",
"removes",
"the",
"associated",
"deployment",
"operations",
".",
"Deleting",
"a",
"template",
"deployment",
"does",
"not",
"affect",
"the",
"state",
"of",
"the",
"resource",
"group",
".",
"This",
"is",
"an",
"asynchronous",
"operation",
"that",
"returns",
"a",
"status",
"of",
"202",
"until",
"the",
"template",
"deployment",
"is",
"successfully",
"deleted",
".",
"The",
"Location",
"response",
"header",
"contains",
"the",
"URI",
"that",
"is",
"used",
"to",
"obtain",
"the",
"status",
"of",
"the",
"process",
".",
"While",
"the",
"process",
"is",
"running",
"a",
"call",
"to",
"the",
"URI",
"in",
"the",
"Location",
"header",
"returns",
"a",
"status",
"of",
"202",
".",
"When",
"the",
"process",
"finishes",
"the",
"URI",
"in",
"the",
"Location",
"header",
"returns",
"a",
"status",
"of",
"204",
"on",
"success",
".",
"If",
"the",
"asynchronous",
"request",
"failed",
"the",
"URI",
"in",
"the",
"Location",
"header",
"returns",
"an",
"error",
"-",
"level",
"status",
"code",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/DeploymentsInner.java#L197-L199
|
gmessner/gitlab4j-api
|
src/main/java/org/gitlab4j/api/PackagesApi.java
|
PackagesApi.getPackage
|
public Package getPackage(Object projectIdOrPath, Integer packageId) throws GitLabApiException {
"""
Get a single project package.
<pre><code>GitLab Endpoint: GET /projects/:id/packages/:package_id</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param packageId the ID of the package to get
@return a Package instance for the specified package ID
@throws GitLabApiException if any exception occurs
"""
Response response = get(Response.Status.OK, null,
"projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId);
return (response.readEntity(Package.class));
}
|
java
|
public Package getPackage(Object projectIdOrPath, Integer packageId) throws GitLabApiException {
Response response = get(Response.Status.OK, null,
"projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId);
return (response.readEntity(Package.class));
}
|
[
"public",
"Package",
"getPackage",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"packageId",
")",
"throws",
"GitLabApiException",
"{",
"Response",
"response",
"=",
"get",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"null",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"packages\"",
",",
"packageId",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"Package",
".",
"class",
")",
")",
";",
"}"
] |
Get a single project package.
<pre><code>GitLab Endpoint: GET /projects/:id/packages/:package_id</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param packageId the ID of the package to get
@return a Package instance for the specified package ID
@throws GitLabApiException if any exception occurs
|
[
"Get",
"a",
"single",
"project",
"package",
"."
] |
train
|
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/PackagesApi.java#L119-L123
|
Azure/azure-sdk-for-java
|
appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DomainsInner.java
|
DomainsInner.listOwnershipIdentifiersAsync
|
public Observable<Page<DomainOwnershipIdentifierInner>> listOwnershipIdentifiersAsync(final String resourceGroupName, final String domainName) {
"""
Lists domain ownership identifiers.
Lists domain ownership identifiers.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param domainName Name of domain.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DomainOwnershipIdentifierInner> object
"""
return listOwnershipIdentifiersWithServiceResponseAsync(resourceGroupName, domainName)
.map(new Func1<ServiceResponse<Page<DomainOwnershipIdentifierInner>>, Page<DomainOwnershipIdentifierInner>>() {
@Override
public Page<DomainOwnershipIdentifierInner> call(ServiceResponse<Page<DomainOwnershipIdentifierInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<Page<DomainOwnershipIdentifierInner>> listOwnershipIdentifiersAsync(final String resourceGroupName, final String domainName) {
return listOwnershipIdentifiersWithServiceResponseAsync(resourceGroupName, domainName)
.map(new Func1<ServiceResponse<Page<DomainOwnershipIdentifierInner>>, Page<DomainOwnershipIdentifierInner>>() {
@Override
public Page<DomainOwnershipIdentifierInner> call(ServiceResponse<Page<DomainOwnershipIdentifierInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Page",
"<",
"DomainOwnershipIdentifierInner",
">",
">",
"listOwnershipIdentifiersAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"domainName",
")",
"{",
"return",
"listOwnershipIdentifiersWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"domainName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DomainOwnershipIdentifierInner",
">",
">",
",",
"Page",
"<",
"DomainOwnershipIdentifierInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"DomainOwnershipIdentifierInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"DomainOwnershipIdentifierInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Lists domain ownership identifiers.
Lists domain ownership identifiers.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param domainName Name of domain.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DomainOwnershipIdentifierInner> object
|
[
"Lists",
"domain",
"ownership",
"identifiers",
".",
"Lists",
"domain",
"ownership",
"identifiers",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DomainsInner.java#L1335-L1343
|
alkacon/opencms-core
|
src/org/opencms/db/CmsUserSettings.java
|
CmsUserSettings.setEditorSettings
|
public void setEditorSettings(Map<String, String> settings) {
"""
Sets the editor settings of the user.<p>
@param settings the editor settings of the user
"""
m_editorSettings = new TreeMap<String, String>(settings);
}
|
java
|
public void setEditorSettings(Map<String, String> settings) {
m_editorSettings = new TreeMap<String, String>(settings);
}
|
[
"public",
"void",
"setEditorSettings",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"settings",
")",
"{",
"m_editorSettings",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"String",
">",
"(",
"settings",
")",
";",
"}"
] |
Sets the editor settings of the user.<p>
@param settings the editor settings of the user
|
[
"Sets",
"the",
"editor",
"settings",
"of",
"the",
"user",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsUserSettings.java#L1874-L1877
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java
|
ReflectUtil.getPublicMethod
|
public static Method getPublicMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) throws SecurityException {
"""
查找指定Public方法 如果找不到对应的方法或方法不为public的则返回<code>null</code>
@param clazz 类
@param methodName 方法名
@param paramTypes 参数类型
@return 方法
@throws SecurityException 无权访问抛出异常
"""
try {
return clazz.getMethod(methodName, paramTypes);
} catch (NoSuchMethodException ex) {
return null;
}
}
|
java
|
public static Method getPublicMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) throws SecurityException {
try {
return clazz.getMethod(methodName, paramTypes);
} catch (NoSuchMethodException ex) {
return null;
}
}
|
[
"public",
"static",
"Method",
"getPublicMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"...",
"paramTypes",
")",
"throws",
"SecurityException",
"{",
"try",
"{",
"return",
"clazz",
".",
"getMethod",
"(",
"methodName",
",",
"paramTypes",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
查找指定Public方法 如果找不到对应的方法或方法不为public的则返回<code>null</code>
@param clazz 类
@param methodName 方法名
@param paramTypes 参数类型
@return 方法
@throws SecurityException 无权访问抛出异常
|
[
"查找指定Public方法",
"如果找不到对应的方法或方法不为public的则返回<code",
">",
"null<",
"/",
"code",
">"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java#L372-L378
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java
|
WordVectorSerializer.writeTsneFormat
|
public static void writeTsneFormat(Glove vec, INDArray tsne, File csv) throws Exception {
"""
Write the tsne format
@param vec the word vectors to use for labeling
@param tsne the tsne array to write
@param csv the file to use
@throws Exception
"""
try (BufferedWriter write = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv), StandardCharsets.UTF_8))) {
int words = 0;
InMemoryLookupCache l = (InMemoryLookupCache) vec.vocab();
for (String word : vec.vocab().words()) {
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
INDArray wordVector = tsne.getRow(l.wordFor(word).getIndex());
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(",");
}
}
sb.append(",");
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
sb.append("\n");
write.write(sb.toString());
}
log.info("Wrote " + words + " with size of " + vec.lookupTable().layerSize());
}
}
|
java
|
public static void writeTsneFormat(Glove vec, INDArray tsne, File csv) throws Exception {
try (BufferedWriter write = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv), StandardCharsets.UTF_8))) {
int words = 0;
InMemoryLookupCache l = (InMemoryLookupCache) vec.vocab();
for (String word : vec.vocab().words()) {
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
INDArray wordVector = tsne.getRow(l.wordFor(word).getIndex());
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(",");
}
}
sb.append(",");
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
sb.append("\n");
write.write(sb.toString());
}
log.info("Wrote " + words + " with size of " + vec.lookupTable().layerSize());
}
}
|
[
"public",
"static",
"void",
"writeTsneFormat",
"(",
"Glove",
"vec",
",",
"INDArray",
"tsne",
",",
"File",
"csv",
")",
"throws",
"Exception",
"{",
"try",
"(",
"BufferedWriter",
"write",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"csv",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
"{",
"int",
"words",
"=",
"0",
";",
"InMemoryLookupCache",
"l",
"=",
"(",
"InMemoryLookupCache",
")",
"vec",
".",
"vocab",
"(",
")",
";",
"for",
"(",
"String",
"word",
":",
"vec",
".",
"vocab",
"(",
")",
".",
"words",
"(",
")",
")",
"{",
"if",
"(",
"word",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"INDArray",
"wordVector",
"=",
"tsne",
".",
"getRow",
"(",
"l",
".",
"wordFor",
"(",
"word",
")",
".",
"getIndex",
"(",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"wordVector",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"wordVector",
".",
"getDouble",
"(",
"j",
")",
")",
";",
"if",
"(",
"j",
"<",
"wordVector",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"sb",
".",
"append",
"(",
"word",
".",
"replaceAll",
"(",
"\" \"",
",",
"WHITESPACE_REPLACEMENT",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"write",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Wrote \"",
"+",
"words",
"+",
"\" with size of \"",
"+",
"vec",
".",
"lookupTable",
"(",
")",
".",
"layerSize",
"(",
")",
")",
";",
"}",
"}"
] |
Write the tsne format
@param vec the word vectors to use for labeling
@param tsne the tsne array to write
@param csv the file to use
@throws Exception
|
[
"Write",
"the",
"tsne",
"format"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java#L1819-L1846
|
vkostyukov/la4j
|
src/main/java/org/la4j/Vector.java
|
Vector.swapElements
|
public void swapElements(int i, int j) {
"""
Swaps the specified elements of this vector.
@param i element's index
@param j element's index
"""
if (i != j) {
double s = get(i);
set(i, get(j));
set(j, s);
}
}
|
java
|
public void swapElements(int i, int j) {
if (i != j) {
double s = get(i);
set(i, get(j));
set(j, s);
}
}
|
[
"public",
"void",
"swapElements",
"(",
"int",
"i",
",",
"int",
"j",
")",
"{",
"if",
"(",
"i",
"!=",
"j",
")",
"{",
"double",
"s",
"=",
"get",
"(",
"i",
")",
";",
"set",
"(",
"i",
",",
"get",
"(",
"j",
")",
")",
";",
"set",
"(",
"j",
",",
"s",
")",
";",
"}",
"}"
] |
Swaps the specified elements of this vector.
@param i element's index
@param j element's index
|
[
"Swaps",
"the",
"specified",
"elements",
"of",
"this",
"vector",
"."
] |
train
|
https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Vector.java#L556-L562
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.createXStream
|
protected XStream createXStream(HierarchicalStreamDriver driver, NaaccrPatientConverter patientConverter) {
"""
Creates the instance of XStream to us for all reading and writing operations
@param driver an XStream driver (see createDriver())
@param patientConverter a patient converter (see createPatientConverter())
@return an instance of XStream, never null
"""
XStream xstream = new XStream(driver) {
@Override
protected void setupConverters() {
registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
registerConverter(new IntConverter(), PRIORITY_NORMAL);
registerConverter(new FloatConverter(), PRIORITY_NORMAL);
registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
registerConverter(new LongConverter(), PRIORITY_NORMAL);
registerConverter(new ShortConverter(), PRIORITY_NORMAL);
registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
registerConverter(new ByteConverter(), PRIORITY_NORMAL);
registerConverter(new StringConverter(), PRIORITY_NORMAL);
registerConverter(new DateConverter(), PRIORITY_NORMAL);
registerConverter(new CollectionConverter(getMapper()), PRIORITY_NORMAL);
registerConverter(new ReflectionConverter(getMapper(), getReflectionProvider()), PRIORITY_VERY_LOW);
}
};
// setup proper security environment
xstream.addPermission(NoTypePermission.NONE);
xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));
// tell XStream how to read/write our main entities
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ROOT, NaaccrData.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ITEM, Item.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT, Patient.class);
// add some attributes
xstream.aliasAttribute(NaaccrData.class, "_baseDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_BASE_DICT);
xstream.aliasAttribute(NaaccrData.class, "_userDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_USER_DICT);
xstream.aliasAttribute(NaaccrData.class, "_recordType", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_REC_TYPE);
xstream.aliasAttribute(NaaccrData.class, "_timeGenerated", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_TIME_GENERATED);
xstream.aliasAttribute(NaaccrData.class, "_specificationVersion", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_SPEC_VERSION);
// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though
xstream.addImplicitCollection(NaaccrData.class, "_items", Item.class);
xstream.addImplicitCollection(NaaccrData.class, "_patients", Patient.class);
// handle patients
xstream.registerConverter(patientConverter);
return xstream;
}
|
java
|
protected XStream createXStream(HierarchicalStreamDriver driver, NaaccrPatientConverter patientConverter) {
XStream xstream = new XStream(driver) {
@Override
protected void setupConverters() {
registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
registerConverter(new IntConverter(), PRIORITY_NORMAL);
registerConverter(new FloatConverter(), PRIORITY_NORMAL);
registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
registerConverter(new LongConverter(), PRIORITY_NORMAL);
registerConverter(new ShortConverter(), PRIORITY_NORMAL);
registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
registerConverter(new ByteConverter(), PRIORITY_NORMAL);
registerConverter(new StringConverter(), PRIORITY_NORMAL);
registerConverter(new DateConverter(), PRIORITY_NORMAL);
registerConverter(new CollectionConverter(getMapper()), PRIORITY_NORMAL);
registerConverter(new ReflectionConverter(getMapper(), getReflectionProvider()), PRIORITY_VERY_LOW);
}
};
// setup proper security environment
xstream.addPermission(NoTypePermission.NONE);
xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));
// tell XStream how to read/write our main entities
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ROOT, NaaccrData.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ITEM, Item.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT, Patient.class);
// add some attributes
xstream.aliasAttribute(NaaccrData.class, "_baseDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_BASE_DICT);
xstream.aliasAttribute(NaaccrData.class, "_userDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_USER_DICT);
xstream.aliasAttribute(NaaccrData.class, "_recordType", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_REC_TYPE);
xstream.aliasAttribute(NaaccrData.class, "_timeGenerated", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_TIME_GENERATED);
xstream.aliasAttribute(NaaccrData.class, "_specificationVersion", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_SPEC_VERSION);
// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though
xstream.addImplicitCollection(NaaccrData.class, "_items", Item.class);
xstream.addImplicitCollection(NaaccrData.class, "_patients", Patient.class);
// handle patients
xstream.registerConverter(patientConverter);
return xstream;
}
|
[
"protected",
"XStream",
"createXStream",
"(",
"HierarchicalStreamDriver",
"driver",
",",
"NaaccrPatientConverter",
"patientConverter",
")",
"{",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"driver",
")",
"{",
"@",
"Override",
"protected",
"void",
"setupConverters",
"(",
")",
"{",
"registerConverter",
"(",
"new",
"NullConverter",
"(",
")",
",",
"PRIORITY_VERY_HIGH",
")",
";",
"registerConverter",
"(",
"new",
"IntConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"FloatConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"DoubleConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"LongConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ShortConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"BooleanConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ByteConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"StringConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"DateConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"CollectionConverter",
"(",
"getMapper",
"(",
")",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ReflectionConverter",
"(",
"getMapper",
"(",
")",
",",
"getReflectionProvider",
"(",
")",
")",
",",
"PRIORITY_VERY_LOW",
")",
";",
"}",
"}",
";",
"// setup proper security environment",
"xstream",
".",
"addPermission",
"(",
"NoTypePermission",
".",
"NONE",
")",
";",
"xstream",
".",
"addPermission",
"(",
"new",
"WildcardTypePermission",
"(",
"new",
"String",
"[",
"]",
"{",
"\"com.imsweb.naaccrxml.**\"",
"}",
")",
")",
";",
"// tell XStream how to read/write our main entities",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_ROOT",
",",
"NaaccrData",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_ITEM",
",",
"Item",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_PATIENT",
",",
"Patient",
".",
"class",
")",
";",
"// add some attributes",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_baseDictionaryUri\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_BASE_DICT",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_userDictionaryUri\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_USER_DICT",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_recordType\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_REC_TYPE",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_timeGenerated\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_TIME_GENERATED",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_specificationVersion\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_SPEC_VERSION",
")",
";",
"// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though",
"xstream",
".",
"addImplicitCollection",
"(",
"NaaccrData",
".",
"class",
",",
"\"_items\"",
",",
"Item",
".",
"class",
")",
";",
"xstream",
".",
"addImplicitCollection",
"(",
"NaaccrData",
".",
"class",
",",
"\"_patients\"",
",",
"Patient",
".",
"class",
")",
";",
"// handle patients",
"xstream",
".",
"registerConverter",
"(",
"patientConverter",
")",
";",
"return",
"xstream",
";",
"}"
] |
Creates the instance of XStream to us for all reading and writing operations
@param driver an XStream driver (see createDriver())
@param patientConverter a patient converter (see createPatientConverter())
@return an instance of XStream, never null
|
[
"Creates",
"the",
"instance",
"of",
"XStream",
"to",
"us",
"for",
"all",
"reading",
"and",
"writing",
"operations"
] |
train
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L134-L177
|
alibaba/simpleimage
|
simpleimage.core/src/main/java/com/alibaba/simpleimage/util/ImageColorConvertHelper.java
|
ImageColorConvertHelper.convertCMYK2RGB
|
public static PlanarImage convertCMYK2RGB(PlanarImage src) {
"""
JAI在读cmyk格式的时候分2种:
<pre>
CMYK的图形读取,JAI使用的RGBA的模式的, 因此,为了替换使用自己的Color Profile, 直接使用format的操作。
<li>如果cmyk自带了 ICC_Profile, 那么数据是不会被修改的。 这个情况下, 我们应该使用内置的Color Profile</li>
<li>如果cmyk图形使用默认的ICC_Profile, 那么他使用内置的InvertedCMYKColorSpace, 这是时候颜色会发生反转</li>
</pre>
@param src 任意颜色空间图形
@return ColorSpace.CS_sRGB 表示的BufferedImage
"""
ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
// check if BufferedImage is cmyk format
if (srcColorSpace.getType() != ColorSpace.TYPE_CMYK) {
return src;
}
/**
* ICC_ColorSpace object mean jai read ColorSpace from image embed profile, we can not inverted cmyk color, and
* can not repace BufferedImage's ColorSpace
*/
if (srcColorSpace instanceof ICC_ColorSpace) {
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
pb.addSource(src);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
} else {
// get user defined color from ColorProfile data
ColorSpace cmykColorSpace = CMMColorSpace.getInstance(src.getColorModel().getColorSpace().getType());
ColorModel cmykColorModel = RasterFactory.createComponentColorModel(src.getSampleModel().getDataType(),
cmykColorSpace, false, true,
Transparency.OPAQUE);
// replace ColorSpace by format convertor with CMYK ColorSpace
ImageLayout cmykImageLayout = new ImageLayout();
cmykImageLayout.setColorModel(cmykColorModel);
RenderingHints cmykHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykImageLayout);
cmykHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("format");
pb.addSource(src);
pb.setParameter("datatype", src.getSampleModel().getDataType());
PlanarImage op = JAI.create("format", pb, cmykHints);
// invert CMYK pixel value
pb = new ParameterBlockJAI("invert");
pb.addSource(src);
op = JAI.create("invert", pb, cmykHints);
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
pb = new ParameterBlockJAI("colorconvert");
pb.addSource(op);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
}// endif
}
|
java
|
public static PlanarImage convertCMYK2RGB(PlanarImage src) {
ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
// check if BufferedImage is cmyk format
if (srcColorSpace.getType() != ColorSpace.TYPE_CMYK) {
return src;
}
/**
* ICC_ColorSpace object mean jai read ColorSpace from image embed profile, we can not inverted cmyk color, and
* can not repace BufferedImage's ColorSpace
*/
if (srcColorSpace instanceof ICC_ColorSpace) {
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
pb.addSource(src);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
} else {
// get user defined color from ColorProfile data
ColorSpace cmykColorSpace = CMMColorSpace.getInstance(src.getColorModel().getColorSpace().getType());
ColorModel cmykColorModel = RasterFactory.createComponentColorModel(src.getSampleModel().getDataType(),
cmykColorSpace, false, true,
Transparency.OPAQUE);
// replace ColorSpace by format convertor with CMYK ColorSpace
ImageLayout cmykImageLayout = new ImageLayout();
cmykImageLayout.setColorModel(cmykColorModel);
RenderingHints cmykHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykImageLayout);
cmykHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("format");
pb.addSource(src);
pb.setParameter("datatype", src.getSampleModel().getDataType());
PlanarImage op = JAI.create("format", pb, cmykHints);
// invert CMYK pixel value
pb = new ParameterBlockJAI("invert");
pb.addSource(src);
op = JAI.create("invert", pb, cmykHints);
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
pb = new ParameterBlockJAI("colorconvert");
pb.addSource(op);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
}// endif
}
|
[
"public",
"static",
"PlanarImage",
"convertCMYK2RGB",
"(",
"PlanarImage",
"src",
")",
"{",
"ColorSpace",
"srcColorSpace",
"=",
"src",
".",
"getColorModel",
"(",
")",
".",
"getColorSpace",
"(",
")",
";",
"// check if BufferedImage is cmyk format",
"if",
"(",
"srcColorSpace",
".",
"getType",
"(",
")",
"!=",
"ColorSpace",
".",
"TYPE_CMYK",
")",
"{",
"return",
"src",
";",
"}",
"/**\n * ICC_ColorSpace object mean jai read ColorSpace from image embed profile, we can not inverted cmyk color, and\n * can not repace BufferedImage's ColorSpace\n */",
"if",
"(",
"srcColorSpace",
"instanceof",
"ICC_ColorSpace",
")",
"{",
"// -- Convert CMYK to RGB",
"ColorSpace",
"rgbColorSpace",
"=",
"ColorSpace",
".",
"getInstance",
"(",
"ColorSpace",
".",
"CS_sRGB",
")",
";",
"ColorModel",
"rgbColorModel",
"=",
"RasterFactory",
".",
"createComponentColorModel",
"(",
"DataBuffer",
".",
"TYPE_BYTE",
",",
"rgbColorSpace",
",",
"false",
",",
"true",
",",
"Transparency",
".",
"OPAQUE",
")",
";",
"ImageLayout",
"rgbImageLayout",
"=",
"new",
"ImageLayout",
"(",
")",
";",
"rgbImageLayout",
".",
"setSampleModel",
"(",
"rgbColorModel",
".",
"createCompatibleSampleModel",
"(",
"src",
".",
"getWidth",
"(",
")",
",",
"src",
".",
"getHeight",
"(",
")",
")",
")",
";",
"RenderingHints",
"rgbHints",
"=",
"new",
"RenderingHints",
"(",
"JAI",
".",
"KEY_IMAGE_LAYOUT",
",",
"rgbImageLayout",
")",
";",
"rgbHints",
".",
"put",
"(",
"RenderingHints",
".",
"KEY_RENDERING",
",",
"RenderingHints",
".",
"VALUE_RENDER_QUALITY",
")",
";",
"ParameterBlockJAI",
"pb",
"=",
"new",
"ParameterBlockJAI",
"(",
"\"colorconvert\"",
")",
";",
"pb",
".",
"addSource",
"(",
"src",
")",
";",
"pb",
".",
"setParameter",
"(",
"\"colormodel\"",
",",
"rgbColorModel",
")",
";",
"return",
"JAI",
".",
"create",
"(",
"\"colorconvert\"",
",",
"pb",
",",
"rgbHints",
")",
";",
"}",
"else",
"{",
"// get user defined color from ColorProfile data",
"ColorSpace",
"cmykColorSpace",
"=",
"CMMColorSpace",
".",
"getInstance",
"(",
"src",
".",
"getColorModel",
"(",
")",
".",
"getColorSpace",
"(",
")",
".",
"getType",
"(",
")",
")",
";",
"ColorModel",
"cmykColorModel",
"=",
"RasterFactory",
".",
"createComponentColorModel",
"(",
"src",
".",
"getSampleModel",
"(",
")",
".",
"getDataType",
"(",
")",
",",
"cmykColorSpace",
",",
"false",
",",
"true",
",",
"Transparency",
".",
"OPAQUE",
")",
";",
"// replace ColorSpace by format convertor with CMYK ColorSpace",
"ImageLayout",
"cmykImageLayout",
"=",
"new",
"ImageLayout",
"(",
")",
";",
"cmykImageLayout",
".",
"setColorModel",
"(",
"cmykColorModel",
")",
";",
"RenderingHints",
"cmykHints",
"=",
"new",
"RenderingHints",
"(",
"JAI",
".",
"KEY_IMAGE_LAYOUT",
",",
"cmykImageLayout",
")",
";",
"cmykHints",
".",
"put",
"(",
"RenderingHints",
".",
"KEY_RENDERING",
",",
"RenderingHints",
".",
"VALUE_RENDER_QUALITY",
")",
";",
"ParameterBlockJAI",
"pb",
"=",
"new",
"ParameterBlockJAI",
"(",
"\"format\"",
")",
";",
"pb",
".",
"addSource",
"(",
"src",
")",
";",
"pb",
".",
"setParameter",
"(",
"\"datatype\"",
",",
"src",
".",
"getSampleModel",
"(",
")",
".",
"getDataType",
"(",
")",
")",
";",
"PlanarImage",
"op",
"=",
"JAI",
".",
"create",
"(",
"\"format\"",
",",
"pb",
",",
"cmykHints",
")",
";",
"// invert CMYK pixel value",
"pb",
"=",
"new",
"ParameterBlockJAI",
"(",
"\"invert\"",
")",
";",
"pb",
".",
"addSource",
"(",
"src",
")",
";",
"op",
"=",
"JAI",
".",
"create",
"(",
"\"invert\"",
",",
"pb",
",",
"cmykHints",
")",
";",
"// -- Convert CMYK to RGB",
"ColorSpace",
"rgbColorSpace",
"=",
"ColorSpace",
".",
"getInstance",
"(",
"ColorSpace",
".",
"CS_sRGB",
")",
";",
"ColorModel",
"rgbColorModel",
"=",
"RasterFactory",
".",
"createComponentColorModel",
"(",
"DataBuffer",
".",
"TYPE_BYTE",
",",
"rgbColorSpace",
",",
"false",
",",
"true",
",",
"Transparency",
".",
"OPAQUE",
")",
";",
"ImageLayout",
"rgbImageLayout",
"=",
"new",
"ImageLayout",
"(",
")",
";",
"rgbImageLayout",
".",
"setSampleModel",
"(",
"rgbColorModel",
".",
"createCompatibleSampleModel",
"(",
"op",
".",
"getWidth",
"(",
")",
",",
"op",
".",
"getHeight",
"(",
")",
")",
")",
";",
"RenderingHints",
"rgbHints",
"=",
"new",
"RenderingHints",
"(",
"JAI",
".",
"KEY_IMAGE_LAYOUT",
",",
"rgbImageLayout",
")",
";",
"rgbHints",
".",
"put",
"(",
"RenderingHints",
".",
"KEY_RENDERING",
",",
"RenderingHints",
".",
"VALUE_RENDER_QUALITY",
")",
";",
"pb",
"=",
"new",
"ParameterBlockJAI",
"(",
"\"colorconvert\"",
")",
";",
"pb",
".",
"addSource",
"(",
"op",
")",
";",
"pb",
".",
"setParameter",
"(",
"\"colormodel\"",
",",
"rgbColorModel",
")",
";",
"return",
"JAI",
".",
"create",
"(",
"\"colorconvert\"",
",",
"pb",
",",
"rgbHints",
")",
";",
"}",
"// endif",
"}"
] |
JAI在读cmyk格式的时候分2种:
<pre>
CMYK的图形读取,JAI使用的RGBA的模式的, 因此,为了替换使用自己的Color Profile, 直接使用format的操作。
<li>如果cmyk自带了 ICC_Profile, 那么数据是不会被修改的。 这个情况下, 我们应该使用内置的Color Profile</li>
<li>如果cmyk图形使用默认的ICC_Profile, 那么他使用内置的InvertedCMYKColorSpace, 这是时候颜色会发生反转</li>
</pre>
@param src 任意颜色空间图形
@return ColorSpace.CS_sRGB 表示的BufferedImage
|
[
"JAI在读cmyk格式的时候分2种:"
] |
train
|
https://github.com/alibaba/simpleimage/blob/aabe559c267402b754c2ad606b796c4c6570788c/simpleimage.core/src/main/java/com/alibaba/simpleimage/util/ImageColorConvertHelper.java#L89-L152
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java
|
ApiOvhDomain.zone_zoneName_dynHost_record_POST
|
public OvhDynHostRecord zone_zoneName_dynHost_record_POST(String zoneName, String ip, String subDomain) throws IOException {
"""
Create a new DynHost record (Don't forget to refresh the zone)
REST: POST /domain/zone/{zoneName}/dynHost/record
@param ip [required] Ip address of the DynHost record
@param subDomain [required] Subdomain of the DynHost record
@param zoneName [required] The internal name of your zone
"""
String qPath = "/domain/zone/{zoneName}/dynHost/record";
StringBuilder sb = path(qPath, zoneName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ip", ip);
addBody(o, "subDomain", subDomain);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhDynHostRecord.class);
}
|
java
|
public OvhDynHostRecord zone_zoneName_dynHost_record_POST(String zoneName, String ip, String subDomain) throws IOException {
String qPath = "/domain/zone/{zoneName}/dynHost/record";
StringBuilder sb = path(qPath, zoneName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ip", ip);
addBody(o, "subDomain", subDomain);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhDynHostRecord.class);
}
|
[
"public",
"OvhDynHostRecord",
"zone_zoneName_dynHost_record_POST",
"(",
"String",
"zoneName",
",",
"String",
"ip",
",",
"String",
"subDomain",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/domain/zone/{zoneName}/dynHost/record\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"zoneName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"ip\"",
",",
"ip",
")",
";",
"addBody",
"(",
"o",
",",
"\"subDomain\"",
",",
"subDomain",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDynHostRecord",
".",
"class",
")",
";",
"}"
] |
Create a new DynHost record (Don't forget to refresh the zone)
REST: POST /domain/zone/{zoneName}/dynHost/record
@param ip [required] Ip address of the DynHost record
@param subDomain [required] Subdomain of the DynHost record
@param zoneName [required] The internal name of your zone
|
[
"Create",
"a",
"new",
"DynHost",
"record",
"(",
"Don",
"t",
"forget",
"to",
"refresh",
"the",
"zone",
")"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java#L380-L388
|
DDTH/ddth-commons
|
ddth-commons-core/src/main/java/com/github/ddth/commons/utils/TypesafeConfigUtils.java
|
TypesafeConfigUtils.getBoolean
|
public static Boolean getBoolean(Config config, String path) {
"""
Get a configuration as Boolean. Return {@code null} if missing or wrong type.
@param config
@param path
@return
"""
try {
return config.getBoolean(path) ? Boolean.TRUE : Boolean.FALSE;
} catch (ConfigException.Missing | ConfigException.WrongType e) {
if (e instanceof ConfigException.WrongType) {
LOGGER.warn(e.getMessage(), e);
}
return null;
}
}
|
java
|
public static Boolean getBoolean(Config config, String path) {
try {
return config.getBoolean(path) ? Boolean.TRUE : Boolean.FALSE;
} catch (ConfigException.Missing | ConfigException.WrongType e) {
if (e instanceof ConfigException.WrongType) {
LOGGER.warn(e.getMessage(), e);
}
return null;
}
}
|
[
"public",
"static",
"Boolean",
"getBoolean",
"(",
"Config",
"config",
",",
"String",
"path",
")",
"{",
"try",
"{",
"return",
"config",
".",
"getBoolean",
"(",
"path",
")",
"?",
"Boolean",
".",
"TRUE",
":",
"Boolean",
".",
"FALSE",
";",
"}",
"catch",
"(",
"ConfigException",
".",
"Missing",
"|",
"ConfigException",
".",
"WrongType",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"ConfigException",
".",
"WrongType",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] |
Get a configuration as Boolean. Return {@code null} if missing or wrong type.
@param config
@param path
@return
|
[
"Get",
"a",
"configuration",
"as",
"Boolean",
".",
"Return",
"{",
"@code",
"null",
"}",
"if",
"missing",
"or",
"wrong",
"type",
"."
] |
train
|
https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/TypesafeConfigUtils.java#L247-L256
|
beders/Resty
|
src/main/java/us/monoid/json/JSONObject.java
|
JSONObject.putOnce
|
public JSONObject putOnce(Enum<?> key, Object value) throws JSONException {
"""
Put a key/value pair in the JSONObject, but only if the key and the value
are both non-null, and only if there is not already a member with that
name.
@param key
@param value
@return his.
@throws JSONException
if the key is a duplicate
"""
return putOnce(key.name(), value);
}
|
java
|
public JSONObject putOnce(Enum<?> key, Object value) throws JSONException {
return putOnce(key.name(), value);
}
|
[
"public",
"JSONObject",
"putOnce",
"(",
"Enum",
"<",
"?",
">",
"key",
",",
"Object",
"value",
")",
"throws",
"JSONException",
"{",
"return",
"putOnce",
"(",
"key",
".",
"name",
"(",
")",
",",
"value",
")",
";",
"}"
] |
Put a key/value pair in the JSONObject, but only if the key and the value
are both non-null, and only if there is not already a member with that
name.
@param key
@param value
@return his.
@throws JSONException
if the key is a duplicate
|
[
"Put",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"JSONObject",
"but",
"only",
"if",
"the",
"key",
"and",
"the",
"value",
"are",
"both",
"non",
"-",
"null",
"and",
"only",
"if",
"there",
"is",
"not",
"already",
"a",
"member",
"with",
"that",
"name",
"."
] |
train
|
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/json/JSONObject.java#L1531-L1533
|
apereo/cas
|
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/DefaultRegisteredServiceAccessStrategy.java
|
DefaultRegisteredServiceAccessStrategy.requiredAttributesFoundInMap
|
protected boolean requiredAttributesFoundInMap(final Map<String, Object> principalAttributes, final Map<String, Set<String>> requiredAttributes) {
"""
Check whether required attributes are found in the given map.
@param principalAttributes the principal attributes
@param requiredAttributes the attributes
@return the boolean
"""
val difference = requiredAttributes.keySet().stream().filter(a -> principalAttributes.keySet().contains(a)).collect(Collectors.toSet());
LOGGER.debug("Difference of checking required attributes: [{}]", difference);
if (this.requireAllAttributes && difference.size() < requiredAttributes.size()) {
return false;
}
if (this.requireAllAttributes) {
return difference.stream().allMatch(key -> requiredAttributeFound(key, principalAttributes, requiredAttributes));
}
return difference.stream().anyMatch(key -> requiredAttributeFound(key, principalAttributes, requiredAttributes));
}
|
java
|
protected boolean requiredAttributesFoundInMap(final Map<String, Object> principalAttributes, final Map<String, Set<String>> requiredAttributes) {
val difference = requiredAttributes.keySet().stream().filter(a -> principalAttributes.keySet().contains(a)).collect(Collectors.toSet());
LOGGER.debug("Difference of checking required attributes: [{}]", difference);
if (this.requireAllAttributes && difference.size() < requiredAttributes.size()) {
return false;
}
if (this.requireAllAttributes) {
return difference.stream().allMatch(key -> requiredAttributeFound(key, principalAttributes, requiredAttributes));
}
return difference.stream().anyMatch(key -> requiredAttributeFound(key, principalAttributes, requiredAttributes));
}
|
[
"protected",
"boolean",
"requiredAttributesFoundInMap",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"principalAttributes",
",",
"final",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"requiredAttributes",
")",
"{",
"val",
"difference",
"=",
"requiredAttributes",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"a",
"->",
"principalAttributes",
".",
"keySet",
"(",
")",
".",
"contains",
"(",
"a",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Difference of checking required attributes: [{}]\"",
",",
"difference",
")",
";",
"if",
"(",
"this",
".",
"requireAllAttributes",
"&&",
"difference",
".",
"size",
"(",
")",
"<",
"requiredAttributes",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"requireAllAttributes",
")",
"{",
"return",
"difference",
".",
"stream",
"(",
")",
".",
"allMatch",
"(",
"key",
"->",
"requiredAttributeFound",
"(",
"key",
",",
"principalAttributes",
",",
"requiredAttributes",
")",
")",
";",
"}",
"return",
"difference",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"key",
"->",
"requiredAttributeFound",
"(",
"key",
",",
"principalAttributes",
",",
"requiredAttributes",
")",
")",
";",
"}"
] |
Check whether required attributes are found in the given map.
@param principalAttributes the principal attributes
@param requiredAttributes the attributes
@return the boolean
|
[
"Check",
"whether",
"required",
"attributes",
"are",
"found",
"in",
"the",
"given",
"map",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/DefaultRegisteredServiceAccessStrategy.java#L262-L272
|
dottydingo/hyperion
|
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
|
HyperionClient.executeRequest
|
protected <R> R executeRequest(Request request, JavaType javaType) {
"""
Execute the request
@param request The request
@param javaType The return type
@return The response
"""
long start = System.currentTimeMillis();
boolean error = true;
try
{
Response response = executeRequest(request);
R r = readResponse(response, javaType);
error = false;
return r;
}
finally
{
if(clientEventListener != null)
{
ClientEvent event = new ClientEvent(baseUrl,request.getEntityName(),request.getRequestMethod(),
System.currentTimeMillis() - start,error);
clientEventListener.handleEvent(event);
}
}
}
|
java
|
protected <R> R executeRequest(Request request, JavaType javaType)
{
long start = System.currentTimeMillis();
boolean error = true;
try
{
Response response = executeRequest(request);
R r = readResponse(response, javaType);
error = false;
return r;
}
finally
{
if(clientEventListener != null)
{
ClientEvent event = new ClientEvent(baseUrl,request.getEntityName(),request.getRequestMethod(),
System.currentTimeMillis() - start,error);
clientEventListener.handleEvent(event);
}
}
}
|
[
"protected",
"<",
"R",
">",
"R",
"executeRequest",
"(",
"Request",
"request",
",",
"JavaType",
"javaType",
")",
"{",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"boolean",
"error",
"=",
"true",
";",
"try",
"{",
"Response",
"response",
"=",
"executeRequest",
"(",
"request",
")",
";",
"R",
"r",
"=",
"readResponse",
"(",
"response",
",",
"javaType",
")",
";",
"error",
"=",
"false",
";",
"return",
"r",
";",
"}",
"finally",
"{",
"if",
"(",
"clientEventListener",
"!=",
"null",
")",
"{",
"ClientEvent",
"event",
"=",
"new",
"ClientEvent",
"(",
"baseUrl",
",",
"request",
".",
"getEntityName",
"(",
")",
",",
"request",
".",
"getRequestMethod",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
",",
"error",
")",
";",
"clientEventListener",
".",
"handleEvent",
"(",
"event",
")",
";",
"}",
"}",
"}"
] |
Execute the request
@param request The request
@param javaType The return type
@return The response
|
[
"Execute",
"the",
"request"
] |
train
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L255-L275
|
Mozu/mozu-java
|
mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/SearchUrl.java
|
SearchUrl.updateSynonymDefinitionUrl
|
public static MozuUrl updateSynonymDefinitionUrl(String responseFields, Integer synonymId) {
"""
Get Resource Url for UpdateSynonymDefinition
@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.
@param synonymId The unique identifier of the synonym definition.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/search/synonyms/{synonymId}?responseFields={responseFields}");
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("synonymId", synonymId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
java
|
public static MozuUrl updateSynonymDefinitionUrl(String responseFields, Integer synonymId)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/search/synonyms/{synonymId}?responseFields={responseFields}");
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("synonymId", synonymId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"updateSynonymDefinitionUrl",
"(",
"String",
"responseFields",
",",
"Integer",
"synonymId",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/search/synonyms/{synonymId}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"synonymId\"",
",",
"synonymId",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] |
Get Resource Url for UpdateSynonymDefinition
@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.
@param synonymId The unique identifier of the synonym definition.
@return String Resource Url
|
[
"Get",
"Resource",
"Url",
"for",
"UpdateSynonymDefinition"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/SearchUrl.java#L204-L210
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.