repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
218
| func_name
stringlengths 5
140
| whole_func_string
stringlengths 79
3.99k
| language
stringclasses 1
value | func_code_string
stringlengths 79
3.99k
| func_code_tokens
listlengths 20
624
| func_documentation_string
stringlengths 61
1.96k
| func_documentation_tokens
listlengths 1
478
| split_name
stringclasses 1
value | func_code_url
stringlengths 107
339
|
---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/TrmMessageFactoryImpl.java
|
TrmMessageFactoryImpl.createInboundTrmFirstContactMessage
|
public TrmFirstContactMessage createInboundTrmFirstContactMessage(byte rawMessage[], int offset, int length)
throws MessageDecodeFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createInboundTrmFirstContactMessage", new Object[]{rawMessage, Integer.valueOf(offset), Integer.valueOf(length)});
JsMsgObject jmo = new JsMsgObject(TrmFirstContactAccess.schema, rawMessage, offset, length);
TrmFirstContactMessage message = new TrmFirstContactMessageImpl(jmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createInboundTrmFirstContactMessage", message);
return message;
}
|
java
|
public TrmFirstContactMessage createInboundTrmFirstContactMessage(byte rawMessage[], int offset, int length)
throws MessageDecodeFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createInboundTrmFirstContactMessage", new Object[]{rawMessage, Integer.valueOf(offset), Integer.valueOf(length)});
JsMsgObject jmo = new JsMsgObject(TrmFirstContactAccess.schema, rawMessage, offset, length);
TrmFirstContactMessage message = new TrmFirstContactMessageImpl(jmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createInboundTrmFirstContactMessage", message);
return message;
}
|
[
"public",
"TrmFirstContactMessage",
"createInboundTrmFirstContactMessage",
"(",
"byte",
"rawMessage",
"[",
"]",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"MessageDecodeFailedException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"createInboundTrmFirstContactMessage\"",
",",
"new",
"Object",
"[",
"]",
"{",
"rawMessage",
",",
"Integer",
".",
"valueOf",
"(",
"offset",
")",
",",
"Integer",
".",
"valueOf",
"(",
"length",
")",
"}",
")",
";",
"JsMsgObject",
"jmo",
"=",
"new",
"JsMsgObject",
"(",
"TrmFirstContactAccess",
".",
"schema",
",",
"rawMessage",
",",
"offset",
",",
"length",
")",
";",
"TrmFirstContactMessage",
"message",
"=",
"new",
"TrmFirstContactMessageImpl",
"(",
"jmo",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"createInboundTrmFirstContactMessage\"",
",",
"message",
")",
";",
"return",
"message",
";",
"}"
] |
Create a TrmFirstContactMessage to represent an inbound message.
@param rawMessage The inbound byte array containging a complete message
@param offset The offset in the byte array at which the message begins
@param length The length of the message within the byte array
@return The new TrmFirstContactMessage
@exception MessageDecodeFailedException Thrown if the inbound message could not be decoded
|
[
"Create",
"a",
"TrmFirstContactMessage",
"to",
"represent",
"an",
"inbound",
"message",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/TrmMessageFactoryImpl.java#L336-L346
|
samskivert/pythagoras
|
src/main/java/pythagoras/f/Line.java
|
Line.setLine
|
public void setLine (float x1, float y1, float x2, float y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
|
java
|
public void setLine (float x1, float y1, float x2, float y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
|
[
"public",
"void",
"setLine",
"(",
"float",
"x1",
",",
"float",
"y1",
",",
"float",
"x2",
",",
"float",
"y2",
")",
"{",
"this",
".",
"x1",
"=",
"x1",
";",
"this",
".",
"y1",
"=",
"y1",
";",
"this",
".",
"x2",
"=",
"x2",
";",
"this",
".",
"y2",
"=",
"y2",
";",
"}"
] |
Sets the start and end point of this line to the specified values.
|
[
"Sets",
"the",
"start",
"and",
"end",
"point",
"of",
"this",
"line",
"to",
"the",
"specified",
"values",
"."
] |
train
|
https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/f/Line.java#L51-L56
|
spring-projects/spring-android
|
spring-android-core/src/main/java/org/springframework/core/BridgeMethodResolver.java
|
BridgeMethodResolver.isBridgedCandidateFor
|
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
candidateMethod.getName().equals(bridgeMethod.getName()) &&
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
}
|
java
|
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
candidateMethod.getName().equals(bridgeMethod.getName()) &&
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
}
|
[
"private",
"static",
"boolean",
"isBridgedCandidateFor",
"(",
"Method",
"candidateMethod",
",",
"Method",
"bridgeMethod",
")",
"{",
"return",
"(",
"!",
"candidateMethod",
".",
"isBridge",
"(",
")",
"&&",
"!",
"candidateMethod",
".",
"equals",
"(",
"bridgeMethod",
")",
"&&",
"candidateMethod",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"bridgeMethod",
".",
"getName",
"(",
")",
")",
"&&",
"candidateMethod",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"==",
"bridgeMethod",
".",
"getParameterTypes",
"(",
")",
".",
"length",
")",
";",
"}"
] |
Returns {@code true} if the supplied '{@code candidateMethod}' can be
consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged}
by the supplied {@link Method bridge Method}. This method performs inexpensive
checks and can be used quickly filter for a set of possible matches.
|
[
"Returns",
"{"
] |
train
|
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/core/BridgeMethodResolver.java#L121-L125
|
b3log/latke
|
latke-core/src/main/java/org/b3log/latke/repository/jdbc/util/JdbcUtil.java
|
JdbcUtil.executeSql
|
public static boolean executeSql(final String sql, final Connection connection, final boolean isDebug) throws SQLException {
if (isDebug || LOGGER.isTraceEnabled()) {
LOGGER.log(Level.INFO, "Executing SQL [" + sql + "]");
}
final Statement statement = connection.createStatement();
final boolean isSuccess = !statement.execute(sql);
statement.close();
return isSuccess;
}
|
java
|
public static boolean executeSql(final String sql, final Connection connection, final boolean isDebug) throws SQLException {
if (isDebug || LOGGER.isTraceEnabled()) {
LOGGER.log(Level.INFO, "Executing SQL [" + sql + "]");
}
final Statement statement = connection.createStatement();
final boolean isSuccess = !statement.execute(sql);
statement.close();
return isSuccess;
}
|
[
"public",
"static",
"boolean",
"executeSql",
"(",
"final",
"String",
"sql",
",",
"final",
"Connection",
"connection",
",",
"final",
"boolean",
"isDebug",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"isDebug",
"||",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Executing SQL [\"",
"+",
"sql",
"+",
"\"]\"",
")",
";",
"}",
"final",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"final",
"boolean",
"isSuccess",
"=",
"!",
"statement",
".",
"execute",
"(",
"sql",
")",
";",
"statement",
".",
"close",
"(",
")",
";",
"return",
"isSuccess",
";",
"}"
] |
Executes the specified SQL with the specified connection.
@param sql the specified SQL
@param connection connection the specified connection
@param isDebug the specified debug flag
@return {@code true} if success, returns {@false} otherwise
@throws SQLException SQLException
|
[
"Executes",
"the",
"specified",
"SQL",
"with",
"the",
"specified",
"connection",
"."
] |
train
|
https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/b3log/latke/repository/jdbc/util/JdbcUtil.java#L60-L70
|
johncarl81/transfuse
|
transfuse/src/main/java/org/androidtransfuse/analysis/module/ModuleTransactionWorker.java
|
ModuleTransactionWorker.createConfigurationsForModuleType
|
private void createConfigurationsForModuleType(ImmutableList.Builder<ModuleConfiguration> configurations, ASTType module, ASTType scanTarget, Set<MethodSignature> scanned, Map<String, Set<MethodSignature>> packagePrivateScanned) {
configureModuleAnnotations(configurations, module, scanTarget, scanTarget.getAnnotations());
configureModuleMethods(configurations, module, scanTarget, scanTarget.getMethods(), scanned, packagePrivateScanned);
// Add scanned methods to allow for method overriding.
for (ASTMethod astMethod : scanTarget.getMethods()) {
MethodSignature signature = new MethodSignature(astMethod);
if(astMethod.getAccessModifier() == ASTAccessModifier.PUBLIC || astMethod.getAccessModifier() == ASTAccessModifier.PROTECTED){
scanned.add(signature);
}
else if(astMethod.getAccessModifier() == ASTAccessModifier.PACKAGE_PRIVATE){
if(!packagePrivateScanned.containsKey(scanTarget.getPackageClass().getPackage())){
packagePrivateScanned.put(scanTarget.getPackageClass().getPackage(), new HashSet<MethodSignature>());
}
packagePrivateScanned.get(scanTarget.getPackageClass().getPackage()).add(signature);
}
}
// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.
if(scanTarget.getSuperClass() != null) {
// recurse our way up the tree so we add the top most providers first and clobber them on the way down
createConfigurationsForModuleType(configurations, module, scanTarget.getSuperClass(), scanned, packagePrivateScanned);
}
}
|
java
|
private void createConfigurationsForModuleType(ImmutableList.Builder<ModuleConfiguration> configurations, ASTType module, ASTType scanTarget, Set<MethodSignature> scanned, Map<String, Set<MethodSignature>> packagePrivateScanned) {
configureModuleAnnotations(configurations, module, scanTarget, scanTarget.getAnnotations());
configureModuleMethods(configurations, module, scanTarget, scanTarget.getMethods(), scanned, packagePrivateScanned);
// Add scanned methods to allow for method overriding.
for (ASTMethod astMethod : scanTarget.getMethods()) {
MethodSignature signature = new MethodSignature(astMethod);
if(astMethod.getAccessModifier() == ASTAccessModifier.PUBLIC || astMethod.getAccessModifier() == ASTAccessModifier.PROTECTED){
scanned.add(signature);
}
else if(astMethod.getAccessModifier() == ASTAccessModifier.PACKAGE_PRIVATE){
if(!packagePrivateScanned.containsKey(scanTarget.getPackageClass().getPackage())){
packagePrivateScanned.put(scanTarget.getPackageClass().getPackage(), new HashSet<MethodSignature>());
}
packagePrivateScanned.get(scanTarget.getPackageClass().getPackage()).add(signature);
}
}
// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.
if(scanTarget.getSuperClass() != null) {
// recurse our way up the tree so we add the top most providers first and clobber them on the way down
createConfigurationsForModuleType(configurations, module, scanTarget.getSuperClass(), scanned, packagePrivateScanned);
}
}
|
[
"private",
"void",
"createConfigurationsForModuleType",
"(",
"ImmutableList",
".",
"Builder",
"<",
"ModuleConfiguration",
">",
"configurations",
",",
"ASTType",
"module",
",",
"ASTType",
"scanTarget",
",",
"Set",
"<",
"MethodSignature",
">",
"scanned",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"MethodSignature",
">",
">",
"packagePrivateScanned",
")",
"{",
"configureModuleAnnotations",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
",",
"scanTarget",
".",
"getAnnotations",
"(",
")",
")",
";",
"configureModuleMethods",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
",",
"scanTarget",
".",
"getMethods",
"(",
")",
",",
"scanned",
",",
"packagePrivateScanned",
")",
";",
"// Add scanned methods to allow for method overriding.",
"for",
"(",
"ASTMethod",
"astMethod",
":",
"scanTarget",
".",
"getMethods",
"(",
")",
")",
"{",
"MethodSignature",
"signature",
"=",
"new",
"MethodSignature",
"(",
"astMethod",
")",
";",
"if",
"(",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PUBLIC",
"||",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PROTECTED",
")",
"{",
"scanned",
".",
"add",
"(",
"signature",
")",
";",
"}",
"else",
"if",
"(",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PACKAGE_PRIVATE",
")",
"{",
"if",
"(",
"!",
"packagePrivateScanned",
".",
"containsKey",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
")",
")",
"{",
"packagePrivateScanned",
".",
"put",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
",",
"new",
"HashSet",
"<",
"MethodSignature",
">",
"(",
")",
")",
";",
"}",
"packagePrivateScanned",
".",
"get",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
")",
".",
"add",
"(",
"signature",
")",
";",
"}",
"}",
"// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.",
"if",
"(",
"scanTarget",
".",
"getSuperClass",
"(",
")",
"!=",
"null",
")",
"{",
"// recurse our way up the tree so we add the top most providers first and clobber them on the way down",
"createConfigurationsForModuleType",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
".",
"getSuperClass",
"(",
")",
",",
"scanned",
",",
"packagePrivateScanned",
")",
";",
"}",
"}"
] |
Recursive method that finds module methods and annotations on all parents of moduleAncestor and moduleAncestor, but creates configuration based on the module.
This allows any class in the module hierarchy to contribute annotations or providers that can be overridden by subclasses.
@param configurations the holder for annotation and method configurations
@param module the module type we are configuring
|
[
"Recursive",
"method",
"that",
"finds",
"module",
"methods",
"and",
"annotations",
"on",
"all",
"parents",
"of",
"moduleAncestor",
"and",
"moduleAncestor",
"but",
"creates",
"configuration",
"based",
"on",
"the",
"module",
".",
"This",
"allows",
"any",
"class",
"in",
"the",
"module",
"hierarchy",
"to",
"contribute",
"annotations",
"or",
"providers",
"that",
"can",
"be",
"overridden",
"by",
"subclasses",
"."
] |
train
|
https://github.com/johncarl81/transfuse/blob/a5f837504797a6c4f8628f7e1dde09b8e6368c8b/transfuse/src/main/java/org/androidtransfuse/analysis/module/ModuleTransactionWorker.java#L124-L148
|
phax/ph-oton
|
ph-oton-jscode/src/main/java/com/helger/html/jscode/AbstractJSBlock.java
|
AbstractJSBlock.staticInvoke
|
@Nonnull
public JSInvocation staticInvoke (@Nullable final AbstractJSClass aType, @Nonnull final JSMethod aMethod)
{
final JSInvocation aInvocation = new JSInvocation (aType, aMethod);
return addStatement (aInvocation);
}
|
java
|
@Nonnull
public JSInvocation staticInvoke (@Nullable final AbstractJSClass aType, @Nonnull final JSMethod aMethod)
{
final JSInvocation aInvocation = new JSInvocation (aType, aMethod);
return addStatement (aInvocation);
}
|
[
"@",
"Nonnull",
"public",
"JSInvocation",
"staticInvoke",
"(",
"@",
"Nullable",
"final",
"AbstractJSClass",
"aType",
",",
"@",
"Nonnull",
"final",
"JSMethod",
"aMethod",
")",
"{",
"final",
"JSInvocation",
"aInvocation",
"=",
"new",
"JSInvocation",
"(",
"aType",
",",
"aMethod",
")",
";",
"return",
"addStatement",
"(",
"aInvocation",
")",
";",
"}"
] |
Creates a static invocation statement.
@param aType
Type to use
@param aMethod
Method to invoke
@return Never <code>null</code>.
|
[
"Creates",
"a",
"static",
"invocation",
"statement",
"."
] |
train
|
https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-jscode/src/main/java/com/helger/html/jscode/AbstractJSBlock.java#L551-L556
|
knightliao/disconf
|
disconf-core/src/main/java/org/apache/zookeeper/recipes/lock/ProtocolSupport.java
|
ProtocolSupport.ensureExists
|
protected void ensureExists(final String path, final byte[] data, final List<ACL> acl, final CreateMode flags) {
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
Stat stat = zookeeper.exists(path, false);
if (stat != null) {
return true;
}
zookeeper.create(path, data, acl, flags);
return true;
}
});
} catch (KeeperException e) {
LOG.warn("Caught: " + e, e);
} catch (InterruptedException e) {
LOG.warn("Caught: " + e, e);
}
}
|
java
|
protected void ensureExists(final String path, final byte[] data, final List<ACL> acl, final CreateMode flags) {
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
Stat stat = zookeeper.exists(path, false);
if (stat != null) {
return true;
}
zookeeper.create(path, data, acl, flags);
return true;
}
});
} catch (KeeperException e) {
LOG.warn("Caught: " + e, e);
} catch (InterruptedException e) {
LOG.warn("Caught: " + e, e);
}
}
|
[
"protected",
"void",
"ensureExists",
"(",
"final",
"String",
"path",
",",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"List",
"<",
"ACL",
">",
"acl",
",",
"final",
"CreateMode",
"flags",
")",
"{",
"try",
"{",
"retryOperation",
"(",
"new",
"ZooKeeperOperation",
"(",
")",
"{",
"public",
"boolean",
"execute",
"(",
")",
"throws",
"KeeperException",
",",
"InterruptedException",
"{",
"Stat",
"stat",
"=",
"zookeeper",
".",
"exists",
"(",
"path",
",",
"false",
")",
";",
"if",
"(",
"stat",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"zookeeper",
".",
"create",
"(",
"path",
",",
"data",
",",
"acl",
",",
"flags",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"KeeperException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Caught: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Caught: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}"
] |
Ensures that the given path exists with the given data, ACL and flags
@param path
@param acl
@param flags
|
[
"Ensures",
"that",
"the",
"given",
"path",
"exists",
"with",
"the",
"given",
"data",
"ACL",
"and",
"flags"
] |
train
|
https://github.com/knightliao/disconf/blob/d413cbce9334fe38a5a24982ce4db3a6ed8e98ea/disconf-core/src/main/java/org/apache/zookeeper/recipes/lock/ProtocolSupport.java#L155-L172
|
pgjdbc/pgjdbc
|
pgjdbc/src/main/java/org/postgresql/ds/PGConnectionPoolDataSource.java
|
PGConnectionPoolDataSource.getPooledConnection
|
public PooledConnection getPooledConnection(String user, String password) throws SQLException {
return new PGPooledConnection(getConnection(user, password), defaultAutoCommit);
}
|
java
|
public PooledConnection getPooledConnection(String user, String password) throws SQLException {
return new PGPooledConnection(getConnection(user, password), defaultAutoCommit);
}
|
[
"public",
"PooledConnection",
"getPooledConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"PGPooledConnection",
"(",
"getConnection",
"(",
"user",
",",
"password",
")",
",",
"defaultAutoCommit",
")",
";",
"}"
] |
Gets a connection which may be pooled by the app server or middleware implementation of
DataSource.
@throws java.sql.SQLException Occurs when the physical database connection cannot be
established.
|
[
"Gets",
"a",
"connection",
"which",
"may",
"be",
"pooled",
"by",
"the",
"app",
"server",
"or",
"middleware",
"implementation",
"of",
"DataSource",
"."
] |
train
|
https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/ds/PGConnectionPoolDataSource.java#L68-L70
|
intive-FDV/DynamicJasper
|
src/main/java/ar/com/fdvs/dj/domain/builders/CrosstabBuilder.java
|
CrosstabBuilder.setColumnStyles
|
public CrosstabBuilder setColumnStyles(Style headerStyle, Style totalStyle, Style totalHeaderStyle) {
crosstab.setColumnHeaderStyle(headerStyle);
crosstab.setColumnTotalheaderStyle(totalHeaderStyle);
crosstab.setColumnTotalStyle(totalStyle);
return this;
}
|
java
|
public CrosstabBuilder setColumnStyles(Style headerStyle, Style totalStyle, Style totalHeaderStyle) {
crosstab.setColumnHeaderStyle(headerStyle);
crosstab.setColumnTotalheaderStyle(totalHeaderStyle);
crosstab.setColumnTotalStyle(totalStyle);
return this;
}
|
[
"public",
"CrosstabBuilder",
"setColumnStyles",
"(",
"Style",
"headerStyle",
",",
"Style",
"totalStyle",
",",
"Style",
"totalHeaderStyle",
")",
"{",
"crosstab",
".",
"setColumnHeaderStyle",
"(",
"headerStyle",
")",
";",
"crosstab",
".",
"setColumnTotalheaderStyle",
"(",
"totalHeaderStyle",
")",
";",
"crosstab",
".",
"setColumnTotalStyle",
"(",
"totalStyle",
")",
";",
"return",
"this",
";",
"}"
] |
Should be called after all columns have been created
@param headerStyle
@param totalStyle
@param totalHeaderStyle
@return
|
[
"Should",
"be",
"called",
"after",
"all",
"columns",
"have",
"been",
"created"
] |
train
|
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/CrosstabBuilder.java#L399-L404
|
ngageoint/geopackage-android-map
|
geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java
|
GoogleMapShapeConverter.toMultiLineStringFromOptions
|
public MultiLineString toMultiLineStringFromOptions(
MultiPolylineOptions multiPolylineOptions, boolean hasZ,
boolean hasM) {
MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
for (PolylineOptions polyline : multiPolylineOptions
.getPolylineOptions()) {
LineString lineString = toLineString(polyline);
multiLineString.addLineString(lineString);
}
return multiLineString;
}
|
java
|
public MultiLineString toMultiLineStringFromOptions(
MultiPolylineOptions multiPolylineOptions, boolean hasZ,
boolean hasM) {
MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
for (PolylineOptions polyline : multiPolylineOptions
.getPolylineOptions()) {
LineString lineString = toLineString(polyline);
multiLineString.addLineString(lineString);
}
return multiLineString;
}
|
[
"public",
"MultiLineString",
"toMultiLineStringFromOptions",
"(",
"MultiPolylineOptions",
"multiPolylineOptions",
",",
"boolean",
"hasZ",
",",
"boolean",
"hasM",
")",
"{",
"MultiLineString",
"multiLineString",
"=",
"new",
"MultiLineString",
"(",
"hasZ",
",",
"hasM",
")",
";",
"for",
"(",
"PolylineOptions",
"polyline",
":",
"multiPolylineOptions",
".",
"getPolylineOptions",
"(",
")",
")",
"{",
"LineString",
"lineString",
"=",
"toLineString",
"(",
"polyline",
")",
";",
"multiLineString",
".",
"addLineString",
"(",
"lineString",
")",
";",
"}",
"return",
"multiLineString",
";",
"}"
] |
Convert a {@link MultiPolylineOptions} to a {@link MultiLineString}
@param multiPolylineOptions multi polyline options
@param hasZ has z flag
@param hasM has m flag
@return multi line string
|
[
"Convert",
"a",
"{",
"@link",
"MultiPolylineOptions",
"}",
"to",
"a",
"{",
"@link",
"MultiLineString",
"}"
] |
train
|
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java#L935-L948
|
biojava/biojava
|
biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java
|
SequenceMixin.countGC
|
public static int countGC(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound G = cs.getCompoundForString("G");
NucleotideCompound C = cs.getCompoundForString("C");
NucleotideCompound g = cs.getCompoundForString("g");
NucleotideCompound c = cs.getCompoundForString("c");
return countCompounds(sequence, G, C, g, c);
}
|
java
|
public static int countGC(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound G = cs.getCompoundForString("G");
NucleotideCompound C = cs.getCompoundForString("C");
NucleotideCompound g = cs.getCompoundForString("g");
NucleotideCompound c = cs.getCompoundForString("c");
return countCompounds(sequence, G, C, g, c);
}
|
[
"public",
"static",
"int",
"countGC",
"(",
"Sequence",
"<",
"NucleotideCompound",
">",
"sequence",
")",
"{",
"CompoundSet",
"<",
"NucleotideCompound",
">",
"cs",
"=",
"sequence",
".",
"getCompoundSet",
"(",
")",
";",
"NucleotideCompound",
"G",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"G\"",
")",
";",
"NucleotideCompound",
"C",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"C\"",
")",
";",
"NucleotideCompound",
"g",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"g\"",
")",
";",
"NucleotideCompound",
"c",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"c\"",
")",
";",
"return",
"countCompounds",
"(",
"sequence",
",",
"G",
",",
"C",
",",
"g",
",",
"c",
")",
";",
"}"
] |
Returns the count of GC in the given sequence
@param sequence The {@link NucleotideCompound} {@link Sequence} to perform
the GC analysis on
@return The number of GC compounds in the sequence
|
[
"Returns",
"the",
"count",
"of",
"GC",
"in",
"the",
"given",
"sequence"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L81-L88
|
haifengl/smile
|
plot/src/main/java/smile/swing/AlphaIcon.java
|
AlphaIcon.paintIcon
|
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setComposite(AlphaComposite.SrcAtop.derive(alpha));
icon.paintIcon(c, g2, x, y);
g2.dispose();
}
|
java
|
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setComposite(AlphaComposite.SrcAtop.derive(alpha));
icon.paintIcon(c, g2, x, y);
g2.dispose();
}
|
[
"@",
"Override",
"public",
"void",
"paintIcon",
"(",
"Component",
"c",
",",
"Graphics",
"g",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"Graphics2D",
"g2",
"=",
"(",
"Graphics2D",
")",
"g",
".",
"create",
"(",
")",
";",
"g2",
".",
"setComposite",
"(",
"AlphaComposite",
".",
"SrcAtop",
".",
"derive",
"(",
"alpha",
")",
")",
";",
"icon",
".",
"paintIcon",
"(",
"c",
",",
"g2",
",",
"x",
",",
"y",
")",
";",
"g2",
".",
"dispose",
"(",
")",
";",
"}"
] |
Paints the wrapped icon with this
<CODE>AlphaIcon</CODE>'s transparency.
@param c The component to which the icon is painted
@param g the graphics context
@param x the X coordinate of the icon's top-left corner
@param y the Y coordinate of the icon's top-left corner
|
[
"Paints",
"the",
"wrapped",
"icon",
"with",
"this",
"<CODE",
">",
"AlphaIcon<",
"/",
"CODE",
">",
"s",
"transparency",
"."
] |
train
|
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/swing/AlphaIcon.java#L78-L84
|
adamfisk/littleshoot-commons-id
|
src/main/java/org/apache/commons/id/uuid/VersionFourGenerator.java
|
VersionFourGenerator.setPRNGProvider
|
public static void setPRNGProvider(String prngName, String packageName) {
VersionFourGenerator.usePRNG = prngName;
VersionFourGenerator.usePRNGPackage = packageName;
VersionFourGenerator.secureRandom = null;
}
|
java
|
public static void setPRNGProvider(String prngName, String packageName) {
VersionFourGenerator.usePRNG = prngName;
VersionFourGenerator.usePRNGPackage = packageName;
VersionFourGenerator.secureRandom = null;
}
|
[
"public",
"static",
"void",
"setPRNGProvider",
"(",
"String",
"prngName",
",",
"String",
"packageName",
")",
"{",
"VersionFourGenerator",
".",
"usePRNG",
"=",
"prngName",
";",
"VersionFourGenerator",
".",
"usePRNGPackage",
"=",
"packageName",
";",
"VersionFourGenerator",
".",
"secureRandom",
"=",
"null",
";",
"}"
] |
<p>Allows clients to set the pseudo-random number generator implementation used when generating a version four uuid with
the secure option. The secure option uses a <code>SecureRandom</code>. The packageName string may be null to specify
no preferred package.</p>
@param prngName the pseudo-random number generator implementation name. For example "SHA1PRNG".
@param packageName the package name for the PRNG provider. For example "SUN".
|
[
"<p",
">",
"Allows",
"clients",
"to",
"set",
"the",
"pseudo",
"-",
"random",
"number",
"generator",
"implementation",
"used",
"when",
"generating",
"a",
"version",
"four",
"uuid",
"with",
"the",
"secure",
"option",
".",
"The",
"secure",
"option",
"uses",
"a",
"<code",
">",
"SecureRandom<",
"/",
"code",
">",
".",
"The",
"packageName",
"string",
"may",
"be",
"null",
"to",
"specify",
"no",
"preferred",
"package",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/adamfisk/littleshoot-commons-id/blob/49a8f5f2b10831c509876ca463bf1a87e1e49ae9/src/main/java/org/apache/commons/id/uuid/VersionFourGenerator.java#L156-L160
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java
|
CommonOps_DDRM.invertSPD
|
public static boolean invertSPD(DMatrixRMaj mat, DMatrixRMaj result ) {
if( mat.numRows != mat.numCols )
throw new IllegalArgumentException("Must be a square matrix");
result.reshape(mat.numRows,mat.numRows);
if( mat.numRows <= UnrolledCholesky_DDRM.MAX ) {
// L*L' = A
if( !UnrolledCholesky_DDRM.lower(mat,result) )
return false;
// L = inv(L)
TriangularSolver_DDRM.invertLower(result.data,result.numCols);
// inv(A) = inv(L')*inv(L)
SpecializedOps_DDRM.multLowerTranA(result);
} else {
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.chol(mat.numCols);
if( solver.modifiesA() )
mat = mat.copy();
if( !solver.setA(mat))
return false;
solver.invert(result);
}
return true;
}
|
java
|
public static boolean invertSPD(DMatrixRMaj mat, DMatrixRMaj result ) {
if( mat.numRows != mat.numCols )
throw new IllegalArgumentException("Must be a square matrix");
result.reshape(mat.numRows,mat.numRows);
if( mat.numRows <= UnrolledCholesky_DDRM.MAX ) {
// L*L' = A
if( !UnrolledCholesky_DDRM.lower(mat,result) )
return false;
// L = inv(L)
TriangularSolver_DDRM.invertLower(result.data,result.numCols);
// inv(A) = inv(L')*inv(L)
SpecializedOps_DDRM.multLowerTranA(result);
} else {
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.chol(mat.numCols);
if( solver.modifiesA() )
mat = mat.copy();
if( !solver.setA(mat))
return false;
solver.invert(result);
}
return true;
}
|
[
"public",
"static",
"boolean",
"invertSPD",
"(",
"DMatrixRMaj",
"mat",
",",
"DMatrixRMaj",
"result",
")",
"{",
"if",
"(",
"mat",
".",
"numRows",
"!=",
"mat",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must be a square matrix\"",
")",
";",
"result",
".",
"reshape",
"(",
"mat",
".",
"numRows",
",",
"mat",
".",
"numRows",
")",
";",
"if",
"(",
"mat",
".",
"numRows",
"<=",
"UnrolledCholesky_DDRM",
".",
"MAX",
")",
"{",
"// L*L' = A",
"if",
"(",
"!",
"UnrolledCholesky_DDRM",
".",
"lower",
"(",
"mat",
",",
"result",
")",
")",
"return",
"false",
";",
"// L = inv(L)",
"TriangularSolver_DDRM",
".",
"invertLower",
"(",
"result",
".",
"data",
",",
"result",
".",
"numCols",
")",
";",
"// inv(A) = inv(L')*inv(L)",
"SpecializedOps_DDRM",
".",
"multLowerTranA",
"(",
"result",
")",
";",
"}",
"else",
"{",
"LinearSolverDense",
"<",
"DMatrixRMaj",
">",
"solver",
"=",
"LinearSolverFactory_DDRM",
".",
"chol",
"(",
"mat",
".",
"numCols",
")",
";",
"if",
"(",
"solver",
".",
"modifiesA",
"(",
")",
")",
"mat",
"=",
"mat",
".",
"copy",
"(",
")",
";",
"if",
"(",
"!",
"solver",
".",
"setA",
"(",
"mat",
")",
")",
"return",
"false",
";",
"solver",
".",
"invert",
"(",
"result",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Matrix inverse for symmetric positive definite matrices. For small matrices an unrolled
cholesky is used. Otherwise a standard decomposition.
@see UnrolledCholesky_DDRM
@see LinearSolverFactory_DDRM#chol(int)
@param mat (Input) SPD matrix
@param result (Output) Inverted matrix.
@return true if it could invert the matrix false if it could not.
|
[
"Matrix",
"inverse",
"for",
"symmetric",
"positive",
"definite",
"matrices",
".",
"For",
"small",
"matrices",
"an",
"unrolled",
"cholesky",
"is",
"used",
".",
"Otherwise",
"a",
"standard",
"decomposition",
"."
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L818-L842
|
elki-project/elki
|
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
|
ByteArrayUtil.writeShort
|
public static int writeShort(byte[] array, int offset, int v) {
array[offset + 0] = (byte) (v >>> 8);
array[offset + 1] = (byte) (v >>> 0);
return SIZE_SHORT;
}
|
java
|
public static int writeShort(byte[] array, int offset, int v) {
array[offset + 0] = (byte) (v >>> 8);
array[offset + 1] = (byte) (v >>> 0);
return SIZE_SHORT;
}
|
[
"public",
"static",
"int",
"writeShort",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
",",
"int",
"v",
")",
"{",
"array",
"[",
"offset",
"+",
"0",
"]",
"=",
"(",
"byte",
")",
"(",
"v",
">>>",
"8",
")",
";",
"array",
"[",
"offset",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"v",
">>>",
"0",
")",
";",
"return",
"SIZE_SHORT",
";",
"}"
] |
Write a short to the byte array at the given offset.
@param array Array to write to
@param offset Offset to write to
@param v data
@return number of bytes written
|
[
"Write",
"a",
"short",
"to",
"the",
"byte",
"array",
"at",
"the",
"given",
"offset",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L106-L110
|
hawkular/hawkular-commons
|
hawkular-bus/hawkular-bus-common/src/main/java/org/hawkular/bus/common/MessageProcessor.java
|
MessageProcessor.createMessageWithBinaryData
|
protected Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage,
InputStream inputStream) throws JMSException {
return createMessageWithBinaryData(context, basicMessage, inputStream, null);
}
|
java
|
protected Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage,
InputStream inputStream) throws JMSException {
return createMessageWithBinaryData(context, basicMessage, inputStream, null);
}
|
[
"protected",
"Message",
"createMessageWithBinaryData",
"(",
"ConnectionContext",
"context",
",",
"BasicMessage",
"basicMessage",
",",
"InputStream",
"inputStream",
")",
"throws",
"JMSException",
"{",
"return",
"createMessageWithBinaryData",
"(",
"context",
",",
"basicMessage",
",",
"inputStream",
",",
"null",
")",
";",
"}"
] |
Same as {@link #createMessage(ConnectionContext, BasicMessage, Map)} with <code>null</code> headers.
|
[
"Same",
"as",
"{"
] |
train
|
https://github.com/hawkular/hawkular-commons/blob/e4a832862b3446d7f4d629bb05790f2df578e035/hawkular-bus/hawkular-bus-common/src/main/java/org/hawkular/bus/common/MessageProcessor.java#L418-L421
|
ops4j/org.ops4j.pax.logging
|
pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
|
ThrowableProxy.formatWrapper
|
public void formatWrapper(final StringBuilder sb, final ThrowableProxy cause, final String suffix) {
this.formatWrapper(sb, cause, null, PlainTextRenderer.getInstance(), suffix);
}
|
java
|
public void formatWrapper(final StringBuilder sb, final ThrowableProxy cause, final String suffix) {
this.formatWrapper(sb, cause, null, PlainTextRenderer.getInstance(), suffix);
}
|
[
"public",
"void",
"formatWrapper",
"(",
"final",
"StringBuilder",
"sb",
",",
"final",
"ThrowableProxy",
"cause",
",",
"final",
"String",
"suffix",
")",
"{",
"this",
".",
"formatWrapper",
"(",
"sb",
",",
"cause",
",",
"null",
",",
"PlainTextRenderer",
".",
"getInstance",
"(",
")",
",",
"suffix",
")",
";",
"}"
] |
Formats the specified Throwable.
@param sb StringBuilder to contain the formatted Throwable.
@param cause The Throwable to format.
@param suffix
|
[
"Formats",
"the",
"specified",
"Throwable",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java#L349-L351
|
phax/ph-commons
|
ph-commons/src/main/java/com/helger/commons/string/StringParser.java
|
StringParser.parseByteObj
|
@Nullable
public static Byte parseByteObj (@Nullable final Object aObject)
{
return parseByteObj (aObject, DEFAULT_RADIX, null);
}
|
java
|
@Nullable
public static Byte parseByteObj (@Nullable final Object aObject)
{
return parseByteObj (aObject, DEFAULT_RADIX, null);
}
|
[
"@",
"Nullable",
"public",
"static",
"Byte",
"parseByteObj",
"(",
"@",
"Nullable",
"final",
"Object",
"aObject",
")",
"{",
"return",
"parseByteObj",
"(",
"aObject",
",",
"DEFAULT_RADIX",
",",
"null",
")",
";",
"}"
] |
Parse the given {@link Object} as {@link Byte} with radix
{@value #DEFAULT_RADIX}.
@param aObject
The object to parse. May be <code>null</code>.
@return <code>null</code> if the object does not represent a valid value.
|
[
"Parse",
"the",
"given",
"{",
"@link",
"Object",
"}",
"as",
"{",
"@link",
"Byte",
"}",
"with",
"radix",
"{",
"@value",
"#DEFAULT_RADIX",
"}",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L338-L342
|
xcesco/kripton
|
kripton-orm/src/main/java/com/abubusoft/kripton/android/sqlite/SQLiteEvent.java
|
SQLiteEvent.createInsertWithId
|
public static SQLiteEvent createInsertWithId(Long result) {
return new SQLiteEvent(SqlModificationType.INSERT, null, result, null);
}
|
java
|
public static SQLiteEvent createInsertWithId(Long result) {
return new SQLiteEvent(SqlModificationType.INSERT, null, result, null);
}
|
[
"public",
"static",
"SQLiteEvent",
"createInsertWithId",
"(",
"Long",
"result",
")",
"{",
"return",
"new",
"SQLiteEvent",
"(",
"SqlModificationType",
".",
"INSERT",
",",
"null",
",",
"result",
",",
"null",
")",
";",
"}"
] |
Creates the insert.
@param result
the result
@return the SQ lite event
|
[
"Creates",
"the",
"insert",
"."
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-orm/src/main/java/com/abubusoft/kripton/android/sqlite/SQLiteEvent.java#L57-L59
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java
|
ClassLoaderUtils.listFiles
|
public static Collection<String> listFiles(ClassLoader classLoader, String rootPath) {
return listResources(classLoader, rootPath, path -> !StringUtils.endsWith(path, "/"));
}
|
java
|
public static Collection<String> listFiles(ClassLoader classLoader, String rootPath) {
return listResources(classLoader, rootPath, path -> !StringUtils.endsWith(path, "/"));
}
|
[
"public",
"static",
"Collection",
"<",
"String",
">",
"listFiles",
"(",
"ClassLoader",
"classLoader",
",",
"String",
"rootPath",
")",
"{",
"return",
"listResources",
"(",
"classLoader",
",",
"rootPath",
",",
"path",
"->",
"!",
"StringUtils",
".",
"endsWith",
"(",
"path",
",",
"\"/\"",
")",
")",
";",
"}"
] |
Finds files within a given directory and its subdirectories
@param classLoader
@param rootPath the root directory, for example org/sonar/sqale
@return a list of relative paths, for example {"org/sonar/sqale/foo/bar.txt}. Never null.
|
[
"Finds",
"files",
"within",
"a",
"given",
"directory",
"and",
"its",
"subdirectories"
] |
train
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java#L50-L52
|
phax/ph-commons
|
ph-jaxb/src/main/java/com/helger/jaxb/JAXBContextCache.java
|
JAXBContextCache.getFromCache
|
@Nullable
public JAXBContext getFromCache (@Nonnull final Package aPackage)
{
return getFromCache (aPackage, (ClassLoader) null);
}
|
java
|
@Nullable
public JAXBContext getFromCache (@Nonnull final Package aPackage)
{
return getFromCache (aPackage, (ClassLoader) null);
}
|
[
"@",
"Nullable",
"public",
"JAXBContext",
"getFromCache",
"(",
"@",
"Nonnull",
"final",
"Package",
"aPackage",
")",
"{",
"return",
"getFromCache",
"(",
"aPackage",
",",
"(",
"ClassLoader",
")",
"null",
")",
";",
"}"
] |
Special overload with package and default {@link ClassLoader}.
@param aPackage
Package to load. May not be <code>null</code>.
@return <code>null</code> if package is <code>null</code>.
|
[
"Special",
"overload",
"with",
"package",
"and",
"default",
"{",
"@link",
"ClassLoader",
"}",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-jaxb/src/main/java/com/helger/jaxb/JAXBContextCache.java#L115-L119
|
groupe-sii/ogham
|
ogham-core/src/main/java/fr/sii/ogham/core/util/EqualsBuilder.java
|
EqualsBuilder.reflectionsEquals
|
public static boolean reflectionsEquals(Object object, Object other, String... excludeFields) {
return org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(object, other, excludeFields);
}
|
java
|
public static boolean reflectionsEquals(Object object, Object other, String... excludeFields) {
return org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(object, other, excludeFields);
}
|
[
"public",
"static",
"boolean",
"reflectionsEquals",
"(",
"Object",
"object",
",",
"Object",
"other",
",",
"String",
"...",
"excludeFields",
")",
"{",
"return",
"org",
".",
"apache",
".",
"commons",
".",
"lang3",
".",
"builder",
".",
"EqualsBuilder",
".",
"reflectionEquals",
"(",
"object",
",",
"other",
",",
"excludeFields",
")",
";",
"}"
] |
<p>
This method uses reflection to determine if the two Objects are equal.
</p>
<p>
It uses AccessibleObject.setAccessible to gain access to private fields.
This means that it will throw a security exception if run under a
security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly. Non-primitive fields are compared
using equals().
</p>
<p>
Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.
</p>
<p>
Static fields will not be tested. Superclass fields will be included.
</p>
@param object
this object
@param other
the other object
@param excludeFields
array of field names to exclude from testing
@return true if the two Objects have tested equals.
|
[
"<p",
">",
"This",
"method",
"uses",
"reflection",
"to",
"determine",
"if",
"the",
"two",
"Objects",
"are",
"equal",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/core/util/EqualsBuilder.java#L245-L247
|
jbundle/jbundle
|
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
|
BaseMessageRecordDesc.setDataIndex
|
public Rec setDataIndex(int iNodeIndex, Rec record)
{
if (END_OF_NODES == iNodeIndex)
iNodeIndex = 0;
m_iNodeIndex = iNodeIndex;
return record;
}
|
java
|
public Rec setDataIndex(int iNodeIndex, Rec record)
{
if (END_OF_NODES == iNodeIndex)
iNodeIndex = 0;
m_iNodeIndex = iNodeIndex;
return record;
}
|
[
"public",
"Rec",
"setDataIndex",
"(",
"int",
"iNodeIndex",
",",
"Rec",
"record",
")",
"{",
"if",
"(",
"END_OF_NODES",
"==",
"iNodeIndex",
")",
"iNodeIndex",
"=",
"0",
";",
"m_iNodeIndex",
"=",
"iNodeIndex",
";",
"return",
"record",
";",
"}"
] |
Position to this node in the tree.
@param iNodeIndex The node to position to.
@param record The record I am moving data to. If this is null, don't position/setup the data.
@return An error code.
|
[
"Position",
"to",
"this",
"node",
"in",
"the",
"tree",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L328-L334
|
powermock/powermock
|
powermock-api/powermock-api-easymock/src/main/java/org/powermock/api/easymock/PowerMock.java
|
PowerMock.suppressMethod
|
@Deprecated
public static synchronized void suppressMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {
SuppressCode.suppressMethod(clazz, methodName, parameterTypes);
}
|
java
|
@Deprecated
public static synchronized void suppressMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {
SuppressCode.suppressMethod(clazz, methodName, parameterTypes);
}
|
[
"@",
"Deprecated",
"public",
"static",
"synchronized",
"void",
"suppressMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
")",
"{",
"SuppressCode",
".",
"suppressMethod",
"(",
"clazz",
",",
"methodName",
",",
"parameterTypes",
")",
";",
"}"
] |
Suppress a specific method call. Use this for overloaded methods.
@deprecated Use {@link #suppress(Method)} instead.
|
[
"Suppress",
"a",
"specific",
"method",
"call",
".",
"Use",
"this",
"for",
"overloaded",
"methods",
"."
] |
train
|
https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-api/powermock-api-easymock/src/main/java/org/powermock/api/easymock/PowerMock.java#L1912-L1915
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
|
DefaultDisseminatorImpl.viewDublinCore
|
public MIMETypedStream viewDublinCore() throws ServerException {
// get dublin core record as xml
Datastream dcmd = null;
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(512);
dcmd =
reader.GetDatastream("DC",
asOfDateTime);
ObjectInfoAsXML.getOAIDublinCore(dcmd, out);
out.close();
in = out.toReader();
} catch (ClassCastException cce) {
throw new ObjectIntegrityException("Object "
+ reader.GetObjectPID()
+ " has a DC datastream, but it's not inline XML.");
}
// convert the dublin core xml to an html view
try {
//InputStream in = getDublinCore().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(1024);
PrintWriter out =
new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile = new File(reposHomeDir, "access/viewDublinCore.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewDublinCore. "
+ "Underlying exception was: " + e.getMessage());
}
}
|
java
|
public MIMETypedStream viewDublinCore() throws ServerException {
// get dublin core record as xml
Datastream dcmd = null;
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(512);
dcmd =
reader.GetDatastream("DC",
asOfDateTime);
ObjectInfoAsXML.getOAIDublinCore(dcmd, out);
out.close();
in = out.toReader();
} catch (ClassCastException cce) {
throw new ObjectIntegrityException("Object "
+ reader.GetObjectPID()
+ " has a DC datastream, but it's not inline XML.");
}
// convert the dublin core xml to an html view
try {
//InputStream in = getDublinCore().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(1024);
PrintWriter out =
new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile = new File(reposHomeDir, "access/viewDublinCore.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewDublinCore. "
+ "Underlying exception was: " + e.getMessage());
}
}
|
[
"public",
"MIMETypedStream",
"viewDublinCore",
"(",
")",
"throws",
"ServerException",
"{",
"// get dublin core record as xml",
"Datastream",
"dcmd",
"=",
"null",
";",
"Reader",
"in",
"=",
"null",
";",
"try",
"{",
"ReadableCharArrayWriter",
"out",
"=",
"new",
"ReadableCharArrayWriter",
"(",
"512",
")",
";",
"dcmd",
"=",
"reader",
".",
"GetDatastream",
"(",
"\"DC\"",
",",
"asOfDateTime",
")",
";",
"ObjectInfoAsXML",
".",
"getOAIDublinCore",
"(",
"dcmd",
",",
"out",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"in",
"=",
"out",
".",
"toReader",
"(",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"cce",
")",
"{",
"throw",
"new",
"ObjectIntegrityException",
"(",
"\"Object \"",
"+",
"reader",
".",
"GetObjectPID",
"(",
")",
"+",
"\" has a DC datastream, but it's not inline XML.\"",
")",
";",
"}",
"// convert the dublin core xml to an html view",
"try",
"{",
"//InputStream in = getDublinCore().getStream();",
"ReadableByteArrayOutputStream",
"bytes",
"=",
"new",
"ReadableByteArrayOutputStream",
"(",
"1024",
")",
";",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"bytes",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
")",
";",
"File",
"xslFile",
"=",
"new",
"File",
"(",
"reposHomeDir",
",",
"\"access/viewDublinCore.xslt\"",
")",
";",
"Templates",
"template",
"=",
"XmlTransformUtility",
".",
"getTemplates",
"(",
"xslFile",
")",
";",
"Transformer",
"transformer",
"=",
"template",
".",
"newTransformer",
"(",
")",
";",
"transformer",
".",
"setParameter",
"(",
"\"fedora\"",
",",
"context",
".",
"getEnvironmentValue",
"(",
"Constants",
".",
"FEDORA_APP_CONTEXT_NAME",
")",
")",
";",
"transformer",
".",
"transform",
"(",
"new",
"StreamSource",
"(",
"in",
")",
",",
"new",
"StreamResult",
"(",
"out",
")",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"return",
"new",
"MIMETypedStream",
"(",
"\"text/html\"",
",",
"bytes",
".",
"toInputStream",
"(",
")",
",",
"null",
",",
"bytes",
".",
"length",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DisseminationException",
"(",
"\"[DefaultDisseminatorImpl] had an error \"",
"+",
"\"in transforming xml for viewDublinCore. \"",
"+",
"\"Underlying exception was: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Returns the Dublin Core record for the object, if one exists. The record
is returned as HTML in a presentation-oriented format.
@return html packaged as a MIMETypedStream
@throws ServerException
|
[
"Returns",
"the",
"Dublin",
"Core",
"record",
"for",
"the",
"object",
"if",
"one",
"exists",
".",
"The",
"record",
"is",
"returned",
"as",
"HTML",
"in",
"a",
"presentation",
"-",
"oriented",
"format",
"."
] |
train
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L267-L309
|
rhuss/jolokia
|
agent/osgi/src/main/java/org/jolokia/osgi/util/LogHelper.java
|
LogHelper.logError
|
public static void logError(String pMessage, Throwable pThrowable) {
final BundleContext bundleContext = FrameworkUtil
.getBundle(ServiceAuthenticationHttpContext.class)
.getBundleContext();
logError(bundleContext, pMessage, pThrowable);
}
|
java
|
public static void logError(String pMessage, Throwable pThrowable) {
final BundleContext bundleContext = FrameworkUtil
.getBundle(ServiceAuthenticationHttpContext.class)
.getBundleContext();
logError(bundleContext, pMessage, pThrowable);
}
|
[
"public",
"static",
"void",
"logError",
"(",
"String",
"pMessage",
",",
"Throwable",
"pThrowable",
")",
"{",
"final",
"BundleContext",
"bundleContext",
"=",
"FrameworkUtil",
".",
"getBundle",
"(",
"ServiceAuthenticationHttpContext",
".",
"class",
")",
".",
"getBundleContext",
"(",
")",
";",
"logError",
"(",
"bundleContext",
",",
"pMessage",
",",
"pThrowable",
")",
";",
"}"
] |
Log error to a logging service (if available), otherwise log to std error
@param pMessage message to log
@param pThrowable an exception to log
|
[
"Log",
"error",
"to",
"a",
"logging",
"service",
"(",
"if",
"available",
")",
"otherwise",
"log",
"to",
"std",
"error"
] |
train
|
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/osgi/src/main/java/org/jolokia/osgi/util/LogHelper.java#L24-L29
|
jenkinsci/jenkins
|
core/src/main/java/hudson/model/Job.java
|
Job.getEnvironment
|
public @Nonnull EnvVars getEnvironment(@CheckForNull Node node, @Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
if (node != null) {
final Computer computer = node.toComputer();
if (computer != null) {
// we need to get computer environment to inherit platform details
env = computer.getEnvironment();
env.putAll(computer.buildEnvironment(listener));
}
}
env.putAll(getCharacteristicEnvVars());
// servlet container may have set CLASSPATH in its launch script,
// so don't let that inherit to the new child process.
// see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html
env.put("CLASSPATH","");
// apply them in a reverse order so that higher ordinal ones can modify values added by lower ordinal ones
for (EnvironmentContributor ec : EnvironmentContributor.all().reverseView())
ec.buildEnvironmentFor(this,env,listener);
return env;
}
|
java
|
public @Nonnull EnvVars getEnvironment(@CheckForNull Node node, @Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
if (node != null) {
final Computer computer = node.toComputer();
if (computer != null) {
// we need to get computer environment to inherit platform details
env = computer.getEnvironment();
env.putAll(computer.buildEnvironment(listener));
}
}
env.putAll(getCharacteristicEnvVars());
// servlet container may have set CLASSPATH in its launch script,
// so don't let that inherit to the new child process.
// see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html
env.put("CLASSPATH","");
// apply them in a reverse order so that higher ordinal ones can modify values added by lower ordinal ones
for (EnvironmentContributor ec : EnvironmentContributor.all().reverseView())
ec.buildEnvironmentFor(this,env,listener);
return env;
}
|
[
"public",
"@",
"Nonnull",
"EnvVars",
"getEnvironment",
"(",
"@",
"CheckForNull",
"Node",
"node",
",",
"@",
"Nonnull",
"TaskListener",
"listener",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"EnvVars",
"env",
"=",
"new",
"EnvVars",
"(",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"final",
"Computer",
"computer",
"=",
"node",
".",
"toComputer",
"(",
")",
";",
"if",
"(",
"computer",
"!=",
"null",
")",
"{",
"// we need to get computer environment to inherit platform details ",
"env",
"=",
"computer",
".",
"getEnvironment",
"(",
")",
";",
"env",
".",
"putAll",
"(",
"computer",
".",
"buildEnvironment",
"(",
"listener",
")",
")",
";",
"}",
"}",
"env",
".",
"putAll",
"(",
"getCharacteristicEnvVars",
"(",
")",
")",
";",
"// servlet container may have set CLASSPATH in its launch script,",
"// so don't let that inherit to the new child process.",
"// see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html",
"env",
".",
"put",
"(",
"\"CLASSPATH\"",
",",
"\"\"",
")",
";",
"// apply them in a reverse order so that higher ordinal ones can modify values added by lower ordinal ones",
"for",
"(",
"EnvironmentContributor",
"ec",
":",
"EnvironmentContributor",
".",
"all",
"(",
")",
".",
"reverseView",
"(",
")",
")",
"ec",
".",
"buildEnvironmentFor",
"(",
"this",
",",
"env",
",",
"listener",
")",
";",
"return",
"env",
";",
"}"
] |
Creates an environment variable override for launching processes for this project.
<p>
This is for process launching outside the build execution (such as polling, tagging, deployment, etc.)
that happens in a context of a specific job.
@param node
Node to eventually run a process on. The implementation must cope with this parameter being null
(in which case none of the node specific properties would be reflected in the resulting override.)
|
[
"Creates",
"an",
"environment",
"variable",
"override",
"for",
"launching",
"processes",
"for",
"this",
"project",
"."
] |
train
|
https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/Job.java#L375-L400
|
Netflix/conductor
|
redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisMock.java
|
JedisMock.expire
|
@Override public Long expire(final String key, final int seconds) {
try {
return redis.expire(key, seconds) ? 1L : 0L;
}
catch (Exception e) {
throw new JedisException(e);
}
}
|
java
|
@Override public Long expire(final String key, final int seconds) {
try {
return redis.expire(key, seconds) ? 1L : 0L;
}
catch (Exception e) {
throw new JedisException(e);
}
}
|
[
"@",
"Override",
"public",
"Long",
"expire",
"(",
"final",
"String",
"key",
",",
"final",
"int",
"seconds",
")",
"{",
"try",
"{",
"return",
"redis",
".",
"expire",
"(",
"key",
",",
"seconds",
")",
"?",
"1L",
":",
"0L",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JedisException",
"(",
"e",
")",
";",
"}",
"}"
] |
/*
public Set<String> keys(final String pattern) {
checkIsInMulti();
client.keys(pattern);
return BuilderFactory.STRING_SET.build(client.getBinaryMultiBulkReply());
}
public String randomKey() {
checkIsInMulti();
client.randomKey();
return client.getBulkReply();
}
public String rename(final String oldkey, final String newkey) {
checkIsInMulti();
client.rename(oldkey, newkey);
return client.getStatusCodeReply();
}
public Long renamenx(final String oldkey, final String newkey) {
checkIsInMulti();
client.renamenx(oldkey, newkey);
return client.getIntegerReply();
}
|
[
"/",
"*",
"public",
"Set<String",
">",
"keys",
"(",
"final",
"String",
"pattern",
")",
"{",
"checkIsInMulti",
"()",
";",
"client",
".",
"keys",
"(",
"pattern",
")",
";",
"return",
"BuilderFactory",
".",
"STRING_SET",
".",
"build",
"(",
"client",
".",
"getBinaryMultiBulkReply",
"()",
")",
";",
"}"
] |
train
|
https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisMock.java#L151-L158
|
overturetool/overture
|
core/interpreter/src/main/java/IO.java
|
IO.getFile
|
protected static File getFile(Value fval)
{
String path = stringOf(fval).replace('/', File.separatorChar);
File file = new File(path);
if (!file.isAbsolute())
{
file = new File(Settings.baseDir, path);
}
return file;
}
|
java
|
protected static File getFile(Value fval)
{
String path = stringOf(fval).replace('/', File.separatorChar);
File file = new File(path);
if (!file.isAbsolute())
{
file = new File(Settings.baseDir, path);
}
return file;
}
|
[
"protected",
"static",
"File",
"getFile",
"(",
"Value",
"fval",
")",
"{",
"String",
"path",
"=",
"stringOf",
"(",
"fval",
")",
".",
"replace",
"(",
"'",
"'",
",",
"File",
".",
"separatorChar",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"file",
".",
"isAbsolute",
"(",
")",
")",
"{",
"file",
"=",
"new",
"File",
"(",
"Settings",
".",
"baseDir",
",",
"path",
")",
";",
"}",
"return",
"file",
";",
"}"
] |
Gets the absolute path the file based on the filename parsed and the working dir of the IDE or the execution dir
of VDMJ
@param fval
file name
@return
|
[
"Gets",
"the",
"absolute",
"path",
"the",
"file",
"based",
"on",
"the",
"filename",
"parsed",
"and",
"the",
"working",
"dir",
"of",
"the",
"IDE",
"or",
"the",
"execution",
"dir",
"of",
"VDMJ"
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/interpreter/src/main/java/IO.java#L131-L141
|
super-csv/super-csv
|
super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java
|
RequireSubStr.execute
|
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final String stringValue = value.toString();
for( final String required : requiredSubStrings ) {
if( stringValue.contains(required) ) {
return next.execute(value, context); // just need to match a single substring
}
}
throw new SuperCsvConstraintViolationException(String.format("'%s' does not contain any of the required substrings", value),
context, this);
}
|
java
|
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final String stringValue = value.toString();
for( final String required : requiredSubStrings ) {
if( stringValue.contains(required) ) {
return next.execute(value, context); // just need to match a single substring
}
}
throw new SuperCsvConstraintViolationException(String.format("'%s' does not contain any of the required substrings", value),
context, this);
}
|
[
"public",
"Object",
"execute",
"(",
"final",
"Object",
"value",
",",
"final",
"CsvContext",
"context",
")",
"{",
"validateInputNotNull",
"(",
"value",
",",
"context",
")",
";",
"final",
"String",
"stringValue",
"=",
"value",
".",
"toString",
"(",
")",
";",
"for",
"(",
"final",
"String",
"required",
":",
"requiredSubStrings",
")",
"{",
"if",
"(",
"stringValue",
".",
"contains",
"(",
"required",
")",
")",
"{",
"return",
"next",
".",
"execute",
"(",
"value",
",",
"context",
")",
";",
"// just need to match a single substring",
"}",
"}",
"throw",
"new",
"SuperCsvConstraintViolationException",
"(",
"String",
".",
"format",
"(",
"\"'%s' does not contain any of the required substrings\"",
",",
"value",
")",
",",
"context",
",",
"this",
")",
";",
"}"
] |
{@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null
@throws SuperCsvConstraintViolationException
if value doesn't contain any of the required substrings
|
[
"{",
"@inheritDoc",
"}"
] |
train
|
https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java#L184-L197
|
ansell/csvstream
|
src/main/java/com/github/ansell/csv/stream/CSVStream.java
|
CSVStream.parse
|
public static <T> void parse(final InputStream inputStream, final Consumer<List<String>> headersValidator,
final BiFunction<List<String>, List<String>, T> lineConverter, final Consumer<T> resultConsumer)
throws IOException, CSVStreamException {
try (final Reader inputStreamReader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8));) {
parse(inputStreamReader, headersValidator, lineConverter, resultConsumer);
}
}
|
java
|
public static <T> void parse(final InputStream inputStream, final Consumer<List<String>> headersValidator,
final BiFunction<List<String>, List<String>, T> lineConverter, final Consumer<T> resultConsumer)
throws IOException, CSVStreamException {
try (final Reader inputStreamReader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8));) {
parse(inputStreamReader, headersValidator, lineConverter, resultConsumer);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"parse",
"(",
"final",
"InputStream",
"inputStream",
",",
"final",
"Consumer",
"<",
"List",
"<",
"String",
">",
">",
"headersValidator",
",",
"final",
"BiFunction",
"<",
"List",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
",",
"T",
">",
"lineConverter",
",",
"final",
"Consumer",
"<",
"T",
">",
"resultConsumer",
")",
"throws",
"IOException",
",",
"CSVStreamException",
"{",
"try",
"(",
"final",
"Reader",
"inputStreamReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
")",
"{",
"parse",
"(",
"inputStreamReader",
",",
"headersValidator",
",",
"lineConverter",
",",
"resultConsumer",
")",
";",
"}",
"}"
] |
Stream a CSV file from the given InputStream through the header validator,
line checker, and if the line checker succeeds, send the checked/converted
line to the consumer.
@param inputStream
The {@link InputStream} containing the CSV file.
@param headersValidator
The validator of the header line. Throwing
IllegalArgumentException or other RuntimeExceptions causes the
parsing process to short-circuit after parsing the header line,
with a CSVStreamException being rethrown by this code.
@param lineConverter
The validator and converter of lines, based on the header line. If
the lineChecker returns null, the line will not be passed to the
writer.
@param resultConsumer
The consumer of the checked lines.
@param <T>
The type of the results that will be created by the lineChecker
and pushed into the writer {@link Consumer}.
@throws IOException
If an error occurred accessing the input.
@throws CSVStreamException
If an error occurred validating the input.
|
[
"Stream",
"a",
"CSV",
"file",
"from",
"the",
"given",
"InputStream",
"through",
"the",
"header",
"validator",
"line",
"checker",
"and",
"if",
"the",
"line",
"checker",
"succeeds",
"send",
"the",
"checked",
"/",
"converted",
"line",
"to",
"the",
"consumer",
"."
] |
train
|
https://github.com/ansell/csvstream/blob/9468bfbd6997fbc4237eafc990ba811cd5905dc1/src/main/java/com/github/ansell/csv/stream/CSVStream.java#L95-L102
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.readCharactersUntilEndTag
|
protected String readCharactersUntilEndTag(XMLEventReader reader,
QName tagName)
throws XMLStreamException, JournalException {
StringBuffer stringValue = new StringBuffer();
while (true) {
XMLEvent event = reader.nextEvent();
if (event.isCharacters()) {
stringValue.append(event.asCharacters().getData());
} else if (isEndTagEvent(event, tagName)) {
break;
} else {
throw getNotCharactersException(tagName, event);
}
}
return stringValue.toString();
}
|
java
|
protected String readCharactersUntilEndTag(XMLEventReader reader,
QName tagName)
throws XMLStreamException, JournalException {
StringBuffer stringValue = new StringBuffer();
while (true) {
XMLEvent event = reader.nextEvent();
if (event.isCharacters()) {
stringValue.append(event.asCharacters().getData());
} else if (isEndTagEvent(event, tagName)) {
break;
} else {
throw getNotCharactersException(tagName, event);
}
}
return stringValue.toString();
}
|
[
"protected",
"String",
"readCharactersUntilEndTag",
"(",
"XMLEventReader",
"reader",
",",
"QName",
"tagName",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"StringBuffer",
"stringValue",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextEvent",
"(",
")",
";",
"if",
"(",
"event",
".",
"isCharacters",
"(",
")",
")",
"{",
"stringValue",
".",
"append",
"(",
"event",
".",
"asCharacters",
"(",
")",
".",
"getData",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"isEndTagEvent",
"(",
"event",
",",
"tagName",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"throw",
"getNotCharactersException",
"(",
"tagName",
",",
"event",
")",
";",
"}",
"}",
"return",
"stringValue",
".",
"toString",
"(",
")",
";",
"}"
] |
Loop through a series of character events, accumulating the data into a
String. The character events should be terminated by an EndTagEvent with
the expected tag name.
|
[
"Loop",
"through",
"a",
"series",
"of",
"character",
"events",
"accumulating",
"the",
"data",
"into",
"a",
"String",
".",
"The",
"character",
"events",
"should",
"be",
"terminated",
"by",
"an",
"EndTagEvent",
"with",
"the",
"expected",
"tag",
"name",
"."
] |
train
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L103-L118
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java
|
ShapeFittingOps.fitEllipse_F64
|
public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations ,
boolean computeError ,
FitData<EllipseRotated_F64> outputStorage ) {
if( outputStorage == null ) {
outputStorage = new FitData<>(new EllipseRotated_F64());
}
// Compute the optimal algebraic error
FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64();
if( !algebraic.process(points)) {
// could be a line or some other weird case. Create a crude estimate instead
FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null);
Circle2D_F64 circle = circleData.shape;
outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0);
} else {
UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape);
}
// Improve the solution from algebraic into Euclidean
if( iterations > 0 ) {
RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64();
leastSquares.setMaxIterations(iterations);
leastSquares.refine(outputStorage.shape,points);
outputStorage.shape.set( leastSquares.getFound() );
}
// compute the average Euclidean error if the user requests it
if( computeError ) {
ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100);
closestPoint.setEllipse(outputStorage.shape);
double total = 0;
for( Point2D_F64 p : points ) {
closestPoint.process(p);
total += p.distance(closestPoint.getClosest());
}
outputStorage.error = total/points.size();
} else {
outputStorage.error = 0;
}
return outputStorage;
}
|
java
|
public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations ,
boolean computeError ,
FitData<EllipseRotated_F64> outputStorage ) {
if( outputStorage == null ) {
outputStorage = new FitData<>(new EllipseRotated_F64());
}
// Compute the optimal algebraic error
FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64();
if( !algebraic.process(points)) {
// could be a line or some other weird case. Create a crude estimate instead
FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null);
Circle2D_F64 circle = circleData.shape;
outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0);
} else {
UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape);
}
// Improve the solution from algebraic into Euclidean
if( iterations > 0 ) {
RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64();
leastSquares.setMaxIterations(iterations);
leastSquares.refine(outputStorage.shape,points);
outputStorage.shape.set( leastSquares.getFound() );
}
// compute the average Euclidean error if the user requests it
if( computeError ) {
ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100);
closestPoint.setEllipse(outputStorage.shape);
double total = 0;
for( Point2D_F64 p : points ) {
closestPoint.process(p);
total += p.distance(closestPoint.getClosest());
}
outputStorage.error = total/points.size();
} else {
outputStorage.error = 0;
}
return outputStorage;
}
|
[
"public",
"static",
"FitData",
"<",
"EllipseRotated_F64",
">",
"fitEllipse_F64",
"(",
"List",
"<",
"Point2D_F64",
">",
"points",
",",
"int",
"iterations",
",",
"boolean",
"computeError",
",",
"FitData",
"<",
"EllipseRotated_F64",
">",
"outputStorage",
")",
"{",
"if",
"(",
"outputStorage",
"==",
"null",
")",
"{",
"outputStorage",
"=",
"new",
"FitData",
"<>",
"(",
"new",
"EllipseRotated_F64",
"(",
")",
")",
";",
"}",
"// Compute the optimal algebraic error",
"FitEllipseAlgebraic_F64",
"algebraic",
"=",
"new",
"FitEllipseAlgebraic_F64",
"(",
")",
";",
"if",
"(",
"!",
"algebraic",
".",
"process",
"(",
"points",
")",
")",
"{",
"// could be a line or some other weird case. Create a crude estimate instead",
"FitData",
"<",
"Circle2D_F64",
">",
"circleData",
"=",
"averageCircle_F64",
"(",
"points",
",",
"null",
",",
"null",
")",
";",
"Circle2D_F64",
"circle",
"=",
"circleData",
".",
"shape",
";",
"outputStorage",
".",
"shape",
".",
"set",
"(",
"circle",
".",
"center",
".",
"x",
",",
"circle",
".",
"center",
".",
"y",
",",
"circle",
".",
"radius",
",",
"circle",
".",
"radius",
",",
"0",
")",
";",
"}",
"else",
"{",
"UtilEllipse_F64",
".",
"convert",
"(",
"algebraic",
".",
"getEllipse",
"(",
")",
",",
"outputStorage",
".",
"shape",
")",
";",
"}",
"// Improve the solution from algebraic into Euclidean",
"if",
"(",
"iterations",
">",
"0",
")",
"{",
"RefineEllipseEuclideanLeastSquares_F64",
"leastSquares",
"=",
"new",
"RefineEllipseEuclideanLeastSquares_F64",
"(",
")",
";",
"leastSquares",
".",
"setMaxIterations",
"(",
"iterations",
")",
";",
"leastSquares",
".",
"refine",
"(",
"outputStorage",
".",
"shape",
",",
"points",
")",
";",
"outputStorage",
".",
"shape",
".",
"set",
"(",
"leastSquares",
".",
"getFound",
"(",
")",
")",
";",
"}",
"// compute the average Euclidean error if the user requests it",
"if",
"(",
"computeError",
")",
"{",
"ClosestPointEllipseAngle_F64",
"closestPoint",
"=",
"new",
"ClosestPointEllipseAngle_F64",
"(",
"1e-8",
",",
"100",
")",
";",
"closestPoint",
".",
"setEllipse",
"(",
"outputStorage",
".",
"shape",
")",
";",
"double",
"total",
"=",
"0",
";",
"for",
"(",
"Point2D_F64",
"p",
":",
"points",
")",
"{",
"closestPoint",
".",
"process",
"(",
"p",
")",
";",
"total",
"+=",
"p",
".",
"distance",
"(",
"closestPoint",
".",
"getClosest",
"(",
")",
")",
";",
"}",
"outputStorage",
".",
"error",
"=",
"total",
"/",
"points",
".",
"size",
"(",
")",
";",
"}",
"else",
"{",
"outputStorage",
".",
"error",
"=",
"0",
";",
"}",
"return",
"outputStorage",
";",
"}"
] |
Computes the best fit ellipse based on minimizing Euclidean distance. An estimate is initially provided
using algebraic algorithm which is then refined using non-linear optimization. The amount of non-linear
optimization can be controlled using 'iterations' parameter. Will work with partial and complete contours
of objects.
<p>NOTE: To improve speed, make calls directly to classes in Georegression. Look at the code for details.</p>
@param points (Input) Set of unordered points. Not modified.
@param iterations Number of iterations used to refine the fit. If set to zero then an algebraic solution
is returned.
@param computeError If true it will compute the average Euclidean distance error
@param outputStorage (Output/Optional) Storage for the ellipse. Can be null.
@return Found ellipse.
|
[
"Computes",
"the",
"best",
"fit",
"ellipse",
"based",
"on",
"minimizing",
"Euclidean",
"distance",
".",
"An",
"estimate",
"is",
"initially",
"provided",
"using",
"algebraic",
"algorithm",
"which",
"is",
"then",
"refined",
"using",
"non",
"-",
"linear",
"optimization",
".",
"The",
"amount",
"of",
"non",
"-",
"linear",
"optimization",
"can",
"be",
"controlled",
"using",
"iterations",
"parameter",
".",
"Will",
"work",
"with",
"partial",
"and",
"complete",
"contours",
"of",
"objects",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java#L104-L148
|
apache/flink
|
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
|
SqlDateTimeUtils.timestampCeil
|
public static long timestampCeil(TimeUnitRange range, long ts, TimeZone tz) {
// assume that we are at UTC timezone, just for algorithm performance
long offset = tz.getOffset(ts);
long utcTs = ts + offset;
switch (range) {
case HOUR:
return ceil(utcTs, MILLIS_PER_HOUR) - offset;
case DAY:
return ceil(utcTs, MILLIS_PER_DAY) - offset;
case MONTH:
case YEAR:
case QUARTER:
int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN);
return julianDateFloor(range, days, false) * MILLIS_PER_DAY - offset;
default:
// for MINUTE and SECONDS etc...,
// it is more effective to use arithmetic Method
throw new AssertionError(range);
}
}
|
java
|
public static long timestampCeil(TimeUnitRange range, long ts, TimeZone tz) {
// assume that we are at UTC timezone, just for algorithm performance
long offset = tz.getOffset(ts);
long utcTs = ts + offset;
switch (range) {
case HOUR:
return ceil(utcTs, MILLIS_PER_HOUR) - offset;
case DAY:
return ceil(utcTs, MILLIS_PER_DAY) - offset;
case MONTH:
case YEAR:
case QUARTER:
int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN);
return julianDateFloor(range, days, false) * MILLIS_PER_DAY - offset;
default:
// for MINUTE and SECONDS etc...,
// it is more effective to use arithmetic Method
throw new AssertionError(range);
}
}
|
[
"public",
"static",
"long",
"timestampCeil",
"(",
"TimeUnitRange",
"range",
",",
"long",
"ts",
",",
"TimeZone",
"tz",
")",
"{",
"// assume that we are at UTC timezone, just for algorithm performance",
"long",
"offset",
"=",
"tz",
".",
"getOffset",
"(",
"ts",
")",
";",
"long",
"utcTs",
"=",
"ts",
"+",
"offset",
";",
"switch",
"(",
"range",
")",
"{",
"case",
"HOUR",
":",
"return",
"ceil",
"(",
"utcTs",
",",
"MILLIS_PER_HOUR",
")",
"-",
"offset",
";",
"case",
"DAY",
":",
"return",
"ceil",
"(",
"utcTs",
",",
"MILLIS_PER_DAY",
")",
"-",
"offset",
";",
"case",
"MONTH",
":",
"case",
"YEAR",
":",
"case",
"QUARTER",
":",
"int",
"days",
"=",
"(",
"int",
")",
"(",
"utcTs",
"/",
"MILLIS_PER_DAY",
"+",
"EPOCH_JULIAN",
")",
";",
"return",
"julianDateFloor",
"(",
"range",
",",
"days",
",",
"false",
")",
"*",
"MILLIS_PER_DAY",
"-",
"offset",
";",
"default",
":",
"// for MINUTE and SECONDS etc...,",
"// it is more effective to use arithmetic Method",
"throw",
"new",
"AssertionError",
"(",
"range",
")",
";",
"}",
"}"
] |
Keep the algorithm consistent with Calcite DateTimeUtils.julianDateFloor, but here
we take time zone into account.
|
[
"Keep",
"the",
"algorithm",
"consistent",
"with",
"Calcite",
"DateTimeUtils",
".",
"julianDateFloor",
"but",
"here",
"we",
"take",
"time",
"zone",
"into",
"account",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java#L627-L647
|
sebastiangraf/treetank
|
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RestXPathProcessor.java
|
RestXPathProcessor.doXPathRes
|
private void doXPathRes(final String resource, final Long revision, final OutputStream output,
final boolean nodeid, final String xpath) throws TTException {
// Storage connection to treetank
ISession session = null;
INodeReadTrx rtx = null;
try {
if (mDatabase.existsResource(resource)) {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// Creating a transaction
if (revision == null) {
rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion()));
} else {
rtx = new NodeReadTrx(session.beginBucketRtx(revision));
}
final AbsAxis axis = new XPathAxis(rtx, xpath);
for (final long key : axis) {
WorkerHelper.serializeXML(session, output, false, nodeid, key, revision).call();
}
}
} catch (final Exception globExcep) {
throw new WebApplicationException(globExcep, Response.Status.INTERNAL_SERVER_ERROR);
} finally {
WorkerHelper.closeRTX(rtx, session);
}
}
|
java
|
private void doXPathRes(final String resource, final Long revision, final OutputStream output,
final boolean nodeid, final String xpath) throws TTException {
// Storage connection to treetank
ISession session = null;
INodeReadTrx rtx = null;
try {
if (mDatabase.existsResource(resource)) {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// Creating a transaction
if (revision == null) {
rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion()));
} else {
rtx = new NodeReadTrx(session.beginBucketRtx(revision));
}
final AbsAxis axis = new XPathAxis(rtx, xpath);
for (final long key : axis) {
WorkerHelper.serializeXML(session, output, false, nodeid, key, revision).call();
}
}
} catch (final Exception globExcep) {
throw new WebApplicationException(globExcep, Response.Status.INTERNAL_SERVER_ERROR);
} finally {
WorkerHelper.closeRTX(rtx, session);
}
}
|
[
"private",
"void",
"doXPathRes",
"(",
"final",
"String",
"resource",
",",
"final",
"Long",
"revision",
",",
"final",
"OutputStream",
"output",
",",
"final",
"boolean",
"nodeid",
",",
"final",
"String",
"xpath",
")",
"throws",
"TTException",
"{",
"// Storage connection to treetank",
"ISession",
"session",
"=",
"null",
";",
"INodeReadTrx",
"rtx",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"mDatabase",
".",
"existsResource",
"(",
"resource",
")",
")",
"{",
"session",
"=",
"mDatabase",
".",
"getSession",
"(",
"new",
"SessionConfiguration",
"(",
"resource",
",",
"StandardSettings",
".",
"KEY",
")",
")",
";",
"// Creating a transaction",
"if",
"(",
"revision",
"==",
"null",
")",
"{",
"rtx",
"=",
"new",
"NodeReadTrx",
"(",
"session",
".",
"beginBucketRtx",
"(",
"session",
".",
"getMostRecentVersion",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"rtx",
"=",
"new",
"NodeReadTrx",
"(",
"session",
".",
"beginBucketRtx",
"(",
"revision",
")",
")",
";",
"}",
"final",
"AbsAxis",
"axis",
"=",
"new",
"XPathAxis",
"(",
"rtx",
",",
"xpath",
")",
";",
"for",
"(",
"final",
"long",
"key",
":",
"axis",
")",
"{",
"WorkerHelper",
".",
"serializeXML",
"(",
"session",
",",
"output",
",",
"false",
",",
"nodeid",
",",
"key",
",",
"revision",
")",
".",
"call",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"globExcep",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"globExcep",
",",
"Response",
".",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"finally",
"{",
"WorkerHelper",
".",
"closeRTX",
"(",
"rtx",
",",
"session",
")",
";",
"}",
"}"
] |
This method performs an XPath evaluation and writes it to a given output
stream.
@param resource
The existing resource.
@param revision
The revision of the requested document.
@param output
The output stream where the results are written.
@param nodeid
<code>true</code> if node id's have to be delivered. <code>false</code> otherwise.
@param xpath
The XPath expression.
@throws TTException
|
[
"This",
"method",
"performs",
"an",
"XPath",
"evaluation",
"and",
"writes",
"it",
"to",
"a",
"given",
"output",
"stream",
"."
] |
train
|
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RestXPathProcessor.java#L216-L242
|
cloudinary/cloudinary_java
|
cloudinary-core/src/main/java/com/cloudinary/Api.java
|
Api.createStreamingProfile
|
public ApiResponse createStreamingProfile(String name, String displayName, List<Map> representations, Map options) throws Exception {
if (options == null)
options = ObjectUtils.emptyMap();
List<Map> serializedRepresentations = new ArrayList<Map>(representations.size());
for (Map t : representations) {
final Object transformation = t.get("transformation");
serializedRepresentations.add(ObjectUtils.asMap("transformation", transformation.toString()));
}
List<String> uri = Collections.singletonList("streaming_profiles");
final Map params = ObjectUtils.asMap(
"name", name,
"representations", new JSONArray(serializedRepresentations.toArray())
);
if (displayName != null) {
params.put("display_name", displayName);
}
return callApi(HttpMethod.POST, uri, params, options);
}
|
java
|
public ApiResponse createStreamingProfile(String name, String displayName, List<Map> representations, Map options) throws Exception {
if (options == null)
options = ObjectUtils.emptyMap();
List<Map> serializedRepresentations = new ArrayList<Map>(representations.size());
for (Map t : representations) {
final Object transformation = t.get("transformation");
serializedRepresentations.add(ObjectUtils.asMap("transformation", transformation.toString()));
}
List<String> uri = Collections.singletonList("streaming_profiles");
final Map params = ObjectUtils.asMap(
"name", name,
"representations", new JSONArray(serializedRepresentations.toArray())
);
if (displayName != null) {
params.put("display_name", displayName);
}
return callApi(HttpMethod.POST, uri, params, options);
}
|
[
"public",
"ApiResponse",
"createStreamingProfile",
"(",
"String",
"name",
",",
"String",
"displayName",
",",
"List",
"<",
"Map",
">",
"representations",
",",
"Map",
"options",
")",
"throws",
"Exception",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"options",
"=",
"ObjectUtils",
".",
"emptyMap",
"(",
")",
";",
"List",
"<",
"Map",
">",
"serializedRepresentations",
"=",
"new",
"ArrayList",
"<",
"Map",
">",
"(",
"representations",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
"t",
":",
"representations",
")",
"{",
"final",
"Object",
"transformation",
"=",
"t",
".",
"get",
"(",
"\"transformation\"",
")",
";",
"serializedRepresentations",
".",
"add",
"(",
"ObjectUtils",
".",
"asMap",
"(",
"\"transformation\"",
",",
"transformation",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"List",
"<",
"String",
">",
"uri",
"=",
"Collections",
".",
"singletonList",
"(",
"\"streaming_profiles\"",
")",
";",
"final",
"Map",
"params",
"=",
"ObjectUtils",
".",
"asMap",
"(",
"\"name\"",
",",
"name",
",",
"\"representations\"",
",",
"new",
"JSONArray",
"(",
"serializedRepresentations",
".",
"toArray",
"(",
")",
")",
")",
";",
"if",
"(",
"displayName",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"display_name\"",
",",
"displayName",
")",
";",
"}",
"return",
"callApi",
"(",
"HttpMethod",
".",
"POST",
",",
"uri",
",",
"params",
",",
"options",
")",
";",
"}"
] |
Create a new streaming profile
@param name the of the profile
@param displayName the display name of the profile
@param representations a collection of Maps with a transformation key
@param options additional options
@return the new streaming profile
@throws Exception an exception
|
[
"Create",
"a",
"new",
"streaming",
"profile"
] |
train
|
https://github.com/cloudinary/cloudinary_java/blob/58ee1823180da2dea6a2eb7e5cf00d5a760f8aef/cloudinary-core/src/main/java/com/cloudinary/Api.java#L347-L364
|
alkacon/opencms-core
|
src-setup/org/opencms/setup/db/update6to7/postgresql/CmsUpdateDBAlterTables.java
|
CmsUpdateDBAlterTables.initReplacer
|
private void initReplacer(Map<String, String> replacer, String tableName, String fieldName) {
replacer.clear();
replacer.put(REPLACEMENT_TABLENAME, tableName);
replacer.put(REPLACEMENT_FIELD_NAME, fieldName);
}
|
java
|
private void initReplacer(Map<String, String> replacer, String tableName, String fieldName) {
replacer.clear();
replacer.put(REPLACEMENT_TABLENAME, tableName);
replacer.put(REPLACEMENT_FIELD_NAME, fieldName);
}
|
[
"private",
"void",
"initReplacer",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"replacer",
",",
"String",
"tableName",
",",
"String",
"fieldName",
")",
"{",
"replacer",
".",
"clear",
"(",
")",
";",
"replacer",
".",
"put",
"(",
"REPLACEMENT_TABLENAME",
",",
"tableName",
")",
";",
"replacer",
".",
"put",
"(",
"REPLACEMENT_FIELD_NAME",
",",
"fieldName",
")",
";",
"}"
] |
Initializes the replacer.<p>
@param replacer the replacer
@param tableName the table name
@param fieldName the field name
|
[
"Initializes",
"the",
"replacer",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/db/update6to7/postgresql/CmsUpdateDBAlterTables.java#L178-L183
|
googlegenomics/utils-java
|
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
|
GenomicsFactory.fromServiceAccount
|
public <T extends AbstractGoogleJsonClient.Builder> T fromServiceAccount(T builder,
String serviceAccountId, File p12File) throws GeneralSecurityException, IOException {
Preconditions.checkNotNull(builder);
GoogleCredential creds = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(p12File)
.build();
creds.refreshToken();
return prepareBuilder(builder, creds, null);
}
|
java
|
public <T extends AbstractGoogleJsonClient.Builder> T fromServiceAccount(T builder,
String serviceAccountId, File p12File) throws GeneralSecurityException, IOException {
Preconditions.checkNotNull(builder);
GoogleCredential creds = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(p12File)
.build();
creds.refreshToken();
return prepareBuilder(builder, creds, null);
}
|
[
"public",
"<",
"T",
"extends",
"AbstractGoogleJsonClient",
".",
"Builder",
">",
"T",
"fromServiceAccount",
"(",
"T",
"builder",
",",
"String",
"serviceAccountId",
",",
"File",
"p12File",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"builder",
")",
";",
"GoogleCredential",
"creds",
"=",
"new",
"GoogleCredential",
".",
"Builder",
"(",
")",
".",
"setTransport",
"(",
"httpTransport",
")",
".",
"setJsonFactory",
"(",
"jsonFactory",
")",
".",
"setServiceAccountId",
"(",
"serviceAccountId",
")",
".",
"setServiceAccountScopes",
"(",
"scopes",
")",
".",
"setServiceAccountPrivateKeyFromP12File",
"(",
"p12File",
")",
".",
"build",
"(",
")",
";",
"creds",
".",
"refreshToken",
"(",
")",
";",
"return",
"prepareBuilder",
"(",
"builder",
",",
"creds",
",",
"null",
")",
";",
"}"
] |
Prepare an AbstractGoogleJsonClient.Builder with the given service account ID
and private key {@link File}.
@param builder The builder to be prepared.
@param serviceAccountId The service account ID (typically an email address)
@param p12File The file on disk containing the private key
@return The passed in builder, for easy chaining.
@throws GeneralSecurityException
@throws IOException
|
[
"Prepare",
"an",
"AbstractGoogleJsonClient",
".",
"Builder",
"with",
"the",
"given",
"service",
"account",
"ID",
"and",
"private",
"key",
"{",
"@link",
"File",
"}",
"."
] |
train
|
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L458-L470
|
jhunters/jprotobuf
|
v3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java
|
ProtobufIDLProxy.generateProtobufDefinedForField
|
private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(getTypeName(field));
if (fieldType == null) {
if (enumNames.contains(getTypeName(field))) {
fieldType = "FieldType.ENUM";
} else {
if (field.type().kind() == DataType.Kind.MAP) {
fieldType = "FieldType.MAP";
} else {
fieldType = "FieldType.OBJECT";
}
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.tag());
if (FieldElement.Label.OPTIONAL == field.label()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.label()) {
code.append(", required=true");
}
code.append(")\n");
}
|
java
|
private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(getTypeName(field));
if (fieldType == null) {
if (enumNames.contains(getTypeName(field))) {
fieldType = "FieldType.ENUM";
} else {
if (field.type().kind() == DataType.Kind.MAP) {
fieldType = "FieldType.MAP";
} else {
fieldType = "FieldType.OBJECT";
}
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.tag());
if (FieldElement.Label.OPTIONAL == field.label()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.label()) {
code.append(", required=true");
}
code.append(")\n");
}
|
[
"private",
"static",
"void",
"generateProtobufDefinedForField",
"(",
"StringBuilder",
"code",
",",
"FieldElement",
"field",
",",
"Set",
"<",
"String",
">",
"enumNames",
")",
"{",
"code",
".",
"append",
"(",
"\"@\"",
")",
".",
"append",
"(",
"Protobuf",
".",
"class",
".",
"getSimpleName",
"(",
")",
")",
".",
"append",
"(",
"\"(\"",
")",
";",
"String",
"fieldType",
"=",
"fieldTypeMapping",
".",
"get",
"(",
"getTypeName",
"(",
"field",
")",
")",
";",
"if",
"(",
"fieldType",
"==",
"null",
")",
"{",
"if",
"(",
"enumNames",
".",
"contains",
"(",
"getTypeName",
"(",
"field",
")",
")",
")",
"{",
"fieldType",
"=",
"\"FieldType.ENUM\"",
";",
"}",
"else",
"{",
"if",
"(",
"field",
".",
"type",
"(",
")",
".",
"kind",
"(",
")",
"==",
"DataType",
".",
"Kind",
".",
"MAP",
")",
"{",
"fieldType",
"=",
"\"FieldType.MAP\"",
";",
"}",
"else",
"{",
"fieldType",
"=",
"\"FieldType.OBJECT\"",
";",
"}",
"}",
"}",
"code",
".",
"append",
"(",
"\"fieldType=\"",
")",
".",
"append",
"(",
"fieldType",
")",
";",
"code",
".",
"append",
"(",
"\", order=\"",
")",
".",
"append",
"(",
"field",
".",
"tag",
"(",
")",
")",
";",
"if",
"(",
"FieldElement",
".",
"Label",
".",
"OPTIONAL",
"==",
"field",
".",
"label",
"(",
")",
")",
"{",
"code",
".",
"append",
"(",
"\", required=false\"",
")",
";",
"}",
"else",
"if",
"(",
"Label",
".",
"REQUIRED",
"==",
"field",
".",
"label",
"(",
")",
")",
"{",
"code",
".",
"append",
"(",
"\", required=true\"",
")",
";",
"}",
"code",
".",
"append",
"(",
"\")\\n\"",
")",
";",
"}"
] |
to generate @Protobuf defined code for target field.
@param code the code
@param field the field
@param enumNames the enum names
|
[
"to",
"generate",
"@Protobuf",
"defined",
"code",
"for",
"target",
"field",
"."
] |
train
|
https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/v3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java#L1397-L1423
|
Tristan971/EasyFXML
|
easyfxml/src/main/java/moe/tristan/easyfxml/util/Nodes.java
|
Nodes.centerNode
|
public static void centerNode(final Node node, final Double marginSize) {
AnchorPane.setTopAnchor(node, marginSize);
AnchorPane.setBottomAnchor(node, marginSize);
AnchorPane.setLeftAnchor(node, marginSize);
AnchorPane.setRightAnchor(node, marginSize);
}
|
java
|
public static void centerNode(final Node node, final Double marginSize) {
AnchorPane.setTopAnchor(node, marginSize);
AnchorPane.setBottomAnchor(node, marginSize);
AnchorPane.setLeftAnchor(node, marginSize);
AnchorPane.setRightAnchor(node, marginSize);
}
|
[
"public",
"static",
"void",
"centerNode",
"(",
"final",
"Node",
"node",
",",
"final",
"Double",
"marginSize",
")",
"{",
"AnchorPane",
".",
"setTopAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setBottomAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setLeftAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setRightAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"}"
] |
Centers a node that is inside an enclosing {@link AnchorPane}.
@param node The node to center
@param marginSize The margins to keep on the sides
|
[
"Centers",
"a",
"node",
"that",
"is",
"inside",
"an",
"enclosing",
"{",
"@link",
"AnchorPane",
"}",
"."
] |
train
|
https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Nodes.java#L21-L26
|
alkacon/opencms-core
|
src/org/opencms/ui/components/extensions/CmsGwtDialogExtension.java
|
CmsGwtDialogExtension.getPublishData
|
protected CmsPublishData getPublishData(CmsProject project, List<CmsResource> directPublishResources) {
CmsPublishService publishService = new CmsPublishService();
CmsObject cms = A_CmsUI.getCmsObject();
publishService.setCms(cms);
List<String> pathList = new ArrayList<String>();
if (directPublishResources != null) {
for (CmsResource resource : directPublishResources) {
pathList.add(cms.getSitePath(resource));
}
}
publishService.setRequest((HttpServletRequest)(VaadinService.getCurrentRequest()));
try {
return publishService.getPublishData(
cms,
new HashMap<String, String>()/*params*/,
null/*workflowId*/,
project != null ? project.getUuid().toString() : null /*projectParam*/,
pathList,
null/*closelink*/,
false/*confirmation*/);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
}
|
java
|
protected CmsPublishData getPublishData(CmsProject project, List<CmsResource> directPublishResources) {
CmsPublishService publishService = new CmsPublishService();
CmsObject cms = A_CmsUI.getCmsObject();
publishService.setCms(cms);
List<String> pathList = new ArrayList<String>();
if (directPublishResources != null) {
for (CmsResource resource : directPublishResources) {
pathList.add(cms.getSitePath(resource));
}
}
publishService.setRequest((HttpServletRequest)(VaadinService.getCurrentRequest()));
try {
return publishService.getPublishData(
cms,
new HashMap<String, String>()/*params*/,
null/*workflowId*/,
project != null ? project.getUuid().toString() : null /*projectParam*/,
pathList,
null/*closelink*/,
false/*confirmation*/);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
}
|
[
"protected",
"CmsPublishData",
"getPublishData",
"(",
"CmsProject",
"project",
",",
"List",
"<",
"CmsResource",
">",
"directPublishResources",
")",
"{",
"CmsPublishService",
"publishService",
"=",
"new",
"CmsPublishService",
"(",
")",
";",
"CmsObject",
"cms",
"=",
"A_CmsUI",
".",
"getCmsObject",
"(",
")",
";",
"publishService",
".",
"setCms",
"(",
"cms",
")",
";",
"List",
"<",
"String",
">",
"pathList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"directPublishResources",
"!=",
"null",
")",
"{",
"for",
"(",
"CmsResource",
"resource",
":",
"directPublishResources",
")",
"{",
"pathList",
".",
"add",
"(",
"cms",
".",
"getSitePath",
"(",
"resource",
")",
")",
";",
"}",
"}",
"publishService",
".",
"setRequest",
"(",
"(",
"HttpServletRequest",
")",
"(",
"VaadinService",
".",
"getCurrentRequest",
"(",
")",
")",
")",
";",
"try",
"{",
"return",
"publishService",
".",
"getPublishData",
"(",
"cms",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
"/*params*/",
",",
"null",
"/*workflowId*/",
",",
"project",
"!=",
"null",
"?",
"project",
".",
"getUuid",
"(",
")",
".",
"toString",
"(",
")",
":",
"null",
"/*projectParam*/",
",",
"pathList",
",",
"null",
"/*closelink*/",
",",
"false",
"/*confirmation*/",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Gets the publish data for the given resources.<p>
@param directPublishResources the resources to publish
@param project the project for which to open the dialog
@return the publish data for the resources
|
[
"Gets",
"the",
"publish",
"data",
"for",
"the",
"given",
"resources",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/extensions/CmsGwtDialogExtension.java#L283-L308
|
ozimov/cirneco
|
hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/throwable/ExpectedException.java
|
ExpectedException.exceptionWithMessage
|
public static Matcher<Throwable> exceptionWithMessage(Class<? extends Throwable> type, String expectedMessage) {
return new ExpectedException(type, expectedMessage);
}
|
java
|
public static Matcher<Throwable> exceptionWithMessage(Class<? extends Throwable> type, String expectedMessage) {
return new ExpectedException(type, expectedMessage);
}
|
[
"public",
"static",
"Matcher",
"<",
"Throwable",
">",
"exceptionWithMessage",
"(",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"type",
",",
"String",
"expectedMessage",
")",
"{",
"return",
"new",
"ExpectedException",
"(",
"type",
",",
"expectedMessage",
")",
";",
"}"
] |
Creates a matcher for a {@link Throwable} that matches when the provided {@code Throwable} instance is the same or a subtype
of the given class and has the same message in the error message or the message is contained in the error message
|
[
"Creates",
"a",
"matcher",
"for",
"a",
"{"
] |
train
|
https://github.com/ozimov/cirneco/blob/78ad782da0a2256634cfbebb2f97ed78c993b999/hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/throwable/ExpectedException.java#L40-L42
|
fuinorg/event-store-commons
|
spi/src/main/java/org/fuin/esc/spi/SimpleSerializerDeserializerRegistry.java
|
SimpleSerializerDeserializerRegistry.addDeserializer
|
public final void addDeserializer(@NotNull final SerializedDataType type, final String contentType,
@NotNull final Deserializer deserializer) {
Contract.requireArgNotNull("type", type);
Contract.requireArgNotNull("contentType", contentType);
Contract.requireArgNotNull("deserializer", deserializer);
final Key key = new Key(type, contentType);
desMap.put(key, deserializer);
}
|
java
|
public final void addDeserializer(@NotNull final SerializedDataType type, final String contentType,
@NotNull final Deserializer deserializer) {
Contract.requireArgNotNull("type", type);
Contract.requireArgNotNull("contentType", contentType);
Contract.requireArgNotNull("deserializer", deserializer);
final Key key = new Key(type, contentType);
desMap.put(key, deserializer);
}
|
[
"public",
"final",
"void",
"addDeserializer",
"(",
"@",
"NotNull",
"final",
"SerializedDataType",
"type",
",",
"final",
"String",
"contentType",
",",
"@",
"NotNull",
"final",
"Deserializer",
"deserializer",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"type\"",
",",
"type",
")",
";",
"Contract",
".",
"requireArgNotNull",
"(",
"\"contentType\"",
",",
"contentType",
")",
";",
"Contract",
".",
"requireArgNotNull",
"(",
"\"deserializer\"",
",",
"deserializer",
")",
";",
"final",
"Key",
"key",
"=",
"new",
"Key",
"(",
"type",
",",
"contentType",
")",
";",
"desMap",
".",
"put",
"(",
"key",
",",
"deserializer",
")",
";",
"}"
] |
Adds a new deserializer to the registry.
@param type
Type of the data.
@param contentType
Content type like "application/xml" or "application/json" (without parameters - Only base
type).
@param deserializer
Deserializer.
|
[
"Adds",
"a",
"new",
"deserializer",
"to",
"the",
"registry",
"."
] |
train
|
https://github.com/fuinorg/event-store-commons/blob/ea175582d8cda2b5a6d2fe52bbb2f1c183eee77c/spi/src/main/java/org/fuin/esc/spi/SimpleSerializerDeserializerRegistry.java#L78-L88
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.org.apache.jasper.el/src/org/apache/el/util/ReflectionUtil.java
|
ReflectionUtil.isCoercibleFrom
|
private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) {
// TODO: This isn't pretty but it works. Significant refactoring would
// be required to avoid the exception.
try {
ELSupport.coerceToType(ctx, src, target);
} catch (ELException e) {
return false;
}
return true;
}
|
java
|
private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) {
// TODO: This isn't pretty but it works. Significant refactoring would
// be required to avoid the exception.
try {
ELSupport.coerceToType(ctx, src, target);
} catch (ELException e) {
return false;
}
return true;
}
|
[
"private",
"static",
"boolean",
"isCoercibleFrom",
"(",
"EvaluationContext",
"ctx",
",",
"Object",
"src",
",",
"Class",
"<",
"?",
">",
"target",
")",
"{",
"// TODO: This isn't pretty but it works. Significant refactoring would",
"// be required to avoid the exception.",
"try",
"{",
"ELSupport",
".",
"coerceToType",
"(",
"ctx",
",",
"src",
",",
"target",
")",
";",
"}",
"catch",
"(",
"ELException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
/*
This class duplicates code in javax.el.Util. When making changes keep
the code in sync.
|
[
"/",
"*",
"This",
"class",
"duplicates",
"code",
"in",
"javax",
".",
"el",
".",
"Util",
".",
"When",
"making",
"changes",
"keep",
"the",
"code",
"in",
"sync",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.jasper.el/src/org/apache/el/util/ReflectionUtil.java#L401-L410
|
fcrepo3/fcrepo
|
fcrepo-common/src/main/java/org/fcrepo/common/policy/XacmlName.java
|
XacmlName.looselyMatches
|
public boolean looselyMatches(String in, boolean tryFirstLocalNameChar) {
if (in == null || in.length() == 0) {
return false;
}
if (in.equalsIgnoreCase(localName)) {
return true;
}
if (in.equals(uri)) {
return true;
}
if (tryFirstLocalNameChar
&& in.length() == 1
&& in.toUpperCase().charAt(0) == localName.toUpperCase()
.charAt(0)) {
return true;
}
return false;
}
|
java
|
public boolean looselyMatches(String in, boolean tryFirstLocalNameChar) {
if (in == null || in.length() == 0) {
return false;
}
if (in.equalsIgnoreCase(localName)) {
return true;
}
if (in.equals(uri)) {
return true;
}
if (tryFirstLocalNameChar
&& in.length() == 1
&& in.toUpperCase().charAt(0) == localName.toUpperCase()
.charAt(0)) {
return true;
}
return false;
}
|
[
"public",
"boolean",
"looselyMatches",
"(",
"String",
"in",
",",
"boolean",
"tryFirstLocalNameChar",
")",
"{",
"if",
"(",
"in",
"==",
"null",
"||",
"in",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in",
".",
"equalsIgnoreCase",
"(",
"localName",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"in",
".",
"equals",
"(",
"uri",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"tryFirstLocalNameChar",
"&&",
"in",
".",
"length",
"(",
")",
"==",
"1",
"&&",
"in",
".",
"toUpperCase",
"(",
")",
".",
"charAt",
"(",
"0",
")",
"==",
"localName",
".",
"toUpperCase",
"(",
")",
".",
"charAt",
"(",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Does the given string loosely match this name? Either: 1) It matches
localName (case insensitive) 2) It matches uri (case sensitive) if
(firstLocalNameChar == true): 3) It is one character long, and that
character matches the first character of localName (case insensitive)
|
[
"Does",
"the",
"given",
"string",
"loosely",
"match",
"this",
"name?",
"Either",
":",
"1",
")",
"It",
"matches",
"localName",
"(",
"case",
"insensitive",
")",
"2",
")",
"It",
"matches",
"uri",
"(",
"case",
"sensitive",
")",
"if",
"(",
"firstLocalNameChar",
"==",
"true",
")",
":",
"3",
")",
"It",
"is",
"one",
"character",
"long",
"and",
"that",
"character",
"matches",
"the",
"first",
"character",
"of",
"localName",
"(",
"case",
"insensitive",
")"
] |
train
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/policy/XacmlName.java#L66-L83
|
alkacon/opencms-core
|
src/org/opencms/search/fields/CmsSearchFieldConfiguration.java
|
CmsSearchFieldConfiguration.getLocaleExtendedName
|
public static final String getLocaleExtendedName(String lookup, String locale) {
StringBuffer result = new StringBuffer(32);
result.append(lookup);
result.append('_');
result.append(locale);
return result.toString();
}
|
java
|
public static final String getLocaleExtendedName(String lookup, String locale) {
StringBuffer result = new StringBuffer(32);
result.append(lookup);
result.append('_');
result.append(locale);
return result.toString();
}
|
[
"public",
"static",
"final",
"String",
"getLocaleExtendedName",
"(",
"String",
"lookup",
",",
"String",
"locale",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"32",
")",
";",
"result",
".",
"append",
"(",
"lookup",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"locale",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the locale extended name for the given lookup String.<p>
@param lookup the lookup String
@param locale the locale
@return the locale extended name for the given lookup String
|
[
"Returns",
"the",
"locale",
"extended",
"name",
"for",
"the",
"given",
"lookup",
"String",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/fields/CmsSearchFieldConfiguration.java#L111-L118
|
magro/memcached-session-manager
|
core/src/main/java/de/javakaffee/web/msm/TranscoderService.java
|
TranscoderService.encodeNum
|
public static int encodeNum( final long num, final byte[] data, final int beginIndex, final int maxBytes ) {
for ( int i = 0; i < maxBytes; i++ ) {
final int pos = maxBytes - i - 1; // the position of the byte in the number
final int idx = beginIndex + pos; // the index in the data array
data[idx] = (byte) ( ( num >> ( 8 * i ) ) & 0xff );
}
return beginIndex + maxBytes;
}
|
java
|
public static int encodeNum( final long num, final byte[] data, final int beginIndex, final int maxBytes ) {
for ( int i = 0; i < maxBytes; i++ ) {
final int pos = maxBytes - i - 1; // the position of the byte in the number
final int idx = beginIndex + pos; // the index in the data array
data[idx] = (byte) ( ( num >> ( 8 * i ) ) & 0xff );
}
return beginIndex + maxBytes;
}
|
[
"public",
"static",
"int",
"encodeNum",
"(",
"final",
"long",
"num",
",",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"beginIndex",
",",
"final",
"int",
"maxBytes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxBytes",
";",
"i",
"++",
")",
"{",
"final",
"int",
"pos",
"=",
"maxBytes",
"-",
"i",
"-",
"1",
";",
"// the position of the byte in the number",
"final",
"int",
"idx",
"=",
"beginIndex",
"+",
"pos",
";",
"// the index in the data array",
"data",
"[",
"idx",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"num",
">>",
"(",
"8",
"*",
"i",
")",
")",
"&",
"0xff",
")",
";",
"}",
"return",
"beginIndex",
"+",
"maxBytes",
";",
"}"
] |
Convert a number to bytes (with length of maxBytes) and write bytes into
the provided byte[] data starting at the specified beginIndex.
@param num
the number to encode
@param data
the byte array into that the number is encoded
@param beginIndex
the beginning index of data where to start encoding,
inclusive.
@param maxBytes
the number of bytes to store for the number
@return the next beginIndex (<code>beginIndex + maxBytes</code>).
|
[
"Convert",
"a",
"number",
"to",
"bytes",
"(",
"with",
"length",
"of",
"maxBytes",
")",
"and",
"write",
"bytes",
"into",
"the",
"provided",
"byte",
"[]",
"data",
"starting",
"at",
"the",
"specified",
"beginIndex",
"."
] |
train
|
https://github.com/magro/memcached-session-manager/blob/716e147c9840ab10298c4d2b9edd0662058331e6/core/src/main/java/de/javakaffee/web/msm/TranscoderService.java#L500-L507
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java
|
CrystalBuilder.expandNcsOps
|
public static void expandNcsOps(Structure structure, Map<String,String> chainOrigNames, Map<String,Matrix4d> chainNcsOps) {
PDBCrystallographicInfo xtalInfo = structure.getCrystallographicInfo();
if (xtalInfo ==null) return;
if (xtalInfo.getNcsOperators()==null || xtalInfo.getNcsOperators().length==0)
return;
List<Chain> chainsToAdd = new ArrayList<>();
Matrix4d identity = new Matrix4d();
identity.setIdentity();
Matrix4d[] ncsOps = xtalInfo.getNcsOperators();
for (Chain c:structure.getChains()) {
String cOrigId = c.getId();
String cOrigName = c.getName();
for (int iOperator = 0; iOperator < ncsOps.length; iOperator++) {
Matrix4d m = ncsOps[iOperator];
Chain clonedChain = (Chain)c.clone();
String newChainId = cOrigId+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
String newChainName = cOrigName+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
clonedChain.setId(newChainId);
clonedChain.setName(newChainName);
setChainIdsInResidueNumbers(clonedChain, newChainName);
Calc.transform(clonedChain, m);
chainsToAdd.add(clonedChain);
c.getEntityInfo().addChain(clonedChain);
chainOrigNames.put(newChainName,cOrigName);
chainNcsOps.put(newChainName,m);
}
chainNcsOps.put(cOrigName,identity);
chainOrigNames.put(cOrigName,cOrigName);
}
chainsToAdd.forEach(structure::addChain);
}
|
java
|
public static void expandNcsOps(Structure structure, Map<String,String> chainOrigNames, Map<String,Matrix4d> chainNcsOps) {
PDBCrystallographicInfo xtalInfo = structure.getCrystallographicInfo();
if (xtalInfo ==null) return;
if (xtalInfo.getNcsOperators()==null || xtalInfo.getNcsOperators().length==0)
return;
List<Chain> chainsToAdd = new ArrayList<>();
Matrix4d identity = new Matrix4d();
identity.setIdentity();
Matrix4d[] ncsOps = xtalInfo.getNcsOperators();
for (Chain c:structure.getChains()) {
String cOrigId = c.getId();
String cOrigName = c.getName();
for (int iOperator = 0; iOperator < ncsOps.length; iOperator++) {
Matrix4d m = ncsOps[iOperator];
Chain clonedChain = (Chain)c.clone();
String newChainId = cOrigId+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
String newChainName = cOrigName+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
clonedChain.setId(newChainId);
clonedChain.setName(newChainName);
setChainIdsInResidueNumbers(clonedChain, newChainName);
Calc.transform(clonedChain, m);
chainsToAdd.add(clonedChain);
c.getEntityInfo().addChain(clonedChain);
chainOrigNames.put(newChainName,cOrigName);
chainNcsOps.put(newChainName,m);
}
chainNcsOps.put(cOrigName,identity);
chainOrigNames.put(cOrigName,cOrigName);
}
chainsToAdd.forEach(structure::addChain);
}
|
[
"public",
"static",
"void",
"expandNcsOps",
"(",
"Structure",
"structure",
",",
"Map",
"<",
"String",
",",
"String",
">",
"chainOrigNames",
",",
"Map",
"<",
"String",
",",
"Matrix4d",
">",
"chainNcsOps",
")",
"{",
"PDBCrystallographicInfo",
"xtalInfo",
"=",
"structure",
".",
"getCrystallographicInfo",
"(",
")",
";",
"if",
"(",
"xtalInfo",
"==",
"null",
")",
"return",
";",
"if",
"(",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
"==",
"null",
"||",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
".",
"length",
"==",
"0",
")",
"return",
";",
"List",
"<",
"Chain",
">",
"chainsToAdd",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Matrix4d",
"identity",
"=",
"new",
"Matrix4d",
"(",
")",
";",
"identity",
".",
"setIdentity",
"(",
")",
";",
"Matrix4d",
"[",
"]",
"ncsOps",
"=",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
";",
"for",
"(",
"Chain",
"c",
":",
"structure",
".",
"getChains",
"(",
")",
")",
"{",
"String",
"cOrigId",
"=",
"c",
".",
"getId",
"(",
")",
";",
"String",
"cOrigName",
"=",
"c",
".",
"getName",
"(",
")",
";",
"for",
"(",
"int",
"iOperator",
"=",
"0",
";",
"iOperator",
"<",
"ncsOps",
".",
"length",
";",
"iOperator",
"++",
")",
"{",
"Matrix4d",
"m",
"=",
"ncsOps",
"[",
"iOperator",
"]",
";",
"Chain",
"clonedChain",
"=",
"(",
"Chain",
")",
"c",
".",
"clone",
"(",
")",
";",
"String",
"newChainId",
"=",
"cOrigId",
"+",
"(",
"iOperator",
"+",
"1",
")",
"+",
"NCS_CHAINID_SUFFIX_CHAR",
";",
"String",
"newChainName",
"=",
"cOrigName",
"+",
"(",
"iOperator",
"+",
"1",
")",
"+",
"NCS_CHAINID_SUFFIX_CHAR",
";",
"clonedChain",
".",
"setId",
"(",
"newChainId",
")",
";",
"clonedChain",
".",
"setName",
"(",
"newChainName",
")",
";",
"setChainIdsInResidueNumbers",
"(",
"clonedChain",
",",
"newChainName",
")",
";",
"Calc",
".",
"transform",
"(",
"clonedChain",
",",
"m",
")",
";",
"chainsToAdd",
".",
"add",
"(",
"clonedChain",
")",
";",
"c",
".",
"getEntityInfo",
"(",
")",
".",
"addChain",
"(",
"clonedChain",
")",
";",
"chainOrigNames",
".",
"put",
"(",
"newChainName",
",",
"cOrigName",
")",
";",
"chainNcsOps",
".",
"put",
"(",
"newChainName",
",",
"m",
")",
";",
"}",
"chainNcsOps",
".",
"put",
"(",
"cOrigName",
",",
"identity",
")",
";",
"chainOrigNames",
".",
"put",
"(",
"cOrigName",
",",
"cOrigName",
")",
";",
"}",
"chainsToAdd",
".",
"forEach",
"(",
"structure",
"::",
"addChain",
")",
";",
"}"
] |
Apply the NCS operators in the given Structure adding new chains as needed.
All chains are (re)assigned ids of the form: original_chain_id+ncs_operator_index+{@value #NCS_CHAINID_SUFFIX_CHAR}.
@param structure
the structure to expand
@param chainOrigNames
new chain names mapped to the original chain names
@param chainNcsOps
new chain names mapped to the ncs operators that was used to generate them
@since 5.0.0
|
[
"Apply",
"the",
"NCS",
"operators",
"in",
"the",
"given",
"Structure",
"adding",
"new",
"chains",
"as",
"needed",
".",
"All",
"chains",
"are",
"(",
"re",
")",
"assigned",
"ids",
"of",
"the",
"form",
":",
"original_chain_id",
"+",
"ncs_operator_index",
"+",
"{"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java#L569-L611
|
Baidu-AIP/java-sdk
|
src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java
|
AipImageSearch.productAddUrl
|
public JSONObject productAddUrl(String url, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("url", url);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.PRODUCT_ADD);
postOperation(request);
return requestServer(request);
}
|
java
|
public JSONObject productAddUrl(String url, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("url", url);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.PRODUCT_ADD);
postOperation(request);
return requestServer(request);
}
|
[
"public",
"JSONObject",
"productAddUrl",
"(",
"String",
"url",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"AipRequest",
"request",
"=",
"new",
"AipRequest",
"(",
")",
";",
"preOperation",
"(",
"request",
")",
";",
"request",
".",
"addBody",
"(",
"\"url\"",
",",
"url",
")",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"request",
".",
"addBody",
"(",
"options",
")",
";",
"}",
"request",
".",
"setUri",
"(",
"ImageSearchConsts",
".",
"PRODUCT_ADD",
")",
";",
"postOperation",
"(",
"request",
")",
";",
"return",
"requestServer",
"(",
"request",
")",
";",
"}"
] |
商品检索—入库接口
**该接口实现单张图片入库,入库时需要同步提交图片及可关联至本地图库的摘要信息(具体变量为brief,具体可传入图片在本地标记id、图片url、图片名称等)。同时可提交分类维度信息(具体变量为class_id1、class_id2),方便对图库中的图片进行管理、分类检索。****注:重复添加完全相同的图片会返回错误。**
@param url - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
@param options - 可选参数对象,key: value都为string类型
options - options列表:
brief 检索时原样带回,最长256B。**请注意,检索接口不返回原图,仅反馈当前填写的brief信息,所以调用该入库接口时,brief信息请尽量填写可关联至本地图库的图片id或者图片url、图片名称等信息**
class_id1 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
class_id2 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
@return JSONObject
|
[
"商品检索—入库接口",
"**",
"该接口实现单张图片入库,入库时需要同步提交图片及可关联至本地图库的摘要信息(具体变量为brief,具体可传入图片在本地标记id、图片url、图片名称等)。同时可提交分类维度信息(具体变量为class_id1、class_id2),方便对图库中的图片进行管理、分类检索。",
"****",
"注:重复添加完全相同的图片会返回错误。",
"**"
] |
train
|
https://github.com/Baidu-AIP/java-sdk/blob/16bb8b7bb8f9bbcb7c8af62d0a67a1e79eecad90/src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java#L744-L755
|
infinispan/infinispan
|
core/src/main/java/org/infinispan/remoting/transport/AbstractRequest.java
|
AbstractRequest.setTimeout
|
public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
cancelTimeoutTask();
ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
setTimeoutFuture(timeoutFuture);
}
|
java
|
public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
cancelTimeoutTask();
ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
setTimeoutFuture(timeoutFuture);
}
|
[
"public",
"void",
"setTimeout",
"(",
"ScheduledExecutorService",
"timeoutExecutor",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"cancelTimeoutTask",
"(",
")",
";",
"ScheduledFuture",
"<",
"Void",
">",
"timeoutFuture",
"=",
"timeoutExecutor",
".",
"schedule",
"(",
"this",
",",
"timeout",
",",
"unit",
")",
";",
"setTimeoutFuture",
"(",
"timeoutFuture",
")",
";",
"}"
] |
Schedule a timeout task on the given executor, and complete the request with a {@link
org.infinispan.util.concurrent.TimeoutException}
when the task runs.
If a timeout task was already registered with this request, it is cancelled.
|
[
"Schedule",
"a",
"timeout",
"task",
"on",
"the",
"given",
"executor",
"and",
"complete",
"the",
"request",
"with",
"a",
"{",
"@link",
"org",
".",
"infinispan",
".",
"util",
".",
"concurrent",
".",
"TimeoutException",
"}",
"when",
"the",
"task",
"runs",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/remoting/transport/AbstractRequest.java#L52-L56
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java
|
FilesImpl.listFromComputeNode
|
public PagedList<NodeFile> listFromComputeNode(final String poolId, final String nodeId, final Boolean recursive, final FileListFromComputeNodeOptions fileListFromComputeNodeOptions) {
ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> response = listFromComputeNodeSinglePageAsync(poolId, nodeId, recursive, fileListFromComputeNodeOptions).toBlocking().single();
return new PagedList<NodeFile>(response.body()) {
@Override
public Page<NodeFile> nextPage(String nextPageLink) {
FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions = null;
if (fileListFromComputeNodeOptions != null) {
fileListFromComputeNodeNextOptions = new FileListFromComputeNodeNextOptions();
fileListFromComputeNodeNextOptions.withClientRequestId(fileListFromComputeNodeOptions.clientRequestId());
fileListFromComputeNodeNextOptions.withReturnClientRequestId(fileListFromComputeNodeOptions.returnClientRequestId());
fileListFromComputeNodeNextOptions.withOcpDate(fileListFromComputeNodeOptions.ocpDate());
}
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single().body();
}
};
}
|
java
|
public PagedList<NodeFile> listFromComputeNode(final String poolId, final String nodeId, final Boolean recursive, final FileListFromComputeNodeOptions fileListFromComputeNodeOptions) {
ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> response = listFromComputeNodeSinglePageAsync(poolId, nodeId, recursive, fileListFromComputeNodeOptions).toBlocking().single();
return new PagedList<NodeFile>(response.body()) {
@Override
public Page<NodeFile> nextPage(String nextPageLink) {
FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions = null;
if (fileListFromComputeNodeOptions != null) {
fileListFromComputeNodeNextOptions = new FileListFromComputeNodeNextOptions();
fileListFromComputeNodeNextOptions.withClientRequestId(fileListFromComputeNodeOptions.clientRequestId());
fileListFromComputeNodeNextOptions.withReturnClientRequestId(fileListFromComputeNodeOptions.returnClientRequestId());
fileListFromComputeNodeNextOptions.withOcpDate(fileListFromComputeNodeOptions.ocpDate());
}
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions).toBlocking().single().body();
}
};
}
|
[
"public",
"PagedList",
"<",
"NodeFile",
">",
"listFromComputeNode",
"(",
"final",
"String",
"poolId",
",",
"final",
"String",
"nodeId",
",",
"final",
"Boolean",
"recursive",
",",
"final",
"FileListFromComputeNodeOptions",
"fileListFromComputeNodeOptions",
")",
"{",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
"response",
"=",
"listFromComputeNodeSinglePageAsync",
"(",
"poolId",
",",
"nodeId",
",",
"recursive",
",",
"fileListFromComputeNodeOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
";",
"return",
"new",
"PagedList",
"<",
"NodeFile",
">",
"(",
"response",
".",
"body",
"(",
")",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"NodeFile",
">",
"nextPage",
"(",
"String",
"nextPageLink",
")",
"{",
"FileListFromComputeNodeNextOptions",
"fileListFromComputeNodeNextOptions",
"=",
"null",
";",
"if",
"(",
"fileListFromComputeNodeOptions",
"!=",
"null",
")",
"{",
"fileListFromComputeNodeNextOptions",
"=",
"new",
"FileListFromComputeNodeNextOptions",
"(",
")",
";",
"fileListFromComputeNodeNextOptions",
".",
"withClientRequestId",
"(",
"fileListFromComputeNodeOptions",
".",
"clientRequestId",
"(",
")",
")",
";",
"fileListFromComputeNodeNextOptions",
".",
"withReturnClientRequestId",
"(",
"fileListFromComputeNodeOptions",
".",
"returnClientRequestId",
"(",
")",
")",
";",
"fileListFromComputeNodeNextOptions",
".",
"withOcpDate",
"(",
"fileListFromComputeNodeOptions",
".",
"ocpDate",
"(",
")",
")",
";",
"}",
"return",
"listFromComputeNodeNextSinglePageAsync",
"(",
"nextPageLink",
",",
"fileListFromComputeNodeNextOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Lists all of the files in task directories on the specified compute node.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node whose files you want to list.
@param recursive Whether to list children of a directory.
@param fileListFromComputeNodeOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PagedList<NodeFile> object if successful.
|
[
"Lists",
"all",
"of",
"the",
"files",
"in",
"task",
"directories",
"on",
"the",
"specified",
"compute",
"node",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java#L2049-L2064
|
qspin/qtaste
|
plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java
|
ComponentCommander.lookForComponent
|
protected Component lookForComponent(String name, ObservableList<Node> components) {
for (int i = 0; i < components.size() && !mFindWithEqual; i++) {
//String componentName = ComponentNamer.getInstance().getNameForComponent(components[c]);
Node c = components.get(i);
checkName(name, c);
if (!mFindWithEqual) {
if (c instanceof Parent) {
Component result = lookForComponent(name, ((Parent) c).getChildrenUnmodifiable());
if (result != null) {
return result;
}
}
}
}
return null;
}
|
java
|
protected Component lookForComponent(String name, ObservableList<Node> components) {
for (int i = 0; i < components.size() && !mFindWithEqual; i++) {
//String componentName = ComponentNamer.getInstance().getNameForComponent(components[c]);
Node c = components.get(i);
checkName(name, c);
if (!mFindWithEqual) {
if (c instanceof Parent) {
Component result = lookForComponent(name, ((Parent) c).getChildrenUnmodifiable());
if (result != null) {
return result;
}
}
}
}
return null;
}
|
[
"protected",
"Component",
"lookForComponent",
"(",
"String",
"name",
",",
"ObservableList",
"<",
"Node",
">",
"components",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"components",
".",
"size",
"(",
")",
"&&",
"!",
"mFindWithEqual",
";",
"i",
"++",
")",
"{",
"//String componentName = ComponentNamer.getInstance().getNameForComponent(components[c]);",
"Node",
"c",
"=",
"components",
".",
"get",
"(",
"i",
")",
";",
"checkName",
"(",
"name",
",",
"c",
")",
";",
"if",
"(",
"!",
"mFindWithEqual",
")",
"{",
"if",
"(",
"c",
"instanceof",
"Parent",
")",
"{",
"Component",
"result",
"=",
"lookForComponent",
"(",
"name",
",",
"(",
"(",
"Parent",
")",
"c",
")",
".",
"getChildrenUnmodifiable",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Browses recursively the components in order to find components with the name.
@param name the component's name.
@param components components to browse.
@return the first component with the name.
|
[
"Browses",
"recursively",
"the",
"components",
"in",
"order",
"to",
"find",
"components",
"with",
"the",
"name",
"."
] |
train
|
https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java#L105-L120
|
opencb/biodata
|
biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamUtils.java
|
BamUtils.checkBamOrCramFile
|
public static void checkBamOrCramFile(InputStream is, String bamFileName, boolean checkSort) throws IOException {
SamReaderFactory srf = SamReaderFactory.make();
srf.validationStringency(ValidationStringency.LENIENT);
SamReader reader = srf.open(SamInputResource.of(is));
SAMFileHeader fileHeader = reader.getFileHeader();
SAMFileHeader.SortOrder sortOrder = fileHeader.getSortOrder();
reader.close();
if (reader.type().equals(SamReader.Type.SAM_TYPE)) {
throw new IOException("Expected binary SAM file. File " + bamFileName + " is not binary.");
}
if (checkSort) {
switch (sortOrder) {
case coordinate:
break;
case queryname:
case unsorted:
default:
throw new IOException("Expected sorted file. File '" + bamFileName + "' is not sorted by coordinates("
+ sortOrder.name() + ")");
}
}
}
|
java
|
public static void checkBamOrCramFile(InputStream is, String bamFileName, boolean checkSort) throws IOException {
SamReaderFactory srf = SamReaderFactory.make();
srf.validationStringency(ValidationStringency.LENIENT);
SamReader reader = srf.open(SamInputResource.of(is));
SAMFileHeader fileHeader = reader.getFileHeader();
SAMFileHeader.SortOrder sortOrder = fileHeader.getSortOrder();
reader.close();
if (reader.type().equals(SamReader.Type.SAM_TYPE)) {
throw new IOException("Expected binary SAM file. File " + bamFileName + " is not binary.");
}
if (checkSort) {
switch (sortOrder) {
case coordinate:
break;
case queryname:
case unsorted:
default:
throw new IOException("Expected sorted file. File '" + bamFileName + "' is not sorted by coordinates("
+ sortOrder.name() + ")");
}
}
}
|
[
"public",
"static",
"void",
"checkBamOrCramFile",
"(",
"InputStream",
"is",
",",
"String",
"bamFileName",
",",
"boolean",
"checkSort",
")",
"throws",
"IOException",
"{",
"SamReaderFactory",
"srf",
"=",
"SamReaderFactory",
".",
"make",
"(",
")",
";",
"srf",
".",
"validationStringency",
"(",
"ValidationStringency",
".",
"LENIENT",
")",
";",
"SamReader",
"reader",
"=",
"srf",
".",
"open",
"(",
"SamInputResource",
".",
"of",
"(",
"is",
")",
")",
";",
"SAMFileHeader",
"fileHeader",
"=",
"reader",
".",
"getFileHeader",
"(",
")",
";",
"SAMFileHeader",
".",
"SortOrder",
"sortOrder",
"=",
"fileHeader",
".",
"getSortOrder",
"(",
")",
";",
"reader",
".",
"close",
"(",
")",
";",
"if",
"(",
"reader",
".",
"type",
"(",
")",
".",
"equals",
"(",
"SamReader",
".",
"Type",
".",
"SAM_TYPE",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expected binary SAM file. File \"",
"+",
"bamFileName",
"+",
"\" is not binary.\"",
")",
";",
"}",
"if",
"(",
"checkSort",
")",
"{",
"switch",
"(",
"sortOrder",
")",
"{",
"case",
"coordinate",
":",
"break",
";",
"case",
"queryname",
":",
"case",
"unsorted",
":",
"default",
":",
"throw",
"new",
"IOException",
"(",
"\"Expected sorted file. File '\"",
"+",
"bamFileName",
"+",
"\"' is not sorted by coordinates(\"",
"+",
"sortOrder",
".",
"name",
"(",
")",
"+",
"\")\"",
")",
";",
"}",
"}",
"}"
] |
Check if the file is a sorted binary bam file.
@param is Bam InputStream
@param bamFileName Bam FileName
@param checkSort
@throws IOException
|
[
"Check",
"if",
"the",
"file",
"is",
"a",
"sorted",
"binary",
"bam",
"file",
"."
] |
train
|
https://github.com/opencb/biodata/blob/21b3d51d71f578efab908422aca4bab7a73097b1/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamUtils.java#L134-L158
|
spring-projects/spring-boot
|
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java
|
Bindable.mapOf
|
public static <K, V> Bindable<Map<K, V>> mapOf(Class<K> keyType, Class<V> valueType) {
return of(ResolvableType.forClassWithGenerics(Map.class, keyType, valueType));
}
|
java
|
public static <K, V> Bindable<Map<K, V>> mapOf(Class<K> keyType, Class<V> valueType) {
return of(ResolvableType.forClassWithGenerics(Map.class, keyType, valueType));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Bindable",
"<",
"Map",
"<",
"K",
",",
"V",
">",
">",
"mapOf",
"(",
"Class",
"<",
"K",
">",
"keyType",
",",
"Class",
"<",
"V",
">",
"valueType",
")",
"{",
"return",
"of",
"(",
"ResolvableType",
".",
"forClassWithGenerics",
"(",
"Map",
".",
"class",
",",
"keyType",
",",
"valueType",
")",
")",
";",
"}"
] |
Create a new {@link Bindable} {@link Map} of the specified key and value type.
@param <K> the key type
@param <V> the value type
@param keyType the map key type
@param valueType the map value type
@return a {@link Bindable} instance
|
[
"Create",
"a",
"new",
"{"
] |
train
|
https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java#L235-L237
|
charithe/kafka-junit
|
src/main/java/com/github/charithe/kafka/KafkaHelper.java
|
KafkaHelper.produceStrings
|
public void produceStrings(String topic, String... values) {
try (KafkaProducer<String, String> producer = createStringProducer()) {
Map<String, String> data = Arrays.stream(values)
.collect(Collectors.toMap(k -> String.valueOf(k.hashCode()), Function.identity()));
produce(topic, producer, data);
}
}
|
java
|
public void produceStrings(String topic, String... values) {
try (KafkaProducer<String, String> producer = createStringProducer()) {
Map<String, String> data = Arrays.stream(values)
.collect(Collectors.toMap(k -> String.valueOf(k.hashCode()), Function.identity()));
produce(topic, producer, data);
}
}
|
[
"public",
"void",
"produceStrings",
"(",
"String",
"topic",
",",
"String",
"...",
"values",
")",
"{",
"try",
"(",
"KafkaProducer",
"<",
"String",
",",
"String",
">",
"producer",
"=",
"createStringProducer",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"data",
"=",
"Arrays",
".",
"stream",
"(",
"values",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"k",
"->",
"String",
".",
"valueOf",
"(",
"k",
".",
"hashCode",
"(",
")",
")",
",",
"Function",
".",
"identity",
"(",
")",
")",
")",
";",
"produce",
"(",
"topic",
",",
"producer",
",",
"data",
")",
";",
"}",
"}"
] |
Convenience method to produce a set of strings to the specified topic
@param topic Topic to produce to
@param values Values produce
|
[
"Convenience",
"method",
"to",
"produce",
"a",
"set",
"of",
"strings",
"to",
"the",
"specified",
"topic"
] |
train
|
https://github.com/charithe/kafka-junit/blob/b808b3d1dec8105346d316f92f68950f36aeb871/src/main/java/com/github/charithe/kafka/KafkaHelper.java#L190-L196
|
stratosphere/stratosphere
|
stratosphere-runtime/src/main/java/eu/stratosphere/nephele/executiongraph/ExecutionGraph.java
|
ExecutionGraph.constructExecutionGraph
|
private void constructExecutionGraph(final JobGraph jobGraph, final InstanceManager instanceManager)
throws GraphConversionException {
// Clean up temporary data structures
final HashMap<AbstractJobVertex, ExecutionVertex> temporaryVertexMap = new HashMap<AbstractJobVertex, ExecutionVertex>();
final HashMap<AbstractJobVertex, ExecutionGroupVertex> temporaryGroupVertexMap = new HashMap<AbstractJobVertex, ExecutionGroupVertex>();
// Initially, create only one execution stage that contains all group vertices
final ExecutionStage initialExecutionStage = new ExecutionStage(this, 0);
this.stages.add(initialExecutionStage);
// Convert job vertices to execution vertices and initialize them
final AbstractJobVertex[] all = jobGraph.getAllJobVertices();
for (int i = 0; i < all.length; i++) {
final ExecutionVertex createdVertex = createVertex(all[i], instanceManager, initialExecutionStage,
jobGraph.getJobConfiguration());
temporaryVertexMap.put(all[i], createdVertex);
temporaryGroupVertexMap.put(all[i], createdVertex.getGroupVertex());
}
// Create initial edges between the vertices
createInitialGroupEdges(temporaryVertexMap);
// Now that an initial graph is built, apply the user settings
applyUserDefinedSettings(temporaryGroupVertexMap);
// Calculate the connection IDs
calculateConnectionIDs();
// Finally, construct the execution pipelines
reconstructExecutionPipelines();
}
|
java
|
private void constructExecutionGraph(final JobGraph jobGraph, final InstanceManager instanceManager)
throws GraphConversionException {
// Clean up temporary data structures
final HashMap<AbstractJobVertex, ExecutionVertex> temporaryVertexMap = new HashMap<AbstractJobVertex, ExecutionVertex>();
final HashMap<AbstractJobVertex, ExecutionGroupVertex> temporaryGroupVertexMap = new HashMap<AbstractJobVertex, ExecutionGroupVertex>();
// Initially, create only one execution stage that contains all group vertices
final ExecutionStage initialExecutionStage = new ExecutionStage(this, 0);
this.stages.add(initialExecutionStage);
// Convert job vertices to execution vertices and initialize them
final AbstractJobVertex[] all = jobGraph.getAllJobVertices();
for (int i = 0; i < all.length; i++) {
final ExecutionVertex createdVertex = createVertex(all[i], instanceManager, initialExecutionStage,
jobGraph.getJobConfiguration());
temporaryVertexMap.put(all[i], createdVertex);
temporaryGroupVertexMap.put(all[i], createdVertex.getGroupVertex());
}
// Create initial edges between the vertices
createInitialGroupEdges(temporaryVertexMap);
// Now that an initial graph is built, apply the user settings
applyUserDefinedSettings(temporaryGroupVertexMap);
// Calculate the connection IDs
calculateConnectionIDs();
// Finally, construct the execution pipelines
reconstructExecutionPipelines();
}
|
[
"private",
"void",
"constructExecutionGraph",
"(",
"final",
"JobGraph",
"jobGraph",
",",
"final",
"InstanceManager",
"instanceManager",
")",
"throws",
"GraphConversionException",
"{",
"// Clean up temporary data structures",
"final",
"HashMap",
"<",
"AbstractJobVertex",
",",
"ExecutionVertex",
">",
"temporaryVertexMap",
"=",
"new",
"HashMap",
"<",
"AbstractJobVertex",
",",
"ExecutionVertex",
">",
"(",
")",
";",
"final",
"HashMap",
"<",
"AbstractJobVertex",
",",
"ExecutionGroupVertex",
">",
"temporaryGroupVertexMap",
"=",
"new",
"HashMap",
"<",
"AbstractJobVertex",
",",
"ExecutionGroupVertex",
">",
"(",
")",
";",
"// Initially, create only one execution stage that contains all group vertices",
"final",
"ExecutionStage",
"initialExecutionStage",
"=",
"new",
"ExecutionStage",
"(",
"this",
",",
"0",
")",
";",
"this",
".",
"stages",
".",
"add",
"(",
"initialExecutionStage",
")",
";",
"// Convert job vertices to execution vertices and initialize them",
"final",
"AbstractJobVertex",
"[",
"]",
"all",
"=",
"jobGraph",
".",
"getAllJobVertices",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"all",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"ExecutionVertex",
"createdVertex",
"=",
"createVertex",
"(",
"all",
"[",
"i",
"]",
",",
"instanceManager",
",",
"initialExecutionStage",
",",
"jobGraph",
".",
"getJobConfiguration",
"(",
")",
")",
";",
"temporaryVertexMap",
".",
"put",
"(",
"all",
"[",
"i",
"]",
",",
"createdVertex",
")",
";",
"temporaryGroupVertexMap",
".",
"put",
"(",
"all",
"[",
"i",
"]",
",",
"createdVertex",
".",
"getGroupVertex",
"(",
")",
")",
";",
"}",
"// Create initial edges between the vertices",
"createInitialGroupEdges",
"(",
"temporaryVertexMap",
")",
";",
"// Now that an initial graph is built, apply the user settings",
"applyUserDefinedSettings",
"(",
"temporaryGroupVertexMap",
")",
";",
"// Calculate the connection IDs",
"calculateConnectionIDs",
"(",
")",
";",
"// Finally, construct the execution pipelines",
"reconstructExecutionPipelines",
"(",
")",
";",
"}"
] |
Sets up an execution graph from a job graph.
@param jobGraph
the job graph to create the execution graph from
@param instanceManager
the instance manager
@throws GraphConversionException
thrown if the job graph is not valid and no execution graph can be constructed from it
|
[
"Sets",
"up",
"an",
"execution",
"graph",
"from",
"a",
"job",
"graph",
"."
] |
train
|
https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/executiongraph/ExecutionGraph.java#L261-L292
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/db/GridTable.java
|
GridTable.addNewBookmark
|
public int addNewBookmark(Object bookmark, int iHandleType)
{
if (bookmark == null)
return -1;
if (iHandleType != DBConstants.DATA_SOURCE_HANDLE)
{ // The only thing that I know for sure is the bookmark is correct.
DataRecord dataRecord = new DataRecord(null);
dataRecord.setHandle(bookmark, iHandleType);
bookmark = dataRecord;
}
int iIndexAdded = m_iEndOfFileIndex;
if (m_iEndOfFileIndex == -1)
{ // End of file has not been reached - add this record to the "Add" buffer.
// Add code here
}
else
{
// Update the record cached at this location
m_gridBuffer.addElement(m_iEndOfFileIndex, bookmark, m_gridList);
m_iEndOfFileIndex++;
}
return iIndexAdded;
}
|
java
|
public int addNewBookmark(Object bookmark, int iHandleType)
{
if (bookmark == null)
return -1;
if (iHandleType != DBConstants.DATA_SOURCE_HANDLE)
{ // The only thing that I know for sure is the bookmark is correct.
DataRecord dataRecord = new DataRecord(null);
dataRecord.setHandle(bookmark, iHandleType);
bookmark = dataRecord;
}
int iIndexAdded = m_iEndOfFileIndex;
if (m_iEndOfFileIndex == -1)
{ // End of file has not been reached - add this record to the "Add" buffer.
// Add code here
}
else
{
// Update the record cached at this location
m_gridBuffer.addElement(m_iEndOfFileIndex, bookmark, m_gridList);
m_iEndOfFileIndex++;
}
return iIndexAdded;
}
|
[
"public",
"int",
"addNewBookmark",
"(",
"Object",
"bookmark",
",",
"int",
"iHandleType",
")",
"{",
"if",
"(",
"bookmark",
"==",
"null",
")",
"return",
"-",
"1",
";",
"if",
"(",
"iHandleType",
"!=",
"DBConstants",
".",
"DATA_SOURCE_HANDLE",
")",
"{",
"// The only thing that I know for sure is the bookmark is correct.",
"DataRecord",
"dataRecord",
"=",
"new",
"DataRecord",
"(",
"null",
")",
";",
"dataRecord",
".",
"setHandle",
"(",
"bookmark",
",",
"iHandleType",
")",
";",
"bookmark",
"=",
"dataRecord",
";",
"}",
"int",
"iIndexAdded",
"=",
"m_iEndOfFileIndex",
";",
"if",
"(",
"m_iEndOfFileIndex",
"==",
"-",
"1",
")",
"{",
"// End of file has not been reached - add this record to the \"Add\" buffer.",
"// Add code here",
"}",
"else",
"{",
"// Update the record cached at this location",
"m_gridBuffer",
".",
"addElement",
"(",
"m_iEndOfFileIndex",
",",
"bookmark",
",",
"m_gridList",
")",
";",
"m_iEndOfFileIndex",
"++",
";",
"}",
"return",
"iIndexAdded",
";",
"}"
] |
Here is a bookmark for a brand new record, add it to the end of the list.
@param bookmark The bookmark (usually a DataRecord) of the record to add.
@param iHandleType The type of bookmark to add.
@return the index of the new entry.
|
[
"Here",
"is",
"a",
"bookmark",
"for",
"a",
"brand",
"new",
"record",
"add",
"it",
"to",
"the",
"end",
"of",
"the",
"list",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/GridTable.java#L665-L688
|
google/error-prone
|
core/src/main/java/com/google/errorprone/bugpatterns/AbstractJUnit4InitMethodNotRun.java
|
AbstractJUnit4InitMethodNotRun.matchMethod
|
@Override
public Description matchMethod(MethodTree methodTree, VisitorState state) {
boolean matches =
allOf(
methodMatcher(),
not(hasAnnotationOnAnyOverriddenMethod(JUNIT_TEST)),
enclosingClass(isJUnit4TestClass))
.matches(methodTree, state);
if (!matches) {
return Description.NO_MATCH;
}
// For each annotationReplacement, replace the first annotation that matches. If any of them
// matches, don't try and do the rest of the work.
Description description;
for (AnnotationReplacements replacement : annotationReplacements()) {
description =
tryToReplaceAnnotation(
methodTree, state, replacement.badAnnotation, replacement.goodAnnotation);
if (description != null) {
return description;
}
}
// Search for another @Before annotation on the method and replace the import
// if we find one
String correctAnnotation = correctAnnotation();
String unqualifiedClassName = getUnqualifiedClassName(correctAnnotation);
for (AnnotationTree annotationNode : methodTree.getModifiers().getAnnotations()) {
Symbol annoSymbol = ASTHelpers.getSymbol(annotationNode);
if (annoSymbol.getSimpleName().contentEquals(unqualifiedClassName)) {
SuggestedFix.Builder suggestedFix =
SuggestedFix.builder()
.removeImport(annoSymbol.getQualifiedName().toString())
.addImport(correctAnnotation);
makeProtectedPublic(methodTree, state, suggestedFix);
return describeMatch(annotationNode, suggestedFix.build());
}
}
// Add correctAnnotation() to the unannotated method
// (and convert protected to public if it is)
SuggestedFix.Builder suggestedFix = SuggestedFix.builder().addImport(correctAnnotation);
makeProtectedPublic(methodTree, state, suggestedFix);
suggestedFix.prefixWith(methodTree, "@" + unqualifiedClassName + "\n");
return describeMatch(methodTree, suggestedFix.build());
}
|
java
|
@Override
public Description matchMethod(MethodTree methodTree, VisitorState state) {
boolean matches =
allOf(
methodMatcher(),
not(hasAnnotationOnAnyOverriddenMethod(JUNIT_TEST)),
enclosingClass(isJUnit4TestClass))
.matches(methodTree, state);
if (!matches) {
return Description.NO_MATCH;
}
// For each annotationReplacement, replace the first annotation that matches. If any of them
// matches, don't try and do the rest of the work.
Description description;
for (AnnotationReplacements replacement : annotationReplacements()) {
description =
tryToReplaceAnnotation(
methodTree, state, replacement.badAnnotation, replacement.goodAnnotation);
if (description != null) {
return description;
}
}
// Search for another @Before annotation on the method and replace the import
// if we find one
String correctAnnotation = correctAnnotation();
String unqualifiedClassName = getUnqualifiedClassName(correctAnnotation);
for (AnnotationTree annotationNode : methodTree.getModifiers().getAnnotations()) {
Symbol annoSymbol = ASTHelpers.getSymbol(annotationNode);
if (annoSymbol.getSimpleName().contentEquals(unqualifiedClassName)) {
SuggestedFix.Builder suggestedFix =
SuggestedFix.builder()
.removeImport(annoSymbol.getQualifiedName().toString())
.addImport(correctAnnotation);
makeProtectedPublic(methodTree, state, suggestedFix);
return describeMatch(annotationNode, suggestedFix.build());
}
}
// Add correctAnnotation() to the unannotated method
// (and convert protected to public if it is)
SuggestedFix.Builder suggestedFix = SuggestedFix.builder().addImport(correctAnnotation);
makeProtectedPublic(methodTree, state, suggestedFix);
suggestedFix.prefixWith(methodTree, "@" + unqualifiedClassName + "\n");
return describeMatch(methodTree, suggestedFix.build());
}
|
[
"@",
"Override",
"public",
"Description",
"matchMethod",
"(",
"MethodTree",
"methodTree",
",",
"VisitorState",
"state",
")",
"{",
"boolean",
"matches",
"=",
"allOf",
"(",
"methodMatcher",
"(",
")",
",",
"not",
"(",
"hasAnnotationOnAnyOverriddenMethod",
"(",
"JUNIT_TEST",
")",
")",
",",
"enclosingClass",
"(",
"isJUnit4TestClass",
")",
")",
".",
"matches",
"(",
"methodTree",
",",
"state",
")",
";",
"if",
"(",
"!",
"matches",
")",
"{",
"return",
"Description",
".",
"NO_MATCH",
";",
"}",
"// For each annotationReplacement, replace the first annotation that matches. If any of them",
"// matches, don't try and do the rest of the work.",
"Description",
"description",
";",
"for",
"(",
"AnnotationReplacements",
"replacement",
":",
"annotationReplacements",
"(",
")",
")",
"{",
"description",
"=",
"tryToReplaceAnnotation",
"(",
"methodTree",
",",
"state",
",",
"replacement",
".",
"badAnnotation",
",",
"replacement",
".",
"goodAnnotation",
")",
";",
"if",
"(",
"description",
"!=",
"null",
")",
"{",
"return",
"description",
";",
"}",
"}",
"// Search for another @Before annotation on the method and replace the import",
"// if we find one",
"String",
"correctAnnotation",
"=",
"correctAnnotation",
"(",
")",
";",
"String",
"unqualifiedClassName",
"=",
"getUnqualifiedClassName",
"(",
"correctAnnotation",
")",
";",
"for",
"(",
"AnnotationTree",
"annotationNode",
":",
"methodTree",
".",
"getModifiers",
"(",
")",
".",
"getAnnotations",
"(",
")",
")",
"{",
"Symbol",
"annoSymbol",
"=",
"ASTHelpers",
".",
"getSymbol",
"(",
"annotationNode",
")",
";",
"if",
"(",
"annoSymbol",
".",
"getSimpleName",
"(",
")",
".",
"contentEquals",
"(",
"unqualifiedClassName",
")",
")",
"{",
"SuggestedFix",
".",
"Builder",
"suggestedFix",
"=",
"SuggestedFix",
".",
"builder",
"(",
")",
".",
"removeImport",
"(",
"annoSymbol",
".",
"getQualifiedName",
"(",
")",
".",
"toString",
"(",
")",
")",
".",
"addImport",
"(",
"correctAnnotation",
")",
";",
"makeProtectedPublic",
"(",
"methodTree",
",",
"state",
",",
"suggestedFix",
")",
";",
"return",
"describeMatch",
"(",
"annotationNode",
",",
"suggestedFix",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"// Add correctAnnotation() to the unannotated method",
"// (and convert protected to public if it is)",
"SuggestedFix",
".",
"Builder",
"suggestedFix",
"=",
"SuggestedFix",
".",
"builder",
"(",
")",
".",
"addImport",
"(",
"correctAnnotation",
")",
";",
"makeProtectedPublic",
"(",
"methodTree",
",",
"state",
",",
"suggestedFix",
")",
";",
"suggestedFix",
".",
"prefixWith",
"(",
"methodTree",
",",
"\"@\"",
"+",
"unqualifiedClassName",
"+",
"\"\\n\"",
")",
";",
"return",
"describeMatch",
"(",
"methodTree",
",",
"suggestedFix",
".",
"build",
"(",
")",
")",
";",
"}"
] |
Matches if all of the following conditions are true: 1) The method matches {@link
#methodMatcher()}, (looks like setUp() or tearDown(), and none of the overrides in the
hierarchy of the method have the appropriate @Before or @After annotations) 2) The method is
not annotated with @Test 3) The enclosing class has an @RunWith annotation and does not extend
TestCase. This marks that the test is intended to run with JUnit 4.
|
[
"Matches",
"if",
"all",
"of",
"the",
"following",
"conditions",
"are",
"true",
":",
"1",
")",
"The",
"method",
"matches",
"{"
] |
train
|
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractJUnit4InitMethodNotRun.java#L84-L130
|
j256/ormlite-android
|
src/main/java/com/j256/ormlite/android/apptools/OrmLiteConfigUtil.java
|
OrmLiteConfigUtil.writeConfigFile
|
public static void writeConfigFile(String fileName, Class<?>[] classes, boolean sortClasses)
throws SQLException, IOException {
File rawDir = findRawDir(new File("."));
if (rawDir == null) {
System.err.println("Could not find " + RAW_DIR_NAME + " directory which is typically in the "
+ RESOURCE_DIR_NAME + " directory");
} else {
File configFile = new File(rawDir, fileName);
writeConfigFile(configFile, classes, sortClasses);
}
}
|
java
|
public static void writeConfigFile(String fileName, Class<?>[] classes, boolean sortClasses)
throws SQLException, IOException {
File rawDir = findRawDir(new File("."));
if (rawDir == null) {
System.err.println("Could not find " + RAW_DIR_NAME + " directory which is typically in the "
+ RESOURCE_DIR_NAME + " directory");
} else {
File configFile = new File(rawDir, fileName);
writeConfigFile(configFile, classes, sortClasses);
}
}
|
[
"public",
"static",
"void",
"writeConfigFile",
"(",
"String",
"fileName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
",",
"boolean",
"sortClasses",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"File",
"rawDir",
"=",
"findRawDir",
"(",
"new",
"File",
"(",
"\".\"",
")",
")",
";",
"if",
"(",
"rawDir",
"==",
"null",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Could not find \"",
"+",
"RAW_DIR_NAME",
"+",
"\" directory which is typically in the \"",
"+",
"RESOURCE_DIR_NAME",
"+",
"\" directory\"",
")",
";",
"}",
"else",
"{",
"File",
"configFile",
"=",
"new",
"File",
"(",
"rawDir",
",",
"fileName",
")",
";",
"writeConfigFile",
"(",
"configFile",
",",
"classes",
",",
"sortClasses",
")",
";",
"}",
"}"
] |
Writes a configuration fileName in the raw directory with the configuration for classes.
@param sortClasses
Set to true to sort the classes by name before the file is generated.
|
[
"Writes",
"a",
"configuration",
"fileName",
"in",
"the",
"raw",
"directory",
"with",
"the",
"configuration",
"for",
"classes",
"."
] |
train
|
https://github.com/j256/ormlite-android/blob/e82327a868ae242f994730fe2389f79684d7bcab/src/main/java/com/j256/ormlite/android/apptools/OrmLiteConfigUtil.java#L134-L144
|
gosu-lang/gosu-lang
|
gosu-core-api/src/main/java/gw/util/GosuStringUtil.java
|
GosuStringUtil.getPrechomp
|
public static String getPrechomp(String str, String sep) {
int idx = str.indexOf(sep);
if (idx == -1) {
return EMPTY;
}
return str.substring(0, idx + sep.length());
}
|
java
|
public static String getPrechomp(String str, String sep) {
int idx = str.indexOf(sep);
if (idx == -1) {
return EMPTY;
}
return str.substring(0, idx + sep.length());
}
|
[
"public",
"static",
"String",
"getPrechomp",
"(",
"String",
"str",
",",
"String",
"sep",
")",
"{",
"int",
"idx",
"=",
"str",
".",
"indexOf",
"(",
"sep",
")",
";",
"if",
"(",
"idx",
"==",
"-",
"1",
")",
"{",
"return",
"EMPTY",
";",
"}",
"return",
"str",
".",
"substring",
"(",
"0",
",",
"idx",
"+",
"sep",
".",
"length",
"(",
")",
")",
";",
"}"
] |
<p>Remove and return everything before the first value of a
supplied String from another String.</p>
@param str the String to chomp from, must not be null
@param sep the String to chomp, must not be null
@return String prechomped
@throws NullPointerException if str or sep is <code>null</code>
@deprecated Use {@link #substringBefore(String,String)} instead
(although this doesn't include the separator).
Method will be removed in Commons Lang 3.0.
|
[
"<p",
">",
"Remove",
"and",
"return",
"everything",
"before",
"the",
"first",
"value",
"of",
"a",
"supplied",
"String",
"from",
"another",
"String",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/GosuStringUtil.java#L4090-L4096
|
aws/aws-sdk-java
|
aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/ElasticsearchDomainStatus.java
|
ElasticsearchDomainStatus.withAdvancedOptions
|
public ElasticsearchDomainStatus withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
setAdvancedOptions(advancedOptions);
return this;
}
|
java
|
public ElasticsearchDomainStatus withAdvancedOptions(java.util.Map<String, String> advancedOptions) {
setAdvancedOptions(advancedOptions);
return this;
}
|
[
"public",
"ElasticsearchDomainStatus",
"withAdvancedOptions",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"advancedOptions",
")",
"{",
"setAdvancedOptions",
"(",
"advancedOptions",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
Specifies the status of the <code>AdvancedOptions</code>
</p>
@param advancedOptions
Specifies the status of the <code>AdvancedOptions</code>
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"Specifies",
"the",
"status",
"of",
"the",
"<code",
">",
"AdvancedOptions<",
"/",
"code",
">",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-elasticsearch/src/main/java/com/amazonaws/services/elasticsearch/model/ElasticsearchDomainStatus.java#L1097-L1100
|
box/box-java-sdk
|
src/main/java/com/box/sdk/BoxFile.java
|
BoxFile.uploadVersion
|
@Deprecated
public void uploadVersion(InputStream fileContent, Date modified, long fileSize, ProgressListener listener) {
this.uploadVersion(fileContent, null, modified, fileSize, listener);
}
|
java
|
@Deprecated
public void uploadVersion(InputStream fileContent, Date modified, long fileSize, ProgressListener listener) {
this.uploadVersion(fileContent, null, modified, fileSize, listener);
}
|
[
"@",
"Deprecated",
"public",
"void",
"uploadVersion",
"(",
"InputStream",
"fileContent",
",",
"Date",
"modified",
",",
"long",
"fileSize",
",",
"ProgressListener",
"listener",
")",
"{",
"this",
".",
"uploadVersion",
"(",
"fileContent",
",",
"null",
",",
"modified",
",",
"fileSize",
",",
"listener",
")",
";",
"}"
] |
Uploads a new version of this file, replacing the current version, while reporting the progress to a
ProgressListener. Note that only users with premium accounts will be able to view and recover previous versions
of the file.
@param fileContent a stream containing the new file contents.
@param modified the date that the new version was modified.
@param fileSize the size of the file used for determining the progress of the upload.
@param listener a listener for monitoring the upload's progress.
@deprecated use uploadNewVersion() instead.
|
[
"Uploads",
"a",
"new",
"version",
"of",
"this",
"file",
"replacing",
"the",
"current",
"version",
"while",
"reporting",
"the",
"progress",
"to",
"a",
"ProgressListener",
".",
"Note",
"that",
"only",
"users",
"with",
"premium",
"accounts",
"will",
"be",
"able",
"to",
"view",
"and",
"recover",
"previous",
"versions",
"of",
"the",
"file",
"."
] |
train
|
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L767-L770
|
b3dgs/lionengine
|
lionengine-core/src/main/java/com/b3dgs/lionengine/UtilMath.java
|
UtilMath.isBetween
|
public static boolean isBetween(double value, double min, double max)
{
return Double.compare(value, min) >= 0 && Double.compare(value, max) <= 0;
}
|
java
|
public static boolean isBetween(double value, double min, double max)
{
return Double.compare(value, min) >= 0 && Double.compare(value, max) <= 0;
}
|
[
"public",
"static",
"boolean",
"isBetween",
"(",
"double",
"value",
",",
"double",
"min",
",",
"double",
"max",
")",
"{",
"return",
"Double",
".",
"compare",
"(",
"value",
",",
"min",
")",
">=",
"0",
"&&",
"Double",
".",
"compare",
"(",
"value",
",",
"max",
")",
"<=",
"0",
";",
"}"
] |
Check if value is between an interval.
@param value The value to check.
@param min The minimum value.
@param max The maximum value.
@return <code>true</code> if between, <code>false</code> else.
|
[
"Check",
"if",
"value",
"is",
"between",
"an",
"interval",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilMath.java#L65-L68
|
lindar-open/well-rested-client
|
src/main/java/com/lindar/wellrested/vo/Result.java
|
Result.orElseDoAndReturnDefault
|
public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
}
|
java
|
public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
}
|
[
"public",
"T",
"orElseDoAndReturnDefault",
"(",
"Consumer",
"<",
"Result",
"<",
"T",
">",
">",
"consumer",
",",
"T",
"defaultVal",
")",
"{",
"if",
"(",
"isSuccessAndNotNull",
"(",
")",
")",
"{",
"return",
"data",
";",
"}",
"consumer",
".",
"accept",
"(",
"this",
")",
";",
"return",
"defaultVal",
";",
"}"
] |
The consumer function receives the entire result object as parameter in case you want to log or manage the error message or code in any way.
@param consumer
@param defaultVal
@return
|
[
"The",
"consumer",
"function",
"receives",
"the",
"entire",
"result",
"object",
"as",
"parameter",
"in",
"case",
"you",
"want",
"to",
"log",
"or",
"manage",
"the",
"error",
"message",
"or",
"code",
"in",
"any",
"way",
"."
] |
train
|
https://github.com/lindar-open/well-rested-client/blob/d87542f747cd624e3ce0cdc8230f51836326596b/src/main/java/com/lindar/wellrested/vo/Result.java#L138-L144
|
Azure/azure-sdk-for-java
|
mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java
|
DatabasesInner.listByServerAsync
|
public Observable<List<DatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DatabaseInner>>, List<DatabaseInner>>() {
@Override
public List<DatabaseInner> call(ServiceResponse<List<DatabaseInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<List<DatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DatabaseInner>>, List<DatabaseInner>>() {
@Override
public List<DatabaseInner> call(ServiceResponse<List<DatabaseInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
",",
"List",
"<",
"DatabaseInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"DatabaseInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"DatabaseInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
List all the databases in a given server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DatabaseInner> object
|
[
"List",
"all",
"the",
"databases",
"in",
"a",
"given",
"server",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java#L569-L576
|
b3dgs/lionengine
|
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableConfig.java
|
CollidableConfig.imports
|
public static Integer imports(Configurer configurer)
{
Check.notNull(configurer);
if (configurer.hasNode(NODE_GROUP))
{
final String group = configurer.getText(NODE_GROUP);
try
{
return Integer.valueOf(group);
}
catch (final NumberFormatException exception)
{
throw new LionEngineException(exception, ERROR_INVALID_GROUP + group);
}
}
return DEFAULT_GROUP;
}
|
java
|
public static Integer imports(Configurer configurer)
{
Check.notNull(configurer);
if (configurer.hasNode(NODE_GROUP))
{
final String group = configurer.getText(NODE_GROUP);
try
{
return Integer.valueOf(group);
}
catch (final NumberFormatException exception)
{
throw new LionEngineException(exception, ERROR_INVALID_GROUP + group);
}
}
return DEFAULT_GROUP;
}
|
[
"public",
"static",
"Integer",
"imports",
"(",
"Configurer",
"configurer",
")",
"{",
"Check",
".",
"notNull",
"(",
"configurer",
")",
";",
"if",
"(",
"configurer",
".",
"hasNode",
"(",
"NODE_GROUP",
")",
")",
"{",
"final",
"String",
"group",
"=",
"configurer",
".",
"getText",
"(",
"NODE_GROUP",
")",
";",
"try",
"{",
"return",
"Integer",
".",
"valueOf",
"(",
"group",
")",
";",
"}",
"catch",
"(",
"final",
"NumberFormatException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_INVALID_GROUP",
"+",
"group",
")",
";",
"}",
"}",
"return",
"DEFAULT_GROUP",
";",
"}"
] |
Create the collidable data from node.
@param configurer The configurer reference (must not be <code>null</code>).
@return The associated group, {@link #DEFAULT_GROUP} if not defined.
@throws LionEngineException If unable to read node.
|
[
"Create",
"the",
"collidable",
"data",
"from",
"node",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableConfig.java#L50-L68
|
to2mbn/JMCCC
|
jmccc/src/main/java/org/to2mbn/jmccc/version/parsing/Versions.java
|
Versions.resolveAssets
|
public static Set<Asset> resolveAssets(MinecraftDirectory minecraftDir, Version version) throws IOException {
return resolveAssets(minecraftDir, version.getAssets());
}
|
java
|
public static Set<Asset> resolveAssets(MinecraftDirectory minecraftDir, Version version) throws IOException {
return resolveAssets(minecraftDir, version.getAssets());
}
|
[
"public",
"static",
"Set",
"<",
"Asset",
">",
"resolveAssets",
"(",
"MinecraftDirectory",
"minecraftDir",
",",
"Version",
"version",
")",
"throws",
"IOException",
"{",
"return",
"resolveAssets",
"(",
"minecraftDir",
",",
"version",
".",
"getAssets",
"(",
")",
")",
";",
"}"
] |
Resolves the asset index.
@param minecraftDir the minecraft directory
@param version the owner version of the asset index
@return the asset index, or null if the asset index does not exist
@throws IOException if an I/O error occurs during resolving asset index
@throws NullPointerException if
<code>minecraftDir==null || version==null</code>
|
[
"Resolves",
"the",
"asset",
"index",
"."
] |
train
|
https://github.com/to2mbn/JMCCC/blob/17e5b1b56ff18255cfd60976dca1a24598946647/jmccc/src/main/java/org/to2mbn/jmccc/version/parsing/Versions.java#L86-L88
|
cdk/cdk
|
tool/forcefield/src/main/java/org/openscience/cdk/modeling/builder3d/MMFF94ParametersCall.java
|
MMFF94ParametersCall.getDefaultStretchBendData
|
public List getDefaultStretchBendData(int iR, int jR, int kR) throws Exception {
String dfsbkey = "";
if (pSet.containsKey(("DFSB" + iR + ";" + jR + ";" + kR))) {
dfsbkey = "DFSB" + iR + ";" + jR + ";" + kR;
} /*
* else { System.out.println(
* "KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: "
* + iR + " ; " + jR + " ; " + kR); }
*/
//logger.debug("dfsbkey : " + dfsbkey);
return (List) pSet.get(dfsbkey);
}
|
java
|
public List getDefaultStretchBendData(int iR, int jR, int kR) throws Exception {
String dfsbkey = "";
if (pSet.containsKey(("DFSB" + iR + ";" + jR + ";" + kR))) {
dfsbkey = "DFSB" + iR + ";" + jR + ";" + kR;
} /*
* else { System.out.println(
* "KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: "
* + iR + " ; " + jR + " ; " + kR); }
*/
//logger.debug("dfsbkey : " + dfsbkey);
return (List) pSet.get(dfsbkey);
}
|
[
"public",
"List",
"getDefaultStretchBendData",
"(",
"int",
"iR",
",",
"int",
"jR",
",",
"int",
"kR",
")",
"throws",
"Exception",
"{",
"String",
"dfsbkey",
"=",
"\"\"",
";",
"if",
"(",
"pSet",
".",
"containsKey",
"(",
"(",
"\"DFSB\"",
"+",
"iR",
"+",
"\";\"",
"+",
"jR",
"+",
"\";\"",
"+",
"kR",
")",
")",
")",
"{",
"dfsbkey",
"=",
"\"DFSB\"",
"+",
"iR",
"+",
"\";\"",
"+",
"jR",
"+",
"\";\"",
"+",
"kR",
";",
"}",
"/*\n * else { System.out.println(\n * \"KEYErrorDefaultStretchBend:Unknown default stretch-bend key in pSet: \"\n * + iR + \" ; \" + jR + \" ; \" + kR); }\n */",
"//logger.debug(\"dfsbkey : \" + dfsbkey);",
"return",
"(",
"List",
")",
"pSet",
".",
"get",
"(",
"dfsbkey",
")",
";",
"}"
] |
Gets the bond-angle interaction parameter set.
@param iR ID from Atom 1.
@param jR ID from Atom 2.
@param kR ID from Atom 3.
@return The bond-angle interaction data from the force field parameter set
@exception Exception Description of the Exception
|
[
"Gets",
"the",
"bond",
"-",
"angle",
"interaction",
"parameter",
"set",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/forcefield/src/main/java/org/openscience/cdk/modeling/builder3d/MMFF94ParametersCall.java#L124-L135
|
Mozu/mozu-java
|
mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java
|
CouponSetUrl.getCouponSetUrl
|
public static MozuUrl getCouponSetUrl(String couponSetCode, Boolean includeCounts, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("couponSetCode", couponSetCode);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
java
|
public static MozuUrl getCouponSetUrl(String couponSetCode, Boolean includeCounts, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}");
formatter.formatUrl("couponSetCode", couponSetCode);
formatter.formatUrl("includeCounts", includeCounts);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"getCouponSetUrl",
"(",
"String",
"couponSetCode",
",",
"Boolean",
"includeCounts",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/couponsets/{couponSetCode}?includeCounts={includeCounts}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"couponSetCode\"",
",",
"couponSetCode",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"includeCounts\"",
",",
"includeCounts",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] |
Get Resource Url for GetCouponSet
@param couponSetCode The unique identifier of the coupon set.
@param includeCounts Specifies whether to include the number of redeemed coupons, existing coupon codes, and assigned discounts in the response body.
@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",
"GetCouponSet"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CouponSetUrl.java#L45-L52
|
ngageoint/geopackage-android-map
|
geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java
|
GoogleMapShapeConverter.toCircularString
|
public CircularString toCircularString(List<LatLng> latLngs, boolean hasZ,
boolean hasM) {
CircularString circularString = new CircularString(hasZ, hasM);
populateLineString(circularString, latLngs);
return circularString;
}
|
java
|
public CircularString toCircularString(List<LatLng> latLngs, boolean hasZ,
boolean hasM) {
CircularString circularString = new CircularString(hasZ, hasM);
populateLineString(circularString, latLngs);
return circularString;
}
|
[
"public",
"CircularString",
"toCircularString",
"(",
"List",
"<",
"LatLng",
">",
"latLngs",
",",
"boolean",
"hasZ",
",",
"boolean",
"hasM",
")",
"{",
"CircularString",
"circularString",
"=",
"new",
"CircularString",
"(",
"hasZ",
",",
"hasM",
")",
";",
"populateLineString",
"(",
"circularString",
",",
"latLngs",
")",
";",
"return",
"circularString",
";",
"}"
] |
Convert a list of {@link LatLng} to a {@link CircularString}
@param latLngs lat lngs
@param hasZ has z flag
@param hasM has m flag
@return circular string
|
[
"Convert",
"a",
"list",
"of",
"{",
"@link",
"LatLng",
"}",
"to",
"a",
"{",
"@link",
"CircularString",
"}"
] |
train
|
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java#L375-L383
|
aws/aws-sdk-java
|
aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SegmentDimensions.java
|
SegmentDimensions.withUserAttributes
|
public SegmentDimensions withUserAttributes(java.util.Map<String, AttributeDimension> userAttributes) {
setUserAttributes(userAttributes);
return this;
}
|
java
|
public SegmentDimensions withUserAttributes(java.util.Map<String, AttributeDimension> userAttributes) {
setUserAttributes(userAttributes);
return this;
}
|
[
"public",
"SegmentDimensions",
"withUserAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"AttributeDimension",
">",
"userAttributes",
")",
"{",
"setUserAttributes",
"(",
"userAttributes",
")",
";",
"return",
"this",
";",
"}"
] |
Custom segment user attributes.
@param userAttributes
Custom segment user attributes.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"Custom",
"segment",
"user",
"attributes",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/SegmentDimensions.java#L283-L286
|
eclipse/xtext-lib
|
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java
|
IntegerExtensions.shiftLeft
|
@Pure
@Inline(value="($1 << $2)", constantExpression=true)
@Deprecated
public static int shiftLeft(int a, int distance) {
return a << distance;
}
|
java
|
@Pure
@Inline(value="($1 << $2)", constantExpression=true)
@Deprecated
public static int shiftLeft(int a, int distance) {
return a << distance;
}
|
[
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"($1 << $2)\"",
",",
"constantExpression",
"=",
"true",
")",
"@",
"Deprecated",
"public",
"static",
"int",
"shiftLeft",
"(",
"int",
"a",
",",
"int",
"distance",
")",
"{",
"return",
"a",
"<<",
"distance",
";",
"}"
] |
The binary <code>signed left shift</code> operator. This is the equivalent to the java <code><<</code> operator.
Fills in a zero as the least significant bit.
@param a
an integer.
@param distance
the number of times to shift.
@return <code>a<<distance</code>
@deprecated use {@link #operator_doubleLessThan(int, int)} instead
|
[
"The",
"binary",
"<code",
">",
"signed",
"left",
"shift<",
"/",
"code",
">",
"operator",
".",
"This",
"is",
"the",
"equivalent",
"to",
"the",
"java",
"<code",
">",
"<",
";",
"<",
";",
"<",
"/",
"code",
">",
"operator",
".",
"Fills",
"in",
"a",
"zero",
"as",
"the",
"least",
"significant",
"bit",
"."
] |
train
|
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java#L136-L141
|
xcesco/kripton
|
kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/TypeUtility.java
|
TypeUtility.beginStringConversion
|
public static void beginStringConversion(Builder methodBuilder, ModelProperty property) {
TypeName modelType = typeName(property.getElement().asType());
beginStringConversion(methodBuilder, modelType);
}
|
java
|
public static void beginStringConversion(Builder methodBuilder, ModelProperty property) {
TypeName modelType = typeName(property.getElement().asType());
beginStringConversion(methodBuilder, modelType);
}
|
[
"public",
"static",
"void",
"beginStringConversion",
"(",
"Builder",
"methodBuilder",
",",
"ModelProperty",
"property",
")",
"{",
"TypeName",
"modelType",
"=",
"typeName",
"(",
"property",
".",
"getElement",
"(",
")",
".",
"asType",
"(",
")",
")",
";",
"beginStringConversion",
"(",
"methodBuilder",
",",
"modelType",
")",
";",
"}"
] |
generate begin string to translate in code to used in content value or parameter need to be converted in string through String.valueOf
@param methodBuilder
the method builder
@param property
the property
|
[
"generate",
"begin",
"string",
"to",
"translate",
"in",
"code",
"to",
"used",
"in",
"content",
"value",
"or",
"parameter",
"need",
"to",
"be",
"converted",
"in",
"string",
"through",
"String",
".",
"valueOf"
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/TypeUtility.java#L376-L380
|
aws/aws-sdk-java
|
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java
|
AmazonS3Client.postProcessS3Object
|
private void postProcessS3Object(final S3Object s3Object, final boolean skipClientSideValidation,
final ProgressListener listener) {
InputStream is = s3Object.getObjectContent();
HttpRequestBase httpRequest = s3Object.getObjectContent().getHttpRequest();
// Hold a reference to this client while the InputStream is still
// around - otherwise a finalizer in the HttpClient may reset the
// underlying TCP connection out from under us.
is = new ServiceClientHolderInputStream(is, this);
// used trigger a tranfer complete event when the stream is entirely consumed
ProgressInputStream progressInputStream =
new ProgressInputStream(is, listener) {
@Override protected void onEOF() {
publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
}
};
is = progressInputStream;
// The Etag header contains a server-side MD5 of the object. If
// we're downloading the whole object, by default we wrap the
// stream in a validator that calculates an MD5 of the downloaded
// bytes and complains if what we received doesn't match the Etag.
if (!skipClientSideValidation) {
byte[] serverSideHash = BinaryUtils.fromHex(s3Object.getObjectMetadata().getETag());
try {
// No content length check is performed when the
// MD5 check is enabled, since a correct MD5 check would
// imply a correct content length.
MessageDigest digest = MessageDigest.getInstance("MD5");
is = new DigestValidationInputStream(is, digest, serverSideHash);
} catch (NoSuchAlgorithmException e) {
log.warn("No MD5 digest algorithm available. Unable to calculate "
+ "checksum and verify data integrity.", e);
}
} else {
// Ensures the data received from S3 has the same length as the
// expected content-length
is = new LengthCheckInputStream(is,
s3Object.getObjectMetadata().getContentLength(), // expected length
INCLUDE_SKIPPED_BYTES); // bytes received from S3 are all included even if skipped
}
S3AbortableInputStream abortableInputStream =
new S3AbortableInputStream(is, httpRequest, s3Object.getObjectMetadata().getContentLength());
s3Object.setObjectContent(new S3ObjectInputStream(abortableInputStream, httpRequest, false));
}
|
java
|
private void postProcessS3Object(final S3Object s3Object, final boolean skipClientSideValidation,
final ProgressListener listener) {
InputStream is = s3Object.getObjectContent();
HttpRequestBase httpRequest = s3Object.getObjectContent().getHttpRequest();
// Hold a reference to this client while the InputStream is still
// around - otherwise a finalizer in the HttpClient may reset the
// underlying TCP connection out from under us.
is = new ServiceClientHolderInputStream(is, this);
// used trigger a tranfer complete event when the stream is entirely consumed
ProgressInputStream progressInputStream =
new ProgressInputStream(is, listener) {
@Override protected void onEOF() {
publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
}
};
is = progressInputStream;
// The Etag header contains a server-side MD5 of the object. If
// we're downloading the whole object, by default we wrap the
// stream in a validator that calculates an MD5 of the downloaded
// bytes and complains if what we received doesn't match the Etag.
if (!skipClientSideValidation) {
byte[] serverSideHash = BinaryUtils.fromHex(s3Object.getObjectMetadata().getETag());
try {
// No content length check is performed when the
// MD5 check is enabled, since a correct MD5 check would
// imply a correct content length.
MessageDigest digest = MessageDigest.getInstance("MD5");
is = new DigestValidationInputStream(is, digest, serverSideHash);
} catch (NoSuchAlgorithmException e) {
log.warn("No MD5 digest algorithm available. Unable to calculate "
+ "checksum and verify data integrity.", e);
}
} else {
// Ensures the data received from S3 has the same length as the
// expected content-length
is = new LengthCheckInputStream(is,
s3Object.getObjectMetadata().getContentLength(), // expected length
INCLUDE_SKIPPED_BYTES); // bytes received from S3 are all included even if skipped
}
S3AbortableInputStream abortableInputStream =
new S3AbortableInputStream(is, httpRequest, s3Object.getObjectMetadata().getContentLength());
s3Object.setObjectContent(new S3ObjectInputStream(abortableInputStream, httpRequest, false));
}
|
[
"private",
"void",
"postProcessS3Object",
"(",
"final",
"S3Object",
"s3Object",
",",
"final",
"boolean",
"skipClientSideValidation",
",",
"final",
"ProgressListener",
"listener",
")",
"{",
"InputStream",
"is",
"=",
"s3Object",
".",
"getObjectContent",
"(",
")",
";",
"HttpRequestBase",
"httpRequest",
"=",
"s3Object",
".",
"getObjectContent",
"(",
")",
".",
"getHttpRequest",
"(",
")",
";",
"// Hold a reference to this client while the InputStream is still",
"// around - otherwise a finalizer in the HttpClient may reset the",
"// underlying TCP connection out from under us.",
"is",
"=",
"new",
"ServiceClientHolderInputStream",
"(",
"is",
",",
"this",
")",
";",
"// used trigger a tranfer complete event when the stream is entirely consumed",
"ProgressInputStream",
"progressInputStream",
"=",
"new",
"ProgressInputStream",
"(",
"is",
",",
"listener",
")",
"{",
"@",
"Override",
"protected",
"void",
"onEOF",
"(",
")",
"{",
"publishProgress",
"(",
"getListener",
"(",
")",
",",
"ProgressEventType",
".",
"TRANSFER_COMPLETED_EVENT",
")",
";",
"}",
"}",
";",
"is",
"=",
"progressInputStream",
";",
"// The Etag header contains a server-side MD5 of the object. If",
"// we're downloading the whole object, by default we wrap the",
"// stream in a validator that calculates an MD5 of the downloaded",
"// bytes and complains if what we received doesn't match the Etag.",
"if",
"(",
"!",
"skipClientSideValidation",
")",
"{",
"byte",
"[",
"]",
"serverSideHash",
"=",
"BinaryUtils",
".",
"fromHex",
"(",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getETag",
"(",
")",
")",
";",
"try",
"{",
"// No content length check is performed when the",
"// MD5 check is enabled, since a correct MD5 check would",
"// imply a correct content length.",
"MessageDigest",
"digest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
";",
"is",
"=",
"new",
"DigestValidationInputStream",
"(",
"is",
",",
"digest",
",",
"serverSideHash",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"No MD5 digest algorithm available. Unable to calculate \"",
"+",
"\"checksum and verify data integrity.\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"// Ensures the data received from S3 has the same length as the",
"// expected content-length",
"is",
"=",
"new",
"LengthCheckInputStream",
"(",
"is",
",",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getContentLength",
"(",
")",
",",
"// expected length",
"INCLUDE_SKIPPED_BYTES",
")",
";",
"// bytes received from S3 are all included even if skipped",
"}",
"S3AbortableInputStream",
"abortableInputStream",
"=",
"new",
"S3AbortableInputStream",
"(",
"is",
",",
"httpRequest",
",",
"s3Object",
".",
"getObjectMetadata",
"(",
")",
".",
"getContentLength",
"(",
")",
")",
";",
"s3Object",
".",
"setObjectContent",
"(",
"new",
"S3ObjectInputStream",
"(",
"abortableInputStream",
",",
"httpRequest",
",",
"false",
")",
")",
";",
"}"
] |
Post processing the {@link S3Object} downloaded from S3. It includes wrapping the data with wrapper input streams,
doing client side validation if possible etc.
|
[
"Post",
"processing",
"the",
"{"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L1502-L1546
|
alipay/sofa-rpc
|
extension-impl/remoting-bolt/src/main/java/com/alipay/sofa/rpc/transport/bolt/BoltClientTransport.java
|
BoltClientTransport.doInvokeSync
|
protected SofaResponse doInvokeSync(SofaRequest request, InvokeContext invokeContext, int timeoutMillis)
throws RemotingException, InterruptedException {
return (SofaResponse) RPC_CLIENT.invokeSync(url, request, invokeContext, timeoutMillis);
}
|
java
|
protected SofaResponse doInvokeSync(SofaRequest request, InvokeContext invokeContext, int timeoutMillis)
throws RemotingException, InterruptedException {
return (SofaResponse) RPC_CLIENT.invokeSync(url, request, invokeContext, timeoutMillis);
}
|
[
"protected",
"SofaResponse",
"doInvokeSync",
"(",
"SofaRequest",
"request",
",",
"InvokeContext",
"invokeContext",
",",
"int",
"timeoutMillis",
")",
"throws",
"RemotingException",
",",
"InterruptedException",
"{",
"return",
"(",
"SofaResponse",
")",
"RPC_CLIENT",
".",
"invokeSync",
"(",
"url",
",",
"request",
",",
"invokeContext",
",",
"timeoutMillis",
")",
";",
"}"
] |
同步调用
@param request 请求对象
@param invokeContext 调用上下文
@param timeoutMillis 超时时间(毫秒)
@return 返回对象
@throws RemotingException 远程调用异常
@throws InterruptedException 中断异常
@since 5.2.0
|
[
"同步调用"
] |
train
|
https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/remoting-bolt/src/main/java/com/alipay/sofa/rpc/transport/bolt/BoltClientTransport.java#L273-L276
|
wildfly/wildfly-core
|
protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java
|
AbstractMessageHandler.handleMessage
|
@Override
public void handleMessage(final Channel channel, final DataInput input, final ManagementProtocolHeader header) throws IOException {
final byte type = header.getType();
if(type == ManagementProtocol.TYPE_RESPONSE) {
// Handle response to local requests
final ManagementResponseHeader response = (ManagementResponseHeader) header;
final ActiveRequest<?, ?> request = requests.remove(response.getResponseId());
if(request == null) {
ProtocolLogger.CONNECTION_LOGGER.noSuchRequest(response.getResponseId(), channel);
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(response.getResponseId()));
} else if(response.getError() != null) {
request.handleFailed(response);
} else {
handleRequest(channel, input, header, request);
}
} else {
// Handle requests (or other messages)
try {
final ManagementRequestHeader requestHeader = validateRequest(header);
final ManagementRequestHandler<?, ?> handler = getRequestHandler(requestHeader);
if(handler == null) {
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(requestHeader.getBatchId()));
} else {
handleMessage(channel, input, requestHeader, handler);
}
} catch (Exception e) {
safeWriteErrorResponse(channel, header, e);
}
}
}
|
java
|
@Override
public void handleMessage(final Channel channel, final DataInput input, final ManagementProtocolHeader header) throws IOException {
final byte type = header.getType();
if(type == ManagementProtocol.TYPE_RESPONSE) {
// Handle response to local requests
final ManagementResponseHeader response = (ManagementResponseHeader) header;
final ActiveRequest<?, ?> request = requests.remove(response.getResponseId());
if(request == null) {
ProtocolLogger.CONNECTION_LOGGER.noSuchRequest(response.getResponseId(), channel);
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(response.getResponseId()));
} else if(response.getError() != null) {
request.handleFailed(response);
} else {
handleRequest(channel, input, header, request);
}
} else {
// Handle requests (or other messages)
try {
final ManagementRequestHeader requestHeader = validateRequest(header);
final ManagementRequestHandler<?, ?> handler = getRequestHandler(requestHeader);
if(handler == null) {
safeWriteErrorResponse(channel, header, ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(requestHeader.getBatchId()));
} else {
handleMessage(channel, input, requestHeader, handler);
}
} catch (Exception e) {
safeWriteErrorResponse(channel, header, e);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"handleMessage",
"(",
"final",
"Channel",
"channel",
",",
"final",
"DataInput",
"input",
",",
"final",
"ManagementProtocolHeader",
"header",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"type",
"=",
"header",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"==",
"ManagementProtocol",
".",
"TYPE_RESPONSE",
")",
"{",
"// Handle response to local requests",
"final",
"ManagementResponseHeader",
"response",
"=",
"(",
"ManagementResponseHeader",
")",
"header",
";",
"final",
"ActiveRequest",
"<",
"?",
",",
"?",
">",
"request",
"=",
"requests",
".",
"remove",
"(",
"response",
".",
"getResponseId",
"(",
")",
")",
";",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"ProtocolLogger",
".",
"CONNECTION_LOGGER",
".",
"noSuchRequest",
"(",
"response",
".",
"getResponseId",
"(",
")",
",",
"channel",
")",
";",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"ProtocolLogger",
".",
"ROOT_LOGGER",
".",
"responseHandlerNotFound",
"(",
"response",
".",
"getResponseId",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"getError",
"(",
")",
"!=",
"null",
")",
"{",
"request",
".",
"handleFailed",
"(",
"response",
")",
";",
"}",
"else",
"{",
"handleRequest",
"(",
"channel",
",",
"input",
",",
"header",
",",
"request",
")",
";",
"}",
"}",
"else",
"{",
"// Handle requests (or other messages)",
"try",
"{",
"final",
"ManagementRequestHeader",
"requestHeader",
"=",
"validateRequest",
"(",
"header",
")",
";",
"final",
"ManagementRequestHandler",
"<",
"?",
",",
"?",
">",
"handler",
"=",
"getRequestHandler",
"(",
"requestHeader",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"ProtocolLogger",
".",
"ROOT_LOGGER",
".",
"responseHandlerNotFound",
"(",
"requestHeader",
".",
"getBatchId",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"handleMessage",
"(",
"channel",
",",
"input",
",",
"requestHeader",
",",
"handler",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"safeWriteErrorResponse",
"(",
"channel",
",",
"header",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Handle a message.
@param channel the channel
@param input the message
@param header the management protocol header
@throws IOException
|
[
"Handle",
"a",
"message",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java#L221-L250
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java
|
KeyVaultClientCustomImpl.listCertificateVersionsAsync
|
public ServiceFuture<List<CertificateItem>> listCertificateVersionsAsync(final String vaultBaseUrl,
final String certificateName, final ListOperationCallback<CertificateItem> serviceCallback) {
return getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback);
}
|
java
|
public ServiceFuture<List<CertificateItem>> listCertificateVersionsAsync(final String vaultBaseUrl,
final String certificateName, final ListOperationCallback<CertificateItem> serviceCallback) {
return getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"List",
"<",
"CertificateItem",
">",
">",
"listCertificateVersionsAsync",
"(",
"final",
"String",
"vaultBaseUrl",
",",
"final",
"String",
"certificateName",
",",
"final",
"ListOperationCallback",
"<",
"CertificateItem",
">",
"serviceCallback",
")",
"{",
"return",
"getCertificateVersionsAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"serviceCallback",
")",
";",
"}"
] |
List the versions of a certificate.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param certificateName
The name of the certificate
@param serviceCallback
the async ServiceCallback to handle successful and failed
responses.
@return the {@link ServiceFuture} object
|
[
"List",
"the",
"versions",
"of",
"a",
"certificate",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java#L1561-L1564
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java
|
FileSystem.zipFile
|
public static void zipFile(File input, File output) throws IOException {
try (FileOutputStream fos = new FileOutputStream(output)) {
zipFile(input, fos);
}
}
|
java
|
public static void zipFile(File input, File output) throws IOException {
try (FileOutputStream fos = new FileOutputStream(output)) {
zipFile(input, fos);
}
}
|
[
"public",
"static",
"void",
"zipFile",
"(",
"File",
"input",
",",
"File",
"output",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"output",
")",
")",
"{",
"zipFile",
"(",
"input",
",",
"fos",
")",
";",
"}",
"}"
] |
Create a zip file from the given input file.
@param input the name of the file to compress.
@param output the name of the ZIP file to create.
@throws IOException when ziiping is failing.
@since 6.2
|
[
"Create",
"a",
"zip",
"file",
"from",
"the",
"given",
"input",
"file",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L2923-L2927
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribeSiftCommon.java
|
DescribeSiftCommon.normalizeDescriptor
|
public static void normalizeDescriptor(TupleDesc_F64 descriptor , double maxDescriptorElementValue ) {
// normalize descriptor to unit length
UtilFeature.normalizeL2(descriptor);
// clip the values
for (int i = 0; i < descriptor.size(); i++) {
double value = descriptor.value[i];
if( value > maxDescriptorElementValue ) {
descriptor.value[i] = maxDescriptorElementValue;
}
}
// normalize again
UtilFeature.normalizeL2(descriptor);
}
|
java
|
public static void normalizeDescriptor(TupleDesc_F64 descriptor , double maxDescriptorElementValue ) {
// normalize descriptor to unit length
UtilFeature.normalizeL2(descriptor);
// clip the values
for (int i = 0; i < descriptor.size(); i++) {
double value = descriptor.value[i];
if( value > maxDescriptorElementValue ) {
descriptor.value[i] = maxDescriptorElementValue;
}
}
// normalize again
UtilFeature.normalizeL2(descriptor);
}
|
[
"public",
"static",
"void",
"normalizeDescriptor",
"(",
"TupleDesc_F64",
"descriptor",
",",
"double",
"maxDescriptorElementValue",
")",
"{",
"// normalize descriptor to unit length",
"UtilFeature",
".",
"normalizeL2",
"(",
"descriptor",
")",
";",
"// clip the values",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"descriptor",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"value",
"=",
"descriptor",
".",
"value",
"[",
"i",
"]",
";",
"if",
"(",
"value",
">",
"maxDescriptorElementValue",
")",
"{",
"descriptor",
".",
"value",
"[",
"i",
"]",
"=",
"maxDescriptorElementValue",
";",
"}",
"}",
"// normalize again",
"UtilFeature",
".",
"normalizeL2",
"(",
"descriptor",
")",
";",
"}"
] |
Adjusts the descriptor. This adds lighting invariance and reduces the affects of none-affine changes
in lighting.
1) Apply L2 normalization
2) Clip using max descriptor value
3) Apply L2 normalization again
|
[
"Adjusts",
"the",
"descriptor",
".",
"This",
"adds",
"lighting",
"invariance",
"and",
"reduces",
"the",
"affects",
"of",
"none",
"-",
"affine",
"changes",
"in",
"lighting",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribeSiftCommon.java#L84-L98
|
apereo/cas
|
core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java
|
AbstractCasView.prepareCasResponseAttributesForViewModel
|
protected void prepareCasResponseAttributesForViewModel(final Map<String, Object> model) {
val service = authenticationRequestServiceSelectionStrategies.resolveService(getServiceFrom(model));
val registeredService = this.servicesManager.findServiceBy(service);
val principalAttributes = getCasPrincipalAttributes(model, registeredService);
val attributes = new HashMap<String, Object>(principalAttributes);
LOGGER.trace("Processed principal attributes from the output model to be [{}]", principalAttributes.keySet());
val protocolAttributes = getCasProtocolAuthenticationAttributes(model, registeredService);
attributes.putAll(protocolAttributes);
LOGGER.debug("Final collection of attributes for the response are [{}].", attributes.keySet());
putCasResponseAttributesIntoModel(model, attributes, registeredService, this.attributesRenderer);
}
|
java
|
protected void prepareCasResponseAttributesForViewModel(final Map<String, Object> model) {
val service = authenticationRequestServiceSelectionStrategies.resolveService(getServiceFrom(model));
val registeredService = this.servicesManager.findServiceBy(service);
val principalAttributes = getCasPrincipalAttributes(model, registeredService);
val attributes = new HashMap<String, Object>(principalAttributes);
LOGGER.trace("Processed principal attributes from the output model to be [{}]", principalAttributes.keySet());
val protocolAttributes = getCasProtocolAuthenticationAttributes(model, registeredService);
attributes.putAll(protocolAttributes);
LOGGER.debug("Final collection of attributes for the response are [{}].", attributes.keySet());
putCasResponseAttributesIntoModel(model, attributes, registeredService, this.attributesRenderer);
}
|
[
"protected",
"void",
"prepareCasResponseAttributesForViewModel",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
")",
"{",
"val",
"service",
"=",
"authenticationRequestServiceSelectionStrategies",
".",
"resolveService",
"(",
"getServiceFrom",
"(",
"model",
")",
")",
";",
"val",
"registeredService",
"=",
"this",
".",
"servicesManager",
".",
"findServiceBy",
"(",
"service",
")",
";",
"val",
"principalAttributes",
"=",
"getCasPrincipalAttributes",
"(",
"model",
",",
"registeredService",
")",
";",
"val",
"attributes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"principalAttributes",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"Processed principal attributes from the output model to be [{}]\"",
",",
"principalAttributes",
".",
"keySet",
"(",
")",
")",
";",
"val",
"protocolAttributes",
"=",
"getCasProtocolAuthenticationAttributes",
"(",
"model",
",",
"registeredService",
")",
";",
"attributes",
".",
"putAll",
"(",
"protocolAttributes",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Final collection of attributes for the response are [{}].\"",
",",
"attributes",
".",
"keySet",
"(",
")",
")",
";",
"putCasResponseAttributesIntoModel",
"(",
"model",
",",
"attributes",
",",
"registeredService",
",",
"this",
".",
"attributesRenderer",
")",
";",
"}"
] |
Prepare cas response attributes for view model.
@param model the model
|
[
"Prepare",
"cas",
"response",
"attributes",
"for",
"view",
"model",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java#L232-L245
|
eclipse/xtext-lib
|
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java
|
ObjectExtensions.operator_doubleArrow
|
public static <T> T operator_doubleArrow(T object, Procedure1<? super T> block) {
block.apply(object);
return object;
}
|
java
|
public static <T> T operator_doubleArrow(T object, Procedure1<? super T> block) {
block.apply(object);
return object;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"operator_doubleArrow",
"(",
"T",
"object",
",",
"Procedure1",
"<",
"?",
"super",
"T",
">",
"block",
")",
"{",
"block",
".",
"apply",
"(",
"object",
")",
";",
"return",
"object",
";",
"}"
] |
The <code>doubleArrow</code> operator is used as a 'with'- or 'let'-operation.
It allows to bind an object to a local scope in order to do something on it.
Example:
<code>
new Person => [
firstName = 'Han'
lastName = 'Solo'
]
</code>
@param object
an object. Can be <code>null</code>.
@param block
the block to execute with the given object. Must not be <code>null</code>.
@return the reference to object.
@since 2.3
|
[
"The",
"<code",
">",
"doubleArrow<",
"/",
"code",
">",
"operator",
"is",
"used",
"as",
"a",
"with",
"-",
"or",
"let",
"-",
"operation",
".",
"It",
"allows",
"to",
"bind",
"an",
"object",
"to",
"a",
"local",
"scope",
"in",
"order",
"to",
"do",
"something",
"on",
"it",
"."
] |
train
|
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java#L138-L141
|
line/armeria
|
grpc/src/main/java/com/linecorp/armeria/unsafe/grpc/GrpcUnsafeBufferUtil.java
|
GrpcUnsafeBufferUtil.releaseBuffer
|
public static void releaseBuffer(Object message, RequestContext ctx) {
final IdentityHashMap<Object, ByteBuf> buffers = ctx.attr(BUFFERS).get();
checkState(buffers != null,
"Releasing buffer even though storeBuffer has not been called.");
final ByteBuf removed = buffers.remove(message);
if (removed == null) {
throw new IllegalArgumentException("The provided message does not have a stored buffer.");
}
removed.release();
}
|
java
|
public static void releaseBuffer(Object message, RequestContext ctx) {
final IdentityHashMap<Object, ByteBuf> buffers = ctx.attr(BUFFERS).get();
checkState(buffers != null,
"Releasing buffer even though storeBuffer has not been called.");
final ByteBuf removed = buffers.remove(message);
if (removed == null) {
throw new IllegalArgumentException("The provided message does not have a stored buffer.");
}
removed.release();
}
|
[
"public",
"static",
"void",
"releaseBuffer",
"(",
"Object",
"message",
",",
"RequestContext",
"ctx",
")",
"{",
"final",
"IdentityHashMap",
"<",
"Object",
",",
"ByteBuf",
">",
"buffers",
"=",
"ctx",
".",
"attr",
"(",
"BUFFERS",
")",
".",
"get",
"(",
")",
";",
"checkState",
"(",
"buffers",
"!=",
"null",
",",
"\"Releasing buffer even though storeBuffer has not been called.\"",
")",
";",
"final",
"ByteBuf",
"removed",
"=",
"buffers",
".",
"remove",
"(",
"message",
")",
";",
"if",
"(",
"removed",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The provided message does not have a stored buffer.\"",
")",
";",
"}",
"removed",
".",
"release",
"(",
")",
";",
"}"
] |
Releases the {@link ByteBuf} backing the provided {@link Message}.
|
[
"Releases",
"the",
"{"
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc/src/main/java/com/linecorp/armeria/unsafe/grpc/GrpcUnsafeBufferUtil.java#L53-L62
|
citiususc/hipster
|
hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java
|
Maze2D.validLocationsFrom
|
public Collection<Point> validLocationsFrom(Point loc) {
Collection<Point> validMoves = new HashSet<Point>();
// Check for all valid movements
for (int row = -1; row <= 1; row++) {
for (int column = -1; column <= 1; column++) {
try {
if (isFree(new Point(loc.x + column, loc.y + row))) {
validMoves.add(new Point(loc.x + column, loc.y + row));
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Invalid move!
}
}
}
validMoves.remove(loc);
return validMoves;
}
|
java
|
public Collection<Point> validLocationsFrom(Point loc) {
Collection<Point> validMoves = new HashSet<Point>();
// Check for all valid movements
for (int row = -1; row <= 1; row++) {
for (int column = -1; column <= 1; column++) {
try {
if (isFree(new Point(loc.x + column, loc.y + row))) {
validMoves.add(new Point(loc.x + column, loc.y + row));
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Invalid move!
}
}
}
validMoves.remove(loc);
return validMoves;
}
|
[
"public",
"Collection",
"<",
"Point",
">",
"validLocationsFrom",
"(",
"Point",
"loc",
")",
"{",
"Collection",
"<",
"Point",
">",
"validMoves",
"=",
"new",
"HashSet",
"<",
"Point",
">",
"(",
")",
";",
"// Check for all valid movements",
"for",
"(",
"int",
"row",
"=",
"-",
"1",
";",
"row",
"<=",
"1",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"column",
"=",
"-",
"1",
";",
"column",
"<=",
"1",
";",
"column",
"++",
")",
"{",
"try",
"{",
"if",
"(",
"isFree",
"(",
"new",
"Point",
"(",
"loc",
".",
"x",
"+",
"column",
",",
"loc",
".",
"y",
"+",
"row",
")",
")",
")",
"{",
"validMoves",
".",
"add",
"(",
"new",
"Point",
"(",
"loc",
".",
"x",
"+",
"column",
",",
"loc",
".",
"y",
"+",
"row",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ArrayIndexOutOfBoundsException",
"ex",
")",
"{",
"// Invalid move!",
"}",
"}",
"}",
"validMoves",
".",
"remove",
"(",
"loc",
")",
";",
"return",
"validMoves",
";",
"}"
] |
Return all neighbor empty points from a specific location point.
@param loc source point
@return collection of empty neighbor points.
|
[
"Return",
"all",
"neighbor",
"empty",
"points",
"from",
"a",
"specific",
"location",
"point",
"."
] |
train
|
https://github.com/citiususc/hipster/blob/9ab1236abb833a27641ae73ba9ca890d5c17598e/hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java#L382-L399
|
codeprimate-software/cp-elements
|
src/main/java/org/cp/elements/lang/Assert.java
|
Assert.notEmpty
|
public static void notEmpty(Object[] array, Supplier<String> message) {
if (isEmpty(array)) {
throw new IllegalArgumentException(message.get());
}
}
|
java
|
public static void notEmpty(Object[] array, Supplier<String> message) {
if (isEmpty(array)) {
throw new IllegalArgumentException(message.get());
}
}
|
[
"public",
"static",
"void",
"notEmpty",
"(",
"Object",
"[",
"]",
"array",
",",
"Supplier",
"<",
"String",
">",
"message",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
".",
"get",
"(",
")",
")",
";",
"}",
"}"
] |
Asserts that the {@link Object array} is not empty.
The assertion holds if and only if the {@link Object array} is not {@literal null} and contains at least 1 element.
@param array {@link Object array} to evaluate.
@param message {@link Supplier} containing the message using in the {@link IllegalArgumentException} thrown
if the assertion fails.
@throws java.lang.IllegalArgumentException if the {@link Object array} is {@literal null} or empty.
@see java.lang.Object[]
|
[
"Asserts",
"that",
"the",
"{",
"@link",
"Object",
"array",
"}",
"is",
"not",
"empty",
"."
] |
train
|
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/Assert.java#L973-L977
|
google/closure-compiler
|
src/com/google/javascript/jscomp/TypeCheck.java
|
TypeCheck.visitInterfacePropertyAssignment
|
private void visitInterfacePropertyAssignment(Node object, Node lvalue) {
if (!lvalue.getParent().isAssign()) {
// assignments to interface properties cannot be in destructuring patterns or for-of loops
reportInvalidInterfaceMemberDeclaration(object);
return;
}
Node assign = lvalue.getParent();
Node rvalue = assign.getSecondChild();
JSType rvalueType = getJSType(rvalue);
// Only 2 values are allowed for interface methods:
// goog.abstractMethod
// function () {};
// Other (non-method) interface properties must be stub declarations without assignments, e.g.
// someinterface.prototype.nonMethodProperty;
// which is why we enforce that `rvalueType.isFunctionType()`.
if (!rvalueType.isFunctionType()) {
reportInvalidInterfaceMemberDeclaration(object);
}
if (rvalue.isFunction() && !NodeUtil.isEmptyBlock(NodeUtil.getFunctionBody(rvalue))) {
String abstractMethodName = compiler.getCodingConvention().getAbstractMethodName();
compiler.report(JSError.make(object, INTERFACE_METHOD_NOT_EMPTY, abstractMethodName));
}
}
|
java
|
private void visitInterfacePropertyAssignment(Node object, Node lvalue) {
if (!lvalue.getParent().isAssign()) {
// assignments to interface properties cannot be in destructuring patterns or for-of loops
reportInvalidInterfaceMemberDeclaration(object);
return;
}
Node assign = lvalue.getParent();
Node rvalue = assign.getSecondChild();
JSType rvalueType = getJSType(rvalue);
// Only 2 values are allowed for interface methods:
// goog.abstractMethod
// function () {};
// Other (non-method) interface properties must be stub declarations without assignments, e.g.
// someinterface.prototype.nonMethodProperty;
// which is why we enforce that `rvalueType.isFunctionType()`.
if (!rvalueType.isFunctionType()) {
reportInvalidInterfaceMemberDeclaration(object);
}
if (rvalue.isFunction() && !NodeUtil.isEmptyBlock(NodeUtil.getFunctionBody(rvalue))) {
String abstractMethodName = compiler.getCodingConvention().getAbstractMethodName();
compiler.report(JSError.make(object, INTERFACE_METHOD_NOT_EMPTY, abstractMethodName));
}
}
|
[
"private",
"void",
"visitInterfacePropertyAssignment",
"(",
"Node",
"object",
",",
"Node",
"lvalue",
")",
"{",
"if",
"(",
"!",
"lvalue",
".",
"getParent",
"(",
")",
".",
"isAssign",
"(",
")",
")",
"{",
"// assignments to interface properties cannot be in destructuring patterns or for-of loops",
"reportInvalidInterfaceMemberDeclaration",
"(",
"object",
")",
";",
"return",
";",
"}",
"Node",
"assign",
"=",
"lvalue",
".",
"getParent",
"(",
")",
";",
"Node",
"rvalue",
"=",
"assign",
".",
"getSecondChild",
"(",
")",
";",
"JSType",
"rvalueType",
"=",
"getJSType",
"(",
"rvalue",
")",
";",
"// Only 2 values are allowed for interface methods:",
"// goog.abstractMethod",
"// function () {};",
"// Other (non-method) interface properties must be stub declarations without assignments, e.g.",
"// someinterface.prototype.nonMethodProperty;",
"// which is why we enforce that `rvalueType.isFunctionType()`.",
"if",
"(",
"!",
"rvalueType",
".",
"isFunctionType",
"(",
")",
")",
"{",
"reportInvalidInterfaceMemberDeclaration",
"(",
"object",
")",
";",
"}",
"if",
"(",
"rvalue",
".",
"isFunction",
"(",
")",
"&&",
"!",
"NodeUtil",
".",
"isEmptyBlock",
"(",
"NodeUtil",
".",
"getFunctionBody",
"(",
"rvalue",
")",
")",
")",
"{",
"String",
"abstractMethodName",
"=",
"compiler",
".",
"getCodingConvention",
"(",
")",
".",
"getAbstractMethodName",
"(",
")",
";",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"object",
",",
"INTERFACE_METHOD_NOT_EMPTY",
",",
"abstractMethodName",
")",
")",
";",
"}",
"}"
] |
Visits an lvalue node for cases such as
<pre>
interface.prototype.property = ...;
</pre>
|
[
"Visits",
"an",
"lvalue",
"node",
"for",
"cases",
"such",
"as"
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeCheck.java#L1801-L1825
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
|
FieldUtils.writeField
|
public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
MemberUtils.setAccessibleWorkaround(field);
}
field.set(target, value);
}
|
java
|
public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
MemberUtils.setAccessibleWorkaround(field);
}
field.set(target, value);
}
|
[
"public",
"static",
"void",
"writeField",
"(",
"final",
"Field",
"field",
",",
"final",
"Object",
"target",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"forceAccess",
")",
"throws",
"IllegalAccessException",
"{",
"Validate",
".",
"isTrue",
"(",
"field",
"!=",
"null",
",",
"\"The field must not be null\"",
")",
";",
"if",
"(",
"forceAccess",
"&&",
"!",
"field",
".",
"isAccessible",
"(",
")",
")",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"}",
"else",
"{",
"MemberUtils",
".",
"setAccessibleWorkaround",
"(",
"field",
")",
";",
"}",
"field",
".",
"set",
"(",
"target",
",",
"value",
")",
";",
"}"
] |
Writes a {@link Field}.
@param field
to write
@param target
the object to call on, may be {@code null} for {@code static} fields
@param value
to set
@param forceAccess
whether to break scope restrictions using the
{@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. {@code false} will only
match {@code public} fields.
@throws IllegalArgumentException
if the field is {@code null} or {@code value} is not assignable
@throws IllegalAccessException
if the field is not made accessible or is {@code final}
|
[
"Writes",
"a",
"{",
"@link",
"Field",
"}",
"."
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java#L683-L692
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/json/JsonWriter.java
|
JsonWriter.writeBooleanField
|
private void writeBooleanField(String fieldName, Object value) throws IOException
{
boolean val = ((Boolean) value).booleanValue();
if (val)
{
m_writer.writeNameValuePair(fieldName, val);
}
}
|
java
|
private void writeBooleanField(String fieldName, Object value) throws IOException
{
boolean val = ((Boolean) value).booleanValue();
if (val)
{
m_writer.writeNameValuePair(fieldName, val);
}
}
|
[
"private",
"void",
"writeBooleanField",
"(",
"String",
"fieldName",
",",
"Object",
"value",
")",
"throws",
"IOException",
"{",
"boolean",
"val",
"=",
"(",
"(",
"Boolean",
")",
"value",
")",
".",
"booleanValue",
"(",
")",
";",
"if",
"(",
"val",
")",
"{",
"m_writer",
".",
"writeNameValuePair",
"(",
"fieldName",
",",
"val",
")",
";",
"}",
"}"
] |
Write a boolean field to the JSON file.
@param fieldName field name
@param value field value
|
[
"Write",
"a",
"boolean",
"field",
"to",
"the",
"JSON",
"file",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L400-L407
|
Impetus/Kundera
|
src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java
|
CQLTranslator.buildOrderByClause
|
public void buildOrderByClause(StringBuilder builder, String field, Object orderType, boolean useToken)
{
builder.append(SPACE_STRING);
builder.append(SORT_CLAUSE);
builder = ensureCase(builder, field, useToken);
builder.append(SPACE_STRING);
builder.append(orderType);
}
|
java
|
public void buildOrderByClause(StringBuilder builder, String field, Object orderType, boolean useToken)
{
builder.append(SPACE_STRING);
builder.append(SORT_CLAUSE);
builder = ensureCase(builder, field, useToken);
builder.append(SPACE_STRING);
builder.append(orderType);
}
|
[
"public",
"void",
"buildOrderByClause",
"(",
"StringBuilder",
"builder",
",",
"String",
"field",
",",
"Object",
"orderType",
",",
"boolean",
"useToken",
")",
"{",
"builder",
".",
"append",
"(",
"SPACE_STRING",
")",
";",
"builder",
".",
"append",
"(",
"SORT_CLAUSE",
")",
";",
"builder",
"=",
"ensureCase",
"(",
"builder",
",",
"field",
",",
"useToken",
")",
";",
"builder",
".",
"append",
"(",
"SPACE_STRING",
")",
";",
"builder",
".",
"append",
"(",
"orderType",
")",
";",
"}"
] |
Builds the order by clause.
@param builder
the builder
@param field
the field
@param orderType
the order type
@param useToken
the use token
|
[
"Builds",
"the",
"order",
"by",
"clause",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java#L1488-L1495
|
trellis-ldp/trellis
|
core/http/src/main/java/org/trellisldp/http/impl/HttpUtils.java
|
HttpUtils.checkIfUnmodifiedSince
|
public static void checkIfUnmodifiedSince(final String ifUnmodifiedSince, final Instant modified) {
final Instant time = parseDate(ifUnmodifiedSince);
if (time != null && modified.truncatedTo(SECONDS).isAfter(time)) {
throw new ClientErrorException(status(PRECONDITION_FAILED).build());
}
}
|
java
|
public static void checkIfUnmodifiedSince(final String ifUnmodifiedSince, final Instant modified) {
final Instant time = parseDate(ifUnmodifiedSince);
if (time != null && modified.truncatedTo(SECONDS).isAfter(time)) {
throw new ClientErrorException(status(PRECONDITION_FAILED).build());
}
}
|
[
"public",
"static",
"void",
"checkIfUnmodifiedSince",
"(",
"final",
"String",
"ifUnmodifiedSince",
",",
"final",
"Instant",
"modified",
")",
"{",
"final",
"Instant",
"time",
"=",
"parseDate",
"(",
"ifUnmodifiedSince",
")",
";",
"if",
"(",
"time",
"!=",
"null",
"&&",
"modified",
".",
"truncatedTo",
"(",
"SECONDS",
")",
".",
"isAfter",
"(",
"time",
")",
")",
"{",
"throw",
"new",
"ClientErrorException",
"(",
"status",
"(",
"PRECONDITION_FAILED",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}"
] |
Check for a conditional operation.
@param ifUnmodifiedSince the If-Unmodified-Since header
@param modified the resource modification date
|
[
"Check",
"for",
"a",
"conditional",
"operation",
"."
] |
train
|
https://github.com/trellis-ldp/trellis/blob/789fd7a3df86cab7ebba63e72bf4e58397e5f42d/core/http/src/main/java/org/trellisldp/http/impl/HttpUtils.java#L324-L329
|
BranchMetrics/android-branch-deep-linking
|
Branch-SDK/src/io/branch/referral/Branch.java
|
Branch.initSession
|
public boolean initSession(BranchUniversalReferralInitListener callback, Uri data, Activity activity) {
readAndStripParam(data, activity);
initSession(callback, activity);
return true;
}
|
java
|
public boolean initSession(BranchUniversalReferralInitListener callback, Uri data, Activity activity) {
readAndStripParam(data, activity);
initSession(callback, activity);
return true;
}
|
[
"public",
"boolean",
"initSession",
"(",
"BranchUniversalReferralInitListener",
"callback",
",",
"Uri",
"data",
",",
"Activity",
"activity",
")",
"{",
"readAndStripParam",
"(",
"data",
",",
"activity",
")",
";",
"initSession",
"(",
"callback",
",",
"activity",
")",
";",
"return",
"true",
";",
"}"
] |
<p>Initialises a session with the Branch API.</p>
@param callback A {@link BranchUniversalReferralInitListener} instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.
@param data A {@link Uri} variable containing the details of the source link that
led to this initialisation action.
@param activity The calling {@link Activity} for context.
@return A {@link Boolean} value that will return <i>false</i> if the supplied
<i>data</i> parameter cannot be handled successfully - i.e. is not of a
valid URI format.
|
[
"<p",
">",
"Initialises",
"a",
"session",
"with",
"the",
"Branch",
"API",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L1073-L1077
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java
|
DirectoryConnection.submitAsyncRequest
|
public ServiceDirectoryFuture submitAsyncRequest(ProtocolHeader h, Protocol request, WatcherRegistration wr){
ServiceDirectoryFuture future = new ServiceDirectoryFuture();
queuePacket(h, request, null, null, future, wr);
return future;
}
|
java
|
public ServiceDirectoryFuture submitAsyncRequest(ProtocolHeader h, Protocol request, WatcherRegistration wr){
ServiceDirectoryFuture future = new ServiceDirectoryFuture();
queuePacket(h, request, null, null, future, wr);
return future;
}
|
[
"public",
"ServiceDirectoryFuture",
"submitAsyncRequest",
"(",
"ProtocolHeader",
"h",
",",
"Protocol",
"request",
",",
"WatcherRegistration",
"wr",
")",
"{",
"ServiceDirectoryFuture",
"future",
"=",
"new",
"ServiceDirectoryFuture",
"(",
")",
";",
"queuePacket",
"(",
"h",
",",
"request",
",",
"null",
",",
"null",
",",
"future",
",",
"wr",
")",
";",
"return",
"future",
";",
"}"
] |
Submit a Request in asynchronizing, it return a Future for the
Request Response.
@param h
the ProtocolHeader.
@param request
the Protocol.
@param wr
the WatcherRegistration of the Service.
@return
the Future.
|
[
"Submit",
"a",
"Request",
"in",
"asynchronizing",
"it",
"return",
"a",
"Future",
"for",
"the",
"Request",
"Response",
"."
] |
train
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L401-L405
|
VoltDB/voltdb
|
src/frontend/org/voltdb/parser/JDBCParser.java
|
JDBCParser.parseJDBCCall
|
public static ParsedCall parseJDBCCall(String jdbcCall) throws SQLParser.Exception
{
Matcher m = PAT_CALL_WITH_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
String sql = m.group(1);
int parameterCount = PAT_CLEAN_CALL_PARAMETERS.matcher(m.group(2)).replaceAll("").length();
return new ParsedCall(sql, parameterCount);
}
m = PAT_CALL_WITHOUT_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
return new ParsedCall(m.group(1), 0);
}
return null;
}
|
java
|
public static ParsedCall parseJDBCCall(String jdbcCall) throws SQLParser.Exception
{
Matcher m = PAT_CALL_WITH_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
String sql = m.group(1);
int parameterCount = PAT_CLEAN_CALL_PARAMETERS.matcher(m.group(2)).replaceAll("").length();
return new ParsedCall(sql, parameterCount);
}
m = PAT_CALL_WITHOUT_PARAMETERS.matcher(jdbcCall);
if (m.matches()) {
return new ParsedCall(m.group(1), 0);
}
return null;
}
|
[
"public",
"static",
"ParsedCall",
"parseJDBCCall",
"(",
"String",
"jdbcCall",
")",
"throws",
"SQLParser",
".",
"Exception",
"{",
"Matcher",
"m",
"=",
"PAT_CALL_WITH_PARAMETERS",
".",
"matcher",
"(",
"jdbcCall",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"{",
"String",
"sql",
"=",
"m",
".",
"group",
"(",
"1",
")",
";",
"int",
"parameterCount",
"=",
"PAT_CLEAN_CALL_PARAMETERS",
".",
"matcher",
"(",
"m",
".",
"group",
"(",
"2",
")",
")",
".",
"replaceAll",
"(",
"\"\"",
")",
".",
"length",
"(",
")",
";",
"return",
"new",
"ParsedCall",
"(",
"sql",
",",
"parameterCount",
")",
";",
"}",
"m",
"=",
"PAT_CALL_WITHOUT_PARAMETERS",
".",
"matcher",
"(",
"jdbcCall",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"{",
"return",
"new",
"ParsedCall",
"(",
"m",
".",
"group",
"(",
"1",
")",
",",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Parse call statements for JDBC.
@param jdbcCall statement to parse
@return object with parsed data or null if it didn't parse
@throws SQLParser.Exception
|
[
"Parse",
"call",
"statements",
"for",
"JDBC",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/JDBCParser.java#L67-L80
|
bazaarvoice/emodb
|
table/src/main/java/com/bazaarvoice/emodb/table/db/astyanax/RowKeyUtils.java
|
RowKeyUtils.getRowKeyRaw
|
static ByteBuffer getRowKeyRaw(int shardId, long tableUuid, byte[] contentKeyBytes) {
checkArgument(shardId >= 0 && shardId < 256);
// Assemble a single array which is "1 byte shard id + 8 byte table uuid + n-byte content key".
ByteBuffer rowKey = ByteBuffer.allocate(9 + contentKeyBytes.length);
rowKey.put((byte) shardId);
rowKey.putLong(tableUuid);
rowKey.put(contentKeyBytes);
rowKey.flip();
return rowKey;
}
|
java
|
static ByteBuffer getRowKeyRaw(int shardId, long tableUuid, byte[] contentKeyBytes) {
checkArgument(shardId >= 0 && shardId < 256);
// Assemble a single array which is "1 byte shard id + 8 byte table uuid + n-byte content key".
ByteBuffer rowKey = ByteBuffer.allocate(9 + contentKeyBytes.length);
rowKey.put((byte) shardId);
rowKey.putLong(tableUuid);
rowKey.put(contentKeyBytes);
rowKey.flip();
return rowKey;
}
|
[
"static",
"ByteBuffer",
"getRowKeyRaw",
"(",
"int",
"shardId",
",",
"long",
"tableUuid",
",",
"byte",
"[",
"]",
"contentKeyBytes",
")",
"{",
"checkArgument",
"(",
"shardId",
">=",
"0",
"&&",
"shardId",
"<",
"256",
")",
";",
"// Assemble a single array which is \"1 byte shard id + 8 byte table uuid + n-byte content key\".",
"ByteBuffer",
"rowKey",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"9",
"+",
"contentKeyBytes",
".",
"length",
")",
";",
"rowKey",
".",
"put",
"(",
"(",
"byte",
")",
"shardId",
")",
";",
"rowKey",
".",
"putLong",
"(",
"tableUuid",
")",
";",
"rowKey",
".",
"put",
"(",
"contentKeyBytes",
")",
";",
"rowKey",
".",
"flip",
"(",
")",
";",
"return",
"rowKey",
";",
"}"
] |
Constructs a row key when the row's shard ID is already known, which is rare. Generally this is used for
range queries to construct the lower or upper bound for a query, so it doesn't necessarily need to produce
a valid row key.
|
[
"Constructs",
"a",
"row",
"key",
"when",
"the",
"row",
"s",
"shard",
"ID",
"is",
"already",
"known",
"which",
"is",
"rare",
".",
"Generally",
"this",
"is",
"used",
"for",
"range",
"queries",
"to",
"construct",
"the",
"lower",
"or",
"upper",
"bound",
"for",
"a",
"query",
"so",
"it",
"doesn",
"t",
"necessarily",
"need",
"to",
"produce",
"a",
"valid",
"row",
"key",
"."
] |
train
|
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/table/src/main/java/com/bazaarvoice/emodb/table/db/astyanax/RowKeyUtils.java#L82-L93
|
google/closure-compiler
|
src/com/google/javascript/jscomp/CheckJSDoc.java
|
CheckJSDoc.isJSDocOnFunctionNode
|
private boolean isJSDocOnFunctionNode(Node n, JSDocInfo info) {
switch (n.getToken()) {
case FUNCTION:
case GETTER_DEF:
case SETTER_DEF:
case MEMBER_FUNCTION_DEF:
case STRING_KEY:
case COMPUTED_PROP:
case EXPORT:
return true;
case GETELEM:
case GETPROP:
if (n.getFirstChild().isQualifiedName()) {
// assume qualified names may be function declarations
return true;
}
return false;
case VAR:
case LET:
case CONST:
case ASSIGN:
{
Node lhs = n.getFirstChild();
Node rhs = NodeUtil.getRValueOfLValue(lhs);
if (rhs != null && isClass(rhs) && !info.isConstructor()) {
return false;
}
// TODO(b/124081098): Check that the RHS of the assignment is a
// function. Note that it can be a FUNCTION node, but it can also be
// a call to goog.abstractMethod, goog.functions.constant, etc.
return true;
}
default:
return false;
}
}
|
java
|
private boolean isJSDocOnFunctionNode(Node n, JSDocInfo info) {
switch (n.getToken()) {
case FUNCTION:
case GETTER_DEF:
case SETTER_DEF:
case MEMBER_FUNCTION_DEF:
case STRING_KEY:
case COMPUTED_PROP:
case EXPORT:
return true;
case GETELEM:
case GETPROP:
if (n.getFirstChild().isQualifiedName()) {
// assume qualified names may be function declarations
return true;
}
return false;
case VAR:
case LET:
case CONST:
case ASSIGN:
{
Node lhs = n.getFirstChild();
Node rhs = NodeUtil.getRValueOfLValue(lhs);
if (rhs != null && isClass(rhs) && !info.isConstructor()) {
return false;
}
// TODO(b/124081098): Check that the RHS of the assignment is a
// function. Note that it can be a FUNCTION node, but it can also be
// a call to goog.abstractMethod, goog.functions.constant, etc.
return true;
}
default:
return false;
}
}
|
[
"private",
"boolean",
"isJSDocOnFunctionNode",
"(",
"Node",
"n",
",",
"JSDocInfo",
"info",
")",
"{",
"switch",
"(",
"n",
".",
"getToken",
"(",
")",
")",
"{",
"case",
"FUNCTION",
":",
"case",
"GETTER_DEF",
":",
"case",
"SETTER_DEF",
":",
"case",
"MEMBER_FUNCTION_DEF",
":",
"case",
"STRING_KEY",
":",
"case",
"COMPUTED_PROP",
":",
"case",
"EXPORT",
":",
"return",
"true",
";",
"case",
"GETELEM",
":",
"case",
"GETPROP",
":",
"if",
"(",
"n",
".",
"getFirstChild",
"(",
")",
".",
"isQualifiedName",
"(",
")",
")",
"{",
"// assume qualified names may be function declarations",
"return",
"true",
";",
"}",
"return",
"false",
";",
"case",
"VAR",
":",
"case",
"LET",
":",
"case",
"CONST",
":",
"case",
"ASSIGN",
":",
"{",
"Node",
"lhs",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"rhs",
"=",
"NodeUtil",
".",
"getRValueOfLValue",
"(",
"lhs",
")",
";",
"if",
"(",
"rhs",
"!=",
"null",
"&&",
"isClass",
"(",
"rhs",
")",
"&&",
"!",
"info",
".",
"isConstructor",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// TODO(b/124081098): Check that the RHS of the assignment is a",
"// function. Note that it can be a FUNCTION node, but it can also be",
"// a call to goog.abstractMethod, goog.functions.constant, etc.",
"return",
"true",
";",
"}",
"default",
":",
"return",
"false",
";",
"}",
"}"
] |
Whether this node's JSDoc may apply to a function
<p>This has some false positive cases, to allow for patterns like goog.abstractMethod.
|
[
"Whether",
"this",
"node",
"s",
"JSDoc",
"may",
"apply",
"to",
"a",
"function"
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L440-L476
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelFrameworkImpl.java
|
ChannelFrameworkImpl.getRunningChannel
|
public synchronized Channel getRunningChannel(String inputChannelName, Chain chain) {
if (inputChannelName == null || chain == null) {
return null;
}
Channel channel = null;
// Ensure the chain is running.
if (null != this.chainRunningMap.get(chain.getName())) {
ChannelData[] channels = chain.getChannelsData();
for (int index = 0; index < channels.length; index++) {
if (channels[index].getExternalName().equals(inputChannelName)) {
channel = chain.getChannels()[index];
break;
}
}
}
return channel;
}
|
java
|
public synchronized Channel getRunningChannel(String inputChannelName, Chain chain) {
if (inputChannelName == null || chain == null) {
return null;
}
Channel channel = null;
// Ensure the chain is running.
if (null != this.chainRunningMap.get(chain.getName())) {
ChannelData[] channels = chain.getChannelsData();
for (int index = 0; index < channels.length; index++) {
if (channels[index].getExternalName().equals(inputChannelName)) {
channel = chain.getChannels()[index];
break;
}
}
}
return channel;
}
|
[
"public",
"synchronized",
"Channel",
"getRunningChannel",
"(",
"String",
"inputChannelName",
",",
"Chain",
"chain",
")",
"{",
"if",
"(",
"inputChannelName",
"==",
"null",
"||",
"chain",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Channel",
"channel",
"=",
"null",
";",
"// Ensure the chain is running.",
"if",
"(",
"null",
"!=",
"this",
".",
"chainRunningMap",
".",
"get",
"(",
"chain",
".",
"getName",
"(",
")",
")",
")",
"{",
"ChannelData",
"[",
"]",
"channels",
"=",
"chain",
".",
"getChannelsData",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"channels",
".",
"length",
";",
"index",
"++",
")",
"{",
"if",
"(",
"channels",
"[",
"index",
"]",
".",
"getExternalName",
"(",
")",
".",
"equals",
"(",
"inputChannelName",
")",
")",
"{",
"channel",
"=",
"chain",
".",
"getChannels",
"(",
")",
"[",
"index",
"]",
";",
"break",
";",
"}",
"}",
"}",
"return",
"channel",
";",
"}"
] |
Fetch the input channel from the runtime.
@param inputChannelName
of the (parent) channel requested.
@param chain
in which channel is running.
@return Channel requested, or null if not found.
|
[
"Fetch",
"the",
"input",
"channel",
"from",
"the",
"runtime",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelFrameworkImpl.java#L4048-L4065
|
ThreeTen/threetenbp
|
src/main/java/org/threeten/bp/chrono/Chronology.java
|
Chronology.zonedDateTime
|
@SuppressWarnings({ "rawtypes", "unchecked" })
public ChronoZonedDateTime<?> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTime cldt = localDateTime(temporal);
ChronoLocalDateTimeImpl cldtImpl = ensureChronoLocalDateTime(cldt);
return ChronoZonedDateTimeImpl.ofBest(cldtImpl, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
|
java
|
@SuppressWarnings({ "rawtypes", "unchecked" })
public ChronoZonedDateTime<?> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTime cldt = localDateTime(temporal);
ChronoLocalDateTimeImpl cldtImpl = ensureChronoLocalDateTime(cldt);
return ChronoZonedDateTimeImpl.ofBest(cldtImpl, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"public",
"ChronoZonedDateTime",
"<",
"?",
">",
"zonedDateTime",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"try",
"{",
"ZoneId",
"zone",
"=",
"ZoneId",
".",
"from",
"(",
"temporal",
")",
";",
"try",
"{",
"Instant",
"instant",
"=",
"Instant",
".",
"from",
"(",
"temporal",
")",
";",
"return",
"zonedDateTime",
"(",
"instant",
",",
"zone",
")",
";",
"}",
"catch",
"(",
"DateTimeException",
"ex1",
")",
"{",
"ChronoLocalDateTime",
"cldt",
"=",
"localDateTime",
"(",
"temporal",
")",
";",
"ChronoLocalDateTimeImpl",
"cldtImpl",
"=",
"ensureChronoLocalDateTime",
"(",
"cldt",
")",
";",
"return",
"ChronoZonedDateTimeImpl",
".",
"ofBest",
"(",
"cldtImpl",
",",
"zone",
",",
"null",
")",
";",
"}",
"}",
"catch",
"(",
"DateTimeException",
"ex",
")",
"{",
"throw",
"new",
"DateTimeException",
"(",
"\"Unable to obtain ChronoZonedDateTime from TemporalAccessor: \"",
"+",
"temporal",
".",
"getClass",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] |
Obtains a zoned date-time in this chronology from another temporal object.
<p>
This creates a date-time in this chronology based on the specified {@code TemporalAccessor}.
<p>
This should obtain a {@code ZoneId} using {@link ZoneId#from(TemporalAccessor)}.
The date-time should be obtained by obtaining an {@code Instant}.
If that fails, the local date-time should be used.
@param temporal the temporal object to convert, not null
@return the zoned date-time in this chronology, not null
@throws DateTimeException if unable to create the date-time
|
[
"Obtains",
"a",
"zoned",
"date",
"-",
"time",
"in",
"this",
"chronology",
"from",
"another",
"temporal",
"object",
".",
"<p",
">",
"This",
"creates",
"a",
"date",
"-",
"time",
"in",
"this",
"chronology",
"based",
"on",
"the",
"specified",
"{",
"@code",
"TemporalAccessor",
"}",
".",
"<p",
">",
"This",
"should",
"obtain",
"a",
"{",
"@code",
"ZoneId",
"}",
"using",
"{",
"@link",
"ZoneId#from",
"(",
"TemporalAccessor",
")",
"}",
".",
"The",
"date",
"-",
"time",
"should",
"be",
"obtained",
"by",
"obtaining",
"an",
"{",
"@code",
"Instant",
"}",
".",
"If",
"that",
"fails",
"the",
"local",
"date",
"-",
"time",
"should",
"be",
"used",
"."
] |
train
|
https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/chrono/Chronology.java#L598-L614
|
eserating/siren4j
|
src/main/java/com/google/code/siren4j/converter/ReflectingConverter.java
|
ReflectingConverter.handleSubEntity
|
private void handleSubEntity(EntityBuilder builder, Object obj, Field currentField, List<ReflectedInfo> fieldInfo)
throws Siren4JException {
Siren4JSubEntity subAnno = getSubEntityAnnotation(currentField, fieldInfo);
if (subAnno != null) {
if (isCollection(obj, currentField)) {
Collection<?> coll = (Collection<?>) ReflectionUtils.getFieldValue(currentField, obj);
if (coll != null) {
for (Object o : coll) {
builder.addSubEntity(toEntity(o, currentField, obj, fieldInfo));
}
}
} else {
Object subObj = ReflectionUtils.getFieldValue(currentField, obj);
if (subObj != null) {
builder.addSubEntity(toEntity(subObj, currentField, obj, fieldInfo));
}
}
}
}
|
java
|
private void handleSubEntity(EntityBuilder builder, Object obj, Field currentField, List<ReflectedInfo> fieldInfo)
throws Siren4JException {
Siren4JSubEntity subAnno = getSubEntityAnnotation(currentField, fieldInfo);
if (subAnno != null) {
if (isCollection(obj, currentField)) {
Collection<?> coll = (Collection<?>) ReflectionUtils.getFieldValue(currentField, obj);
if (coll != null) {
for (Object o : coll) {
builder.addSubEntity(toEntity(o, currentField, obj, fieldInfo));
}
}
} else {
Object subObj = ReflectionUtils.getFieldValue(currentField, obj);
if (subObj != null) {
builder.addSubEntity(toEntity(subObj, currentField, obj, fieldInfo));
}
}
}
}
|
[
"private",
"void",
"handleSubEntity",
"(",
"EntityBuilder",
"builder",
",",
"Object",
"obj",
",",
"Field",
"currentField",
",",
"List",
"<",
"ReflectedInfo",
">",
"fieldInfo",
")",
"throws",
"Siren4JException",
"{",
"Siren4JSubEntity",
"subAnno",
"=",
"getSubEntityAnnotation",
"(",
"currentField",
",",
"fieldInfo",
")",
";",
"if",
"(",
"subAnno",
"!=",
"null",
")",
"{",
"if",
"(",
"isCollection",
"(",
"obj",
",",
"currentField",
")",
")",
"{",
"Collection",
"<",
"?",
">",
"coll",
"=",
"(",
"Collection",
"<",
"?",
">",
")",
"ReflectionUtils",
".",
"getFieldValue",
"(",
"currentField",
",",
"obj",
")",
";",
"if",
"(",
"coll",
"!=",
"null",
")",
"{",
"for",
"(",
"Object",
"o",
":",
"coll",
")",
"{",
"builder",
".",
"addSubEntity",
"(",
"toEntity",
"(",
"o",
",",
"currentField",
",",
"obj",
",",
"fieldInfo",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"Object",
"subObj",
"=",
"ReflectionUtils",
".",
"getFieldValue",
"(",
"currentField",
",",
"obj",
")",
";",
"if",
"(",
"subObj",
"!=",
"null",
")",
"{",
"builder",
".",
"addSubEntity",
"(",
"toEntity",
"(",
"subObj",
",",
"currentField",
",",
"obj",
",",
"fieldInfo",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Handles sub entities.
@param builder assumed not <code>null</code>.
@param obj assumed not <code>null</code>.
@param currentField assumed not <code>null</code>.
@throws Siren4JException
|
[
"Handles",
"sub",
"entities",
"."
] |
train
|
https://github.com/eserating/siren4j/blob/f12e3185076ad920352ec4f6eb2a071a3683505f/src/main/java/com/google/code/siren4j/converter/ReflectingConverter.java#L474-L494
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/util/MLLibUtil.java
|
MLLibUtil.fromLabeledPoint
|
public static JavaRDD<DataSet> fromLabeledPoint(JavaRDD<LabeledPoint> data, final long numPossibleLabels,
boolean preCache) {
if (preCache && !data.getStorageLevel().useMemory()) {
data.cache();
}
return data.map(new Function<LabeledPoint, DataSet>() {
@Override
public DataSet call(LabeledPoint lp) {
return fromLabeledPoint(lp, numPossibleLabels);
}
});
}
|
java
|
public static JavaRDD<DataSet> fromLabeledPoint(JavaRDD<LabeledPoint> data, final long numPossibleLabels,
boolean preCache) {
if (preCache && !data.getStorageLevel().useMemory()) {
data.cache();
}
return data.map(new Function<LabeledPoint, DataSet>() {
@Override
public DataSet call(LabeledPoint lp) {
return fromLabeledPoint(lp, numPossibleLabels);
}
});
}
|
[
"public",
"static",
"JavaRDD",
"<",
"DataSet",
">",
"fromLabeledPoint",
"(",
"JavaRDD",
"<",
"LabeledPoint",
">",
"data",
",",
"final",
"long",
"numPossibleLabels",
",",
"boolean",
"preCache",
")",
"{",
"if",
"(",
"preCache",
"&&",
"!",
"data",
".",
"getStorageLevel",
"(",
")",
".",
"useMemory",
"(",
")",
")",
"{",
"data",
".",
"cache",
"(",
")",
";",
"}",
"return",
"data",
".",
"map",
"(",
"new",
"Function",
"<",
"LabeledPoint",
",",
"DataSet",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DataSet",
"call",
"(",
"LabeledPoint",
"lp",
")",
"{",
"return",
"fromLabeledPoint",
"(",
"lp",
",",
"numPossibleLabels",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Converts JavaRDD labeled points to JavaRDD DataSets.
@param data JavaRDD LabeledPoints
@param numPossibleLabels number of possible labels
@param preCache boolean pre-cache rdd before operation
@return
|
[
"Converts",
"JavaRDD",
"labeled",
"points",
"to",
"JavaRDD",
"DataSets",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/util/MLLibUtil.java#L358-L369
|
VoltDB/voltdb
|
src/frontend/org/voltcore/utils/ssl/SSLConfiguration.java
|
SSLConfiguration.createTrustManagers
|
private static TrustManagerFactory createTrustManagers(String filepath, String keystorePassword)
throws KeyStoreException, FileNotFoundException,
IOException, NoSuchAlgorithmException, CertificateException {
KeyStore trustStore = KeyStore.getInstance("JKS");
try (InputStream trustStoreIS = new FileInputStream(filepath)) {
trustStore.load(trustStoreIS, keystorePassword.toCharArray());
}
TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(trustStore);
return trustFactory;
}
|
java
|
private static TrustManagerFactory createTrustManagers(String filepath, String keystorePassword)
throws KeyStoreException, FileNotFoundException,
IOException, NoSuchAlgorithmException, CertificateException {
KeyStore trustStore = KeyStore.getInstance("JKS");
try (InputStream trustStoreIS = new FileInputStream(filepath)) {
trustStore.load(trustStoreIS, keystorePassword.toCharArray());
}
TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(trustStore);
return trustFactory;
}
|
[
"private",
"static",
"TrustManagerFactory",
"createTrustManagers",
"(",
"String",
"filepath",
",",
"String",
"keystorePassword",
")",
"throws",
"KeyStoreException",
",",
"FileNotFoundException",
",",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"CertificateException",
"{",
"KeyStore",
"trustStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"\"JKS\"",
")",
";",
"try",
"(",
"InputStream",
"trustStoreIS",
"=",
"new",
"FileInputStream",
"(",
"filepath",
")",
")",
"{",
"trustStore",
".",
"load",
"(",
"trustStoreIS",
",",
"keystorePassword",
".",
"toCharArray",
"(",
")",
")",
";",
"}",
"TrustManagerFactory",
"trustFactory",
"=",
"TrustManagerFactory",
".",
"getInstance",
"(",
"TrustManagerFactory",
".",
"getDefaultAlgorithm",
"(",
")",
")",
";",
"trustFactory",
".",
"init",
"(",
"trustStore",
")",
";",
"return",
"trustFactory",
";",
"}"
] |
Creates the trust managers required to initiate the {@link SSLContext}, using a JKS keystore as an input.
@param filepath - the path to the JKS keystore.
@param keystorePassword - the keystore's password.
@return {@link TrustManager} array, that will be used to initiate the {@link SSLContext}.
@throws Exception
|
[
"Creates",
"the",
"trust",
"managers",
"required",
"to",
"initiate",
"the",
"{",
"@link",
"SSLContext",
"}",
"using",
"a",
"JKS",
"keystore",
"as",
"an",
"input",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/utils/ssl/SSLConfiguration.java#L151-L161
|
Azure/azure-sdk-for-java
|
policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java
|
PolicyStatesInner.summarizeForResourceGroupAsync
|
public Observable<SummarizeResultsInner> summarizeForResourceGroupAsync(String subscriptionId, String resourceGroupName) {
return summarizeForResourceGroupWithServiceResponseAsync(subscriptionId, resourceGroupName).map(new Func1<ServiceResponse<SummarizeResultsInner>, SummarizeResultsInner>() {
@Override
public SummarizeResultsInner call(ServiceResponse<SummarizeResultsInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<SummarizeResultsInner> summarizeForResourceGroupAsync(String subscriptionId, String resourceGroupName) {
return summarizeForResourceGroupWithServiceResponseAsync(subscriptionId, resourceGroupName).map(new Func1<ServiceResponse<SummarizeResultsInner>, SummarizeResultsInner>() {
@Override
public SummarizeResultsInner call(ServiceResponse<SummarizeResultsInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"SummarizeResultsInner",
">",
"summarizeForResourceGroupAsync",
"(",
"String",
"subscriptionId",
",",
"String",
"resourceGroupName",
")",
"{",
"return",
"summarizeForResourceGroupWithServiceResponseAsync",
"(",
"subscriptionId",
",",
"resourceGroupName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"SummarizeResultsInner",
">",
",",
"SummarizeResultsInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"SummarizeResultsInner",
"call",
"(",
"ServiceResponse",
"<",
"SummarizeResultsInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Summarizes policy states for the resources under the resource group.
@param subscriptionId Microsoft Azure subscription ID.
@param resourceGroupName Resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the SummarizeResultsInner object
|
[
"Summarizes",
"policy",
"states",
"for",
"the",
"resources",
"under",
"the",
"resource",
"group",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java#L1128-L1135
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.