repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
204
| func_name
stringlengths 5
103
| whole_func_string
stringlengths 87
3.44k
| language
stringclasses 1
value | func_code_string
stringlengths 87
3.44k
| func_code_tokens
sequencelengths 21
714
| func_documentation_string
stringlengths 61
1.95k
| func_documentation_tokens
sequencelengths 1
482
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
309
|
---|---|---|---|---|---|---|---|---|---|---|
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java | RgbaColor.fromHex | public static RgbaColor fromHex(String hex) {
if (hex.length() == 0 || hex.charAt(0) != '#') return getDefaultColor();
// #rgb
if (hex.length() == 4) {
return new RgbaColor(parseHex(hex, 1, 2),
parseHex(hex, 2, 3),
parseHex(hex, 3, 4));
}
// #rrggbb
else if (hex.length() == 7) {
return new RgbaColor(parseHex(hex, 1, 3),
parseHex(hex, 3, 5),
parseHex(hex, 5, 7));
}
else {
return getDefaultColor();
}
} | java | public static RgbaColor fromHex(String hex) {
if (hex.length() == 0 || hex.charAt(0) != '#') return getDefaultColor();
// #rgb
if (hex.length() == 4) {
return new RgbaColor(parseHex(hex, 1, 2),
parseHex(hex, 2, 3),
parseHex(hex, 3, 4));
}
// #rrggbb
else if (hex.length() == 7) {
return new RgbaColor(parseHex(hex, 1, 3),
parseHex(hex, 3, 5),
parseHex(hex, 5, 7));
}
else {
return getDefaultColor();
}
} | [
"public",
"static",
"RgbaColor",
"fromHex",
"(",
"String",
"hex",
")",
"{",
"if",
"(",
"hex",
".",
"length",
"(",
")",
"==",
"0",
"||",
"hex",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"return",
"getDefaultColor",
"(",
")",
";",
"// #rgb",
"if",
"(",
"hex",
".",
"length",
"(",
")",
"==",
"4",
")",
"{",
"return",
"new",
"RgbaColor",
"(",
"parseHex",
"(",
"hex",
",",
"1",
",",
"2",
")",
",",
"parseHex",
"(",
"hex",
",",
"2",
",",
"3",
")",
",",
"parseHex",
"(",
"hex",
",",
"3",
",",
"4",
")",
")",
";",
"}",
"// #rrggbb",
"else",
"if",
"(",
"hex",
".",
"length",
"(",
")",
"==",
"7",
")",
"{",
"return",
"new",
"RgbaColor",
"(",
"parseHex",
"(",
"hex",
",",
"1",
",",
"3",
")",
",",
"parseHex",
"(",
"hex",
",",
"3",
",",
"5",
")",
",",
"parseHex",
"(",
"hex",
",",
"5",
",",
"7",
")",
")",
";",
"}",
"else",
"{",
"return",
"getDefaultColor",
"(",
")",
";",
"}",
"}"
] | Parses an RgbaColor from a hexadecimal value.
@return returns the parsed color | [
"Parses",
"an",
"RgbaColor",
"from",
"a",
"hexadecimal",
"value",
"."
] | train | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L107-L129 |
oboehm/jfachwert | src/main/java/de/jfachwert/post/Adresse.java | Adresse.of | public static Adresse of(Ort ort, String strasse, String hausnummer) {
return new Adresse(ort, strasse, hausnummer);
} | java | public static Adresse of(Ort ort, String strasse, String hausnummer) {
return new Adresse(ort, strasse, hausnummer);
} | [
"public",
"static",
"Adresse",
"of",
"(",
"Ort",
"ort",
",",
"String",
"strasse",
",",
"String",
"hausnummer",
")",
"{",
"return",
"new",
"Adresse",
"(",
"ort",
",",
"strasse",
",",
"hausnummer",
")",
";",
"}"
] | Liefert eine Adresse mit den uebergebenen Parametern.
@param ort the ort
@param strasse the strasse
@param hausnummer the hausnummer
@return Adresse | [
"Liefert",
"eine",
"Adresse",
"mit",
"den",
"uebergebenen",
"Parametern",
"."
] | train | https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/post/Adresse.java#L155-L157 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/util/BaseApplication.java | BaseApplication.getPDatabaseParent | public ThinPhysicalDatabaseParent getPDatabaseParent(Map<String,Object> properties, boolean bCreateIfNew)
{
return this.getEnvironment().getPDatabaseParent(properties, bCreateIfNew);
} | java | public ThinPhysicalDatabaseParent getPDatabaseParent(Map<String,Object> properties, boolean bCreateIfNew)
{
return this.getEnvironment().getPDatabaseParent(properties, bCreateIfNew);
} | [
"public",
"ThinPhysicalDatabaseParent",
"getPDatabaseParent",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
",",
"boolean",
"bCreateIfNew",
")",
"{",
"return",
"this",
".",
"getEnvironment",
"(",
")",
".",
"getPDatabaseParent",
"(",
"properties",
",",
"bCreateIfNew",
")",
";",
"}"
] | Get the (optional) raw data database manager.
@return The pDatabaseOwner (returns an object, so this package isn't dependent on PDatabaseOwner). | [
"Get",
"the",
"(",
"optional",
")",
"raw",
"data",
"database",
"manager",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/BaseApplication.java#L238-L241 |
DJCordhose/jmte | src/com/floreysoft/jmte/util/Util.java | Util.fileToString | public static String fileToString(String fileName, String charsetName) {
return fileToString(new File(fileName), charsetName);
} | java | public static String fileToString(String fileName, String charsetName) {
return fileToString(new File(fileName), charsetName);
} | [
"public",
"static",
"String",
"fileToString",
"(",
"String",
"fileName",
",",
"String",
"charsetName",
")",
"{",
"return",
"fileToString",
"(",
"new",
"File",
"(",
"fileName",
")",
",",
"charsetName",
")",
";",
"}"
] | Transforms a file into a string.
@param fileName
name of the file to be transformed
@param charsetName
encoding of the file
@return the string containing the content of the file | [
"Transforms",
"a",
"file",
"into",
"a",
"string",
"."
] | train | https://github.com/DJCordhose/jmte/blob/7334e6d111cc2198c5cf69ee336584ab9e192fe5/src/com/floreysoft/jmte/util/Util.java#L111-L113 |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPE.java | JNRPE.getServerBootstrap | private ServerBootstrap getServerBootstrap(final boolean useSSL) {
final CommandInvoker invoker = new CommandInvoker(pluginRepository, commandRepository, acceptParams, getExecutionContext());
final ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(final SocketChannel ch) throws Exception {
if (useSSL) {
final SSLEngine engine = getSSLEngine();
engine.setEnabledCipherSuites(engine.getSupportedCipherSuites());
engine.setUseClientMode(false);
engine.setNeedClientAuth(false);
ch.pipeline().addLast("ssl", new SslHandler(engine));
}
ch.pipeline()
.addLast(new JNRPERequestDecoder(), new JNRPEResponseEncoder(), new JNRPEServerHandler(invoker, context))
.addLast("idleStateHandler", new IdleStateHandler(readTimeout, writeTimeout, 0))
.addLast(
"jnrpeIdleStateHandler",
new JNRPEIdleStateHandler(context));
}
}).option(ChannelOption.SO_BACKLOG, maxAcceptedConnections).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
return serverBootstrap;
} | java | private ServerBootstrap getServerBootstrap(final boolean useSSL) {
final CommandInvoker invoker = new CommandInvoker(pluginRepository, commandRepository, acceptParams, getExecutionContext());
final ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(final SocketChannel ch) throws Exception {
if (useSSL) {
final SSLEngine engine = getSSLEngine();
engine.setEnabledCipherSuites(engine.getSupportedCipherSuites());
engine.setUseClientMode(false);
engine.setNeedClientAuth(false);
ch.pipeline().addLast("ssl", new SslHandler(engine));
}
ch.pipeline()
.addLast(new JNRPERequestDecoder(), new JNRPEResponseEncoder(), new JNRPEServerHandler(invoker, context))
.addLast("idleStateHandler", new IdleStateHandler(readTimeout, writeTimeout, 0))
.addLast(
"jnrpeIdleStateHandler",
new JNRPEIdleStateHandler(context));
}
}).option(ChannelOption.SO_BACKLOG, maxAcceptedConnections).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
return serverBootstrap;
} | [
"private",
"ServerBootstrap",
"getServerBootstrap",
"(",
"final",
"boolean",
"useSSL",
")",
"{",
"final",
"CommandInvoker",
"invoker",
"=",
"new",
"CommandInvoker",
"(",
"pluginRepository",
",",
"commandRepository",
",",
"acceptParams",
",",
"getExecutionContext",
"(",
")",
")",
";",
"final",
"ServerBootstrap",
"serverBootstrap",
"=",
"new",
"ServerBootstrap",
"(",
")",
";",
"serverBootstrap",
".",
"group",
"(",
"bossGroup",
",",
"workerGroup",
")",
".",
"channel",
"(",
"NioServerSocketChannel",
".",
"class",
")",
".",
"childHandler",
"(",
"new",
"ChannelInitializer",
"<",
"SocketChannel",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"initChannel",
"(",
"final",
"SocketChannel",
"ch",
")",
"throws",
"Exception",
"{",
"if",
"(",
"useSSL",
")",
"{",
"final",
"SSLEngine",
"engine",
"=",
"getSSLEngine",
"(",
")",
";",
"engine",
".",
"setEnabledCipherSuites",
"(",
"engine",
".",
"getSupportedCipherSuites",
"(",
")",
")",
";",
"engine",
".",
"setUseClientMode",
"(",
"false",
")",
";",
"engine",
".",
"setNeedClientAuth",
"(",
"false",
")",
";",
"ch",
".",
"pipeline",
"(",
")",
".",
"addLast",
"(",
"\"ssl\"",
",",
"new",
"SslHandler",
"(",
"engine",
")",
")",
";",
"}",
"ch",
".",
"pipeline",
"(",
")",
".",
"addLast",
"(",
"new",
"JNRPERequestDecoder",
"(",
")",
",",
"new",
"JNRPEResponseEncoder",
"(",
")",
",",
"new",
"JNRPEServerHandler",
"(",
"invoker",
",",
"context",
")",
")",
".",
"addLast",
"(",
"\"idleStateHandler\"",
",",
"new",
"IdleStateHandler",
"(",
"readTimeout",
",",
"writeTimeout",
",",
"0",
")",
")",
".",
"addLast",
"(",
"\"jnrpeIdleStateHandler\"",
",",
"new",
"JNRPEIdleStateHandler",
"(",
"context",
")",
")",
";",
"}",
"}",
")",
".",
"option",
"(",
"ChannelOption",
".",
"SO_BACKLOG",
",",
"maxAcceptedConnections",
")",
".",
"childOption",
"(",
"ChannelOption",
".",
"SO_KEEPALIVE",
",",
"Boolean",
".",
"TRUE",
")",
";",
"return",
"serverBootstrap",
";",
"}"
] | Creates and returns a configured NETTY ServerBootstrap object.
@param useSSL
<code>true</code> if SSL must be used.
@return the server bootstrap object | [
"Creates",
"and",
"returns",
"a",
"configured",
"NETTY",
"ServerBootstrap",
"object",
"."
] | train | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPE.java#L325-L352 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.readDelTemplatesFromMetaInf | private static ImmutableSet<String> readDelTemplatesFromMetaInf(ClassLoader loader) {
try {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
Enumeration<URL> resources = loader.getResources(Names.META_INF_DELTEMPLATE_PATH);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
try (InputStream in = url.openStream()) {
BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF_8));
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
builder.add(line);
}
}
}
return builder.build();
} catch (IOException iox) {
throw new RuntimeException("Unable to read deltemplate listing", iox);
}
} | java | private static ImmutableSet<String> readDelTemplatesFromMetaInf(ClassLoader loader) {
try {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
Enumeration<URL> resources = loader.getResources(Names.META_INF_DELTEMPLATE_PATH);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
try (InputStream in = url.openStream()) {
BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF_8));
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
builder.add(line);
}
}
}
return builder.build();
} catch (IOException iox) {
throw new RuntimeException("Unable to read deltemplate listing", iox);
}
} | [
"private",
"static",
"ImmutableSet",
"<",
"String",
">",
"readDelTemplatesFromMetaInf",
"(",
"ClassLoader",
"loader",
")",
"{",
"try",
"{",
"ImmutableSet",
".",
"Builder",
"<",
"String",
">",
"builder",
"=",
"ImmutableSet",
".",
"builder",
"(",
")",
";",
"Enumeration",
"<",
"URL",
">",
"resources",
"=",
"loader",
".",
"getResources",
"(",
"Names",
".",
"META_INF_DELTEMPLATE_PATH",
")",
";",
"while",
"(",
"resources",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"URL",
"url",
"=",
"resources",
".",
"nextElement",
"(",
")",
";",
"try",
"(",
"InputStream",
"in",
"=",
"url",
".",
"openStream",
"(",
")",
")",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
",",
"UTF_8",
")",
")",
";",
"for",
"(",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"line",
"!=",
"null",
";",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"{",
"builder",
".",
"add",
"(",
"line",
")",
";",
"}",
"}",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"iox",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to read deltemplate listing\"",
",",
"iox",
")",
";",
"}",
"}"
] | Walks all resources with the META_INF_DELTEMPLATE_PATH and collects the deltemplates. | [
"Walks",
"all",
"resources",
"with",
"the",
"META_INF_DELTEMPLATE_PATH",
"and",
"collects",
"the",
"deltemplates",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L116-L133 |
SonarSource/sonarqube | server/sonar-db-dao/src/main/java/org/sonar/db/alm/ProjectAlmBindingDao.java | ProjectAlmBindingDao.selectByRepoIds | public List<ProjectAlmBindingDto> selectByRepoIds(final DbSession session, ALM alm, Collection<String> repoIds) {
return executeLargeInputs(repoIds, partitionedIds -> getMapper(session).selectByRepoIds(alm.getId(), partitionedIds));
} | java | public List<ProjectAlmBindingDto> selectByRepoIds(final DbSession session, ALM alm, Collection<String> repoIds) {
return executeLargeInputs(repoIds, partitionedIds -> getMapper(session).selectByRepoIds(alm.getId(), partitionedIds));
} | [
"public",
"List",
"<",
"ProjectAlmBindingDto",
">",
"selectByRepoIds",
"(",
"final",
"DbSession",
"session",
",",
"ALM",
"alm",
",",
"Collection",
"<",
"String",
">",
"repoIds",
")",
"{",
"return",
"executeLargeInputs",
"(",
"repoIds",
",",
"partitionedIds",
"->",
"getMapper",
"(",
"session",
")",
".",
"selectByRepoIds",
"(",
"alm",
".",
"getId",
"(",
")",
",",
"partitionedIds",
")",
")",
";",
"}"
] | Gets a list of bindings by their repo_id. The result does NOT contain {@code null} values for bindings not found, so
the size of result may be less than the number of ids.
<p>Results may be in a different order as input ids.</p> | [
"Gets",
"a",
"list",
"of",
"bindings",
"by",
"their",
"repo_id",
".",
"The",
"result",
"does",
"NOT",
"contain",
"{"
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/ProjectAlmBindingDao.java#L69-L71 |
aws/aws-sdk-java | aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/ChannelsResponse.java | ChannelsResponse.withChannels | public ChannelsResponse withChannels(java.util.Map<String, ChannelResponse> channels) {
setChannels(channels);
return this;
} | java | public ChannelsResponse withChannels(java.util.Map<String, ChannelResponse> channels) {
setChannels(channels);
return this;
} | [
"public",
"ChannelsResponse",
"withChannels",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"ChannelResponse",
">",
"channels",
")",
"{",
"setChannels",
"(",
"channels",
")",
";",
"return",
"this",
";",
"}"
] | A map of channels, with the ChannelType as the key and the Channel as the value.
@param channels
A map of channels, with the ChannelType as the key and the Channel as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"A",
"map",
"of",
"channels",
"with",
"the",
"ChannelType",
"as",
"the",
"key",
"and",
"the",
"Channel",
"as",
"the",
"value",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-pinpoint/src/main/java/com/amazonaws/services/pinpoint/model/ChannelsResponse.java#L61-L64 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java | GrailsHibernateUtil.addOrderPossiblyNested | private static void addOrderPossiblyNested(AbstractHibernateDatastore datastore, Criteria c, Class<?> targetClass, String sort, String order, boolean ignoreCase) {
int firstDotPos = sort.indexOf(".");
if (firstDotPos == -1) {
addOrder(c, sort, order, ignoreCase);
} else { // nested property
String sortHead = sort.substring(0,firstDotPos);
String sortTail = sort.substring(firstDotPos+1);
PersistentProperty property = getGrailsDomainClassProperty(datastore, targetClass, sortHead);
if (property instanceof Embedded) {
// embedded objects cannot reference entities (at time of writing), so no more recursion needed
addOrder(c, sort, order, ignoreCase);
} else if(property instanceof Association) {
Criteria subCriteria = c.createCriteria(sortHead);
Class<?> propertyTargetClass = ((Association)property).getAssociatedEntity().getJavaClass();
GrailsHibernateUtil.cacheCriteriaByMapping(datastore, propertyTargetClass, subCriteria);
addOrderPossiblyNested(datastore, subCriteria, propertyTargetClass, sortTail, order, ignoreCase); // Recurse on nested sort
}
}
} | java | private static void addOrderPossiblyNested(AbstractHibernateDatastore datastore, Criteria c, Class<?> targetClass, String sort, String order, boolean ignoreCase) {
int firstDotPos = sort.indexOf(".");
if (firstDotPos == -1) {
addOrder(c, sort, order, ignoreCase);
} else { // nested property
String sortHead = sort.substring(0,firstDotPos);
String sortTail = sort.substring(firstDotPos+1);
PersistentProperty property = getGrailsDomainClassProperty(datastore, targetClass, sortHead);
if (property instanceof Embedded) {
// embedded objects cannot reference entities (at time of writing), so no more recursion needed
addOrder(c, sort, order, ignoreCase);
} else if(property instanceof Association) {
Criteria subCriteria = c.createCriteria(sortHead);
Class<?> propertyTargetClass = ((Association)property).getAssociatedEntity().getJavaClass();
GrailsHibernateUtil.cacheCriteriaByMapping(datastore, propertyTargetClass, subCriteria);
addOrderPossiblyNested(datastore, subCriteria, propertyTargetClass, sortTail, order, ignoreCase); // Recurse on nested sort
}
}
} | [
"private",
"static",
"void",
"addOrderPossiblyNested",
"(",
"AbstractHibernateDatastore",
"datastore",
",",
"Criteria",
"c",
",",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"sort",
",",
"String",
"order",
",",
"boolean",
"ignoreCase",
")",
"{",
"int",
"firstDotPos",
"=",
"sort",
".",
"indexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"firstDotPos",
"==",
"-",
"1",
")",
"{",
"addOrder",
"(",
"c",
",",
"sort",
",",
"order",
",",
"ignoreCase",
")",
";",
"}",
"else",
"{",
"// nested property",
"String",
"sortHead",
"=",
"sort",
".",
"substring",
"(",
"0",
",",
"firstDotPos",
")",
";",
"String",
"sortTail",
"=",
"sort",
".",
"substring",
"(",
"firstDotPos",
"+",
"1",
")",
";",
"PersistentProperty",
"property",
"=",
"getGrailsDomainClassProperty",
"(",
"datastore",
",",
"targetClass",
",",
"sortHead",
")",
";",
"if",
"(",
"property",
"instanceof",
"Embedded",
")",
"{",
"// embedded objects cannot reference entities (at time of writing), so no more recursion needed",
"addOrder",
"(",
"c",
",",
"sort",
",",
"order",
",",
"ignoreCase",
")",
";",
"}",
"else",
"if",
"(",
"property",
"instanceof",
"Association",
")",
"{",
"Criteria",
"subCriteria",
"=",
"c",
".",
"createCriteria",
"(",
"sortHead",
")",
";",
"Class",
"<",
"?",
">",
"propertyTargetClass",
"=",
"(",
"(",
"Association",
")",
"property",
")",
".",
"getAssociatedEntity",
"(",
")",
".",
"getJavaClass",
"(",
")",
";",
"GrailsHibernateUtil",
".",
"cacheCriteriaByMapping",
"(",
"datastore",
",",
"propertyTargetClass",
",",
"subCriteria",
")",
";",
"addOrderPossiblyNested",
"(",
"datastore",
",",
"subCriteria",
",",
"propertyTargetClass",
",",
"sortTail",
",",
"order",
",",
"ignoreCase",
")",
";",
"// Recurse on nested sort",
"}",
"}",
"}"
] | Add order to criteria, creating necessary subCriteria if nested sort property (ie. sort:'nested.property'). | [
"Add",
"order",
"to",
"criteria",
"creating",
"necessary",
"subCriteria",
"if",
"nested",
"sort",
"property",
"(",
"ie",
".",
"sort",
":",
"nested",
".",
"property",
")",
"."
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java#L206-L224 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java | InternalService.getConversations | @Deprecated
public Observable<ComapiResult<List<ConversationDetails>>> getConversations(@NonNull final Scope scope) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueGetConversations(scope);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doGetConversations(token, dataMgr.getSessionDAO().session().getProfileId(), scope).map(result -> {
List<ConversationDetails> newList = new ArrayList<>();
List<Conversation> oldList = result.getResult();
if (oldList != null && !oldList.isEmpty()) {
newList.addAll(oldList);
}
return new ComapiResult<>(result, newList);
});
}
} | java | @Deprecated
public Observable<ComapiResult<List<ConversationDetails>>> getConversations(@NonNull final Scope scope) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueGetConversations(scope);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doGetConversations(token, dataMgr.getSessionDAO().session().getProfileId(), scope).map(result -> {
List<ConversationDetails> newList = new ArrayList<>();
List<Conversation> oldList = result.getResult();
if (oldList != null && !oldList.isEmpty()) {
newList.addAll(oldList);
}
return new ComapiResult<>(result, newList);
});
}
} | [
"@",
"Deprecated",
"public",
"Observable",
"<",
"ComapiResult",
"<",
"List",
"<",
"ConversationDetails",
">",
">",
">",
"getConversations",
"(",
"@",
"NonNull",
"final",
"Scope",
"scope",
")",
"{",
"final",
"String",
"token",
"=",
"getToken",
"(",
")",
";",
"if",
"(",
"sessionController",
".",
"isCreatingSession",
"(",
")",
")",
"{",
"return",
"getTaskQueue",
"(",
")",
".",
"queueGetConversations",
"(",
"scope",
")",
";",
"}",
"else",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"token",
")",
")",
"{",
"return",
"Observable",
".",
"error",
"(",
"getSessionStateErrorDescription",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"doGetConversations",
"(",
"token",
",",
"dataMgr",
".",
"getSessionDAO",
"(",
")",
".",
"session",
"(",
")",
".",
"getProfileId",
"(",
")",
",",
"scope",
")",
".",
"map",
"(",
"result",
"->",
"{",
"List",
"<",
"ConversationDetails",
">",
"newList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Conversation",
">",
"oldList",
"=",
"result",
".",
"getResult",
"(",
")",
";",
"if",
"(",
"oldList",
"!=",
"null",
"&&",
"!",
"oldList",
".",
"isEmpty",
"(",
")",
")",
"{",
"newList",
".",
"addAll",
"(",
"oldList",
")",
";",
"}",
"return",
"new",
"ComapiResult",
"<>",
"(",
"result",
",",
"newList",
")",
";",
"}",
")",
";",
"}",
"}"
] | Returns observable to get all visible conversations.
@param scope {@link Scope} of the query
@return Observable to to create a conversation.
@deprecated Please use {@link InternalService#getConversations(boolean)} instead. | [
"Returns",
"observable",
"to",
"get",
"all",
"visible",
"conversations",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java#L504-L523 |
belaban/JGroups | src/org/jgroups/jmx/ResourceDMBean.java | ResourceDMBean.findGetter | protected static Accessor findGetter(Object target, String attr_name) {
final String name=Util.attributeNameToMethodName(attr_name);
Class<?> clazz=target.getClass();
Method method=Util.findMethod(target, Arrays.asList("get" + name, "is" + name, toLowerCase(name)));
if(method != null && (isGetMethod(method) || isIsMethod(method)))
return new MethodAccessor(method, target);
// 4. Find a field last_name
Field field=Util.getField(clazz, attr_name);
if(field != null)
return new FieldAccessor(field, target);
return new NoopAccessor();
} | java | protected static Accessor findGetter(Object target, String attr_name) {
final String name=Util.attributeNameToMethodName(attr_name);
Class<?> clazz=target.getClass();
Method method=Util.findMethod(target, Arrays.asList("get" + name, "is" + name, toLowerCase(name)));
if(method != null && (isGetMethod(method) || isIsMethod(method)))
return new MethodAccessor(method, target);
// 4. Find a field last_name
Field field=Util.getField(clazz, attr_name);
if(field != null)
return new FieldAccessor(field, target);
return new NoopAccessor();
} | [
"protected",
"static",
"Accessor",
"findGetter",
"(",
"Object",
"target",
",",
"String",
"attr_name",
")",
"{",
"final",
"String",
"name",
"=",
"Util",
".",
"attributeNameToMethodName",
"(",
"attr_name",
")",
";",
"Class",
"<",
"?",
">",
"clazz",
"=",
"target",
".",
"getClass",
"(",
")",
";",
"Method",
"method",
"=",
"Util",
".",
"findMethod",
"(",
"target",
",",
"Arrays",
".",
"asList",
"(",
"\"get\"",
"+",
"name",
",",
"\"is\"",
"+",
"name",
",",
"toLowerCase",
"(",
"name",
")",
")",
")",
";",
"if",
"(",
"method",
"!=",
"null",
"&&",
"(",
"isGetMethod",
"(",
"method",
")",
"||",
"isIsMethod",
"(",
"method",
")",
")",
")",
"return",
"new",
"MethodAccessor",
"(",
"method",
",",
"target",
")",
";",
"// 4. Find a field last_name",
"Field",
"field",
"=",
"Util",
".",
"getField",
"(",
"clazz",
",",
"attr_name",
")",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"return",
"new",
"FieldAccessor",
"(",
"field",
",",
"target",
")",
";",
"return",
"new",
"NoopAccessor",
"(",
")",
";",
"}"
] | Finds an accessor for an attribute. Tries to find getAttrName(), isAttrName(), attrName() methods. If not
found, tries to use reflection to get the value of attr_name. If still not found, creates a NullAccessor. | [
"Finds",
"an",
"accessor",
"for",
"an",
"attribute",
".",
"Tries",
"to",
"find",
"getAttrName",
"()",
"isAttrName",
"()",
"attrName",
"()",
"methods",
".",
"If",
"not",
"found",
"tries",
"to",
"use",
"reflection",
"to",
"get",
"the",
"value",
"of",
"attr_name",
".",
"If",
"still",
"not",
"found",
"creates",
"a",
"NullAccessor",
"."
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/jmx/ResourceDMBean.java#L334-L349 |
HubSpot/Singularity | SingularityExecutor/src/main/java/com/hubspot/singularity/executor/SingularityExecutor.java | SingularityExecutor.launchTask | @Override
public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) {
final String taskId = taskInfo.getTaskId().getValue();
LOG.info("Asked to launch task {}", taskId);
try {
final ch.qos.logback.classic.Logger taskLog = taskBuilder.buildTaskLogger(taskId, taskInfo.getExecutor().getExecutorId().getValue());
final SingularityExecutorTask task = taskBuilder.buildTask(taskId, executorDriver, taskInfo, taskLog);
SubmitState submitState = monitor.submit(task);
switch (submitState) {
case REJECTED:
LOG.warn("Can't launch task {}, it was rejected (probably due to shutdown)", taskInfo);
break;
case TASK_ALREADY_EXISTED:
LOG.error("Can't launch task {}, already had a task with that ID", taskInfo);
break;
case SUBMITTED:
task.getLog().info("Launched task {} with data {}", taskId, task.getExecutorData());
break;
}
} catch (Throwable t) {
LOG.error("Unexpected exception starting task {}", taskId, t);
executorUtils.sendStatusUpdate(executorDriver, taskInfo.getTaskId(), TaskState.TASK_LOST, String.format("Unexpected exception while launching task %s - %s", taskId, t.getMessage()), LOG);
}
} | java | @Override
public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) {
final String taskId = taskInfo.getTaskId().getValue();
LOG.info("Asked to launch task {}", taskId);
try {
final ch.qos.logback.classic.Logger taskLog = taskBuilder.buildTaskLogger(taskId, taskInfo.getExecutor().getExecutorId().getValue());
final SingularityExecutorTask task = taskBuilder.buildTask(taskId, executorDriver, taskInfo, taskLog);
SubmitState submitState = monitor.submit(task);
switch (submitState) {
case REJECTED:
LOG.warn("Can't launch task {}, it was rejected (probably due to shutdown)", taskInfo);
break;
case TASK_ALREADY_EXISTED:
LOG.error("Can't launch task {}, already had a task with that ID", taskInfo);
break;
case SUBMITTED:
task.getLog().info("Launched task {} with data {}", taskId, task.getExecutorData());
break;
}
} catch (Throwable t) {
LOG.error("Unexpected exception starting task {}", taskId, t);
executorUtils.sendStatusUpdate(executorDriver, taskInfo.getTaskId(), TaskState.TASK_LOST, String.format("Unexpected exception while launching task %s - %s", taskId, t.getMessage()), LOG);
}
} | [
"@",
"Override",
"public",
"void",
"launchTask",
"(",
"final",
"ExecutorDriver",
"executorDriver",
",",
"final",
"Protos",
".",
"TaskInfo",
"taskInfo",
")",
"{",
"final",
"String",
"taskId",
"=",
"taskInfo",
".",
"getTaskId",
"(",
")",
".",
"getValue",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Asked to launch task {}\"",
",",
"taskId",
")",
";",
"try",
"{",
"final",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
"taskLog",
"=",
"taskBuilder",
".",
"buildTaskLogger",
"(",
"taskId",
",",
"taskInfo",
".",
"getExecutor",
"(",
")",
".",
"getExecutorId",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"final",
"SingularityExecutorTask",
"task",
"=",
"taskBuilder",
".",
"buildTask",
"(",
"taskId",
",",
"executorDriver",
",",
"taskInfo",
",",
"taskLog",
")",
";",
"SubmitState",
"submitState",
"=",
"monitor",
".",
"submit",
"(",
"task",
")",
";",
"switch",
"(",
"submitState",
")",
"{",
"case",
"REJECTED",
":",
"LOG",
".",
"warn",
"(",
"\"Can't launch task {}, it was rejected (probably due to shutdown)\"",
",",
"taskInfo",
")",
";",
"break",
";",
"case",
"TASK_ALREADY_EXISTED",
":",
"LOG",
".",
"error",
"(",
"\"Can't launch task {}, already had a task with that ID\"",
",",
"taskInfo",
")",
";",
"break",
";",
"case",
"SUBMITTED",
":",
"task",
".",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Launched task {} with data {}\"",
",",
"taskId",
",",
"task",
".",
"getExecutorData",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unexpected exception starting task {}\"",
",",
"taskId",
",",
"t",
")",
";",
"executorUtils",
".",
"sendStatusUpdate",
"(",
"executorDriver",
",",
"taskInfo",
".",
"getTaskId",
"(",
")",
",",
"TaskState",
".",
"TASK_LOST",
",",
"String",
".",
"format",
"(",
"\"Unexpected exception while launching task %s - %s\"",
",",
"taskId",
",",
"t",
".",
"getMessage",
"(",
")",
")",
",",
"LOG",
")",
";",
"}",
"}"
] | Invoked when a task has been launched on this executor (initiated
via Scheduler::launchTasks). Note that this task can be realized
with a thread, a process, or some simple computation, however, no
other callbacks will be invoked on this executor until this
callback has returned. | [
"Invoked",
"when",
"a",
"task",
"has",
"been",
"launched",
"on",
"this",
"executor",
"(",
"initiated",
"via",
"Scheduler",
"::",
"launchTasks",
")",
".",
"Note",
"that",
"this",
"task",
"can",
"be",
"realized",
"with",
"a",
"thread",
"a",
"process",
"or",
"some",
"simple",
"computation",
"however",
"no",
"other",
"callbacks",
"will",
"be",
"invoked",
"on",
"this",
"executor",
"until",
"this",
"callback",
"has",
"returned",
"."
] | train | https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/SingularityExecutor.java#L73-L102 |
jmeetsma/Iglu-Common | src/main/java/org/ijsberg/iglu/caching/module/StandardCache.java | StandardCache.cleanup | public long cleanup() {
int garbageSize = 0;
if (isCachingEnabled()) {
System.out.println(new LogEntry(Level.VERBOSE, "Identifying expired objects"));
ArrayList<K> garbage = getExpiredObjects();
garbageSize = garbage.size();
System.out.println(new LogEntry("cache cleanup: expired objects: " + garbageSize));
for (K key : garbage) {
clear(key);
}
}
return garbageSize;
} | java | public long cleanup() {
int garbageSize = 0;
if (isCachingEnabled()) {
System.out.println(new LogEntry(Level.VERBOSE, "Identifying expired objects"));
ArrayList<K> garbage = getExpiredObjects();
garbageSize = garbage.size();
System.out.println(new LogEntry("cache cleanup: expired objects: " + garbageSize));
for (K key : garbage) {
clear(key);
}
}
return garbageSize;
} | [
"public",
"long",
"cleanup",
"(",
")",
"{",
"int",
"garbageSize",
"=",
"0",
";",
"if",
"(",
"isCachingEnabled",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"new",
"LogEntry",
"(",
"Level",
".",
"VERBOSE",
",",
"\"Identifying expired objects\"",
")",
")",
";",
"ArrayList",
"<",
"K",
">",
"garbage",
"=",
"getExpiredObjects",
"(",
")",
";",
"garbageSize",
"=",
"garbage",
".",
"size",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"new",
"LogEntry",
"(",
"\"cache cleanup: expired objects: \"",
"+",
"garbageSize",
")",
")",
";",
"for",
"(",
"K",
"key",
":",
"garbage",
")",
"{",
"clear",
"(",
"key",
")",
";",
"}",
"}",
"return",
"garbageSize",
";",
"}"
] | Removes all expired objects.
@return the number of removed objects. | [
"Removes",
"all",
"expired",
"objects",
"."
] | train | https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/caching/module/StandardCache.java#L320-L332 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SDLayerParams.java | SDLayerParams.addBiasParam | public void addBiasParam(@NonNull String paramKey, @NonNull long... paramShape) {
Preconditions.checkArgument(paramShape.length > 0, "Provided mia- parameter shape is"
+ " invalid: length 0 provided for shape. Parameter: " + paramKey);
biasParams.put(paramKey, paramShape);
paramsList = null;
weightParamsList = null;
biasParamsList = null;
} | java | public void addBiasParam(@NonNull String paramKey, @NonNull long... paramShape) {
Preconditions.checkArgument(paramShape.length > 0, "Provided mia- parameter shape is"
+ " invalid: length 0 provided for shape. Parameter: " + paramKey);
biasParams.put(paramKey, paramShape);
paramsList = null;
weightParamsList = null;
biasParamsList = null;
} | [
"public",
"void",
"addBiasParam",
"(",
"@",
"NonNull",
"String",
"paramKey",
",",
"@",
"NonNull",
"long",
"...",
"paramShape",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"paramShape",
".",
"length",
">",
"0",
",",
"\"Provided mia- parameter shape is\"",
"+",
"\" invalid: length 0 provided for shape. Parameter: \"",
"+",
"paramKey",
")",
";",
"biasParams",
".",
"put",
"(",
"paramKey",
",",
"paramShape",
")",
";",
"paramsList",
"=",
"null",
";",
"weightParamsList",
"=",
"null",
";",
"biasParamsList",
"=",
"null",
";",
"}"
] | Add a bias parameter to the layer, with the specified shape. For example, a standard fully connected layer
could have bias parameters with shape [1, layerSize]
@param paramKey The parameter key (name) for the bias parameter
@param paramShape Shape of the bias parameter array | [
"Add",
"a",
"bias",
"parameter",
"to",
"the",
"layer",
"with",
"the",
"specified",
"shape",
".",
"For",
"example",
"a",
"standard",
"fully",
"connected",
"layer",
"could",
"have",
"bias",
"parameters",
"with",
"shape",
"[",
"1",
"layerSize",
"]"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SDLayerParams.java#L81-L88 |
elki-project/elki | addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java | AbstractLayout3DPC.buildSpanningTree | protected N buildSpanningTree(int dim, double[] mat, Layout layout) {
assert (layout.edges == null || layout.edges.size() == 0);
int[] iedges = PrimsMinimumSpanningTree.processDense(mat, new LowerTriangularAdapter(dim));
int root = findOptimalRoot(iedges);
// Convert edges:
ArrayList<Edge> edges = new ArrayList<>(iedges.length >> 1);
for(int i = 1; i < iedges.length; i += 2) {
edges.add(new Edge(iedges[i - 1], iedges[i]));
}
layout.edges = edges;
// Prefill nodes array with nulls.
ArrayList<N> nodes = new ArrayList<>(dim);
for(int i = 0; i < dim; i++) {
nodes.add(null);
}
layout.nodes = nodes;
N rootnode = buildTree(iedges, root, -1, nodes);
return rootnode;
} | java | protected N buildSpanningTree(int dim, double[] mat, Layout layout) {
assert (layout.edges == null || layout.edges.size() == 0);
int[] iedges = PrimsMinimumSpanningTree.processDense(mat, new LowerTriangularAdapter(dim));
int root = findOptimalRoot(iedges);
// Convert edges:
ArrayList<Edge> edges = new ArrayList<>(iedges.length >> 1);
for(int i = 1; i < iedges.length; i += 2) {
edges.add(new Edge(iedges[i - 1], iedges[i]));
}
layout.edges = edges;
// Prefill nodes array with nulls.
ArrayList<N> nodes = new ArrayList<>(dim);
for(int i = 0; i < dim; i++) {
nodes.add(null);
}
layout.nodes = nodes;
N rootnode = buildTree(iedges, root, -1, nodes);
return rootnode;
} | [
"protected",
"N",
"buildSpanningTree",
"(",
"int",
"dim",
",",
"double",
"[",
"]",
"mat",
",",
"Layout",
"layout",
")",
"{",
"assert",
"(",
"layout",
".",
"edges",
"==",
"null",
"||",
"layout",
".",
"edges",
".",
"size",
"(",
")",
"==",
"0",
")",
";",
"int",
"[",
"]",
"iedges",
"=",
"PrimsMinimumSpanningTree",
".",
"processDense",
"(",
"mat",
",",
"new",
"LowerTriangularAdapter",
"(",
"dim",
")",
")",
";",
"int",
"root",
"=",
"findOptimalRoot",
"(",
"iedges",
")",
";",
"// Convert edges:",
"ArrayList",
"<",
"Edge",
">",
"edges",
"=",
"new",
"ArrayList",
"<>",
"(",
"iedges",
".",
"length",
">>",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"iedges",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"edges",
".",
"add",
"(",
"new",
"Edge",
"(",
"iedges",
"[",
"i",
"-",
"1",
"]",
",",
"iedges",
"[",
"i",
"]",
")",
")",
";",
"}",
"layout",
".",
"edges",
"=",
"edges",
";",
"// Prefill nodes array with nulls.",
"ArrayList",
"<",
"N",
">",
"nodes",
"=",
"new",
"ArrayList",
"<>",
"(",
"dim",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dim",
";",
"i",
"++",
")",
"{",
"nodes",
".",
"add",
"(",
"null",
")",
";",
"}",
"layout",
".",
"nodes",
"=",
"nodes",
";",
"N",
"rootnode",
"=",
"buildTree",
"(",
"iedges",
",",
"root",
",",
"-",
"1",
",",
"nodes",
")",
";",
"return",
"rootnode",
";",
"}"
] | Build the minimum spanning tree.
@param mat Similarity matrix
@param layout Layout to write to
@return Root node id | [
"Build",
"the",
"minimum",
"spanning",
"tree",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java#L133-L154 |
alkacon/opencms-core | src/org/opencms/xml/A_CmsXmlDocument.java | A_CmsXmlDocument.getBookmarkName | protected static final String getBookmarkName(String name, Locale locale) {
StringBuffer result = new StringBuffer(64);
result.append('/');
result.append(locale.toString());
result.append('/');
result.append(name);
return result.toString();
} | java | protected static final String getBookmarkName(String name, Locale locale) {
StringBuffer result = new StringBuffer(64);
result.append('/');
result.append(locale.toString());
result.append('/');
result.append(name);
return result.toString();
} | [
"protected",
"static",
"final",
"String",
"getBookmarkName",
"(",
"String",
"name",
",",
"Locale",
"locale",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"64",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"locale",
".",
"toString",
"(",
")",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"name",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Creates the bookmark name for a localized element to be used in the bookmark lookup table.<p>
@param name the element name
@param locale the element locale
@return the bookmark name for a localized element | [
"Creates",
"the",
"bookmark",
"name",
"for",
"a",
"localized",
"element",
"to",
"be",
"used",
"in",
"the",
"bookmark",
"lookup",
"table",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/A_CmsXmlDocument.java#L108-L116 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/cache/ObjectCacheJCSPerClassImpl.java | ObjectCacheJCSPerClassImpl.getCachePerClass | private ObjectCache getCachePerClass(Class objectClass, int methodCall)
{
ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
if (cache == null && methodCall == AbstractMetaCache.METHOD_CACHE)
{
/**
* the cache wasn't found, and the cachesByClass didn't contain the key with a
* null value, so create a new cache for this classtype
*/
cache = new ObjectCacheJCSImpl(objectClass.getName());
cachesByClass.put(objectClass.getName(), cache);
}
return cache;
} | java | private ObjectCache getCachePerClass(Class objectClass, int methodCall)
{
ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
if (cache == null && methodCall == AbstractMetaCache.METHOD_CACHE)
{
/**
* the cache wasn't found, and the cachesByClass didn't contain the key with a
* null value, so create a new cache for this classtype
*/
cache = new ObjectCacheJCSImpl(objectClass.getName());
cachesByClass.put(objectClass.getName(), cache);
}
return cache;
} | [
"private",
"ObjectCache",
"getCachePerClass",
"(",
"Class",
"objectClass",
",",
"int",
"methodCall",
")",
"{",
"ObjectCache",
"cache",
"=",
"(",
"ObjectCache",
")",
"cachesByClass",
".",
"get",
"(",
"objectClass",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"cache",
"==",
"null",
"&&",
"methodCall",
"==",
"AbstractMetaCache",
".",
"METHOD_CACHE",
")",
"{",
"/**\r\n * the cache wasn't found, and the cachesByClass didn't contain the key with a\r\n * null value, so create a new cache for this classtype\r\n */",
"cache",
"=",
"new",
"ObjectCacheJCSImpl",
"(",
"objectClass",
".",
"getName",
"(",
")",
")",
";",
"cachesByClass",
".",
"put",
"(",
"objectClass",
".",
"getName",
"(",
")",
",",
"cache",
")",
";",
"}",
"return",
"cache",
";",
"}"
] | Gets the cache for the given class
@param objectClass The class to look up the cache for
@return The cache | [
"Gets",
"the",
"cache",
"for",
"the",
"given",
"class"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/cache/ObjectCacheJCSPerClassImpl.java#L108-L121 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/exception/ContextedException.java | ContextedException.setContextValue | @Override
public ContextedException setContextValue(final String label, final Object value) {
exceptionContext.setContextValue(label, value);
return this;
} | java | @Override
public ContextedException setContextValue(final String label, final Object value) {
exceptionContext.setContextValue(label, value);
return this;
} | [
"@",
"Override",
"public",
"ContextedException",
"setContextValue",
"(",
"final",
"String",
"label",
",",
"final",
"Object",
"value",
")",
"{",
"exceptionContext",
".",
"setContextValue",
"(",
"label",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets information helpful to a developer in diagnosing and correcting the problem.
For the information to be meaningful, the value passed should have a reasonable
toString() implementation.
Any existing values with the same labels are removed before the new one is added.
<p>
Note: This exception is only serializable if the object added as value is serializable.
</p>
@param label a textual label associated with information, {@code null} not recommended
@param value information needed to understand exception, may be {@code null}
@return {@code this}, for method chaining, not {@code null} | [
"Sets",
"information",
"helpful",
"to",
"a",
"developer",
"in",
"diagnosing",
"and",
"correcting",
"the",
"problem",
".",
"For",
"the",
"information",
"to",
"be",
"meaningful",
"the",
"value",
"passed",
"should",
"have",
"a",
"reasonable",
"toString",
"()",
"implementation",
".",
"Any",
"existing",
"values",
"with",
"the",
"same",
"labels",
"are",
"removed",
"before",
"the",
"new",
"one",
"is",
"added",
".",
"<p",
">",
"Note",
":",
"This",
"exception",
"is",
"only",
"serializable",
"if",
"the",
"object",
"added",
"as",
"value",
"is",
"serializable",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/exception/ContextedException.java#L191-L195 |
spring-projects/spring-data-solr | src/main/java/org/springframework/data/solr/core/query/Criteria.java | Criteria.sloppy | public Criteria sloppy(String phrase, int distance) {
if (distance <= 0) {
throw new InvalidDataAccessApiUsageException("Slop distance has to be greater than 0.");
}
if (!StringUtils.contains(phrase, CRITERIA_VALUE_SEPERATOR)) {
throw new InvalidDataAccessApiUsageException("Phrase must consist of multiple terms, separated with spaces.");
}
predicates.add(new Predicate(OperationKey.SLOPPY, new Object[] { phrase, Integer.valueOf(distance) }));
return this;
} | java | public Criteria sloppy(String phrase, int distance) {
if (distance <= 0) {
throw new InvalidDataAccessApiUsageException("Slop distance has to be greater than 0.");
}
if (!StringUtils.contains(phrase, CRITERIA_VALUE_SEPERATOR)) {
throw new InvalidDataAccessApiUsageException("Phrase must consist of multiple terms, separated with spaces.");
}
predicates.add(new Predicate(OperationKey.SLOPPY, new Object[] { phrase, Integer.valueOf(distance) }));
return this;
} | [
"public",
"Criteria",
"sloppy",
"(",
"String",
"phrase",
",",
"int",
"distance",
")",
"{",
"if",
"(",
"distance",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidDataAccessApiUsageException",
"(",
"\"Slop distance has to be greater than 0.\"",
")",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"contains",
"(",
"phrase",
",",
"CRITERIA_VALUE_SEPERATOR",
")",
")",
"{",
"throw",
"new",
"InvalidDataAccessApiUsageException",
"(",
"\"Phrase must consist of multiple terms, separated with spaces.\"",
")",
";",
"}",
"predicates",
".",
"add",
"(",
"new",
"Predicate",
"(",
"OperationKey",
".",
"SLOPPY",
",",
"new",
"Object",
"[",
"]",
"{",
"phrase",
",",
"Integer",
".",
"valueOf",
"(",
"distance",
")",
"}",
")",
")",
";",
"return",
"this",
";",
"}"
] | Crates new {@link Predicate} with trailing {@code ~} followed by distance
@param phrase
@param distance
@return | [
"Crates",
"new",
"{",
"@link",
"Predicate",
"}",
"with",
"trailing",
"{",
"@code",
"~",
"}",
"followed",
"by",
"distance"
] | train | https://github.com/spring-projects/spring-data-solr/blob/20be5cb82498b70134dfda6c1a91ad21f8e657e0/src/main/java/org/springframework/data/solr/core/query/Criteria.java#L356-L367 |
before/uadetector | modules/uadetector-core/src/main/java/net/sf/uadetector/parser/AbstractUserAgentStringParser.java | AbstractUserAgentStringParser.examineAsBrowser | private static void examineAsBrowser(final UserAgent.Builder builder, final Data data) {
Matcher matcher;
VersionNumber version = VersionNumber.UNKNOWN;
for (final Entry<BrowserPattern, Browser> entry : data.getPatternToBrowserMap().entrySet()) {
matcher = entry.getKey().getPattern().matcher(builder.getUserAgentString());
if (matcher.find()) {
entry.getValue().copyTo(builder);
// try to get the browser version from the first subgroup
if (matcher.groupCount() > ZERO_MATCHING_GROUPS) {
version = VersionNumber.parseVersion(matcher.group(1) != null ? matcher.group(1) : "");
}
builder.setVersionNumber(version);
break;
}
}
} | java | private static void examineAsBrowser(final UserAgent.Builder builder, final Data data) {
Matcher matcher;
VersionNumber version = VersionNumber.UNKNOWN;
for (final Entry<BrowserPattern, Browser> entry : data.getPatternToBrowserMap().entrySet()) {
matcher = entry.getKey().getPattern().matcher(builder.getUserAgentString());
if (matcher.find()) {
entry.getValue().copyTo(builder);
// try to get the browser version from the first subgroup
if (matcher.groupCount() > ZERO_MATCHING_GROUPS) {
version = VersionNumber.parseVersion(matcher.group(1) != null ? matcher.group(1) : "");
}
builder.setVersionNumber(version);
break;
}
}
} | [
"private",
"static",
"void",
"examineAsBrowser",
"(",
"final",
"UserAgent",
".",
"Builder",
"builder",
",",
"final",
"Data",
"data",
")",
"{",
"Matcher",
"matcher",
";",
"VersionNumber",
"version",
"=",
"VersionNumber",
".",
"UNKNOWN",
";",
"for",
"(",
"final",
"Entry",
"<",
"BrowserPattern",
",",
"Browser",
">",
"entry",
":",
"data",
".",
"getPatternToBrowserMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"matcher",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"getPattern",
"(",
")",
".",
"matcher",
"(",
"builder",
".",
"getUserAgentString",
"(",
")",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"copyTo",
"(",
"builder",
")",
";",
"// try to get the browser version from the first subgroup",
"if",
"(",
"matcher",
".",
"groupCount",
"(",
")",
">",
"ZERO_MATCHING_GROUPS",
")",
"{",
"version",
"=",
"VersionNumber",
".",
"parseVersion",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
"!=",
"null",
"?",
"matcher",
".",
"group",
"(",
"1",
")",
":",
"\"\"",
")",
";",
"}",
"builder",
".",
"setVersionNumber",
"(",
"version",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Examines the user agent string whether it is a browser.
@param userAgent
String of an user agent
@param builder
Builder for an user agent information | [
"Examines",
"the",
"user",
"agent",
"string",
"whether",
"it",
"is",
"a",
"browser",
"."
] | train | https://github.com/before/uadetector/blob/215fb652723c52866572cff885f52a3fe67b9db5/modules/uadetector-core/src/main/java/net/sf/uadetector/parser/AbstractUserAgentStringParser.java#L54-L72 |
adessoAG/wicked-charts | highcharts-wrapper/src/main/java/de/adesso/wickedcharts/highcharts/options/util/OptionsUtil.java | OptionsUtil.getPointWithWickedChartsId | public static Point getPointWithWickedChartsId(final Options options, final int wickedChartsId) {
for (Series<?> series : options.getSeries()) {
for (Object object : series.getData()) {
if (!(object instanceof Point)) {
break;
} else {
Point point = (Point) object;
if (point.getWickedChartsId() == wickedChartsId) {
return point;
}
}
}
}
return null;
} | java | public static Point getPointWithWickedChartsId(final Options options, final int wickedChartsId) {
for (Series<?> series : options.getSeries()) {
for (Object object : series.getData()) {
if (!(object instanceof Point)) {
break;
} else {
Point point = (Point) object;
if (point.getWickedChartsId() == wickedChartsId) {
return point;
}
}
}
}
return null;
} | [
"public",
"static",
"Point",
"getPointWithWickedChartsId",
"(",
"final",
"Options",
"options",
",",
"final",
"int",
"wickedChartsId",
")",
"{",
"for",
"(",
"Series",
"<",
"?",
">",
"series",
":",
"options",
".",
"getSeries",
"(",
")",
")",
"{",
"for",
"(",
"Object",
"object",
":",
"series",
".",
"getData",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"object",
"instanceof",
"Point",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"Point",
"point",
"=",
"(",
"Point",
")",
"object",
";",
"if",
"(",
"point",
".",
"getWickedChartsId",
"(",
")",
"==",
"wickedChartsId",
")",
"{",
"return",
"point",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Retrieves the {@link Point} object with the given wickedChartsId from the
given {@link Options} object. Returns null if a Point with the given ID
does not exist.
@param options Chartoptions
@param wickedChartsId corresponding ID
@return Point object | [
"Retrieves",
"the",
"{",
"@link",
"Point",
"}",
"object",
"with",
"the",
"given",
"wickedChartsId",
"from",
"the",
"given",
"{",
"@link",
"Options",
"}",
"object",
".",
"Returns",
"null",
"if",
"a",
"Point",
"with",
"the",
"given",
"ID",
"does",
"not",
"exist",
"."
] | train | https://github.com/adessoAG/wicked-charts/blob/498aceff025f612e22ba5135b26531afeabac03c/highcharts-wrapper/src/main/java/de/adesso/wickedcharts/highcharts/options/util/OptionsUtil.java#L193-L207 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringConverter.java | StringConverter.unicodeStringToString | public static String unicodeStringToString(String s) {
if ((s == null) || (s.indexOf("\\u") == -1)) {
return s;
}
int len = s.length();
char[] b = new char[len];
int j = 0;
for (int i = 0; i < len; i++) {
char c = s.charAt(i);
if (c == '\\' && i < len - 5) {
char c1 = s.charAt(i + 1);
if (c1 == 'u') {
i++;
// 4 characters read should always return 0-15
int k = getNibble(s.charAt(++i)) << 12;
k += getNibble(s.charAt(++i)) << 8;
k += getNibble(s.charAt(++i)) << 4;
k += getNibble(s.charAt(++i));
b[j++] = (char) k;
} else {
b[j++] = c;
}
} else {
b[j++] = c;
}
}
return new String(b, 0, j);
} | java | public static String unicodeStringToString(String s) {
if ((s == null) || (s.indexOf("\\u") == -1)) {
return s;
}
int len = s.length();
char[] b = new char[len];
int j = 0;
for (int i = 0; i < len; i++) {
char c = s.charAt(i);
if (c == '\\' && i < len - 5) {
char c1 = s.charAt(i + 1);
if (c1 == 'u') {
i++;
// 4 characters read should always return 0-15
int k = getNibble(s.charAt(++i)) << 12;
k += getNibble(s.charAt(++i)) << 8;
k += getNibble(s.charAt(++i)) << 4;
k += getNibble(s.charAt(++i));
b[j++] = (char) k;
} else {
b[j++] = c;
}
} else {
b[j++] = c;
}
}
return new String(b, 0, j);
} | [
"public",
"static",
"String",
"unicodeStringToString",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"(",
"s",
"==",
"null",
")",
"||",
"(",
"s",
".",
"indexOf",
"(",
"\"\\\\u\"",
")",
"==",
"-",
"1",
")",
")",
"{",
"return",
"s",
";",
"}",
"int",
"len",
"=",
"s",
".",
"length",
"(",
")",
";",
"char",
"[",
"]",
"b",
"=",
"new",
"char",
"[",
"len",
"]",
";",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"&&",
"i",
"<",
"len",
"-",
"5",
")",
"{",
"char",
"c1",
"=",
"s",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
";",
"if",
"(",
"c1",
"==",
"'",
"'",
")",
"{",
"i",
"++",
";",
"// 4 characters read should always return 0-15",
"int",
"k",
"=",
"getNibble",
"(",
"s",
".",
"charAt",
"(",
"++",
"i",
")",
")",
"<<",
"12",
";",
"k",
"+=",
"getNibble",
"(",
"s",
".",
"charAt",
"(",
"++",
"i",
")",
")",
"<<",
"8",
";",
"k",
"+=",
"getNibble",
"(",
"s",
".",
"charAt",
"(",
"++",
"i",
")",
")",
"<<",
"4",
";",
"k",
"+=",
"getNibble",
"(",
"s",
".",
"charAt",
"(",
"++",
"i",
")",
")",
";",
"b",
"[",
"j",
"++",
"]",
"=",
"(",
"char",
")",
"k",
";",
"}",
"else",
"{",
"b",
"[",
"j",
"++",
"]",
"=",
"c",
";",
"}",
"}",
"else",
"{",
"b",
"[",
"j",
"++",
"]",
"=",
"c",
";",
"}",
"}",
"return",
"new",
"String",
"(",
"b",
",",
"0",
",",
"j",
")",
";",
"}"
] | Hsqldb specific decoding used only for log files. This method converts
the 7 bit escaped ASCII strings in a log file back into Java Unicode
strings. See stringToUnicodeBytes() above. <p>
Method based on Hypersonic Code
@param s encoded ASCII string in byte array
@return Java string | [
"Hsqldb",
"specific",
"decoding",
"used",
"only",
"for",
"log",
"files",
".",
"This",
"method",
"converts",
"the",
"7",
"bit",
"escaped",
"ASCII",
"strings",
"in",
"a",
"log",
"file",
"back",
"into",
"Java",
"Unicode",
"strings",
".",
"See",
"stringToUnicodeBytes",
"()",
"above",
".",
"<p",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringConverter.java#L434-L469 |
wcm-io/wcm-io-caconfig | extensions/src/main/java/io/wcm/caconfig/extensions/persistence/impl/PersistenceUtils.java | PersistenceUtils.ensurePageIfNotContainingPage | public static Resource ensurePageIfNotContainingPage(ResourceResolver resolver, String pagePath,
String resourceType, ConfigurationManagementSettings configurationManagementSettings) {
Matcher matcher = PAGE_PATH_PATTERN.matcher(pagePath);
if (matcher.matches()) {
// ensure that shorted path part that ends with /jcr:content is created as AEM page (if not existent already)
String detectedPagePath = matcher.group(1);
ensurePage(resolver, detectedPagePath, null, resourceType, null, configurationManagementSettings);
return getOrCreateResource(resolver, pagePath, DEFAULT_FOLDER_NODE_TYPE_IN_PAGE, null, configurationManagementSettings);
}
return ensurePage(resolver, pagePath, null, resourceType, null, configurationManagementSettings);
} | java | public static Resource ensurePageIfNotContainingPage(ResourceResolver resolver, String pagePath,
String resourceType, ConfigurationManagementSettings configurationManagementSettings) {
Matcher matcher = PAGE_PATH_PATTERN.matcher(pagePath);
if (matcher.matches()) {
// ensure that shorted path part that ends with /jcr:content is created as AEM page (if not existent already)
String detectedPagePath = matcher.group(1);
ensurePage(resolver, detectedPagePath, null, resourceType, null, configurationManagementSettings);
return getOrCreateResource(resolver, pagePath, DEFAULT_FOLDER_NODE_TYPE_IN_PAGE, null, configurationManagementSettings);
}
return ensurePage(resolver, pagePath, null, resourceType, null, configurationManagementSettings);
} | [
"public",
"static",
"Resource",
"ensurePageIfNotContainingPage",
"(",
"ResourceResolver",
"resolver",
",",
"String",
"pagePath",
",",
"String",
"resourceType",
",",
"ConfigurationManagementSettings",
"configurationManagementSettings",
")",
"{",
"Matcher",
"matcher",
"=",
"PAGE_PATH_PATTERN",
".",
"matcher",
"(",
"pagePath",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"// ensure that shorted path part that ends with /jcr:content is created as AEM page (if not existent already)",
"String",
"detectedPagePath",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"ensurePage",
"(",
"resolver",
",",
"detectedPagePath",
",",
"null",
",",
"resourceType",
",",
"null",
",",
"configurationManagementSettings",
")",
";",
"return",
"getOrCreateResource",
"(",
"resolver",
",",
"pagePath",
",",
"DEFAULT_FOLDER_NODE_TYPE_IN_PAGE",
",",
"null",
",",
"configurationManagementSettings",
")",
";",
"}",
"return",
"ensurePage",
"(",
"resolver",
",",
"pagePath",
",",
"null",
",",
"resourceType",
",",
"null",
",",
"configurationManagementSettings",
")",
";",
"}"
] | Ensure that a page at the given path exists, if the path is not already contained in a page.
@param resolver Resource resolver
@param pagePath Page path
@param resourceType Resource type for page (if not template is set)
@param configurationManagementSettings Configuration management settings
@return Resource for AEM page or resource inside a page. | [
"Ensure",
"that",
"a",
"page",
"at",
"the",
"given",
"path",
"exists",
"if",
"the",
"path",
"is",
"not",
"already",
"contained",
"in",
"a",
"page",
"."
] | train | https://github.com/wcm-io/wcm-io-caconfig/blob/48592eadb0b62a09eec555cedfae7e00b213f6ed/extensions/src/main/java/io/wcm/caconfig/extensions/persistence/impl/PersistenceUtils.java#L118-L128 |
jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java | MetaFilter.createMetaMatcher | protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) {
for ( String key : metaMatchers.keySet() ){
if ( filterAsString.startsWith(key)){
return metaMatchers.get(key);
}
}
if (filterAsString.startsWith(GROOVY)) {
return new GroovyMetaMatcher();
}
return new DefaultMetaMatcher();
} | java | protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) {
for ( String key : metaMatchers.keySet() ){
if ( filterAsString.startsWith(key)){
return metaMatchers.get(key);
}
}
if (filterAsString.startsWith(GROOVY)) {
return new GroovyMetaMatcher();
}
return new DefaultMetaMatcher();
} | [
"protected",
"MetaMatcher",
"createMetaMatcher",
"(",
"String",
"filterAsString",
",",
"Map",
"<",
"String",
",",
"MetaMatcher",
">",
"metaMatchers",
")",
"{",
"for",
"(",
"String",
"key",
":",
"metaMatchers",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"filterAsString",
".",
"startsWith",
"(",
"key",
")",
")",
"{",
"return",
"metaMatchers",
".",
"get",
"(",
"key",
")",
";",
"}",
"}",
"if",
"(",
"filterAsString",
".",
"startsWith",
"(",
"GROOVY",
")",
")",
"{",
"return",
"new",
"GroovyMetaMatcher",
"(",
")",
";",
"}",
"return",
"new",
"DefaultMetaMatcher",
"(",
")",
";",
"}"
] | Creates a MetaMatcher based on the filter content.
@param filterAsString the String representation of the filter
@param metaMatchers the Map of custom MetaMatchers
@return A MetaMatcher used to match the filter content | [
"Creates",
"a",
"MetaMatcher",
"based",
"on",
"the",
"filter",
"content",
"."
] | train | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java#L112-L122 |
twilliamson/mogwee-logging | src/main/java/com/mogwee/logging/Logger.java | Logger.warnf | public final void warnf(String message, Object... args)
{
logf(Level.WARN, null, message, args);
} | java | public final void warnf(String message, Object... args)
{
logf(Level.WARN, null, message, args);
} | [
"public",
"final",
"void",
"warnf",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"WARN",
",",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] | Logs a formatted message if WARN logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string. | [
"Logs",
"a",
"formatted",
"message",
"if",
"WARN",
"logging",
"is",
"enabled",
"."
] | train | https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L213-L216 |
stratosphere/stratosphere | stratosphere-addons/spargel/src/main/java/eu/stratosphere/spargel/java/VertexCentricIteration.java | VertexCentricIteration.addBroadcastSetForMessagingFunction | public void addBroadcastSetForMessagingFunction(String name, DataSet<?> data) {
this.bcVarsMessaging.add(new Tuple2<String, DataSet<?>>(name, data));
} | java | public void addBroadcastSetForMessagingFunction(String name, DataSet<?> data) {
this.bcVarsMessaging.add(new Tuple2<String, DataSet<?>>(name, data));
} | [
"public",
"void",
"addBroadcastSetForMessagingFunction",
"(",
"String",
"name",
",",
"DataSet",
"<",
"?",
">",
"data",
")",
"{",
"this",
".",
"bcVarsMessaging",
".",
"add",
"(",
"new",
"Tuple2",
"<",
"String",
",",
"DataSet",
"<",
"?",
">",
">",
"(",
"name",
",",
"data",
")",
")",
";",
"}"
] | Adds a data set as a broadcast set to the messaging function.
@param name The name under which the broadcast data is available in the messaging function.
@param data The data set to be broadcasted. | [
"Adds",
"a",
"data",
"set",
"as",
"a",
"broadcast",
"set",
"to",
"the",
"messaging",
"function",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-addons/spargel/src/main/java/eu/stratosphere/spargel/java/VertexCentricIteration.java#L180-L182 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/graph/SparkComputationGraph.java | SparkComputationGraph.doEvaluation | public IEvaluation[] doEvaluation(JavaRDD<String> data, int evalNumWorkers, int evalBatchSize, DataSetLoader loader, IEvaluation... emptyEvaluations) {
return doEvaluation(data, evalNumWorkers, evalBatchSize, loader, null, emptyEvaluations);
} | java | public IEvaluation[] doEvaluation(JavaRDD<String> data, int evalNumWorkers, int evalBatchSize, DataSetLoader loader, IEvaluation... emptyEvaluations) {
return doEvaluation(data, evalNumWorkers, evalBatchSize, loader, null, emptyEvaluations);
} | [
"public",
"IEvaluation",
"[",
"]",
"doEvaluation",
"(",
"JavaRDD",
"<",
"String",
">",
"data",
",",
"int",
"evalNumWorkers",
",",
"int",
"evalBatchSize",
",",
"DataSetLoader",
"loader",
",",
"IEvaluation",
"...",
"emptyEvaluations",
")",
"{",
"return",
"doEvaluation",
"(",
"data",
",",
"evalNumWorkers",
",",
"evalBatchSize",
",",
"loader",
",",
"null",
",",
"emptyEvaluations",
")",
";",
"}"
] | Perform evaluation on serialized DataSet objects on disk, (potentially in any format), that are loaded using an {@link DataSetLoader}.
@param data List of paths to the data (that can be loaded as / converted to DataSets)
@param evalNumWorkers Number of workers to perform evaluation with. To reduce memory requirements and cache thrashing,
it is common to set this to a lower value than the number of spark threads per JVM/executor
@param evalBatchSize Batch size to use when performing evaluation
@param loader Used to load DataSets from their paths
@param emptyEvaluations Evaluations to perform
@return Evaluation | [
"Perform",
"evaluation",
"on",
"serialized",
"DataSet",
"objects",
"on",
"disk",
"(",
"potentially",
"in",
"any",
"format",
")",
"that",
"are",
"loaded",
"using",
"an",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/graph/SparkComputationGraph.java#L881-L883 |
eclipse/xtext-extras | org.eclipse.xtext.generator/xtend-gen/org/eclipse/xtext/generator/grammarAccess/GrammarAccess.java | GrammarAccess.toJavaIdentifier | public String toJavaIdentifier(final String text, final boolean uppercaseFirst) {
return GrammarAccessUtil.toJavaIdentifier(text, Boolean.valueOf(uppercaseFirst));
} | java | public String toJavaIdentifier(final String text, final boolean uppercaseFirst) {
return GrammarAccessUtil.toJavaIdentifier(text, Boolean.valueOf(uppercaseFirst));
} | [
"public",
"String",
"toJavaIdentifier",
"(",
"final",
"String",
"text",
",",
"final",
"boolean",
"uppercaseFirst",
")",
"{",
"return",
"GrammarAccessUtil",
".",
"toJavaIdentifier",
"(",
"text",
",",
"Boolean",
".",
"valueOf",
"(",
"uppercaseFirst",
")",
")",
";",
"}"
] | Converts an arbitary string to a valid Java identifier.
The string is split up along the the characters that are not valid as Java
identifier. The first character of each segments is made upper case which
leads to a camel-case style.
@param text the string
@param uppercaseFirst whether the first character of the returned identifier should be uppercase or lowercase
@return the java identifier | [
"Converts",
"an",
"arbitary",
"string",
"to",
"a",
"valid",
"Java",
"identifier",
".",
"The",
"string",
"is",
"split",
"up",
"along",
"the",
"the",
"characters",
"that",
"are",
"not",
"valid",
"as",
"Java",
"identifier",
".",
"The",
"first",
"character",
"of",
"each",
"segments",
"is",
"made",
"upper",
"case",
"which",
"leads",
"to",
"a",
"camel",
"-",
"case",
"style",
"."
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.generator/xtend-gen/org/eclipse/xtext/generator/grammarAccess/GrammarAccess.java#L46-L48 |
UrielCh/ovh-java-sdk | ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java | ApiOvhXdsl.serviceName_rma_id_GET | public OvhRma serviceName_rma_id_GET(String serviceName, String id) throws IOException {
String qPath = "/xdsl/{serviceName}/rma/{id}";
StringBuilder sb = path(qPath, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRma.class);
} | java | public OvhRma serviceName_rma_id_GET(String serviceName, String id) throws IOException {
String qPath = "/xdsl/{serviceName}/rma/{id}";
StringBuilder sb = path(qPath, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRma.class);
} | [
"public",
"OvhRma",
"serviceName_rma_id_GET",
"(",
"String",
"serviceName",
",",
"String",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/{serviceName}/rma/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhRma",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /xdsl/{serviceName}/rma/{id}
@param serviceName [required] The internal name of your XDSL offer
@param id [required] Return merchandise authorisation identifier | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L1790-L1795 |
Whiley/WhileyCompiler | src/main/java/wyil/util/AbstractTypedVisitor.java | AbstractTypedVisitor.isDerivation | public boolean isDerivation(Type parent, Type child) {
if (child.equals(parent)) {
return true;
} else if (child instanceof Type.Nominal) {
Type.Nominal t = (Type.Nominal) child;
Decl.Type decl = t.getLink().getTarget();
return isDerivation(parent, decl.getType());
} else {
return false;
}
} | java | public boolean isDerivation(Type parent, Type child) {
if (child.equals(parent)) {
return true;
} else if (child instanceof Type.Nominal) {
Type.Nominal t = (Type.Nominal) child;
Decl.Type decl = t.getLink().getTarget();
return isDerivation(parent, decl.getType());
} else {
return false;
}
} | [
"public",
"boolean",
"isDerivation",
"(",
"Type",
"parent",
",",
"Type",
"child",
")",
"{",
"if",
"(",
"child",
".",
"equals",
"(",
"parent",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"child",
"instanceof",
"Type",
".",
"Nominal",
")",
"{",
"Type",
".",
"Nominal",
"t",
"=",
"(",
"Type",
".",
"Nominal",
")",
"child",
";",
"Decl",
".",
"Type",
"decl",
"=",
"t",
".",
"getLink",
"(",
")",
".",
"getTarget",
"(",
")",
";",
"return",
"isDerivation",
"(",
"parent",
",",
"decl",
".",
"getType",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Check whether one type is a derivation of another. For example, in this
scenario:
<pre>
type parent is (int p) where ...
type child is (parent c) where ...
</pre>
@param parent
The type being derived to
@param child
The type we are trying to derive
@return | [
"Check",
"whether",
"one",
"type",
"is",
"a",
"derivation",
"of",
"another",
".",
"For",
"example",
"in",
"this",
"scenario",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/util/AbstractTypedVisitor.java#L1297-L1307 |
cdapio/tigon | tigon-yarn/src/main/java/co/cask/tigon/internal/io/DatumWriterGenerator.java | DatumWriterGenerator.encodeUnion | private void encodeUnion(GeneratorAdapter mg, TypeToken<?> outputType, Schema schema,
int value, int encoder, int schemaLocal, int seenRefs) {
Label nullLabel = mg.newLabel();
Label endLabel = mg.newLabel();
mg.loadArg(value);
mg.ifNull(nullLabel);
// Not null, write out 0 and then encode the value
encodeInt(mg, 0, encoder);
mg.loadThis();
mg.loadArg(value);
doCast(mg, outputType, schema.getUnionSchema(0));
mg.loadArg(encoder);
mg.loadArg(schemaLocal);
mg.push(0);
mg.invokeVirtual(Type.getType(Schema.class), getMethod(Schema.class, "getUnionSchema", int.class));
mg.loadArg(seenRefs);
mg.invokeVirtual(classType, getEncodeMethod(outputType, schema.getUnionSchema(0)));
mg.goTo(endLabel);
mg.mark(nullLabel);
// Null, write out 1
encodeInt(mg, 1, encoder);
mg.mark(endLabel);
} | java | private void encodeUnion(GeneratorAdapter mg, TypeToken<?> outputType, Schema schema,
int value, int encoder, int schemaLocal, int seenRefs) {
Label nullLabel = mg.newLabel();
Label endLabel = mg.newLabel();
mg.loadArg(value);
mg.ifNull(nullLabel);
// Not null, write out 0 and then encode the value
encodeInt(mg, 0, encoder);
mg.loadThis();
mg.loadArg(value);
doCast(mg, outputType, schema.getUnionSchema(0));
mg.loadArg(encoder);
mg.loadArg(schemaLocal);
mg.push(0);
mg.invokeVirtual(Type.getType(Schema.class), getMethod(Schema.class, "getUnionSchema", int.class));
mg.loadArg(seenRefs);
mg.invokeVirtual(classType, getEncodeMethod(outputType, schema.getUnionSchema(0)));
mg.goTo(endLabel);
mg.mark(nullLabel);
// Null, write out 1
encodeInt(mg, 1, encoder);
mg.mark(endLabel);
} | [
"private",
"void",
"encodeUnion",
"(",
"GeneratorAdapter",
"mg",
",",
"TypeToken",
"<",
"?",
">",
"outputType",
",",
"Schema",
"schema",
",",
"int",
"value",
",",
"int",
"encoder",
",",
"int",
"schemaLocal",
",",
"int",
"seenRefs",
")",
"{",
"Label",
"nullLabel",
"=",
"mg",
".",
"newLabel",
"(",
")",
";",
"Label",
"endLabel",
"=",
"mg",
".",
"newLabel",
"(",
")",
";",
"mg",
".",
"loadArg",
"(",
"value",
")",
";",
"mg",
".",
"ifNull",
"(",
"nullLabel",
")",
";",
"// Not null, write out 0 and then encode the value",
"encodeInt",
"(",
"mg",
",",
"0",
",",
"encoder",
")",
";",
"mg",
".",
"loadThis",
"(",
")",
";",
"mg",
".",
"loadArg",
"(",
"value",
")",
";",
"doCast",
"(",
"mg",
",",
"outputType",
",",
"schema",
".",
"getUnionSchema",
"(",
"0",
")",
")",
";",
"mg",
".",
"loadArg",
"(",
"encoder",
")",
";",
"mg",
".",
"loadArg",
"(",
"schemaLocal",
")",
";",
"mg",
".",
"push",
"(",
"0",
")",
";",
"mg",
".",
"invokeVirtual",
"(",
"Type",
".",
"getType",
"(",
"Schema",
".",
"class",
")",
",",
"getMethod",
"(",
"Schema",
".",
"class",
",",
"\"getUnionSchema\"",
",",
"int",
".",
"class",
")",
")",
";",
"mg",
".",
"loadArg",
"(",
"seenRefs",
")",
";",
"mg",
".",
"invokeVirtual",
"(",
"classType",
",",
"getEncodeMethod",
"(",
"outputType",
",",
"schema",
".",
"getUnionSchema",
"(",
"0",
")",
")",
")",
";",
"mg",
".",
"goTo",
"(",
"endLabel",
")",
";",
"mg",
".",
"mark",
"(",
"nullLabel",
")",
";",
"// Null, write out 1",
"encodeInt",
"(",
"mg",
",",
"1",
",",
"encoder",
")",
";",
"mg",
".",
"mark",
"(",
"endLabel",
")",
";",
"}"
] | Generates method body for encoding union schema. Union schema is used for representing object references that
could be {@code null}.
@param mg
@param outputType
@param schema
@param value
@param encoder
@param schemaLocal
@param seenRefs | [
"Generates",
"method",
"body",
"for",
"encoding",
"union",
"schema",
".",
"Union",
"schema",
"is",
"used",
"for",
"representing",
"object",
"references",
"that",
"could",
"be",
"{"
] | train | https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-yarn/src/main/java/co/cask/tigon/internal/io/DatumWriterGenerator.java#L805-L831 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java | DomHelper.moveElement | public boolean moveElement(String name, Object sourceParent, Object targetParent) {
Element sourceGroup = null;
Element targetGroup = null;
Element element = null;
if (sourceParent != null) {
sourceGroup = getGroup(sourceParent);
element = getElement(sourceParent, name);
}
if (targetParent != null) {
targetGroup = getGroup(targetParent);
}
if (sourceGroup == null || targetGroup == null) {
return false;
}
if (Dom.isOrHasChild(sourceGroup, element)) {
Dom.removeChild(sourceGroup, element);
String newId = Dom.assembleId(targetGroup.getId(), name);
elementToName.remove(element.getId());
elementToName.put(newId, name);
Dom.setElementAttribute(element, "id", newId);
Dom.appendChild(targetGroup, element);
return true;
}
return false;
} | java | public boolean moveElement(String name, Object sourceParent, Object targetParent) {
Element sourceGroup = null;
Element targetGroup = null;
Element element = null;
if (sourceParent != null) {
sourceGroup = getGroup(sourceParent);
element = getElement(sourceParent, name);
}
if (targetParent != null) {
targetGroup = getGroup(targetParent);
}
if (sourceGroup == null || targetGroup == null) {
return false;
}
if (Dom.isOrHasChild(sourceGroup, element)) {
Dom.removeChild(sourceGroup, element);
String newId = Dom.assembleId(targetGroup.getId(), name);
elementToName.remove(element.getId());
elementToName.put(newId, name);
Dom.setElementAttribute(element, "id", newId);
Dom.appendChild(targetGroup, element);
return true;
}
return false;
} | [
"public",
"boolean",
"moveElement",
"(",
"String",
"name",
",",
"Object",
"sourceParent",
",",
"Object",
"targetParent",
")",
"{",
"Element",
"sourceGroup",
"=",
"null",
";",
"Element",
"targetGroup",
"=",
"null",
";",
"Element",
"element",
"=",
"null",
";",
"if",
"(",
"sourceParent",
"!=",
"null",
")",
"{",
"sourceGroup",
"=",
"getGroup",
"(",
"sourceParent",
")",
";",
"element",
"=",
"getElement",
"(",
"sourceParent",
",",
"name",
")",
";",
"}",
"if",
"(",
"targetParent",
"!=",
"null",
")",
"{",
"targetGroup",
"=",
"getGroup",
"(",
"targetParent",
")",
";",
"}",
"if",
"(",
"sourceGroup",
"==",
"null",
"||",
"targetGroup",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Dom",
".",
"isOrHasChild",
"(",
"sourceGroup",
",",
"element",
")",
")",
"{",
"Dom",
".",
"removeChild",
"(",
"sourceGroup",
",",
"element",
")",
";",
"String",
"newId",
"=",
"Dom",
".",
"assembleId",
"(",
"targetGroup",
".",
"getId",
"(",
")",
",",
"name",
")",
";",
"elementToName",
".",
"remove",
"(",
"element",
".",
"getId",
"(",
")",
")",
";",
"elementToName",
".",
"put",
"(",
"newId",
",",
"name",
")",
";",
"Dom",
".",
"setElementAttribute",
"(",
"element",
",",
"\"id\"",
",",
"newId",
")",
";",
"Dom",
".",
"appendChild",
"(",
"targetGroup",
",",
"element",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Move an element from on group to another. The elements name will remain the same.
@param name
The name of the element within the sourceParent group.
@param sourceParent
The original parent group of the element.
@param targetParent
The target parent group for the element.
@return true when move was successful | [
"Move",
"an",
"element",
"from",
"on",
"group",
"to",
"another",
".",
"The",
"elements",
"name",
"will",
"remain",
"the",
"same",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java#L284-L308 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/jetty/Server.java | Server.addWebApplications | public WebApplicationContext[] addWebApplications(String host,
String webapps,
String defaults,
boolean extract)
throws IOException
{
return addWebApplications(host,webapps,defaults,extract,true);
} | java | public WebApplicationContext[] addWebApplications(String host,
String webapps,
String defaults,
boolean extract)
throws IOException
{
return addWebApplications(host,webapps,defaults,extract,true);
} | [
"public",
"WebApplicationContext",
"[",
"]",
"addWebApplications",
"(",
"String",
"host",
",",
"String",
"webapps",
",",
"String",
"defaults",
",",
"boolean",
"extract",
")",
"throws",
"IOException",
"{",
"return",
"addWebApplications",
"(",
"host",
",",
"webapps",
",",
"defaults",
",",
"extract",
",",
"true",
")",
";",
"}"
] | Add Web Applications.
Add auto webapplications to the server. The name of the
webapp directory or war is used as the context name. If the
webapp matches the rootWebApp it is added as the "/" context.
@param host Virtual host name or null
@param webapps Directory file name or URL to look for auto
webapplication.
@param defaults The defaults xml filename or URL which is
loaded before any in the web app. Must respect the web.dtd.
If null the default defaults file is used. If the empty string, then
no defaults file is used.
@param extract If true, extract war files
@exception IOException | [
"Add",
"Web",
"Applications",
".",
"Add",
"auto",
"webapplications",
"to",
"the",
"server",
".",
"The",
"name",
"of",
"the",
"webapp",
"directory",
"or",
"war",
"is",
"used",
"as",
"the",
"context",
"name",
".",
"If",
"the",
"webapp",
"matches",
"the",
"rootWebApp",
"it",
"is",
"added",
"as",
"the",
"/",
"context",
"."
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/jetty/Server.java#L331-L338 |
undertow-io/undertow | core/src/main/java/io/undertow/server/protocol/http/HttpContinue.java | HttpContinue.sendContinueResponse | public static void sendContinueResponse(final HttpServerExchange exchange, final IoCallback callback) {
if (!exchange.isResponseChannelAvailable()) {
callback.onException(exchange, null, UndertowMessages.MESSAGES.cannotSendContinueResponse());
return;
}
internalSendContinueResponse(exchange, callback);
} | java | public static void sendContinueResponse(final HttpServerExchange exchange, final IoCallback callback) {
if (!exchange.isResponseChannelAvailable()) {
callback.onException(exchange, null, UndertowMessages.MESSAGES.cannotSendContinueResponse());
return;
}
internalSendContinueResponse(exchange, callback);
} | [
"public",
"static",
"void",
"sendContinueResponse",
"(",
"final",
"HttpServerExchange",
"exchange",
",",
"final",
"IoCallback",
"callback",
")",
"{",
"if",
"(",
"!",
"exchange",
".",
"isResponseChannelAvailable",
"(",
")",
")",
"{",
"callback",
".",
"onException",
"(",
"exchange",
",",
"null",
",",
"UndertowMessages",
".",
"MESSAGES",
".",
"cannotSendContinueResponse",
"(",
")",
")",
";",
"return",
";",
"}",
"internalSendContinueResponse",
"(",
"exchange",
",",
"callback",
")",
";",
"}"
] | Sends a continuation using async IO, and calls back when it is complete.
@param exchange The exchange
@param callback The completion callback | [
"Sends",
"a",
"continuation",
"using",
"async",
"IO",
"and",
"calls",
"back",
"when",
"it",
"is",
"complete",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/protocol/http/HttpContinue.java#L101-L107 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDocumentImpl.java | DTMDocumentImpl.getAttributeNode | public int getAttributeNode(int nodeHandle, String namespaceURI, String name) {
int nsIndex = m_nsNames.stringToIndex(namespaceURI),
nameIndex = m_localNames.stringToIndex(name);
nodeHandle &= NODEHANDLE_MASK;
nodes.readSlot(nodeHandle, gotslot);
short type = (short) (gotslot[0] & 0xFFFF);
// If nodeHandle points to element next slot would be first attribute
if (type == ELEMENT_NODE)
nodeHandle++;
// Iterate through Attribute Nodes
while (type == ATTRIBUTE_NODE) {
if ((nsIndex == (gotslot[0] << 16)) && (gotslot[3] == nameIndex))
return nodeHandle | m_docHandle;
// Goto next sibling
nodeHandle = gotslot[2];
nodes.readSlot(nodeHandle, gotslot);
}
return NULL;
} | java | public int getAttributeNode(int nodeHandle, String namespaceURI, String name) {
int nsIndex = m_nsNames.stringToIndex(namespaceURI),
nameIndex = m_localNames.stringToIndex(name);
nodeHandle &= NODEHANDLE_MASK;
nodes.readSlot(nodeHandle, gotslot);
short type = (short) (gotslot[0] & 0xFFFF);
// If nodeHandle points to element next slot would be first attribute
if (type == ELEMENT_NODE)
nodeHandle++;
// Iterate through Attribute Nodes
while (type == ATTRIBUTE_NODE) {
if ((nsIndex == (gotslot[0] << 16)) && (gotslot[3] == nameIndex))
return nodeHandle | m_docHandle;
// Goto next sibling
nodeHandle = gotslot[2];
nodes.readSlot(nodeHandle, gotslot);
}
return NULL;
} | [
"public",
"int",
"getAttributeNode",
"(",
"int",
"nodeHandle",
",",
"String",
"namespaceURI",
",",
"String",
"name",
")",
"{",
"int",
"nsIndex",
"=",
"m_nsNames",
".",
"stringToIndex",
"(",
"namespaceURI",
")",
",",
"nameIndex",
"=",
"m_localNames",
".",
"stringToIndex",
"(",
"name",
")",
";",
"nodeHandle",
"&=",
"NODEHANDLE_MASK",
";",
"nodes",
".",
"readSlot",
"(",
"nodeHandle",
",",
"gotslot",
")",
";",
"short",
"type",
"=",
"(",
"short",
")",
"(",
"gotslot",
"[",
"0",
"]",
"&",
"0xFFFF",
")",
";",
"// If nodeHandle points to element next slot would be first attribute",
"if",
"(",
"type",
"==",
"ELEMENT_NODE",
")",
"nodeHandle",
"++",
";",
"// Iterate through Attribute Nodes",
"while",
"(",
"type",
"==",
"ATTRIBUTE_NODE",
")",
"{",
"if",
"(",
"(",
"nsIndex",
"==",
"(",
"gotslot",
"[",
"0",
"]",
"<<",
"16",
")",
")",
"&&",
"(",
"gotslot",
"[",
"3",
"]",
"==",
"nameIndex",
")",
")",
"return",
"nodeHandle",
"|",
"m_docHandle",
";",
"// Goto next sibling",
"nodeHandle",
"=",
"gotslot",
"[",
"2",
"]",
";",
"nodes",
".",
"readSlot",
"(",
"nodeHandle",
",",
"gotslot",
")",
";",
"}",
"return",
"NULL",
";",
"}"
] | Retrieves an attribute node by by qualified name and namespace URI.
@param nodeHandle int Handle of the node upon which to look up this attribute.
@param namespaceURI The namespace URI of the attribute to
retrieve, or null.
@param name The local name of the attribute to
retrieve.
@return The attribute node handle with the specified name (
<code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
attribute. | [
"Retrieves",
"an",
"attribute",
"node",
"by",
"by",
"qualified",
"name",
"and",
"namespace",
"URI",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDocumentImpl.java#L1086-L1104 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java | FSDirectory.getFullPathName | static String getFullPathName(INode inode) throws IOException {
INode[] inodes = getINodeArray(inode);
return getFullPathName(inodes, inodes.length-1);
} | java | static String getFullPathName(INode inode) throws IOException {
INode[] inodes = getINodeArray(inode);
return getFullPathName(inodes, inodes.length-1);
} | [
"static",
"String",
"getFullPathName",
"(",
"INode",
"inode",
")",
"throws",
"IOException",
"{",
"INode",
"[",
"]",
"inodes",
"=",
"getINodeArray",
"(",
"inode",
")",
";",
"return",
"getFullPathName",
"(",
"inodes",
",",
"inodes",
".",
"length",
"-",
"1",
")",
";",
"}"
] | Return the full path name of the specified inode
@param inode
@return its full path name
@throws IOException if the inode is invalid | [
"Return",
"the",
"full",
"path",
"name",
"of",
"the",
"specified",
"inode"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java#L2271-L2274 |
jbossws/jbossws-common | src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java | ReflectionUtils.assertOnlyOneMethod | public static void assertOnlyOneMethod(final Collection<Method> methods, Class<? extends Annotation> annotation)
{
if (methods.size() > 1)
{
throw annotation == null ? MESSAGES.onlyOneMethodCanExist() : MESSAGES.onlyOneMethodCanExist2(annotation);
}
} | java | public static void assertOnlyOneMethod(final Collection<Method> methods, Class<? extends Annotation> annotation)
{
if (methods.size() > 1)
{
throw annotation == null ? MESSAGES.onlyOneMethodCanExist() : MESSAGES.onlyOneMethodCanExist2(annotation);
}
} | [
"public",
"static",
"void",
"assertOnlyOneMethod",
"(",
"final",
"Collection",
"<",
"Method",
">",
"methods",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"if",
"(",
"methods",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"throw",
"annotation",
"==",
"null",
"?",
"MESSAGES",
".",
"onlyOneMethodCanExist",
"(",
")",
":",
"MESSAGES",
".",
"onlyOneMethodCanExist2",
"(",
"annotation",
")",
";",
"}",
"}"
] | Asserts only one method is annotated with annotation.
@param method collection of methods to validate
@param annotation annotation to propagate in exception message | [
"Asserts",
"only",
"one",
"method",
"is",
"annotated",
"with",
"annotation",
"."
] | train | https://github.com/jbossws/jbossws-common/blob/fcff8a3ef9bfe046d6fa8c855a3fe4f62841add7/src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java#L330-L336 |
groupon/odo | proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java | OverrideService.updateResponseCode | public void updateResponseCode(int id, String responseCode) {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
String queryString = "UPDATE " + Constants.DB_TABLE_ENABLED_OVERRIDE +
" SET " + Constants.ENABLED_OVERRIDES_RESPONSE_CODE + "= ? " +
" WHERE " + Constants.GENERIC_ID + " = ?";
statement = sqlConnection.prepareStatement(queryString);
statement.setString(1, responseCode);
statement.setInt(2, id);
statement.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | java | public void updateResponseCode(int id, String responseCode) {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
String queryString = "UPDATE " + Constants.DB_TABLE_ENABLED_OVERRIDE +
" SET " + Constants.ENABLED_OVERRIDES_RESPONSE_CODE + "= ? " +
" WHERE " + Constants.GENERIC_ID + " = ?";
statement = sqlConnection.prepareStatement(queryString);
statement.setString(1, responseCode);
statement.setInt(2, id);
statement.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | [
"public",
"void",
"updateResponseCode",
"(",
"int",
"id",
",",
"String",
"responseCode",
")",
"{",
"PreparedStatement",
"statement",
"=",
"null",
";",
"try",
"(",
"Connection",
"sqlConnection",
"=",
"sqlService",
".",
"getConnection",
"(",
")",
")",
"{",
"String",
"queryString",
"=",
"\"UPDATE \"",
"+",
"Constants",
".",
"DB_TABLE_ENABLED_OVERRIDE",
"+",
"\" SET \"",
"+",
"Constants",
".",
"ENABLED_OVERRIDES_RESPONSE_CODE",
"+",
"\"= ? \"",
"+",
"\" WHERE \"",
"+",
"Constants",
".",
"GENERIC_ID",
"+",
"\" = ?\"",
";",
"statement",
"=",
"sqlConnection",
".",
"prepareStatement",
"(",
"queryString",
")",
";",
"statement",
".",
"setString",
"(",
"1",
",",
"responseCode",
")",
";",
"statement",
".",
"setInt",
"(",
"2",
",",
"id",
")",
";",
"statement",
".",
"executeUpdate",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"statement",
"!=",
"null",
")",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] | Update the response code for a given enabled override
@param id enabled override ID to update
@param responseCode updated value of responseCode | [
"Update",
"the",
"response",
"code",
"for",
"a",
"given",
"enabled",
"override"
] | train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java#L260-L281 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/javax/xml/datatype/DatatypeFactory.java | DatatypeFactory.newDurationYearMonth | public Duration newDurationYearMonth(
final boolean isPositive,
final int year,
final int month) {
return newDuration(isPositive, year, month,
DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
} | java | public Duration newDurationYearMonth(
final boolean isPositive,
final int year,
final int month) {
return newDuration(isPositive, year, month,
DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
} | [
"public",
"Duration",
"newDurationYearMonth",
"(",
"final",
"boolean",
"isPositive",
",",
"final",
"int",
"year",
",",
"final",
"int",
"month",
")",
"{",
"return",
"newDuration",
"(",
"isPositive",
",",
"year",
",",
"month",
",",
"DatatypeConstants",
".",
"FIELD_UNDEFINED",
",",
"DatatypeConstants",
".",
"FIELD_UNDEFINED",
",",
"DatatypeConstants",
".",
"FIELD_UNDEFINED",
",",
"DatatypeConstants",
".",
"FIELD_UNDEFINED",
")",
";",
"}"
] | <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
<code>year</code> and <code>month</code> as defined in
<a href="http://www.w3.org/TR/xpath-datamodel#dt-yearMonthyDuration">
XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
<p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
@param isPositive Set to <code>false</code> to create a negative duration. When the length
of the duration is zero, this parameter will be ignored.
@param year Year of <code>Duration</code>.
@param month Month of <code>Duration</code>.
@return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
@throws IllegalArgumentException If any values would create an invalid <code>Duration</code>. | [
"<p",
">",
"Create",
"a",
"<code",
">",
"Duration<",
"/",
"code",
">",
"of",
"type",
"<code",
">",
"xdt",
":",
"yearMonthDuration<",
"/",
"code",
">",
"using",
"the",
"specified",
"<code",
">",
"year<",
"/",
"code",
">",
"and",
"<code",
">",
"month<",
"/",
"code",
">",
"as",
"defined",
"in",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"xpath",
"-",
"datamodel#dt",
"-",
"yearMonthyDuration",
">",
"XQuery",
"1",
".",
"0",
"and",
"XPath",
"2",
".",
"0",
"Data",
"Model",
"xdt",
":",
"yearMonthDuration<",
"/",
"a",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/javax/xml/datatype/DatatypeFactory.java#L653-L660 |
alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/handler/BaseContentHandler.java | BaseContentHandler.startNewElement | public void startNewElement(String localName, Attributes atts) {
String arg0 = localName;
this.currentKey = arg0;
if (isEndElement(arg0)) {
endNewElement();
if (writerContentHandler != null) {
this.currentFeatureGeoJSON = writerContentHandler.startFeature();
this.currentGeometryGeoJSON = writerContentHandler.startPoint();
}
this.currentFeature = contentHandler.startFeature();
this.currentPoint = contentHandler.startPoint();
}
this.currentLocalName = localName;
// FIXME improve the support for attributes
if (atts != null) {
int length = atts.getLength();
for (int i = 0; i < length; i++) {
String key = atts.getQName(i);
String value = atts.getValue(i);
this.currentKey = key;
this.processValue(value);
}
}
} | java | public void startNewElement(String localName, Attributes atts) {
String arg0 = localName;
this.currentKey = arg0;
if (isEndElement(arg0)) {
endNewElement();
if (writerContentHandler != null) {
this.currentFeatureGeoJSON = writerContentHandler.startFeature();
this.currentGeometryGeoJSON = writerContentHandler.startPoint();
}
this.currentFeature = contentHandler.startFeature();
this.currentPoint = contentHandler.startPoint();
}
this.currentLocalName = localName;
// FIXME improve the support for attributes
if (atts != null) {
int length = atts.getLength();
for (int i = 0; i < length; i++) {
String key = atts.getQName(i);
String value = atts.getValue(i);
this.currentKey = key;
this.processValue(value);
}
}
} | [
"public",
"void",
"startNewElement",
"(",
"String",
"localName",
",",
"Attributes",
"atts",
")",
"{",
"String",
"arg0",
"=",
"localName",
";",
"this",
".",
"currentKey",
"=",
"arg0",
";",
"if",
"(",
"isEndElement",
"(",
"arg0",
")",
")",
"{",
"endNewElement",
"(",
")",
";",
"if",
"(",
"writerContentHandler",
"!=",
"null",
")",
"{",
"this",
".",
"currentFeatureGeoJSON",
"=",
"writerContentHandler",
".",
"startFeature",
"(",
")",
";",
"this",
".",
"currentGeometryGeoJSON",
"=",
"writerContentHandler",
".",
"startPoint",
"(",
")",
";",
"}",
"this",
".",
"currentFeature",
"=",
"contentHandler",
".",
"startFeature",
"(",
")",
";",
"this",
".",
"currentPoint",
"=",
"contentHandler",
".",
"startPoint",
"(",
")",
";",
"}",
"this",
".",
"currentLocalName",
"=",
"localName",
";",
"// FIXME improve the support for attributes",
"if",
"(",
"atts",
"!=",
"null",
")",
"{",
"int",
"length",
"=",
"atts",
".",
"getLength",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"String",
"key",
"=",
"atts",
".",
"getQName",
"(",
"i",
")",
";",
"String",
"value",
"=",
"atts",
".",
"getValue",
"(",
"i",
")",
";",
"this",
".",
"currentKey",
"=",
"key",
";",
"this",
".",
"processValue",
"(",
"value",
")",
";",
"}",
"}",
"}"
] | Compares the localname with the {@link FeatureType#getFeature()}
attribute of the current {@link FeatureType} of the
{@link DescribeService}
If the current tag being parsed is equals to
{@link FeatureType#getFeature()} then the
{@link JPEContentHandler#startFeature()} and
{@link JPEContentHandler#startPoint()} are thrown
@param localName
The current tag name being parsed
@param atts
Additional attributes
@param atts | [
"Compares",
"the",
"localname",
"with",
"the",
"{",
"@link",
"FeatureType#getFeature",
"()",
"}",
"attribute",
"of",
"the",
"current",
"{",
"@link",
"FeatureType",
"}",
"of",
"the",
"{",
"@link",
"DescribeService",
"}"
] | train | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/handler/BaseContentHandler.java#L326-L352 |
box/box-java-sdk | src/main/java/com/box/sdk/MetadataTemplate.java | MetadataTemplate.createMetadataTemplate | public static MetadataTemplate createMetadataTemplate(BoxAPIConnection api, String scope, String templateKey,
String displayName, boolean hidden, List<Field> fields) {
JsonObject jsonObject = new JsonObject();
jsonObject.add("scope", scope);
jsonObject.add("displayName", displayName);
jsonObject.add("hidden", hidden);
if (templateKey != null) {
jsonObject.add("templateKey", templateKey);
}
JsonArray fieldsArray = new JsonArray();
if (fields != null && !fields.isEmpty()) {
for (Field field : fields) {
JsonObject fieldObj = getFieldJsonObject(field);
fieldsArray.add(fieldObj);
}
jsonObject.add("fields", fieldsArray);
}
URL url = METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(jsonObject.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
return new MetadataTemplate(responseJSON);
} | java | public static MetadataTemplate createMetadataTemplate(BoxAPIConnection api, String scope, String templateKey,
String displayName, boolean hidden, List<Field> fields) {
JsonObject jsonObject = new JsonObject();
jsonObject.add("scope", scope);
jsonObject.add("displayName", displayName);
jsonObject.add("hidden", hidden);
if (templateKey != null) {
jsonObject.add("templateKey", templateKey);
}
JsonArray fieldsArray = new JsonArray();
if (fields != null && !fields.isEmpty()) {
for (Field field : fields) {
JsonObject fieldObj = getFieldJsonObject(field);
fieldsArray.add(fieldObj);
}
jsonObject.add("fields", fieldsArray);
}
URL url = METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(jsonObject.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
return new MetadataTemplate(responseJSON);
} | [
"public",
"static",
"MetadataTemplate",
"createMetadataTemplate",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"scope",
",",
"String",
"templateKey",
",",
"String",
"displayName",
",",
"boolean",
"hidden",
",",
"List",
"<",
"Field",
">",
"fields",
")",
"{",
"JsonObject",
"jsonObject",
"=",
"new",
"JsonObject",
"(",
")",
";",
"jsonObject",
".",
"add",
"(",
"\"scope\"",
",",
"scope",
")",
";",
"jsonObject",
".",
"add",
"(",
"\"displayName\"",
",",
"displayName",
")",
";",
"jsonObject",
".",
"add",
"(",
"\"hidden\"",
",",
"hidden",
")",
";",
"if",
"(",
"templateKey",
"!=",
"null",
")",
"{",
"jsonObject",
".",
"add",
"(",
"\"templateKey\"",
",",
"templateKey",
")",
";",
"}",
"JsonArray",
"fieldsArray",
"=",
"new",
"JsonArray",
"(",
")",
";",
"if",
"(",
"fields",
"!=",
"null",
"&&",
"!",
"fields",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"JsonObject",
"fieldObj",
"=",
"getFieldJsonObject",
"(",
"field",
")",
";",
"fieldsArray",
".",
"add",
"(",
"fieldObj",
")",
";",
"}",
"jsonObject",
".",
"add",
"(",
"\"fields\"",
",",
"fieldsArray",
")",
";",
"}",
"URL",
"url",
"=",
"METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"api",
",",
"url",
",",
"\"POST\"",
")",
";",
"request",
".",
"setBody",
"(",
"jsonObject",
".",
"toString",
"(",
")",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"return",
"new",
"MetadataTemplate",
"(",
"responseJSON",
")",
";",
"}"
] | Creates new metadata template.
@param api the API connection to be used.
@param scope the scope of the object.
@param templateKey a unique identifier for the template.
@param displayName the display name of the field.
@param hidden whether this template is hidden in the UI.
@param fields the ordered set of fields for the template
@return the metadata template returned from the server. | [
"Creates",
"new",
"metadata",
"template",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L198-L229 |
apache/incubator-shardingsphere | sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/SQLExecuteTemplate.java | SQLExecuteTemplate.executeGroup | public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends StatementExecuteUnit>> sqlExecuteGroups, final SQLExecuteCallback<T> callback) throws SQLException {
return executeGroup(sqlExecuteGroups, null, callback);
} | java | public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends StatementExecuteUnit>> sqlExecuteGroups, final SQLExecuteCallback<T> callback) throws SQLException {
return executeGroup(sqlExecuteGroups, null, callback);
} | [
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"executeGroup",
"(",
"final",
"Collection",
"<",
"ShardingExecuteGroup",
"<",
"?",
"extends",
"StatementExecuteUnit",
">",
">",
"sqlExecuteGroups",
",",
"final",
"SQLExecuteCallback",
"<",
"T",
">",
"callback",
")",
"throws",
"SQLException",
"{",
"return",
"executeGroup",
"(",
"sqlExecuteGroups",
",",
"null",
",",
"callback",
")",
";",
"}"
] | Execute group.
@param sqlExecuteGroups SQL execute groups
@param callback SQL execute callback
@param <T> class type of return value
@return execute result
@throws SQLException SQL exception | [
"Execute",
"group",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/SQLExecuteTemplate.java#L55-L57 |
datacleaner/DataCleaner | desktop/ui/src/main/java/org/datacleaner/panels/DCSplashPanel.java | DCSplashPanel.wrapContent | protected JScrollPane wrapContent(final JComponent panel) {
panel.setMaximumSize(new Dimension(WIDTH_CONTENT, Integer.MAX_VALUE));
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
final DCPanel wrappingPanel = new DCPanel();
final BoxLayout layout = new BoxLayout(wrappingPanel, BoxLayout.PAGE_AXIS);
wrappingPanel.setLayout(layout);
wrappingPanel.add(panel);
wrappingPanel.setBorder(new EmptyBorder(0, MARGIN_LEFT, 0, 0));
return WidgetUtils.scrolleable(wrappingPanel);
} | java | protected JScrollPane wrapContent(final JComponent panel) {
panel.setMaximumSize(new Dimension(WIDTH_CONTENT, Integer.MAX_VALUE));
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
final DCPanel wrappingPanel = new DCPanel();
final BoxLayout layout = new BoxLayout(wrappingPanel, BoxLayout.PAGE_AXIS);
wrappingPanel.setLayout(layout);
wrappingPanel.add(panel);
wrappingPanel.setBorder(new EmptyBorder(0, MARGIN_LEFT, 0, 0));
return WidgetUtils.scrolleable(wrappingPanel);
} | [
"protected",
"JScrollPane",
"wrapContent",
"(",
"final",
"JComponent",
"panel",
")",
"{",
"panel",
".",
"setMaximumSize",
"(",
"new",
"Dimension",
"(",
"WIDTH_CONTENT",
",",
"Integer",
".",
"MAX_VALUE",
")",
")",
";",
"panel",
".",
"setAlignmentX",
"(",
"Component",
".",
"LEFT_ALIGNMENT",
")",
";",
"final",
"DCPanel",
"wrappingPanel",
"=",
"new",
"DCPanel",
"(",
")",
";",
"final",
"BoxLayout",
"layout",
"=",
"new",
"BoxLayout",
"(",
"wrappingPanel",
",",
"BoxLayout",
".",
"PAGE_AXIS",
")",
";",
"wrappingPanel",
".",
"setLayout",
"(",
"layout",
")",
";",
"wrappingPanel",
".",
"add",
"(",
"panel",
")",
";",
"wrappingPanel",
".",
"setBorder",
"(",
"new",
"EmptyBorder",
"(",
"0",
",",
"MARGIN_LEFT",
",",
"0",
",",
"0",
")",
")",
";",
"return",
"WidgetUtils",
".",
"scrolleable",
"(",
"wrappingPanel",
")",
";",
"}"
] | Wraps a content panel in a scroll pane and applies a maximum width to the
content to keep it nicely in place on the screen.
@param panel
@return | [
"Wraps",
"a",
"content",
"panel",
"in",
"a",
"scroll",
"pane",
"and",
"applies",
"a",
"maximum",
"width",
"to",
"the",
"content",
"to",
"keep",
"it",
"nicely",
"in",
"place",
"on",
"the",
"screen",
"."
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/desktop/ui/src/main/java/org/datacleaner/panels/DCSplashPanel.java#L147-L158 |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java | ScriptUtils.readScript | private static String readScript(EncodedResource resource, String commentPrefix, String separator)
throws IOException {
LineNumberReader lnr = new LineNumberReader(resource.getReader());
try {
return readScript(lnr, commentPrefix, separator);
} finally {
lnr.close();
}
} | java | private static String readScript(EncodedResource resource, String commentPrefix, String separator)
throws IOException {
LineNumberReader lnr = new LineNumberReader(resource.getReader());
try {
return readScript(lnr, commentPrefix, separator);
} finally {
lnr.close();
}
} | [
"private",
"static",
"String",
"readScript",
"(",
"EncodedResource",
"resource",
",",
"String",
"commentPrefix",
",",
"String",
"separator",
")",
"throws",
"IOException",
"{",
"LineNumberReader",
"lnr",
"=",
"new",
"LineNumberReader",
"(",
"resource",
".",
"getReader",
"(",
")",
")",
";",
"try",
"{",
"return",
"readScript",
"(",
"lnr",
",",
"commentPrefix",
",",
"separator",
")",
";",
"}",
"finally",
"{",
"lnr",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Read a script from the provided resource, using the supplied comment
prefix and statement separator, and build a {@code String} containing the
lines.
<p>
Lines <em>beginning</em> with the comment prefix are excluded from the
results; however, line comments anywhere else — for example, within
a statement — will be included in the results.
@param resource the {@code EncodedResource} containing the script to be
processed
@param commentPrefix the prefix that identifies comments in the SQL script —
typically "--"
@param separator the statement separator in the SQL script — typically
";"
@return a {@code String} containing the script lines
@throws IOException in case of I/O errors | [
"Read",
"a",
"script",
"from",
"the",
"provided",
"resource",
"using",
"the",
"supplied",
"comment",
"prefix",
"and",
"statement",
"separator",
"and",
"build",
"a",
"{",
"@code",
"String",
"}",
"containing",
"the",
"lines",
".",
"<p",
">",
"Lines",
"<em",
">",
"beginning<",
"/",
"em",
">",
"with",
"the",
"comment",
"prefix",
"are",
"excluded",
"from",
"the",
"results",
";",
"however",
"line",
"comments",
"anywhere",
"else",
"&mdash",
";",
"for",
"example",
"within",
"a",
"statement",
"&mdash",
";",
"will",
"be",
"included",
"in",
"the",
"results",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java#L266-L275 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/SystemUtil.java | SystemUtil.createTempDirectory | public static File createTempDirectory(String _path, String _name, boolean _deleteOnExit) {
File outputDir = new File(concatFilePath(_path, _name));
if (!outputDir.exists()) {
try {
Files.createDirectory(Paths.get(outputDir.toString()));
} catch (IOException _ex) {
LOGGER.error("Error while creating temp directory: ", _ex);
}
} else {
return null;
}
if (_deleteOnExit) {
outputDir.deleteOnExit();
}
return outputDir;
} | java | public static File createTempDirectory(String _path, String _name, boolean _deleteOnExit) {
File outputDir = new File(concatFilePath(_path, _name));
if (!outputDir.exists()) {
try {
Files.createDirectory(Paths.get(outputDir.toString()));
} catch (IOException _ex) {
LOGGER.error("Error while creating temp directory: ", _ex);
}
} else {
return null;
}
if (_deleteOnExit) {
outputDir.deleteOnExit();
}
return outputDir;
} | [
"public",
"static",
"File",
"createTempDirectory",
"(",
"String",
"_path",
",",
"String",
"_name",
",",
"boolean",
"_deleteOnExit",
")",
"{",
"File",
"outputDir",
"=",
"new",
"File",
"(",
"concatFilePath",
"(",
"_path",
",",
"_name",
")",
")",
";",
"if",
"(",
"!",
"outputDir",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"Files",
".",
"createDirectory",
"(",
"Paths",
".",
"get",
"(",
"outputDir",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error while creating temp directory: \"",
",",
"_ex",
")",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"_deleteOnExit",
")",
"{",
"outputDir",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"return",
"outputDir",
";",
"}"
] | Creates a new temporary directory in the given path.
@param _path path
@param _name directory name
@param _deleteOnExit delete directory on jvm shutdown
@return created Directory, null if directory/file was already existing | [
"Creates",
"a",
"new",
"temporary",
"directory",
"in",
"the",
"given",
"path",
"."
] | train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L200-L216 |
scaleset/scaleset-geo | src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java | GoogleMapsTileMath.tileBbox | public Envelope tileBbox(int tx, int ty, int zoomLevel) {
Coordinate topLeft = tileTopLeft(tx, ty, zoomLevel);
// upperLeft of tx+1,ty+1 == lowRight
Coordinate lowerRight = tileTopLeft(tx + 1, ty + 1, zoomLevel);
Envelope result = new Envelope(topLeft, lowerRight);
return result;
} | java | public Envelope tileBbox(int tx, int ty, int zoomLevel) {
Coordinate topLeft = tileTopLeft(tx, ty, zoomLevel);
// upperLeft of tx+1,ty+1 == lowRight
Coordinate lowerRight = tileTopLeft(tx + 1, ty + 1, zoomLevel);
Envelope result = new Envelope(topLeft, lowerRight);
return result;
} | [
"public",
"Envelope",
"tileBbox",
"(",
"int",
"tx",
",",
"int",
"ty",
",",
"int",
"zoomLevel",
")",
"{",
"Coordinate",
"topLeft",
"=",
"tileTopLeft",
"(",
"tx",
",",
"ty",
",",
"zoomLevel",
")",
";",
"// upperLeft of tx+1,ty+1 == lowRight",
"Coordinate",
"lowerRight",
"=",
"tileTopLeft",
"(",
"tx",
"+",
"1",
",",
"ty",
"+",
"1",
",",
"zoomLevel",
")",
";",
"Envelope",
"result",
"=",
"new",
"Envelope",
"(",
"topLeft",
",",
"lowerRight",
")",
";",
"return",
"result",
";",
"}"
] | Returns the EPSG:3857 bounding of the specified tile coordinate
@param tx The tile x coordinate
@param ty The tile y coordinate
@param zoomLevel The tile zoom level
@return the EPSG:3857 bounding box | [
"Returns",
"the",
"EPSG",
":",
"3857",
"bounding",
"of",
"the",
"specified",
"tile",
"coordinate"
] | train | https://github.com/scaleset/scaleset-geo/blob/5cff2349668037dc287928a6c1a1f67c76d96b02/src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java#L285-L291 |
lingochamp/okdownload | okdownload-filedownloader/src/main/java/com/liulishuo/filedownloader/notification/FileDownloadNotificationHelper.java | FileDownloadNotificationHelper.showIndeterminate | public void showIndeterminate(final int id, int status) {
final BaseNotificationItem notification = get(id);
if (notification == null) {
return;
}
notification.updateStatus(status);
notification.show(false);
} | java | public void showIndeterminate(final int id, int status) {
final BaseNotificationItem notification = get(id);
if (notification == null) {
return;
}
notification.updateStatus(status);
notification.show(false);
} | [
"public",
"void",
"showIndeterminate",
"(",
"final",
"int",
"id",
",",
"int",
"status",
")",
"{",
"final",
"BaseNotificationItem",
"notification",
"=",
"get",
"(",
"id",
")",
";",
"if",
"(",
"notification",
"==",
"null",
")",
"{",
"return",
";",
"}",
"notification",
".",
"updateStatus",
"(",
"status",
")",
";",
"notification",
".",
"show",
"(",
"false",
")",
";",
"}"
] | Show the notification with indeterminate progress.
@param id The download id.
@param status {@link FileDownloadStatus} | [
"Show",
"the",
"notification",
"with",
"indeterminate",
"progress",
"."
] | train | https://github.com/lingochamp/okdownload/blob/403e2c814556ef7f2fade1f5bee83a02a5eaecb2/okdownload-filedownloader/src/main/java/com/liulishuo/filedownloader/notification/FileDownloadNotificationHelper.java#L96-L105 |
OpenTSDB/opentsdb | src/tools/Search.java | Search.runCommand | private static int runCommand(final TSDB tsdb,
final boolean use_data_table,
final String[] args) throws Exception {
final int nargs = args.length;
if (args[0].equals("lookup")) {
if (nargs < 2) { // need a query
usage(null, "Not enough arguments");
return 2;
}
return lookup(tsdb, use_data_table, args);
} else {
usage(null, "Unknown sub command: " + args[0]);
return 2;
}
} | java | private static int runCommand(final TSDB tsdb,
final boolean use_data_table,
final String[] args) throws Exception {
final int nargs = args.length;
if (args[0].equals("lookup")) {
if (nargs < 2) { // need a query
usage(null, "Not enough arguments");
return 2;
}
return lookup(tsdb, use_data_table, args);
} else {
usage(null, "Unknown sub command: " + args[0]);
return 2;
}
} | [
"private",
"static",
"int",
"runCommand",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"boolean",
"use_data_table",
",",
"final",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"final",
"int",
"nargs",
"=",
"args",
".",
"length",
";",
"if",
"(",
"args",
"[",
"0",
"]",
".",
"equals",
"(",
"\"lookup\"",
")",
")",
"{",
"if",
"(",
"nargs",
"<",
"2",
")",
"{",
"// need a query",
"usage",
"(",
"null",
",",
"\"Not enough arguments\"",
")",
";",
"return",
"2",
";",
"}",
"return",
"lookup",
"(",
"tsdb",
",",
"use_data_table",
",",
"args",
")",
";",
"}",
"else",
"{",
"usage",
"(",
"null",
",",
"\"Unknown sub command: \"",
"+",
"args",
"[",
"0",
"]",
")",
";",
"return",
"2",
";",
"}",
"}"
] | Determines the command requested of the user can calls the appropriate
method.
@param tsdb The TSDB to use for communication
@param use_data_table Whether or not lookups should be done on the full
data table
@param args Arguments to parse
@return An exit code | [
"Determines",
"the",
"command",
"requested",
"of",
"the",
"user",
"can",
"calls",
"the",
"appropriate",
"method",
"."
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Search.java#L97-L111 |
bazaarvoice/emodb | mapreduce/sor-hadoop/src/main/java/com/bazaarvoice/emodb/hadoop/io/LocationUtil.java | LocationUtil.getCuratorForLocation | public static Optional<CuratorFramework> getCuratorForLocation(URI location) {
final String defaultConnectionString;
final String namespace;
if (getLocationType(location) != LocationType.EMO_HOST_DISCOVERY) {
// Only host discovery may require ZooKeeper
return Optional.absent();
}
if (getHostOverride(location).isPresent()) {
// Fixed host discovery doesn't require ZooKeeper
return Optional.absent();
}
Matcher matcher = getLocatorMatcher(location);
checkArgument(matcher.matches(), "Invalid location: %s", location);
if (matcher.group("universe") != null) {
// Normal host discovery
String universe = matcher.group("universe");
Region region = getRegion(Objects.firstNonNull(matcher.group("region"), DEFAULT_REGION));
namespace = format("%s/%s", universe, region);
defaultConnectionString = DEFAULT_ZK_CONNECTION_STRING;
} else {
// Local host discovery; typically for developer testing
namespace = null;
defaultConnectionString = DEFAULT_LOCAL_ZK_CONNECTION_STRING;
}
String connectionString = getZkConnectionStringOverride(location).or(defaultConnectionString);
CuratorFramework curator = CuratorFrameworkFactory.builder()
.ensembleProvider(new ResolvingEnsembleProvider(connectionString))
.retryPolicy(new BoundedExponentialBackoffRetry(100, 1000, 10))
.threadFactory(new ThreadFactoryBuilder().setNameFormat("emo-zookeeper-%d").build())
.namespace(namespace)
.build();
curator.start();
return Optional.of(curator);
} | java | public static Optional<CuratorFramework> getCuratorForLocation(URI location) {
final String defaultConnectionString;
final String namespace;
if (getLocationType(location) != LocationType.EMO_HOST_DISCOVERY) {
// Only host discovery may require ZooKeeper
return Optional.absent();
}
if (getHostOverride(location).isPresent()) {
// Fixed host discovery doesn't require ZooKeeper
return Optional.absent();
}
Matcher matcher = getLocatorMatcher(location);
checkArgument(matcher.matches(), "Invalid location: %s", location);
if (matcher.group("universe") != null) {
// Normal host discovery
String universe = matcher.group("universe");
Region region = getRegion(Objects.firstNonNull(matcher.group("region"), DEFAULT_REGION));
namespace = format("%s/%s", universe, region);
defaultConnectionString = DEFAULT_ZK_CONNECTION_STRING;
} else {
// Local host discovery; typically for developer testing
namespace = null;
defaultConnectionString = DEFAULT_LOCAL_ZK_CONNECTION_STRING;
}
String connectionString = getZkConnectionStringOverride(location).or(defaultConnectionString);
CuratorFramework curator = CuratorFrameworkFactory.builder()
.ensembleProvider(new ResolvingEnsembleProvider(connectionString))
.retryPolicy(new BoundedExponentialBackoffRetry(100, 1000, 10))
.threadFactory(new ThreadFactoryBuilder().setNameFormat("emo-zookeeper-%d").build())
.namespace(namespace)
.build();
curator.start();
return Optional.of(curator);
} | [
"public",
"static",
"Optional",
"<",
"CuratorFramework",
">",
"getCuratorForLocation",
"(",
"URI",
"location",
")",
"{",
"final",
"String",
"defaultConnectionString",
";",
"final",
"String",
"namespace",
";",
"if",
"(",
"getLocationType",
"(",
"location",
")",
"!=",
"LocationType",
".",
"EMO_HOST_DISCOVERY",
")",
"{",
"// Only host discovery may require ZooKeeper",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}",
"if",
"(",
"getHostOverride",
"(",
"location",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"// Fixed host discovery doesn't require ZooKeeper",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}",
"Matcher",
"matcher",
"=",
"getLocatorMatcher",
"(",
"location",
")",
";",
"checkArgument",
"(",
"matcher",
".",
"matches",
"(",
")",
",",
"\"Invalid location: %s\"",
",",
"location",
")",
";",
"if",
"(",
"matcher",
".",
"group",
"(",
"\"universe\"",
")",
"!=",
"null",
")",
"{",
"// Normal host discovery",
"String",
"universe",
"=",
"matcher",
".",
"group",
"(",
"\"universe\"",
")",
";",
"Region",
"region",
"=",
"getRegion",
"(",
"Objects",
".",
"firstNonNull",
"(",
"matcher",
".",
"group",
"(",
"\"region\"",
")",
",",
"DEFAULT_REGION",
")",
")",
";",
"namespace",
"=",
"format",
"(",
"\"%s/%s\"",
",",
"universe",
",",
"region",
")",
";",
"defaultConnectionString",
"=",
"DEFAULT_ZK_CONNECTION_STRING",
";",
"}",
"else",
"{",
"// Local host discovery; typically for developer testing",
"namespace",
"=",
"null",
";",
"defaultConnectionString",
"=",
"DEFAULT_LOCAL_ZK_CONNECTION_STRING",
";",
"}",
"String",
"connectionString",
"=",
"getZkConnectionStringOverride",
"(",
"location",
")",
".",
"or",
"(",
"defaultConnectionString",
")",
";",
"CuratorFramework",
"curator",
"=",
"CuratorFrameworkFactory",
".",
"builder",
"(",
")",
".",
"ensembleProvider",
"(",
"new",
"ResolvingEnsembleProvider",
"(",
"connectionString",
")",
")",
".",
"retryPolicy",
"(",
"new",
"BoundedExponentialBackoffRetry",
"(",
"100",
",",
"1000",
",",
"10",
")",
")",
".",
"threadFactory",
"(",
"new",
"ThreadFactoryBuilder",
"(",
")",
".",
"setNameFormat",
"(",
"\"emo-zookeeper-%d\"",
")",
".",
"build",
"(",
")",
")",
".",
"namespace",
"(",
"namespace",
")",
".",
"build",
"(",
")",
";",
"curator",
".",
"start",
"(",
")",
";",
"return",
"Optional",
".",
"of",
"(",
"curator",
")",
";",
"}"
] | Returns a configured, started Curator for a given location, or absent if the location does not
use host discovery. | [
"Returns",
"a",
"configured",
"started",
"Curator",
"for",
"a",
"given",
"location",
"or",
"absent",
"if",
"the",
"location",
"does",
"not",
"use",
"host",
"discovery",
"."
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/mapreduce/sor-hadoop/src/main/java/com/bazaarvoice/emodb/hadoop/io/LocationUtil.java#L198-L239 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.iiop/src/com/ibm/ws/transport/iiop/yoko/ORBConfigAdapter.java | ORBConfigAdapter.translateToClientProps | private Properties translateToClientProps(Map<String, Object> clientProps, Collection<SubsystemFactory> subsystemFactories) throws ConfigException {
Properties result = createYokoORBProperties();
for (SubsystemFactory sf : subsystemFactories) {
addInitializerPropertyForSubsystem(result, sf, false);
sf.addClientORBInitProperties(result, clientProps);
}
return result;
} | java | private Properties translateToClientProps(Map<String, Object> clientProps, Collection<SubsystemFactory> subsystemFactories) throws ConfigException {
Properties result = createYokoORBProperties();
for (SubsystemFactory sf : subsystemFactories) {
addInitializerPropertyForSubsystem(result, sf, false);
sf.addClientORBInitProperties(result, clientProps);
}
return result;
} | [
"private",
"Properties",
"translateToClientProps",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"clientProps",
",",
"Collection",
"<",
"SubsystemFactory",
">",
"subsystemFactories",
")",
"throws",
"ConfigException",
"{",
"Properties",
"result",
"=",
"createYokoORBProperties",
"(",
")",
";",
"for",
"(",
"SubsystemFactory",
"sf",
":",
"subsystemFactories",
")",
"{",
"addInitializerPropertyForSubsystem",
"(",
"result",
",",
"sf",
",",
"false",
")",
";",
"sf",
".",
"addClientORBInitProperties",
"(",
"result",
",",
"clientProps",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Translate client configuration into the
property bundle necessary to configure the
client ORB instance.
@param clientProps configuration properties
@param subsystemFactories configured subsystem factories
@return A property bundle that can be passed to ORB.init();
@exception ConfigException if configuration cannot be interpreted | [
"Translate",
"client",
"configuration",
"into",
"the",
"property",
"bundle",
"necessary",
"to",
"configure",
"the",
"client",
"ORB",
"instance",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.iiop/src/com/ibm/ws/transport/iiop/yoko/ORBConfigAdapter.java#L179-L186 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/entity/message/MessageSetImpl.java | MessageSetImpl.getMessagesBefore | public static CompletableFuture<MessageSet> getMessagesBefore(TextChannel channel, int limit, long before) {
return getMessages(channel, limit, before, -1);
} | java | public static CompletableFuture<MessageSet> getMessagesBefore(TextChannel channel, int limit, long before) {
return getMessages(channel, limit, before, -1);
} | [
"public",
"static",
"CompletableFuture",
"<",
"MessageSet",
">",
"getMessagesBefore",
"(",
"TextChannel",
"channel",
",",
"int",
"limit",
",",
"long",
"before",
")",
"{",
"return",
"getMessages",
"(",
"channel",
",",
"limit",
",",
"before",
",",
"-",
"1",
")",
";",
"}"
] | Gets up to a given amount of messages in the given channel before a given message in any channel.
@param channel The channel of the messages.
@param limit The limit of messages to get.
@param before Get messages before the message with this id.
@return The messages.
@see #getMessagesBeforeAsStream(TextChannel, long) | [
"Gets",
"up",
"to",
"a",
"given",
"amount",
"of",
"messages",
"in",
"the",
"given",
"channel",
"before",
"a",
"given",
"message",
"in",
"any",
"channel",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/entity/message/MessageSetImpl.java#L316-L318 |
drinkjava2/jBeanBox | jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/ASMifier.java | ASMifier.main | public static void main(final String[] args) throws Exception {
int i = 0;
int flags = ClassReader.SKIP_DEBUG;
boolean ok = true;
if (args.length < 1 || args.length > 2) {
ok = false;
}
if (ok && "-debug".equals(args[0])) {
i = 1;
flags = 0;
if (args.length != 2) {
ok = false;
}
}
if (!ok) {
System.err
.println("Prints the ASM code to generate the given class.");
System.err.println("Usage: ASMifier [-debug] "
+ "<fully qualified class name or class file name>");
return;
}
ClassReader cr;
if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
|| args[i].indexOf('/') > -1) {
cr = new ClassReader(new FileInputStream(args[i]));
} else {
cr = new ClassReader(args[i]);
}
cr.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
System.out)), flags);
} | java | public static void main(final String[] args) throws Exception {
int i = 0;
int flags = ClassReader.SKIP_DEBUG;
boolean ok = true;
if (args.length < 1 || args.length > 2) {
ok = false;
}
if (ok && "-debug".equals(args[0])) {
i = 1;
flags = 0;
if (args.length != 2) {
ok = false;
}
}
if (!ok) {
System.err
.println("Prints the ASM code to generate the given class.");
System.err.println("Usage: ASMifier [-debug] "
+ "<fully qualified class name or class file name>");
return;
}
ClassReader cr;
if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1
|| args[i].indexOf('/') > -1) {
cr = new ClassReader(new FileInputStream(args[i]));
} else {
cr = new ClassReader(args[i]);
}
cr.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
System.out)), flags);
} | [
"public",
"static",
"void",
"main",
"(",
"final",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"int",
"i",
"=",
"0",
";",
"int",
"flags",
"=",
"ClassReader",
".",
"SKIP_DEBUG",
";",
"boolean",
"ok",
"=",
"true",
";",
"if",
"(",
"args",
".",
"length",
"<",
"1",
"||",
"args",
".",
"length",
">",
"2",
")",
"{",
"ok",
"=",
"false",
";",
"}",
"if",
"(",
"ok",
"&&",
"\"-debug\"",
".",
"equals",
"(",
"args",
"[",
"0",
"]",
")",
")",
"{",
"i",
"=",
"1",
";",
"flags",
"=",
"0",
";",
"if",
"(",
"args",
".",
"length",
"!=",
"2",
")",
"{",
"ok",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"ok",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Prints the ASM code to generate the given class.\"",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"Usage: ASMifier [-debug] \"",
"+",
"\"<fully qualified class name or class file name>\"",
")",
";",
"return",
";",
"}",
"ClassReader",
"cr",
";",
"if",
"(",
"args",
"[",
"i",
"]",
".",
"endsWith",
"(",
"\".class\"",
")",
"||",
"args",
"[",
"i",
"]",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"-",
"1",
"||",
"args",
"[",
"i",
"]",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"-",
"1",
")",
"{",
"cr",
"=",
"new",
"ClassReader",
"(",
"new",
"FileInputStream",
"(",
"args",
"[",
"i",
"]",
")",
")",
";",
"}",
"else",
"{",
"cr",
"=",
"new",
"ClassReader",
"(",
"args",
"[",
"i",
"]",
")",
";",
"}",
"cr",
".",
"accept",
"(",
"new",
"TraceClassVisitor",
"(",
"null",
",",
"new",
"ASMifier",
"(",
")",
",",
"new",
"PrintWriter",
"(",
"System",
".",
"out",
")",
")",
",",
"flags",
")",
";",
"}"
] | Prints the ASM source code to generate the given class to the standard
output.
<p>
Usage: ASMifier [-debug] <binary class name or class file name>
@param args
the command line arguments.
@throws Exception
if the class cannot be found, or if an IO exception occurs. | [
"Prints",
"the",
"ASM",
"source",
"code",
"to",
"generate",
"the",
"given",
"class",
"to",
"the",
"standard",
"output",
".",
"<p",
">",
"Usage",
":",
"ASMifier",
"[",
"-",
"debug",
"]",
"<",
";",
"binary",
"class",
"name",
"or",
"class",
"file",
"name>",
";"
] | train | https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/ASMifier.java#L128-L159 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.common/src/com/ibm/ws/sib/ra/impl/SibRaConnection.java | SibRaConnection.createBrowserSession | @Override
public BrowserSession createBrowserSession(
final SIDestinationAddress destinationAddress,
final DestinationType destType, final SelectionCriteria criteria,
final String alternateUser) throws SIConnectionDroppedException,
SIConnectionUnavailableException, SIConnectionLostException,
SILimitExceededException, SINotAuthorizedException,
SITemporaryDestinationNotFoundException, SIResourceException,
SIErrorException, SIIncorrectCallException,
SINotPossibleInCurrentConfigurationException {
checkValid();
final BrowserSession session = _delegateConnection
.createBrowserSession(destinationAddress, destType, criteria,
alternateUser);
return new SibRaBrowserSession(this, session);
} | java | @Override
public BrowserSession createBrowserSession(
final SIDestinationAddress destinationAddress,
final DestinationType destType, final SelectionCriteria criteria,
final String alternateUser) throws SIConnectionDroppedException,
SIConnectionUnavailableException, SIConnectionLostException,
SILimitExceededException, SINotAuthorizedException,
SITemporaryDestinationNotFoundException, SIResourceException,
SIErrorException, SIIncorrectCallException,
SINotPossibleInCurrentConfigurationException {
checkValid();
final BrowserSession session = _delegateConnection
.createBrowserSession(destinationAddress, destType, criteria,
alternateUser);
return new SibRaBrowserSession(this, session);
} | [
"@",
"Override",
"public",
"BrowserSession",
"createBrowserSession",
"(",
"final",
"SIDestinationAddress",
"destinationAddress",
",",
"final",
"DestinationType",
"destType",
",",
"final",
"SelectionCriteria",
"criteria",
",",
"final",
"String",
"alternateUser",
")",
"throws",
"SIConnectionDroppedException",
",",
"SIConnectionUnavailableException",
",",
"SIConnectionLostException",
",",
"SILimitExceededException",
",",
"SINotAuthorizedException",
",",
"SITemporaryDestinationNotFoundException",
",",
"SIResourceException",
",",
"SIErrorException",
",",
"SIIncorrectCallException",
",",
"SINotPossibleInCurrentConfigurationException",
"{",
"checkValid",
"(",
")",
";",
"final",
"BrowserSession",
"session",
"=",
"_delegateConnection",
".",
"createBrowserSession",
"(",
"destinationAddress",
",",
"destType",
",",
"criteria",
",",
"alternateUser",
")",
";",
"return",
"new",
"SibRaBrowserSession",
"(",
"this",
",",
"session",
")",
";",
"}"
] | Creates a browser session. Checks that the connection is valid and then
delegates. Wraps the <code>BrowserSession</code> returned from the
delegate in a <code>SibRaBrowserSession</code>.
@param destinationAddress
the address of the destination
@param destType
the destination type
@param criteria
the selection criteria
@param alternateUser
the name of the user under whose authority operations of the
BrowserSession should be performed (may be null)
@return the browser session
@throws SINotPossibleInCurrentConfigurationException
if the delegation fails
@throws SIIncorrectCallException
if the delegation fails
@throws SIErrorException
if the delegation fails
@throws SIResourceException
if the delegation fails
@throws SITemporaryDestinationNotFoundException
if the delegation fails
@throws SINotAuthorizedException
if the delegation fails
@throws SILimitExceededException
if the delegation fails
@throws SIConnectionLostException
if the delegation fails
@throws SIConnectionUnavailableException
if the connection is not valid
@throws SIConnectionDroppedException
if the delegation fails | [
"Creates",
"a",
"browser",
"session",
".",
"Checks",
"that",
"the",
"connection",
"is",
"valid",
"and",
"then",
"delegates",
".",
"Wraps",
"the",
"<code",
">",
"BrowserSession<",
"/",
"code",
">",
"returned",
"from",
"the",
"delegate",
"in",
"a",
"<code",
">",
"SibRaBrowserSession<",
"/",
"code",
">",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.common/src/com/ibm/ws/sib/ra/impl/SibRaConnection.java#L1530-L1549 |
davidcarboni/restolino | src/main/java/com/github/davidcarboni/restolino/routes/DefaultIndexRedirect.java | DefaultIndexRedirect.get | @Override
public Object get(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.sendRedirect(path);
return null;
} | java | @Override
public Object get(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.sendRedirect(path);
return null;
} | [
"@",
"Override",
"public",
"Object",
"get",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
")",
"throws",
"IOException",
"{",
"res",
".",
"sendRedirect",
"(",
"path",
")",
";",
"return",
"null",
";",
"}"
] | Extending this class and implementing {@link Home} will make use of this
method. | [
"Extending",
"this",
"class",
"and",
"implementing",
"{"
] | train | https://github.com/davidcarboni/restolino/blob/3f84ece1bd016fbb597c624d46fcca5a2580a33d/src/main/java/com/github/davidcarboni/restolino/routes/DefaultIndexRedirect.java#L38-L43 |
ravendb/ravendb-jvm-client | src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java | AbstractDocumentQuery._search | @Override
public void _search(String fieldName, String searchTerms) {
_search(fieldName, searchTerms, SearchOperator.OR);
} | java | @Override
public void _search(String fieldName, String searchTerms) {
_search(fieldName, searchTerms, SearchOperator.OR);
} | [
"@",
"Override",
"public",
"void",
"_search",
"(",
"String",
"fieldName",
",",
"String",
"searchTerms",
")",
"{",
"_search",
"(",
"fieldName",
",",
"searchTerms",
",",
"SearchOperator",
".",
"OR",
")",
";",
"}"
] | Perform a search for documents which fields that match the searchTerms.
If there is more than a single term, each of them will be checked independently.
@param fieldName Field name
@param searchTerms Search terms | [
"Perform",
"a",
"search",
"for",
"documents",
"which",
"fields",
"that",
"match",
"the",
"searchTerms",
".",
"If",
"there",
"is",
"more",
"than",
"a",
"single",
"term",
"each",
"of",
"them",
"will",
"be",
"checked",
"independently",
"."
] | train | https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L1022-L1025 |
jenkinsci/jenkins | core/src/main/java/hudson/Util.java | Util.createFileSet | @Nonnull
public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes, @CheckForNull String excludes) {
FileSet fs = new FileSet();
fs.setDir(baseDir);
fs.setProject(new Project());
StringTokenizer tokens;
tokens = new StringTokenizer(includes,",");
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
fs.createInclude().setName(token);
}
if(excludes!=null) {
tokens = new StringTokenizer(excludes,",");
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
fs.createExclude().setName(token);
}
}
return fs;
} | java | @Nonnull
public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes, @CheckForNull String excludes) {
FileSet fs = new FileSet();
fs.setDir(baseDir);
fs.setProject(new Project());
StringTokenizer tokens;
tokens = new StringTokenizer(includes,",");
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
fs.createInclude().setName(token);
}
if(excludes!=null) {
tokens = new StringTokenizer(excludes,",");
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
fs.createExclude().setName(token);
}
}
return fs;
} | [
"@",
"Nonnull",
"public",
"static",
"FileSet",
"createFileSet",
"(",
"@",
"Nonnull",
"File",
"baseDir",
",",
"@",
"Nonnull",
"String",
"includes",
",",
"@",
"CheckForNull",
"String",
"excludes",
")",
"{",
"FileSet",
"fs",
"=",
"new",
"FileSet",
"(",
")",
";",
"fs",
".",
"setDir",
"(",
"baseDir",
")",
";",
"fs",
".",
"setProject",
"(",
"new",
"Project",
"(",
")",
")",
";",
"StringTokenizer",
"tokens",
";",
"tokens",
"=",
"new",
"StringTokenizer",
"(",
"includes",
",",
"\",\"",
")",
";",
"while",
"(",
"tokens",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"token",
"=",
"tokens",
".",
"nextToken",
"(",
")",
".",
"trim",
"(",
")",
";",
"fs",
".",
"createInclude",
"(",
")",
".",
"setName",
"(",
"token",
")",
";",
"}",
"if",
"(",
"excludes",
"!=",
"null",
")",
"{",
"tokens",
"=",
"new",
"StringTokenizer",
"(",
"excludes",
",",
"\",\"",
")",
";",
"while",
"(",
"tokens",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"token",
"=",
"tokens",
".",
"nextToken",
"(",
")",
".",
"trim",
"(",
")",
";",
"fs",
".",
"createExclude",
"(",
")",
".",
"setName",
"(",
"token",
")",
";",
"}",
"}",
"return",
"fs",
";",
"}"
] | Creates Ant {@link FileSet} with the base dir and include pattern.
<p>
The difference with this and using {@link FileSet#setIncludes(String)}
is that this method doesn't treat whitespace as a pattern separator,
which makes it impossible to use space in the file path.
@param includes
String like "foo/bar/*.xml" Multiple patterns can be separated
by ',', and whitespace can surround ',' (so that you can write
"abc, def" and "abc,def" to mean the same thing.
@param excludes
Exclusion pattern. Follows the same format as the 'includes' parameter.
Can be null.
@since 1.172 | [
"Creates",
"Ant",
"{",
"@link",
"FileSet",
"}",
"with",
"the",
"base",
"dir",
"and",
"include",
"pattern",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/Util.java#L1143-L1164 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/datastructure/JMMap.java | JMMap.newFilteredMap | public static <K, V> Map<K, V> newFilteredMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter)
.collect(toMap(Entry::getKey, Entry::getValue));
} | java | public static <K, V> Map<K, V> newFilteredMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter)
.collect(toMap(Entry::getKey, Entry::getValue));
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"newFilteredMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"Entry",
"::",
"getKey",
",",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] | New filtered map map.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param filter the filter
@return the map | [
"New",
"filtered",
"map",
"map",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L385-L389 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java | SARLQuickfixProvider.removeExecutableFeature | public void removeExecutableFeature(EObject element, IModificationContext context) throws BadLocationException {
final ICompositeNode node;
final SarlAction action = EcoreUtil2.getContainerOfType(element, SarlAction.class);
if (action == null) {
final XtendMember feature = EcoreUtil2.getContainerOfType(element, XtendMember.class);
node = NodeModelUtils.findActualNodeFor(feature);
} else {
node = NodeModelUtils.findActualNodeFor(action);
}
if (node != null) {
remove(context.getXtextDocument(), node);
}
} | java | public void removeExecutableFeature(EObject element, IModificationContext context) throws BadLocationException {
final ICompositeNode node;
final SarlAction action = EcoreUtil2.getContainerOfType(element, SarlAction.class);
if (action == null) {
final XtendMember feature = EcoreUtil2.getContainerOfType(element, XtendMember.class);
node = NodeModelUtils.findActualNodeFor(feature);
} else {
node = NodeModelUtils.findActualNodeFor(action);
}
if (node != null) {
remove(context.getXtextDocument(), node);
}
} | [
"public",
"void",
"removeExecutableFeature",
"(",
"EObject",
"element",
",",
"IModificationContext",
"context",
")",
"throws",
"BadLocationException",
"{",
"final",
"ICompositeNode",
"node",
";",
"final",
"SarlAction",
"action",
"=",
"EcoreUtil2",
".",
"getContainerOfType",
"(",
"element",
",",
"SarlAction",
".",
"class",
")",
";",
"if",
"(",
"action",
"==",
"null",
")",
"{",
"final",
"XtendMember",
"feature",
"=",
"EcoreUtil2",
".",
"getContainerOfType",
"(",
"element",
",",
"XtendMember",
".",
"class",
")",
";",
"node",
"=",
"NodeModelUtils",
".",
"findActualNodeFor",
"(",
"feature",
")",
";",
"}",
"else",
"{",
"node",
"=",
"NodeModelUtils",
".",
"findActualNodeFor",
"(",
"action",
")",
";",
"}",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"remove",
"(",
"context",
".",
"getXtextDocument",
"(",
")",
",",
"node",
")",
";",
"}",
"}"
] | Remove the exectuable feature.
@param element the executable feature to remove.
@param context the context of the change.
@throws BadLocationException if there is a problem with the location of the element. | [
"Remove",
"the",
"exectuable",
"feature",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java#L587-L599 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-cache/xwiki-commons-cache-infinispan/src/main/java/org/xwiki/cache/infinispan/internal/InfinispanCache.java | InfinispanCache.cacheEntryInserted | private void cacheEntryInserted(String key, T value)
{
InfinispanCacheEntryEvent<T> event =
new InfinispanCacheEntryEvent<>(new InfinispanCacheEntry<T>(this, key, value));
T previousValue = this.preEventData.get(key);
if (previousValue != null) {
if (previousValue != value) {
disposeCacheValue(previousValue);
}
sendEntryModifiedEvent(event);
} else {
sendEntryAddedEvent(event);
}
} | java | private void cacheEntryInserted(String key, T value)
{
InfinispanCacheEntryEvent<T> event =
new InfinispanCacheEntryEvent<>(new InfinispanCacheEntry<T>(this, key, value));
T previousValue = this.preEventData.get(key);
if (previousValue != null) {
if (previousValue != value) {
disposeCacheValue(previousValue);
}
sendEntryModifiedEvent(event);
} else {
sendEntryAddedEvent(event);
}
} | [
"private",
"void",
"cacheEntryInserted",
"(",
"String",
"key",
",",
"T",
"value",
")",
"{",
"InfinispanCacheEntryEvent",
"<",
"T",
">",
"event",
"=",
"new",
"InfinispanCacheEntryEvent",
"<>",
"(",
"new",
"InfinispanCacheEntry",
"<",
"T",
">",
"(",
"this",
",",
"key",
",",
"value",
")",
")",
";",
"T",
"previousValue",
"=",
"this",
".",
"preEventData",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"previousValue",
"!=",
"null",
")",
"{",
"if",
"(",
"previousValue",
"!=",
"value",
")",
"{",
"disposeCacheValue",
"(",
"previousValue",
")",
";",
"}",
"sendEntryModifiedEvent",
"(",
"event",
")",
";",
"}",
"else",
"{",
"sendEntryAddedEvent",
"(",
"event",
")",
";",
"}",
"}"
] | Dispatch data insertion event.
@param key the entry key.
@param value the entry value. | [
"Dispatch",
"data",
"insertion",
"event",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-cache/xwiki-commons-cache-infinispan/src/main/java/org/xwiki/cache/infinispan/internal/InfinispanCache.java#L200-L216 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/DashboardResources.java | DashboardResources.updateDashboard | @PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{dashboardId}")
@Description("Updates a dashboard having the given ID.")
public DashboardDto updateDashboard(@Context HttpServletRequest req,
@PathParam("dashboardId") BigInteger dashboardId, DashboardDto dashboardDto) {
if (dashboardId == null || dashboardId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Dashboard Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
if (dashboardDto == null) {
throw new WebApplicationException("Null object cannot be updated.", Status.BAD_REQUEST);
}
PrincipalUser owner = validateAndGetOwner(req, dashboardDto.getOwnerName());
Dashboard oldDashboard = dService.findDashboardByPrimaryKey(dashboardId);
if (oldDashboard == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
}
validateResourceAuthorization(req, oldDashboard.getOwner(), owner);
copyProperties(oldDashboard, dashboardDto);
oldDashboard.setModifiedBy(getRemoteUser(req));
return DashboardDto.transformToDto(dService.updateDashboard(oldDashboard));
} | java | @PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{dashboardId}")
@Description("Updates a dashboard having the given ID.")
public DashboardDto updateDashboard(@Context HttpServletRequest req,
@PathParam("dashboardId") BigInteger dashboardId, DashboardDto dashboardDto) {
if (dashboardId == null || dashboardId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Dashboard Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
if (dashboardDto == null) {
throw new WebApplicationException("Null object cannot be updated.", Status.BAD_REQUEST);
}
PrincipalUser owner = validateAndGetOwner(req, dashboardDto.getOwnerName());
Dashboard oldDashboard = dService.findDashboardByPrimaryKey(dashboardId);
if (oldDashboard == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
}
validateResourceAuthorization(req, oldDashboard.getOwner(), owner);
copyProperties(oldDashboard, dashboardDto);
oldDashboard.setModifiedBy(getRemoteUser(req));
return DashboardDto.transformToDto(dService.updateDashboard(oldDashboard));
} | [
"@",
"PUT",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Path",
"(",
"\"/{dashboardId}\"",
")",
"@",
"Description",
"(",
"\"Updates a dashboard having the given ID.\"",
")",
"public",
"DashboardDto",
"updateDashboard",
"(",
"@",
"Context",
"HttpServletRequest",
"req",
",",
"@",
"PathParam",
"(",
"\"dashboardId\"",
")",
"BigInteger",
"dashboardId",
",",
"DashboardDto",
"dashboardDto",
")",
"{",
"if",
"(",
"dashboardId",
"==",
"null",
"||",
"dashboardId",
".",
"compareTo",
"(",
"BigInteger",
".",
"ZERO",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Dashboard Id cannot be null and must be a positive non-zero number.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"if",
"(",
"dashboardDto",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null object cannot be updated.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"PrincipalUser",
"owner",
"=",
"validateAndGetOwner",
"(",
"req",
",",
"dashboardDto",
".",
"getOwnerName",
"(",
")",
")",
";",
"Dashboard",
"oldDashboard",
"=",
"dService",
".",
"findDashboardByPrimaryKey",
"(",
"dashboardId",
")",
";",
"if",
"(",
"oldDashboard",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
".",
"getReasonPhrase",
"(",
")",
",",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
";",
"}",
"validateResourceAuthorization",
"(",
"req",
",",
"oldDashboard",
".",
"getOwner",
"(",
")",
",",
"owner",
")",
";",
"copyProperties",
"(",
"oldDashboard",
",",
"dashboardDto",
")",
";",
"oldDashboard",
".",
"setModifiedBy",
"(",
"getRemoteUser",
"(",
"req",
")",
")",
";",
"return",
"DashboardDto",
".",
"transformToDto",
"(",
"dService",
".",
"updateDashboard",
"(",
"oldDashboard",
")",
")",
";",
"}"
] | Updates a dashboard having the given ID.
@param req The HTTP request.
@param dashboardId The dashboard ID to update.
@param dashboardDto The updated date.
@return The updated dashboard DTO.
@throws WebApplicationException If an error occurs. | [
"Updates",
"a",
"dashboard",
"having",
"the",
"given",
"ID",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/DashboardResources.java#L312-L336 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ExportConfigurationsInner.java | ExportConfigurationsInner.createAsync | public Observable<List<ApplicationInsightsComponentExportConfigurationInner>> createAsync(String resourceGroupName, String resourceName, ApplicationInsightsComponentExportRequest exportProperties) {
return createWithServiceResponseAsync(resourceGroupName, resourceName, exportProperties).map(new Func1<ServiceResponse<List<ApplicationInsightsComponentExportConfigurationInner>>, List<ApplicationInsightsComponentExportConfigurationInner>>() {
@Override
public List<ApplicationInsightsComponentExportConfigurationInner> call(ServiceResponse<List<ApplicationInsightsComponentExportConfigurationInner>> response) {
return response.body();
}
});
} | java | public Observable<List<ApplicationInsightsComponentExportConfigurationInner>> createAsync(String resourceGroupName, String resourceName, ApplicationInsightsComponentExportRequest exportProperties) {
return createWithServiceResponseAsync(resourceGroupName, resourceName, exportProperties).map(new Func1<ServiceResponse<List<ApplicationInsightsComponentExportConfigurationInner>>, List<ApplicationInsightsComponentExportConfigurationInner>>() {
@Override
public List<ApplicationInsightsComponentExportConfigurationInner> call(ServiceResponse<List<ApplicationInsightsComponentExportConfigurationInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"ApplicationInsightsComponentExportRequest",
"exportProperties",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"exportProperties",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
">",
",",
"List",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a Continuous Export configuration of an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param exportProperties Properties that need to be specified to create a Continuous Export configuration of a Application Insights component.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ApplicationInsightsComponentExportConfigurationInner> object | [
"Create",
"a",
"Continuous",
"Export",
"configuration",
"of",
"an",
"Application",
"Insights",
"component",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ExportConfigurationsInner.java#L207-L214 |
playn/playn | android/src/playn/android/AndroidHttpClient.java | AndroidHttpClient.newInstance | public static AndroidHttpClient newInstance(String userAgent) {
HttpParams params = new BasicHttpParams();
// Turn off stale checking. Our connections break all the time anyway,
// and it's not worth it to pay the penalty of checking every time.
HttpConnectionParams.setStaleCheckingEnabled(params, false);
// Default connection and socket timeout of 20 seconds. Tweak to taste.
HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
HttpConnectionParams.setSoTimeout(params, 20 * 1000);
HttpConnectionParams.setSocketBufferSize(params, 8192);
// Don't handle redirects -- return them to the caller. Our code
// often wants to re-POST after a redirect, which we must do ourselves.
HttpClientParams.setRedirecting(params, false);
// Set the specified user agent and register standard protocols.
HttpProtocolParams.setUserAgent(params, userAgent);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry);
// We use a factory method to modify superclass initialization
// parameters without the funny call-a-static-method dance.
return new AndroidHttpClient(manager, params);
} | java | public static AndroidHttpClient newInstance(String userAgent) {
HttpParams params = new BasicHttpParams();
// Turn off stale checking. Our connections break all the time anyway,
// and it's not worth it to pay the penalty of checking every time.
HttpConnectionParams.setStaleCheckingEnabled(params, false);
// Default connection and socket timeout of 20 seconds. Tweak to taste.
HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
HttpConnectionParams.setSoTimeout(params, 20 * 1000);
HttpConnectionParams.setSocketBufferSize(params, 8192);
// Don't handle redirects -- return them to the caller. Our code
// often wants to re-POST after a redirect, which we must do ourselves.
HttpClientParams.setRedirecting(params, false);
// Set the specified user agent and register standard protocols.
HttpProtocolParams.setUserAgent(params, userAgent);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry);
// We use a factory method to modify superclass initialization
// parameters without the funny call-a-static-method dance.
return new AndroidHttpClient(manager, params);
} | [
"public",
"static",
"AndroidHttpClient",
"newInstance",
"(",
"String",
"userAgent",
")",
"{",
"HttpParams",
"params",
"=",
"new",
"BasicHttpParams",
"(",
")",
";",
"// Turn off stale checking. Our connections break all the time anyway,",
"// and it's not worth it to pay the penalty of checking every time.",
"HttpConnectionParams",
".",
"setStaleCheckingEnabled",
"(",
"params",
",",
"false",
")",
";",
"// Default connection and socket timeout of 20 seconds. Tweak to taste.",
"HttpConnectionParams",
".",
"setConnectionTimeout",
"(",
"params",
",",
"20",
"*",
"1000",
")",
";",
"HttpConnectionParams",
".",
"setSoTimeout",
"(",
"params",
",",
"20",
"*",
"1000",
")",
";",
"HttpConnectionParams",
".",
"setSocketBufferSize",
"(",
"params",
",",
"8192",
")",
";",
"// Don't handle redirects -- return them to the caller. Our code",
"// often wants to re-POST after a redirect, which we must do ourselves.",
"HttpClientParams",
".",
"setRedirecting",
"(",
"params",
",",
"false",
")",
";",
"// Set the specified user agent and register standard protocols.",
"HttpProtocolParams",
".",
"setUserAgent",
"(",
"params",
",",
"userAgent",
")",
";",
"SchemeRegistry",
"schemeRegistry",
"=",
"new",
"SchemeRegistry",
"(",
")",
";",
"schemeRegistry",
".",
"register",
"(",
"new",
"Scheme",
"(",
"\"http\"",
",",
"PlainSocketFactory",
".",
"getSocketFactory",
"(",
")",
",",
"80",
")",
")",
";",
"schemeRegistry",
".",
"register",
"(",
"new",
"Scheme",
"(",
"\"https\"",
",",
"SSLSocketFactory",
".",
"getSocketFactory",
"(",
")",
",",
"443",
")",
")",
";",
"ClientConnectionManager",
"manager",
"=",
"new",
"ThreadSafeClientConnManager",
"(",
"params",
",",
"schemeRegistry",
")",
";",
"// We use a factory method to modify superclass initialization",
"// parameters without the funny call-a-static-method dance.",
"return",
"new",
"AndroidHttpClient",
"(",
"manager",
",",
"params",
")",
";",
"}"
] | Create a new HttpClient with reasonable defaults (which you can update).
@param userAgent to report in your HTTP requests.
@return AndroidHttpClient for you to use for all your requests. | [
"Create",
"a",
"new",
"HttpClient",
"with",
"reasonable",
"defaults",
"(",
"which",
"you",
"can",
"update",
")",
"."
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/android/src/playn/android/AndroidHttpClient.java#L80-L106 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/dictionary/CoreBiGramTableDictionary.java | CoreBiGramTableDictionary.binarySearch | private static int binarySearch(int[] a, int fromIndex, int length, int key)
{
int low = fromIndex;
int high = fromIndex + length - 1;
while (low <= high)
{
int mid = (low + high) >>> 1;
int midVal = a[mid << 1];
if (midVal < key)
low = mid + 1;
else if (midVal > key)
high = mid - 1;
else
return mid; // key found
}
return -(low + 1); // key not found.
} | java | private static int binarySearch(int[] a, int fromIndex, int length, int key)
{
int low = fromIndex;
int high = fromIndex + length - 1;
while (low <= high)
{
int mid = (low + high) >>> 1;
int midVal = a[mid << 1];
if (midVal < key)
low = mid + 1;
else if (midVal > key)
high = mid - 1;
else
return mid; // key found
}
return -(low + 1); // key not found.
} | [
"private",
"static",
"int",
"binarySearch",
"(",
"int",
"[",
"]",
"a",
",",
"int",
"fromIndex",
",",
"int",
"length",
",",
"int",
"key",
")",
"{",
"int",
"low",
"=",
"fromIndex",
";",
"int",
"high",
"=",
"fromIndex",
"+",
"length",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"int",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
">>>",
"1",
";",
"int",
"midVal",
"=",
"a",
"[",
"mid",
"<<",
"1",
"]",
";",
"if",
"(",
"midVal",
"<",
"key",
")",
"low",
"=",
"mid",
"+",
"1",
";",
"else",
"if",
"(",
"midVal",
">",
"key",
")",
"high",
"=",
"mid",
"-",
"1",
";",
"else",
"return",
"mid",
";",
"// key found",
"}",
"return",
"-",
"(",
"low",
"+",
"1",
")",
";",
"// key not found.",
"}"
] | 二分搜索,由于二元接续前一个词固定时,后一个词比较少,所以二分也能取得很高的性能
@param a 目标数组
@param fromIndex 开始下标
@param length 长度
@param key 词的id
@return 共现频次 | [
"二分搜索,由于二元接续前一个词固定时,后一个词比较少,所以二分也能取得很高的性能"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dictionary/CoreBiGramTableDictionary.java#L218-L236 |
JOML-CI/JOML | src/org/joml/Intersectionf.java | Intersectionf.intersectRayAab | public static boolean intersectRayAab(Vector3fc origin, Vector3fc dir, Vector3fc min, Vector3fc max, Vector2f result) {
return intersectRayAab(origin.x(), origin.y(), origin.z(), dir.x(), dir.y(), dir.z(), min.x(), min.y(), min.z(), max.x(), max.y(), max.z(), result);
} | java | public static boolean intersectRayAab(Vector3fc origin, Vector3fc dir, Vector3fc min, Vector3fc max, Vector2f result) {
return intersectRayAab(origin.x(), origin.y(), origin.z(), dir.x(), dir.y(), dir.z(), min.x(), min.y(), min.z(), max.x(), max.y(), max.z(), result);
} | [
"public",
"static",
"boolean",
"intersectRayAab",
"(",
"Vector3fc",
"origin",
",",
"Vector3fc",
"dir",
",",
"Vector3fc",
"min",
",",
"Vector3fc",
"max",
",",
"Vector2f",
"result",
")",
"{",
"return",
"intersectRayAab",
"(",
"origin",
".",
"x",
"(",
")",
",",
"origin",
".",
"y",
"(",
")",
",",
"origin",
".",
"z",
"(",
")",
",",
"dir",
".",
"x",
"(",
")",
",",
"dir",
".",
"y",
"(",
")",
",",
"dir",
".",
"z",
"(",
")",
",",
"min",
".",
"x",
"(",
")",
",",
"min",
".",
"y",
"(",
")",
",",
"min",
".",
"z",
"(",
")",
",",
"max",
".",
"x",
"(",
")",
",",
"max",
".",
"y",
"(",
")",
",",
"max",
".",
"z",
"(",
")",
",",
"result",
")",
";",
"}"
] | Test whether the ray with the given <code>origin</code> and direction <code>dir</code>
intersects the axis-aligned box specified as its minimum corner <code>min</code> and maximum corner <code>max</code>,
and return the values of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the near and far point of intersection..
<p>
This method returns <code>true</code> for a ray whose origin lies inside the axis-aligned box.
<p>
If many boxes need to be tested against the same ray, then the {@link RayAabIntersection} class is likely more efficient.
<p>
Reference: <a href="https://dl.acm.org/citation.cfm?id=1198748">An Efficient and Robust Ray–Box Intersection</a>
@see #intersectRayAab(float, float, float, float, float, float, float, float, float, float, float, float, Vector2f)
@see RayAabIntersection
@param origin
the ray's origin
@param dir
the ray's direction
@param min
the minimum corner of the axis-aligned box
@param max
the maximum corner of the axis-aligned box
@param result
a vector which will hold the resulting values of the parameter
<i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the near and far point of intersection
iff the ray intersects the axis-aligned box
@return <code>true</code> if the given ray intersects the axis-aligned box; <code>false</code> otherwise | [
"Test",
"whether",
"the",
"ray",
"with",
"the",
"given",
"<code",
">",
"origin<",
"/",
"code",
">",
"and",
"direction",
"<code",
">",
"dir<",
"/",
"code",
">",
"intersects",
"the",
"axis",
"-",
"aligned",
"box",
"specified",
"as",
"its",
"minimum",
"corner",
"<code",
">",
"min<",
"/",
"code",
">",
"and",
"maximum",
"corner",
"<code",
">",
"max<",
"/",
"code",
">",
"and",
"return",
"the",
"values",
"of",
"the",
"parameter",
"<i",
">",
"t<",
"/",
"i",
">",
"in",
"the",
"ray",
"equation",
"<i",
">",
"p",
"(",
"t",
")",
"=",
"origin",
"+",
"t",
"*",
"dir<",
"/",
"i",
">",
"of",
"the",
"near",
"and",
"far",
"point",
"of",
"intersection",
"..",
"<p",
">",
"This",
"method",
"returns",
"<code",
">",
"true<",
"/",
"code",
">",
"for",
"a",
"ray",
"whose",
"origin",
"lies",
"inside",
"the",
"axis",
"-",
"aligned",
"box",
".",
"<p",
">",
"If",
"many",
"boxes",
"need",
"to",
"be",
"tested",
"against",
"the",
"same",
"ray",
"then",
"the",
"{",
"@link",
"RayAabIntersection",
"}",
"class",
"is",
"likely",
"more",
"efficient",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"https",
":",
"//",
"dl",
".",
"acm",
".",
"org",
"/",
"citation",
".",
"cfm?id",
"=",
"1198748",
">",
"An",
"Efficient",
"and",
"Robust",
"Ray–Box",
"Intersection<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Intersectionf.java#L2411-L2413 |
xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java | XsdAsmVisitor.addVisitorAttributeMethod | private static void addVisitorAttributeMethod(ClassWriter classWriter, XsdAttribute attribute) {
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, VISIT_ATTRIBUTE_NAME + getCleanName(attribute.getName()), "(" + JAVA_STRING_DESC + ")V", null, null);
mVisitor.visitLocalVariable(firstToLower(getCleanName(attribute.getName())), JAVA_STRING_DESC, null, new Label(), new Label(),1);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitLdcInsn(attribute.getRawName());
mVisitor.visitVarInsn(ALOAD, 1);
mVisitor.visitMethodInsn(INVOKEVIRTUAL, elementVisitorType, VISIT_ATTRIBUTE_NAME, "(" + JAVA_STRING_DESC + JAVA_STRING_DESC + ")V", false);
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(3, 2);
mVisitor.visitEnd();
} | java | private static void addVisitorAttributeMethod(ClassWriter classWriter, XsdAttribute attribute) {
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, VISIT_ATTRIBUTE_NAME + getCleanName(attribute.getName()), "(" + JAVA_STRING_DESC + ")V", null, null);
mVisitor.visitLocalVariable(firstToLower(getCleanName(attribute.getName())), JAVA_STRING_DESC, null, new Label(), new Label(),1);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitLdcInsn(attribute.getRawName());
mVisitor.visitVarInsn(ALOAD, 1);
mVisitor.visitMethodInsn(INVOKEVIRTUAL, elementVisitorType, VISIT_ATTRIBUTE_NAME, "(" + JAVA_STRING_DESC + JAVA_STRING_DESC + ")V", false);
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(3, 2);
mVisitor.visitEnd();
} | [
"private",
"static",
"void",
"addVisitorAttributeMethod",
"(",
"ClassWriter",
"classWriter",
",",
"XsdAttribute",
"attribute",
")",
"{",
"MethodVisitor",
"mVisitor",
"=",
"classWriter",
".",
"visitMethod",
"(",
"ACC_PUBLIC",
",",
"VISIT_ATTRIBUTE_NAME",
"+",
"getCleanName",
"(",
"attribute",
".",
"getName",
"(",
")",
")",
",",
"\"(\"",
"+",
"JAVA_STRING_DESC",
"+",
"\")V\"",
",",
"null",
",",
"null",
")",
";",
"mVisitor",
".",
"visitLocalVariable",
"(",
"firstToLower",
"(",
"getCleanName",
"(",
"attribute",
".",
"getName",
"(",
")",
")",
")",
",",
"JAVA_STRING_DESC",
",",
"null",
",",
"new",
"Label",
"(",
")",
",",
"new",
"Label",
"(",
")",
",",
"1",
")",
";",
"mVisitor",
".",
"visitCode",
"(",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitLdcInsn",
"(",
"attribute",
".",
"getRawName",
"(",
")",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"1",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEVIRTUAL",
",",
"elementVisitorType",
",",
"VISIT_ATTRIBUTE_NAME",
",",
"\"(\"",
"+",
"JAVA_STRING_DESC",
"+",
"JAVA_STRING_DESC",
"+",
"\")V\"",
",",
"false",
")",
";",
"mVisitor",
".",
"visitInsn",
"(",
"RETURN",
")",
";",
"mVisitor",
".",
"visitMaxs",
"(",
"3",
",",
"2",
")",
";",
"mVisitor",
".",
"visitEnd",
"(",
")",
";",
"}"
] | Adds a specific method for a visitAttribute call.
Example:
void visitAttributeManifest(String manifestValue){
visitAttribute("manifest", manifestValue);
}
@param classWriter The ElementVisitor class {@link ClassWriter}.
@param attribute The specific attribute. | [
"Adds",
"a",
"specific",
"method",
"for",
"a",
"visitAttribute",
"call",
".",
"Example",
":",
"void",
"visitAttributeManifest",
"(",
"String",
"manifestValue",
")",
"{",
"visitAttribute",
"(",
"manifest",
"manifestValue",
")",
";",
"}"
] | train | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java#L107-L118 |
upwork/java-upwork | src/com/Upwork/api/Routers/Reports/Time.java | Time.getByTeamLimited | public JSONObject getByTeamLimited(String company, String team, HashMap<String, String> params) throws JSONException {
return _getByType(company, team, null, params, true);
} | java | public JSONObject getByTeamLimited(String company, String team, HashMap<String, String> params) throws JSONException {
return _getByType(company, team, null, params, true);
} | [
"public",
"JSONObject",
"getByTeamLimited",
"(",
"String",
"company",
",",
"String",
"team",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"_getByType",
"(",
"company",
",",
"team",
",",
"null",
",",
"params",
",",
"true",
")",
";",
"}"
] | Generate Time Reports for a Specific Team (hide financial info)
@param company Company ID
@param team Team ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Generate",
"Time",
"Reports",
"for",
"a",
"Specific",
"Team",
"(",
"hide",
"financial",
"info",
")"
] | train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Reports/Time.java#L93-L95 |
calimero-project/calimero-core | src/tuwien/auto/calimero/knxnetip/ConnectionBase.java | ConnectionBase.checkChannelId | protected boolean checkChannelId(final int id, final String svcType)
{
if (id == channelId)
return true;
logger.warn("received service " + svcType + " with wrong channel ID " + id + ", expected " + channelId
+ " - ignored");
return false;
} | java | protected boolean checkChannelId(final int id, final String svcType)
{
if (id == channelId)
return true;
logger.warn("received service " + svcType + " with wrong channel ID " + id + ", expected " + channelId
+ " - ignored");
return false;
} | [
"protected",
"boolean",
"checkChannelId",
"(",
"final",
"int",
"id",
",",
"final",
"String",
"svcType",
")",
"{",
"if",
"(",
"id",
"==",
"channelId",
")",
"return",
"true",
";",
"logger",
".",
"warn",
"(",
"\"received service \"",
"+",
"svcType",
"+",
"\" with wrong channel ID \"",
"+",
"id",
"+",
"\", expected \"",
"+",
"channelId",
"+",
"\" - ignored\"",
")",
";",
"return",
"false",
";",
"}"
] | Validates channel id received in a packet against the one assigned to this connection.
@param id received id to check
@param svcType packet service type
@return <code>true</code> if valid, <code>false</code> otherwise | [
"Validates",
"channel",
"id",
"received",
"in",
"a",
"packet",
"against",
"the",
"one",
"assigned",
"to",
"this",
"connection",
"."
] | train | https://github.com/calimero-project/calimero-core/blob/7e6f547c6bd75fa985bfeb5b47ba671df2ea01e8/src/tuwien/auto/calimero/knxnetip/ConnectionBase.java#L487-L494 |
osglworks/java-tool | src/main/java/org/osgl/Lang.java | F5.andThen | public F5<P1, P2, P3, P4, P5, R> andThen(
final Func5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5, ? extends R>... fs
) {
if (0 == fs.length) {
return this;
}
final F5<P1, P2, P3, P4, P5, R> me = this;
return new F5<P1, P2, P3, P4, P5, R>() {
@Override
public R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
R r = me.apply(p1, p2, p3, p4, p5);
for (Func5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5, ? extends R> f : fs) {
r = f.apply(p1, p2, p3, p4, p5);
}
return r;
}
};
} | java | public F5<P1, P2, P3, P4, P5, R> andThen(
final Func5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5, ? extends R>... fs
) {
if (0 == fs.length) {
return this;
}
final F5<P1, P2, P3, P4, P5, R> me = this;
return new F5<P1, P2, P3, P4, P5, R>() {
@Override
public R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
R r = me.apply(p1, p2, p3, p4, p5);
for (Func5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5, ? extends R> f : fs) {
r = f.apply(p1, p2, p3, p4, p5);
}
return r;
}
};
} | [
"public",
"F5",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"P4",
",",
"P5",
",",
"R",
">",
"andThen",
"(",
"final",
"Func5",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"super",
"P3",
",",
"?",
"super",
"P4",
",",
"?",
"super",
"P5",
",",
"?",
"extends",
"R",
">",
"...",
"fs",
")",
"{",
"if",
"(",
"0",
"==",
"fs",
".",
"length",
")",
"{",
"return",
"this",
";",
"}",
"final",
"F5",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"P4",
",",
"P5",
",",
"R",
">",
"me",
"=",
"this",
";",
"return",
"new",
"F5",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"P4",
",",
"P5",
",",
"R",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"R",
"apply",
"(",
"P1",
"p1",
",",
"P2",
"p2",
",",
"P3",
"p3",
",",
"P4",
"p4",
",",
"P5",
"p5",
")",
"{",
"R",
"r",
"=",
"me",
".",
"apply",
"(",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
",",
"p5",
")",
";",
"for",
"(",
"Func5",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"super",
"P3",
",",
"?",
"super",
"P4",
",",
"?",
"super",
"P5",
",",
"?",
"extends",
"R",
">",
"f",
":",
"fs",
")",
"{",
"r",
"=",
"f",
".",
"apply",
"(",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
",",
"p5",
")",
";",
"}",
"return",
"r",
";",
"}",
"}",
";",
"}"
] | Returns a composed function that applied, in sequence, this function and
all functions specified one by one. If applying anyone of the functions
throws an exception, it is relayed to the caller of the composed function.
If an exception is thrown out, the following functions will not be applied.
<p>When apply the composed function, the result of the last function
is returned</p>
@param fs
a sequence of function to be applied after this function
@return a composed function | [
"Returns",
"a",
"composed",
"function",
"that",
"applied",
"in",
"sequence",
"this",
"function",
"and",
"all",
"functions",
"specified",
"one",
"by",
"one",
".",
"If",
"applying",
"anyone",
"of",
"the",
"functions",
"throws",
"an",
"exception",
"it",
"is",
"relayed",
"to",
"the",
"caller",
"of",
"the",
"composed",
"function",
".",
"If",
"an",
"exception",
"is",
"thrown",
"out",
"the",
"following",
"functions",
"will",
"not",
"be",
"applied",
".",
"<p",
">",
"When",
"apply",
"the",
"composed",
"function",
"the",
"result",
"of",
"the",
"last",
"function",
"is",
"returned<",
"/",
"p",
">"
] | train | https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/Lang.java#L1890-L1908 |
windup/windup | reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationService.java | ClassificationService.attachClassification | public ClassificationModel attachClassification(GraphRewrite event, ClassificationModel classificationModel, FileModel fileModel)
{
if (fileModel instanceof DuplicateArchiveModel)
{
fileModel = ((DuplicateArchiveModel) fileModel).getCanonicalArchive();
}
if (!isClassificationLinkedToFileModel(event, classificationModel, fileModel))
{
classificationModel.addFileModel(fileModel);
if (fileModel instanceof SourceFileModel)
((SourceFileModel) fileModel).setGenerateSourceReport(true);
}
ClassificationServiceCache.cacheClassificationFileModel(event, classificationModel, fileModel, true);
return classificationModel;
} | java | public ClassificationModel attachClassification(GraphRewrite event, ClassificationModel classificationModel, FileModel fileModel)
{
if (fileModel instanceof DuplicateArchiveModel)
{
fileModel = ((DuplicateArchiveModel) fileModel).getCanonicalArchive();
}
if (!isClassificationLinkedToFileModel(event, classificationModel, fileModel))
{
classificationModel.addFileModel(fileModel);
if (fileModel instanceof SourceFileModel)
((SourceFileModel) fileModel).setGenerateSourceReport(true);
}
ClassificationServiceCache.cacheClassificationFileModel(event, classificationModel, fileModel, true);
return classificationModel;
} | [
"public",
"ClassificationModel",
"attachClassification",
"(",
"GraphRewrite",
"event",
",",
"ClassificationModel",
"classificationModel",
",",
"FileModel",
"fileModel",
")",
"{",
"if",
"(",
"fileModel",
"instanceof",
"DuplicateArchiveModel",
")",
"{",
"fileModel",
"=",
"(",
"(",
"DuplicateArchiveModel",
")",
"fileModel",
")",
".",
"getCanonicalArchive",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isClassificationLinkedToFileModel",
"(",
"event",
",",
"classificationModel",
",",
"fileModel",
")",
")",
"{",
"classificationModel",
".",
"addFileModel",
"(",
"fileModel",
")",
";",
"if",
"(",
"fileModel",
"instanceof",
"SourceFileModel",
")",
"(",
"(",
"SourceFileModel",
")",
"fileModel",
")",
".",
"setGenerateSourceReport",
"(",
"true",
")",
";",
"}",
"ClassificationServiceCache",
".",
"cacheClassificationFileModel",
"(",
"event",
",",
"classificationModel",
",",
"fileModel",
",",
"true",
")",
";",
"return",
"classificationModel",
";",
"}"
] | This method just attaches the {@link ClassificationModel} to the {@link FileModel}.
It will only do so if this link is not already present. | [
"This",
"method",
"just",
"attaches",
"the",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationService.java#L296-L312 |
dropwizard/dropwizard | dropwizard-jersey/src/main/java/io/dropwizard/jersey/validation/ConstraintMessage.java | ConstraintMessage.getMessage | public static String getMessage(ConstraintViolation<?> v, Invocable invocable) {
final Pair<Path, ? extends ConstraintDescriptor<?>> of =
Pair.of(v.getPropertyPath(), v.getConstraintDescriptor());
final String cachePrefix = PREFIX_CACHE.getIfPresent(of);
if (cachePrefix == null) {
final String prefix = calculatePrefix(v, invocable);
PREFIX_CACHE.put(of, prefix);
return prefix + v.getMessage();
}
return cachePrefix + v.getMessage();
} | java | public static String getMessage(ConstraintViolation<?> v, Invocable invocable) {
final Pair<Path, ? extends ConstraintDescriptor<?>> of =
Pair.of(v.getPropertyPath(), v.getConstraintDescriptor());
final String cachePrefix = PREFIX_CACHE.getIfPresent(of);
if (cachePrefix == null) {
final String prefix = calculatePrefix(v, invocable);
PREFIX_CACHE.put(of, prefix);
return prefix + v.getMessage();
}
return cachePrefix + v.getMessage();
} | [
"public",
"static",
"String",
"getMessage",
"(",
"ConstraintViolation",
"<",
"?",
">",
"v",
",",
"Invocable",
"invocable",
")",
"{",
"final",
"Pair",
"<",
"Path",
",",
"?",
"extends",
"ConstraintDescriptor",
"<",
"?",
">",
">",
"of",
"=",
"Pair",
".",
"of",
"(",
"v",
".",
"getPropertyPath",
"(",
")",
",",
"v",
".",
"getConstraintDescriptor",
"(",
")",
")",
";",
"final",
"String",
"cachePrefix",
"=",
"PREFIX_CACHE",
".",
"getIfPresent",
"(",
"of",
")",
";",
"if",
"(",
"cachePrefix",
"==",
"null",
")",
"{",
"final",
"String",
"prefix",
"=",
"calculatePrefix",
"(",
"v",
",",
"invocable",
")",
";",
"PREFIX_CACHE",
".",
"put",
"(",
"of",
",",
"prefix",
")",
";",
"return",
"prefix",
"+",
"v",
".",
"getMessage",
"(",
")",
";",
"}",
"return",
"cachePrefix",
"+",
"v",
".",
"getMessage",
"(",
")",
";",
"}"
] | Gets the human friendly location of where the violation was raised. | [
"Gets",
"the",
"human",
"friendly",
"location",
"of",
"where",
"the",
"violation",
"was",
"raised",
"."
] | train | https://github.com/dropwizard/dropwizard/blob/7ee09a410476b9681e8072ab684788bb440877bd/dropwizard-jersey/src/main/java/io/dropwizard/jersey/validation/ConstraintMessage.java#L40-L50 |
PrashamTrivedi/SharedPreferenceInspector | sharedpreferenceinspector/src/main/java/com/ceelites/sharedpreferenceinspector/Utils/SharedPreferenceUtils.java | SharedPreferenceUtils.initWith | public static SharedPreferenceUtils initWith(Context context, String name) {
if (sharedPreferenceUtils == null) {
sharedPreferenceUtils = new SharedPreferenceUtils();
}
if (isEmptyString(name)) {
sharedPreferenceUtils.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} else {
sharedPreferenceUtils.sharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
return sharedPreferenceUtils;
} | java | public static SharedPreferenceUtils initWith(Context context, String name) {
if (sharedPreferenceUtils == null) {
sharedPreferenceUtils = new SharedPreferenceUtils();
}
if (isEmptyString(name)) {
sharedPreferenceUtils.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} else {
sharedPreferenceUtils.sharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
return sharedPreferenceUtils;
} | [
"public",
"static",
"SharedPreferenceUtils",
"initWith",
"(",
"Context",
"context",
",",
"String",
"name",
")",
"{",
"if",
"(",
"sharedPreferenceUtils",
"==",
"null",
")",
"{",
"sharedPreferenceUtils",
"=",
"new",
"SharedPreferenceUtils",
"(",
")",
";",
"}",
"if",
"(",
"isEmptyString",
"(",
"name",
")",
")",
"{",
"sharedPreferenceUtils",
".",
"sharedPreferences",
"=",
"PreferenceManager",
".",
"getDefaultSharedPreferences",
"(",
"context",
")",
";",
"}",
"else",
"{",
"sharedPreferenceUtils",
".",
"sharedPreferences",
"=",
"context",
".",
"getSharedPreferences",
"(",
"name",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"}",
"return",
"sharedPreferenceUtils",
";",
"}"
] | Init SharedPreferences with context and a SharedPreferences name
@param context:
Context to init SharedPreferences
@param name:
Name of SharedPreferences file. If you pass <code>null</code> it will create default SharedPrefernces
@return: SharedPreferenceUtils object. It will store given the sharedPreferences value with given SharedPreferences. | [
"Init",
"SharedPreferences",
"with",
"context",
"and",
"a",
"SharedPreferences",
"name"
] | train | https://github.com/PrashamTrivedi/SharedPreferenceInspector/blob/c04d567c4d0fc5e0f8cda308ca85df19c6b3b838/sharedpreferenceinspector/src/main/java/com/ceelites/sharedpreferenceinspector/Utils/SharedPreferenceUtils.java#L63-L73 |
Coveros/selenified | src/main/java/com/coveros/selenified/Selenified.java | Selenified.setVersion | protected static void setVersion(Selenified clazz, ITestContext context, String version) {
context.setAttribute(clazz.getClass().getName() + "Version", version);
} | java | protected static void setVersion(Selenified clazz, ITestContext context, String version) {
context.setAttribute(clazz.getClass().getName() + "Version", version);
} | [
"protected",
"static",
"void",
"setVersion",
"(",
"Selenified",
"clazz",
",",
"ITestContext",
"context",
",",
"String",
"version",
")",
"{",
"context",
".",
"setAttribute",
"(",
"clazz",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"Version\"",
",",
"version",
")",
";",
"}"
] | Sets the version of the current test suite being executed.
@param clazz - the test suite class, used for making threadsafe storage of
application, allowing suites to have independent applications
under test, run at the same time
@param context - the TestNG context associated with the test suite, used for
storing app url information
@param version - the version of the test suite | [
"Sets",
"the",
"version",
"of",
"the",
"current",
"test",
"suite",
"being",
"executed",
"."
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/Selenified.java#L135-L137 |
messagebird/java-rest-api | api/src/main/java/com/messagebird/MessageBirdServiceImpl.java | MessageBirdServiceImpl.doRequest | <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException {
HttpURLConnection connection = null;
InputStream inputStream = null;
if (METHOD_PATCH.equalsIgnoreCase(method)) {
// It'd perhaps be cleaner to call this in the constructor, but
// we'd then need to throw GeneralExceptions from there. This means
// it wouldn't be possible to declare AND initialize _instance_
// fields of MessageBirdServiceImpl at the same time. This method
// already throws this exception, so now we don't have to pollute
// our public API further.
allowPatchRequestsIfNeeded();
}
try {
connection = getConnection(url, payload, method);
int status = connection.getResponseCode();
if (APIResponse.isSuccessStatus(status)) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
return new APIResponse(readToEnd(inputStream), status);
} catch (IOException ioe) {
throw new GeneralException(ioe);
} finally {
saveClose(inputStream);
if (connection != null) {
connection.disconnect();
}
}
} | java | <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException {
HttpURLConnection connection = null;
InputStream inputStream = null;
if (METHOD_PATCH.equalsIgnoreCase(method)) {
// It'd perhaps be cleaner to call this in the constructor, but
// we'd then need to throw GeneralExceptions from there. This means
// it wouldn't be possible to declare AND initialize _instance_
// fields of MessageBirdServiceImpl at the same time. This method
// already throws this exception, so now we don't have to pollute
// our public API further.
allowPatchRequestsIfNeeded();
}
try {
connection = getConnection(url, payload, method);
int status = connection.getResponseCode();
if (APIResponse.isSuccessStatus(status)) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
return new APIResponse(readToEnd(inputStream), status);
} catch (IOException ioe) {
throw new GeneralException(ioe);
} finally {
saveClose(inputStream);
if (connection != null) {
connection.disconnect();
}
}
} | [
"<",
"P",
">",
"APIResponse",
"doRequest",
"(",
"final",
"String",
"method",
",",
"final",
"String",
"url",
",",
"final",
"P",
"payload",
")",
"throws",
"GeneralException",
"{",
"HttpURLConnection",
"connection",
"=",
"null",
";",
"InputStream",
"inputStream",
"=",
"null",
";",
"if",
"(",
"METHOD_PATCH",
".",
"equalsIgnoreCase",
"(",
"method",
")",
")",
"{",
"// It'd perhaps be cleaner to call this in the constructor, but",
"// we'd then need to throw GeneralExceptions from there. This means",
"// it wouldn't be possible to declare AND initialize _instance_",
"// fields of MessageBirdServiceImpl at the same time. This method",
"// already throws this exception, so now we don't have to pollute",
"// our public API further.",
"allowPatchRequestsIfNeeded",
"(",
")",
";",
"}",
"try",
"{",
"connection",
"=",
"getConnection",
"(",
"url",
",",
"payload",
",",
"method",
")",
";",
"int",
"status",
"=",
"connection",
".",
"getResponseCode",
"(",
")",
";",
"if",
"(",
"APIResponse",
".",
"isSuccessStatus",
"(",
"status",
")",
")",
"{",
"inputStream",
"=",
"connection",
".",
"getInputStream",
"(",
")",
";",
"}",
"else",
"{",
"inputStream",
"=",
"connection",
".",
"getErrorStream",
"(",
")",
";",
"}",
"return",
"new",
"APIResponse",
"(",
"readToEnd",
"(",
"inputStream",
")",
",",
"status",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"ioe",
")",
";",
"}",
"finally",
"{",
"saveClose",
"(",
"inputStream",
")",
";",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"connection",
".",
"disconnect",
"(",
")",
";",
"}",
"}",
"}"
] | Actually sends a HTTP request and returns its body and HTTP status code.
@param method HTTP method.
@param url Absolute URL.
@param payload Payload to JSON encode for the request body. May be null.
@param <P> Type of the payload.
@return APIResponse containing the response's body and status. | [
"Actually",
"sends",
"a",
"HTTP",
"request",
"and",
"returns",
"its",
"body",
"and",
"HTTP",
"status",
"code",
"."
] | train | https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L219-L253 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/CalendarPanel.java | CalendarPanel.labelIndicatorSetColorsToDefaultState | private void labelIndicatorSetColorsToDefaultState(JLabel label) {
if (label == null || settings == null) {
return;
}
if (label == labelMonth || label == labelYear) {
label.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
monthAndYearInnerPanel.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
}
if (label == labelSetDateToToday) {
label.setBackground(settings.getColor(DateArea.BackgroundTodayLabel));
}
if (label == labelClearDate) {
label.setBackground(settings.getColor(DateArea.BackgroundClearLabel));
}
label.setBorder(new CompoundBorder(
new EmptyBorder(1, 1, 1, 1), labelIndicatorEmptyBorder));
} | java | private void labelIndicatorSetColorsToDefaultState(JLabel label) {
if (label == null || settings == null) {
return;
}
if (label == labelMonth || label == labelYear) {
label.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
monthAndYearInnerPanel.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
}
if (label == labelSetDateToToday) {
label.setBackground(settings.getColor(DateArea.BackgroundTodayLabel));
}
if (label == labelClearDate) {
label.setBackground(settings.getColor(DateArea.BackgroundClearLabel));
}
label.setBorder(new CompoundBorder(
new EmptyBorder(1, 1, 1, 1), labelIndicatorEmptyBorder));
} | [
"private",
"void",
"labelIndicatorSetColorsToDefaultState",
"(",
"JLabel",
"label",
")",
"{",
"if",
"(",
"label",
"==",
"null",
"||",
"settings",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"label",
"==",
"labelMonth",
"||",
"label",
"==",
"labelYear",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundMonthAndYearMenuLabels",
")",
")",
";",
"monthAndYearInnerPanel",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundMonthAndYearMenuLabels",
")",
")",
";",
"}",
"if",
"(",
"label",
"==",
"labelSetDateToToday",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundTodayLabel",
")",
")",
";",
"}",
"if",
"(",
"label",
"==",
"labelClearDate",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundClearLabel",
")",
")",
";",
"}",
"label",
".",
"setBorder",
"(",
"new",
"CompoundBorder",
"(",
"new",
"EmptyBorder",
"(",
"1",
",",
"1",
",",
"1",
",",
"1",
")",
",",
"labelIndicatorEmptyBorder",
")",
")",
";",
"}"
] | labelIndicatorSetColorsToDefaultState, This event is called to set a label indicator to the
state it should have when there is no mouse hovering over it. | [
"labelIndicatorSetColorsToDefaultState",
"This",
"event",
"is",
"called",
"to",
"set",
"a",
"label",
"indicator",
"to",
"the",
"state",
"it",
"should",
"have",
"when",
"there",
"is",
"no",
"mouse",
"hovering",
"over",
"it",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/CalendarPanel.java#L961-L977 |
darrachequesne/spring-data-jpa-datatables | src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java | DataTablesInput.addColumn | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | java | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | [
"public",
"void",
"addColumn",
"(",
"String",
"columnName",
",",
"boolean",
"searchable",
",",
"boolean",
"orderable",
",",
"String",
"searchValue",
")",
"{",
"this",
".",
"columns",
".",
"add",
"(",
"new",
"Column",
"(",
"columnName",
",",
"\"\"",
",",
"searchable",
",",
"orderable",
",",
"new",
"Search",
"(",
"searchValue",
",",
"false",
")",
")",
")",
";",
"}"
] | Add a new column
@param columnName the name of the column
@param searchable whether the column is searchable or not
@param orderable whether the column is orderable or not
@param searchValue if any, the search value to apply | [
"Add",
"a",
"new",
"column"
] | train | https://github.com/darrachequesne/spring-data-jpa-datatables/blob/0174dec8f52595a8e4b79f32c79922d64b02b732/src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java#L100-L104 |
stephanrauh/AngularFaces | AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/components/puiupdateModelAfterAJAXRequest/PuiUpdateModelAfterAJAXRequestRenderer.java | PuiUpdateModelAfterAJAXRequestRenderer.encodeBegin | @Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (FacesContext.getCurrentInstance().isPostback()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeText("\n", null);
writer.startElement("script", component);
writer.write("if (window.jsfScope) {\n");
List<String> beansAsJSon = PuiModelSync.getFacesModel();
for (String bean : beansAsJSon) {
writer.write("puiUpdateModel(" + bean + ");");
}
writer.writeText("\n}", null);
writer.endElement("script");
}
} | java | @Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (FacesContext.getCurrentInstance().isPostback()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeText("\n", null);
writer.startElement("script", component);
writer.write("if (window.jsfScope) {\n");
List<String> beansAsJSon = PuiModelSync.getFacesModel();
for (String bean : beansAsJSon) {
writer.write("puiUpdateModel(" + bean + ");");
}
writer.writeText("\n}", null);
writer.endElement("script");
}
} | [
"@",
"Override",
"public",
"void",
"encodeBegin",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"isPostback",
"(",
")",
")",
"{",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"writeText",
"(",
"\"\\n\"",
",",
"null",
")",
";",
"writer",
".",
"startElement",
"(",
"\"script\"",
",",
"component",
")",
";",
"writer",
".",
"write",
"(",
"\"if (window.jsfScope) {\\n\"",
")",
";",
"List",
"<",
"String",
">",
"beansAsJSon",
"=",
"PuiModelSync",
".",
"getFacesModel",
"(",
")",
";",
"for",
"(",
"String",
"bean",
":",
"beansAsJSon",
")",
"{",
"writer",
".",
"write",
"(",
"\"puiUpdateModel(\"",
"+",
"bean",
"+",
"\");\"",
")",
";",
"}",
"writer",
".",
"writeText",
"(",
"\"\\n}\"",
",",
"null",
")",
";",
"writer",
".",
"endElement",
"(",
"\"script\"",
")",
";",
"}",
"}"
] | private static final Logger LOGGER = Logger.getLogger("de.beyondjava.angularFaces.components.puiupdateModelAfterAJAXRequest.puiUpdateModelAfterAJAXRequestRenderer"); | [
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"Logger",
".",
"getLogger",
"(",
"de",
".",
"beyondjava",
".",
"angularFaces",
".",
"components",
".",
"puiupdateModelAfterAJAXRequest",
".",
"puiUpdateModelAfterAJAXRequestRenderer",
")",
";"
] | train | https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/components/puiupdateModelAfterAJAXRequest/PuiUpdateModelAfterAJAXRequestRenderer.java#L37-L51 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/DatabaseAutomaticTuningsInner.java | DatabaseAutomaticTuningsInner.updateAsync | public Observable<DatabaseAutomaticTuningInner> updateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseAutomaticTuningInner parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseAutomaticTuningInner>, DatabaseAutomaticTuningInner>() {
@Override
public DatabaseAutomaticTuningInner call(ServiceResponse<DatabaseAutomaticTuningInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseAutomaticTuningInner> updateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseAutomaticTuningInner parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseAutomaticTuningInner>, DatabaseAutomaticTuningInner>() {
@Override
public DatabaseAutomaticTuningInner call(ServiceResponse<DatabaseAutomaticTuningInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseAutomaticTuningInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"DatabaseAutomaticTuningInner",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DatabaseAutomaticTuningInner",
">",
",",
"DatabaseAutomaticTuningInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DatabaseAutomaticTuningInner",
"call",
"(",
"ServiceResponse",
"<",
"DatabaseAutomaticTuningInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update automatic tuning properties for target database.
@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.
@param databaseName The name of the database.
@param parameters The requested automatic tuning resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseAutomaticTuningInner object | [
"Update",
"automatic",
"tuning",
"properties",
"for",
"target",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/DatabaseAutomaticTuningsInner.java#L201-L208 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/BaseField.java | BaseField.setupTableLookup | public ScreenComponent setupTableLookup(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, Rec record, int iQueryKeySeq, Converter fldDisplayFieldDesc, boolean bIncludeBlankOption, boolean bIncludeFormButton)
{
String keyAreaName = null;
if (iQueryKeySeq != -1)
keyAreaName = this.getRecord().getKeyArea(iQueryKeySeq).getKeyName();
return this.setupTableLookup(itsLocation, targetScreen, converter, iDisplayFieldDesc, record, keyAreaName, fldDisplayFieldDesc, bIncludeBlankOption, bIncludeFormButton);
} | java | public ScreenComponent setupTableLookup(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, Rec record, int iQueryKeySeq, Converter fldDisplayFieldDesc, boolean bIncludeBlankOption, boolean bIncludeFormButton)
{
String keyAreaName = null;
if (iQueryKeySeq != -1)
keyAreaName = this.getRecord().getKeyArea(iQueryKeySeq).getKeyName();
return this.setupTableLookup(itsLocation, targetScreen, converter, iDisplayFieldDesc, record, keyAreaName, fldDisplayFieldDesc, bIncludeBlankOption, bIncludeFormButton);
} | [
"public",
"ScreenComponent",
"setupTableLookup",
"(",
"ScreenLoc",
"itsLocation",
",",
"ComponentParent",
"targetScreen",
",",
"Convert",
"converter",
",",
"int",
"iDisplayFieldDesc",
",",
"Rec",
"record",
",",
"int",
"iQueryKeySeq",
",",
"Converter",
"fldDisplayFieldDesc",
",",
"boolean",
"bIncludeBlankOption",
",",
"boolean",
"bIncludeFormButton",
")",
"{",
"String",
"keyAreaName",
"=",
"null",
";",
"if",
"(",
"iQueryKeySeq",
"!=",
"-",
"1",
")",
"keyAreaName",
"=",
"this",
".",
"getRecord",
"(",
")",
".",
"getKeyArea",
"(",
"iQueryKeySeq",
")",
".",
"getKeyName",
"(",
")",
";",
"return",
"this",
".",
"setupTableLookup",
"(",
"itsLocation",
",",
"targetScreen",
",",
"converter",
",",
"iDisplayFieldDesc",
",",
"record",
",",
"keyAreaName",
",",
"fldDisplayFieldDesc",
",",
"bIncludeBlankOption",
",",
"bIncludeFormButton",
")",
";",
"}"
] | Same as setupTablePopup for larger files (that don't fit in a popup).
Displays a [Key to record (opt)] [Record Description] [Lookup button] [Form button (opt)]
@param record Record to display in a popup
@param iQueryKeySeq Key to use for code-lookup operation (-1 = None)
@param iDisplayFieldSeq Description field for the display field (-1 = third field)
@param bIncludeFormButton Include a form button (in addition to the lookup button)?
@return Return the component or ScreenField that is created for this field. | [
"Same",
"as",
"setupTablePopup",
"for",
"larger",
"files",
"(",
"that",
"don",
"t",
"fit",
"in",
"a",
"popup",
")",
".",
"Displays",
"a",
"[",
"Key",
"to",
"record",
"(",
"opt",
")",
"]",
"[",
"Record",
"Description",
"]",
"[",
"Lookup",
"button",
"]",
"[",
"Form",
"button",
"(",
"opt",
")",
"]"
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BaseField.java#L1304-L1310 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java | BaseXmlParser.addProperties | protected void addProperties(Element element, BeanDefinitionBuilder builder) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node node = attributes.item(i);
String attrName = getNodeName(node);
attrName = "class".equals(attrName) ? "clazz" : attrName;
builder.addPropertyValue(attrName, node.getNodeValue());
}
} | java | protected void addProperties(Element element, BeanDefinitionBuilder builder) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node node = attributes.item(i);
String attrName = getNodeName(node);
attrName = "class".equals(attrName) ? "clazz" : attrName;
builder.addPropertyValue(attrName, node.getNodeValue());
}
} | [
"protected",
"void",
"addProperties",
"(",
"Element",
"element",
",",
"BeanDefinitionBuilder",
"builder",
")",
"{",
"NamedNodeMap",
"attributes",
"=",
"element",
".",
"getAttributes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attributes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"node",
"=",
"attributes",
".",
"item",
"(",
"i",
")",
";",
"String",
"attrName",
"=",
"getNodeName",
"(",
"node",
")",
";",
"attrName",
"=",
"\"class\"",
".",
"equals",
"(",
"attrName",
")",
"?",
"\"clazz\"",
":",
"attrName",
";",
"builder",
".",
"addPropertyValue",
"(",
"attrName",
",",
"node",
".",
"getNodeValue",
"(",
")",
")",
";",
"}",
"}"
] | Adds all attributes of the specified elements as properties in the current builder.
@param element Element whose attributes are to be added.
@param builder Target builder. | [
"Adds",
"all",
"attributes",
"of",
"the",
"specified",
"elements",
"as",
"properties",
"in",
"the",
"current",
"builder",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java#L93-L102 |
square/android-times-square | library/src/main/java/com/squareup/timessquare/CalendarPickerView.java | CalendarPickerView.getMonthCellWithIndexByDate | private MonthCellWithMonthIndex getMonthCellWithIndexByDate(Date date) {
Calendar searchCal = Calendar.getInstance(timeZone, locale);
searchCal.setTime(date);
String monthKey = monthKey(searchCal);
Calendar actCal = Calendar.getInstance(timeZone, locale);
int index = cells.getIndexOfKey(monthKey);
List<List<MonthCellDescriptor>> monthCells = cells.get(monthKey);
for (List<MonthCellDescriptor> weekCells : monthCells) {
for (MonthCellDescriptor actCell : weekCells) {
actCal.setTime(actCell.getDate());
if (sameDate(actCal, searchCal) && actCell.isSelectable()) {
return new MonthCellWithMonthIndex(actCell, index);
}
}
}
return null;
} | java | private MonthCellWithMonthIndex getMonthCellWithIndexByDate(Date date) {
Calendar searchCal = Calendar.getInstance(timeZone, locale);
searchCal.setTime(date);
String monthKey = monthKey(searchCal);
Calendar actCal = Calendar.getInstance(timeZone, locale);
int index = cells.getIndexOfKey(monthKey);
List<List<MonthCellDescriptor>> monthCells = cells.get(monthKey);
for (List<MonthCellDescriptor> weekCells : monthCells) {
for (MonthCellDescriptor actCell : weekCells) {
actCal.setTime(actCell.getDate());
if (sameDate(actCal, searchCal) && actCell.isSelectable()) {
return new MonthCellWithMonthIndex(actCell, index);
}
}
}
return null;
} | [
"private",
"MonthCellWithMonthIndex",
"getMonthCellWithIndexByDate",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"searchCal",
"=",
"Calendar",
".",
"getInstance",
"(",
"timeZone",
",",
"locale",
")",
";",
"searchCal",
".",
"setTime",
"(",
"date",
")",
";",
"String",
"monthKey",
"=",
"monthKey",
"(",
"searchCal",
")",
";",
"Calendar",
"actCal",
"=",
"Calendar",
".",
"getInstance",
"(",
"timeZone",
",",
"locale",
")",
";",
"int",
"index",
"=",
"cells",
".",
"getIndexOfKey",
"(",
"monthKey",
")",
";",
"List",
"<",
"List",
"<",
"MonthCellDescriptor",
">",
">",
"monthCells",
"=",
"cells",
".",
"get",
"(",
"monthKey",
")",
";",
"for",
"(",
"List",
"<",
"MonthCellDescriptor",
">",
"weekCells",
":",
"monthCells",
")",
"{",
"for",
"(",
"MonthCellDescriptor",
"actCell",
":",
"weekCells",
")",
"{",
"actCal",
".",
"setTime",
"(",
"actCell",
".",
"getDate",
"(",
")",
")",
";",
"if",
"(",
"sameDate",
"(",
"actCal",
",",
"searchCal",
")",
"&&",
"actCell",
".",
"isSelectable",
"(",
")",
")",
"{",
"return",
"new",
"MonthCellWithMonthIndex",
"(",
"actCell",
",",
"index",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Return cell and month-index (for scrolling) for a given Date. | [
"Return",
"cell",
"and",
"month",
"-",
"index",
"(",
"for",
"scrolling",
")",
"for",
"a",
"given",
"Date",
"."
] | train | https://github.com/square/android-times-square/blob/83b08e7cc220d587845054cd1471a604d17721f6/library/src/main/java/com/squareup/timessquare/CalendarPickerView.java#L861-L878 |
j256/ormlite-core | src/main/java/com/j256/ormlite/stmt/StatementExecutor.java | StatementExecutor.queryForId | public T queryForId(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
if (mappedQueryForId == null) {
mappedQueryForId = MappedQueryForFieldEq.build(dao, tableInfo, null);
}
return mappedQueryForId.execute(databaseConnection, id, objectCache);
} | java | public T queryForId(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
if (mappedQueryForId == null) {
mappedQueryForId = MappedQueryForFieldEq.build(dao, tableInfo, null);
}
return mappedQueryForId.execute(databaseConnection, id, objectCache);
} | [
"public",
"T",
"queryForId",
"(",
"DatabaseConnection",
"databaseConnection",
",",
"ID",
"id",
",",
"ObjectCache",
"objectCache",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"mappedQueryForId",
"==",
"null",
")",
"{",
"mappedQueryForId",
"=",
"MappedQueryForFieldEq",
".",
"build",
"(",
"dao",
",",
"tableInfo",
",",
"null",
")",
";",
"}",
"return",
"mappedQueryForId",
".",
"execute",
"(",
"databaseConnection",
",",
"id",
",",
"objectCache",
")",
";",
"}"
] | Return the object associated with the id or null if none. This does a SQL
{@code SELECT col1,col2,... FROM ... WHERE ... = id} type query. | [
"Return",
"the",
"object",
"associated",
"with",
"the",
"id",
"or",
"null",
"if",
"none",
".",
"This",
"does",
"a",
"SQL",
"{"
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/StatementExecutor.java#L90-L95 |
alkacon/opencms-core | src/org/opencms/ui/login/CmsTokenValidator.java | CmsTokenValidator.createToken | public static String createToken(CmsObject cms, CmsUser user, long currentTime) throws CmsException {
String randomKey = RandomStringUtils.randomAlphanumeric(8);
String value = CmsEncoder.encodeStringsAsBase64Parameter(Arrays.asList(randomKey, "" + currentTime));
user.setAdditionalInfo(ADDINFO_KEY, value);
cms.writeUser(user);
return CmsEncoder.encodeStringsAsBase64Parameter(Arrays.asList(user.getName(), randomKey));
} | java | public static String createToken(CmsObject cms, CmsUser user, long currentTime) throws CmsException {
String randomKey = RandomStringUtils.randomAlphanumeric(8);
String value = CmsEncoder.encodeStringsAsBase64Parameter(Arrays.asList(randomKey, "" + currentTime));
user.setAdditionalInfo(ADDINFO_KEY, value);
cms.writeUser(user);
return CmsEncoder.encodeStringsAsBase64Parameter(Arrays.asList(user.getName(), randomKey));
} | [
"public",
"static",
"String",
"createToken",
"(",
"CmsObject",
"cms",
",",
"CmsUser",
"user",
",",
"long",
"currentTime",
")",
"throws",
"CmsException",
"{",
"String",
"randomKey",
"=",
"RandomStringUtils",
".",
"randomAlphanumeric",
"(",
"8",
")",
";",
"String",
"value",
"=",
"CmsEncoder",
".",
"encodeStringsAsBase64Parameter",
"(",
"Arrays",
".",
"asList",
"(",
"randomKey",
",",
"\"\"",
"+",
"currentTime",
")",
")",
";",
"user",
".",
"setAdditionalInfo",
"(",
"ADDINFO_KEY",
",",
"value",
")",
";",
"cms",
".",
"writeUser",
"(",
"user",
")",
";",
"return",
"CmsEncoder",
".",
"encodeStringsAsBase64Parameter",
"(",
"Arrays",
".",
"asList",
"(",
"user",
".",
"getName",
"(",
")",
",",
"randomKey",
")",
")",
";",
"}"
] | Creates a new token for the given user and stores it in the user's additional info.<p>
@param cms the CMS context
@param user the user
@param currentTime the current time
@return the authorization token
@throws CmsException if something goes wrong | [
"Creates",
"a",
"new",
"token",
"for",
"the",
"given",
"user",
"and",
"stores",
"it",
"in",
"the",
"user",
"s",
"additional",
"info",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/login/CmsTokenValidator.java#L80-L87 |
SonarSource/sonarqube | server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java | ClassLoaderUtils.listResources | public static Collection<String> listResources(ClassLoader classLoader, String rootPath, Predicate<String> predicate) {
String jarPath = null;
JarFile jar = null;
try {
Collection<String> paths = new ArrayList<>();
URL root = classLoader.getResource(rootPath);
if (root != null) {
checkJarFile(root);
// Path of the root directory
// Examples :
// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
// org/sonar/sqale -> rootDirectory is org/sonar/sqale
String rootDirectory = rootPath;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
// strip out only the JAR file
jarPath = root.getPath().substring(5, root.getPath().indexOf('!'));
jar = new JarFile(URLDecoder.decode(jarPath, UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(rootDirectory) && predicate.test(name)) {
paths.add(name);
}
}
}
return paths;
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
closeJar(jar, jarPath);
}
} | java | public static Collection<String> listResources(ClassLoader classLoader, String rootPath, Predicate<String> predicate) {
String jarPath = null;
JarFile jar = null;
try {
Collection<String> paths = new ArrayList<>();
URL root = classLoader.getResource(rootPath);
if (root != null) {
checkJarFile(root);
// Path of the root directory
// Examples :
// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
// org/sonar/sqale -> rootDirectory is org/sonar/sqale
String rootDirectory = rootPath;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
// strip out only the JAR file
jarPath = root.getPath().substring(5, root.getPath().indexOf('!'));
jar = new JarFile(URLDecoder.decode(jarPath, UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(rootDirectory) && predicate.test(name)) {
paths.add(name);
}
}
}
return paths;
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
closeJar(jar, jarPath);
}
} | [
"public",
"static",
"Collection",
"<",
"String",
">",
"listResources",
"(",
"ClassLoader",
"classLoader",
",",
"String",
"rootPath",
",",
"Predicate",
"<",
"String",
">",
"predicate",
")",
"{",
"String",
"jarPath",
"=",
"null",
";",
"JarFile",
"jar",
"=",
"null",
";",
"try",
"{",
"Collection",
"<",
"String",
">",
"paths",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"URL",
"root",
"=",
"classLoader",
".",
"getResource",
"(",
"rootPath",
")",
";",
"if",
"(",
"root",
"!=",
"null",
")",
"{",
"checkJarFile",
"(",
"root",
")",
";",
"// Path of the root directory",
"// Examples :",
"// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale",
"// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale",
"// org/sonar/sqale -> rootDirectory is org/sonar/sqale",
"String",
"rootDirectory",
"=",
"rootPath",
";",
"if",
"(",
"StringUtils",
".",
"substringAfterLast",
"(",
"rootPath",
",",
"\"/\"",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"{",
"rootDirectory",
"=",
"StringUtils",
".",
"substringBeforeLast",
"(",
"rootPath",
",",
"\"/\"",
")",
";",
"}",
"// strip out only the JAR file",
"jarPath",
"=",
"root",
".",
"getPath",
"(",
")",
".",
"substring",
"(",
"5",
",",
"root",
".",
"getPath",
"(",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
";",
"jar",
"=",
"new",
"JarFile",
"(",
"URLDecoder",
".",
"decode",
"(",
"jarPath",
",",
"UTF_8",
".",
"name",
"(",
")",
")",
")",
";",
"Enumeration",
"<",
"JarEntry",
">",
"entries",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entries",
".",
"nextElement",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"rootDirectory",
")",
"&&",
"predicate",
".",
"test",
"(",
"name",
")",
")",
"{",
"paths",
".",
"add",
"(",
"name",
")",
";",
"}",
"}",
"}",
"return",
"paths",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeJar",
"(",
"jar",
",",
"jarPath",
")",
";",
"}",
"}"
] | Finds directories and files within a given directory and its subdirectories.
@param classLoader
@param rootPath the root directory, for example org/sonar/sqale, or a file in this root directory, for example org/sonar/sqale/index.txt
@param predicate
@return a list of relative paths, for example {"org/sonar/sqale", "org/sonar/sqale/foo", "org/sonar/sqale/foo/bar.txt}. Never null. | [
"Finds",
"directories",
"and",
"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#L62-L97 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.createPeer | @GuardedBy("lock")
protected Peer createPeer(PeerAddress address, VersionMessage ver) {
return new Peer(params, ver, address, chain, downloadTxDependencyDepth);
} | java | @GuardedBy("lock")
protected Peer createPeer(PeerAddress address, VersionMessage ver) {
return new Peer(params, ver, address, chain, downloadTxDependencyDepth);
} | [
"@",
"GuardedBy",
"(",
"\"lock\"",
")",
"protected",
"Peer",
"createPeer",
"(",
"PeerAddress",
"address",
",",
"VersionMessage",
"ver",
")",
"{",
"return",
"new",
"Peer",
"(",
"params",
",",
"ver",
",",
"address",
",",
"chain",
",",
"downloadTxDependencyDepth",
")",
";",
"}"
] | You can override this to customise the creation of {@link Peer} objects. | [
"You",
"can",
"override",
"this",
"to",
"customise",
"the",
"creation",
"of",
"{"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1381-L1384 |
aws/aws-sdk-java | aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/UpdateIntegrationResponseResult.java | UpdateIntegrationResponseResult.withResponseTemplates | public UpdateIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
setResponseTemplates(responseTemplates);
return this;
} | java | public UpdateIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
setResponseTemplates(responseTemplates);
return this;
} | [
"public",
"UpdateIntegrationResponseResult",
"withResponseTemplates",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseTemplates",
")",
"{",
"setResponseTemplates",
"(",
"responseTemplates",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Specifies the templates used to transform the integration response body. Response templates are represented as a
key/value map, with a content-type as the key and a template as the value.
</p>
@param responseTemplates
Specifies the templates used to transform the integration response body. Response templates are
represented as a key/value map, with a content-type as the key and a template as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Specifies",
"the",
"templates",
"used",
"to",
"transform",
"the",
"integration",
"response",
"body",
".",
"Response",
"templates",
"are",
"represented",
"as",
"a",
"key",
"/",
"value",
"map",
"with",
"a",
"content",
"-",
"type",
"as",
"the",
"key",
"and",
"a",
"template",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/UpdateIntegrationResponseResult.java#L351-L354 |
facebookarchive/hadoop-20 | src/contrib/data_join/src/java/org/apache/hadoop/contrib/utils/join/JobBase.java | JobBase.addLongValue | protected Long addLongValue(Object name, long inc) {
Long val = this.longCounters.get(name);
Long retv = null;
if (val == null) {
retv = new Long(inc);
} else {
retv = new Long(val.longValue() + inc);
}
this.longCounters.put(name, retv);
return retv;
} | java | protected Long addLongValue(Object name, long inc) {
Long val = this.longCounters.get(name);
Long retv = null;
if (val == null) {
retv = new Long(inc);
} else {
retv = new Long(val.longValue() + inc);
}
this.longCounters.put(name, retv);
return retv;
} | [
"protected",
"Long",
"addLongValue",
"(",
"Object",
"name",
",",
"long",
"inc",
")",
"{",
"Long",
"val",
"=",
"this",
".",
"longCounters",
".",
"get",
"(",
"name",
")",
";",
"Long",
"retv",
"=",
"null",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"retv",
"=",
"new",
"Long",
"(",
"inc",
")",
";",
"}",
"else",
"{",
"retv",
"=",
"new",
"Long",
"(",
"val",
".",
"longValue",
"(",
")",
"+",
"inc",
")",
";",
"}",
"this",
".",
"longCounters",
".",
"put",
"(",
"name",
",",
"retv",
")",
";",
"return",
"retv",
";",
"}"
] | Increment the given counter by the given incremental value If the counter
does not exist, one is created with value 0.
@param name
the counter name
@param inc
the incremental value
@return the updated value. | [
"Increment",
"the",
"given",
"counter",
"by",
"the",
"given",
"incremental",
"value",
"If",
"the",
"counter",
"does",
"not",
"exist",
"one",
"is",
"created",
"with",
"value",
"0",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/data_join/src/java/org/apache/hadoop/contrib/utils/join/JobBase.java#L99-L109 |
albfernandez/itext2 | src/main/java/com/lowagie/text/FontFactoryImp.java | FontFactoryImp.registerFamily | public void registerFamily(String familyName, String fullName, String path) {
if (path != null)
trueTypeFonts.setProperty(fullName, path);
ArrayList tmp = (ArrayList) fontFamilies.get(familyName);
if (tmp == null) {
tmp = new ArrayList();
tmp.add(fullName);
fontFamilies.put(familyName, tmp);
}
else {
int fullNameLength = fullName.length();
boolean inserted = false;
for (int j = 0; j < tmp.size(); ++j) {
if (((String)tmp.get(j)).length() >= fullNameLength) {
tmp.add(j, fullName);
inserted = true;
break;
}
}
if (!inserted)
tmp.add(fullName);
}
} | java | public void registerFamily(String familyName, String fullName, String path) {
if (path != null)
trueTypeFonts.setProperty(fullName, path);
ArrayList tmp = (ArrayList) fontFamilies.get(familyName);
if (tmp == null) {
tmp = new ArrayList();
tmp.add(fullName);
fontFamilies.put(familyName, tmp);
}
else {
int fullNameLength = fullName.length();
boolean inserted = false;
for (int j = 0; j < tmp.size(); ++j) {
if (((String)tmp.get(j)).length() >= fullNameLength) {
tmp.add(j, fullName);
inserted = true;
break;
}
}
if (!inserted)
tmp.add(fullName);
}
} | [
"public",
"void",
"registerFamily",
"(",
"String",
"familyName",
",",
"String",
"fullName",
",",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"!=",
"null",
")",
"trueTypeFonts",
".",
"setProperty",
"(",
"fullName",
",",
"path",
")",
";",
"ArrayList",
"tmp",
"=",
"(",
"ArrayList",
")",
"fontFamilies",
".",
"get",
"(",
"familyName",
")",
";",
"if",
"(",
"tmp",
"==",
"null",
")",
"{",
"tmp",
"=",
"new",
"ArrayList",
"(",
")",
";",
"tmp",
".",
"add",
"(",
"fullName",
")",
";",
"fontFamilies",
".",
"put",
"(",
"familyName",
",",
"tmp",
")",
";",
"}",
"else",
"{",
"int",
"fullNameLength",
"=",
"fullName",
".",
"length",
"(",
")",
";",
"boolean",
"inserted",
"=",
"false",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"tmp",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"if",
"(",
"(",
"(",
"String",
")",
"tmp",
".",
"get",
"(",
"j",
")",
")",
".",
"length",
"(",
")",
">=",
"fullNameLength",
")",
"{",
"tmp",
".",
"add",
"(",
"j",
",",
"fullName",
")",
";",
"inserted",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"inserted",
")",
"tmp",
".",
"add",
"(",
"fullName",
")",
";",
"}",
"}"
] | Register a font by giving explicitly the font family and name.
@param familyName the font family
@param fullName the font name
@param path the font path | [
"Register",
"a",
"font",
"by",
"giving",
"explicitly",
"the",
"font",
"family",
"and",
"name",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/FontFactoryImp.java#L486-L508 |
apereo/cas | core/cas-server-core-rest/src/main/java/org/apereo/cas/rest/factory/CasProtocolServiceTicketResourceEntityResponseFactory.java | CasProtocolServiceTicketResourceEntityResponseFactory.grantServiceTicket | protected String grantServiceTicket(final String ticketGrantingTicket, final Service service, final AuthenticationResult authenticationResult) {
val ticket = centralAuthenticationService.grantServiceTicket(ticketGrantingTicket, service, authenticationResult);
LOGGER.debug("Generated service ticket [{}]", ticket.getId());
return ticket.getId();
} | java | protected String grantServiceTicket(final String ticketGrantingTicket, final Service service, final AuthenticationResult authenticationResult) {
val ticket = centralAuthenticationService.grantServiceTicket(ticketGrantingTicket, service, authenticationResult);
LOGGER.debug("Generated service ticket [{}]", ticket.getId());
return ticket.getId();
} | [
"protected",
"String",
"grantServiceTicket",
"(",
"final",
"String",
"ticketGrantingTicket",
",",
"final",
"Service",
"service",
",",
"final",
"AuthenticationResult",
"authenticationResult",
")",
"{",
"val",
"ticket",
"=",
"centralAuthenticationService",
".",
"grantServiceTicket",
"(",
"ticketGrantingTicket",
",",
"service",
",",
"authenticationResult",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Generated service ticket [{}]\"",
",",
"ticket",
".",
"getId",
"(",
")",
")",
";",
"return",
"ticket",
".",
"getId",
"(",
")",
";",
"}"
] | Grant service ticket service ticket.
@param ticketGrantingTicket the ticket granting ticket
@param service the service
@param authenticationResult the authentication result
@return the service ticket | [
"Grant",
"service",
"ticket",
"service",
"ticket",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-rest/src/main/java/org/apereo/cas/rest/factory/CasProtocolServiceTicketResourceEntityResponseFactory.java#L42-L47 |
code4craft/webmagic | webmagic-core/src/main/java/us/codecraft/webmagic/Site.java | Site.addHeader | public Site addHeader(String key, String value) {
headers.put(key, value);
return this;
} | java | public Site addHeader(String key, String value) {
headers.put(key, value);
return this;
} | [
"public",
"Site",
"addHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"headers",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Put an Http header for downloader. <br>
Use {@link #addCookie(String, String)} for cookie and {@link #setUserAgent(String)} for user-agent. <br>
@param key key of http header, there are some keys constant in {@link HttpConstant.Header}
@param value value of header
@return this | [
"Put",
"an",
"Http",
"header",
"for",
"downloader",
".",
"<br",
">",
"Use",
"{",
"@link",
"#addCookie",
"(",
"String",
"String",
")",
"}",
"for",
"cookie",
"and",
"{",
"@link",
"#setUserAgent",
"(",
"String",
")",
"}",
"for",
"user",
"-",
"agent",
".",
"<br",
">"
] | train | https://github.com/code4craft/webmagic/blob/be892b80bf6682cd063d30ac25a79be0c079a901/webmagic-core/src/main/java/us/codecraft/webmagic/Site.java#L247-L250 |
elastic/elasticsearch-hadoop | mr/src/main/java/org/elasticsearch/hadoop/rest/RestService.java | RestService.initMultiIndices | private static RestRepository initMultiIndices(Settings settings, long currentInstance, Resource resource, Log log) {
if (log.isDebugEnabled()) {
log.debug(String.format("Resource [%s] resolves as an index pattern", resource));
}
// multi-index write - since we don't know before hand what index will be used, use an already selected node
String node = SettingsUtils.getPinnedNode(settings);
if (log.isDebugEnabled()) {
log.debug(String.format("Partition writer instance [%s] assigned to [%s]", currentInstance, node));
}
return new RestRepository(settings);
} | java | private static RestRepository initMultiIndices(Settings settings, long currentInstance, Resource resource, Log log) {
if (log.isDebugEnabled()) {
log.debug(String.format("Resource [%s] resolves as an index pattern", resource));
}
// multi-index write - since we don't know before hand what index will be used, use an already selected node
String node = SettingsUtils.getPinnedNode(settings);
if (log.isDebugEnabled()) {
log.debug(String.format("Partition writer instance [%s] assigned to [%s]", currentInstance, node));
}
return new RestRepository(settings);
} | [
"private",
"static",
"RestRepository",
"initMultiIndices",
"(",
"Settings",
"settings",
",",
"long",
"currentInstance",
",",
"Resource",
"resource",
",",
"Log",
"log",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"String",
".",
"format",
"(",
"\"Resource [%s] resolves as an index pattern\"",
",",
"resource",
")",
")",
";",
"}",
"// multi-index write - since we don't know before hand what index will be used, use an already selected node",
"String",
"node",
"=",
"SettingsUtils",
".",
"getPinnedNode",
"(",
"settings",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"String",
".",
"format",
"(",
"\"Partition writer instance [%s] assigned to [%s]\"",
",",
"currentInstance",
",",
"node",
")",
")",
";",
"}",
"return",
"new",
"RestRepository",
"(",
"settings",
")",
";",
"}"
] | Creates a RestRepository for use with a multi-index resource pattern. The client is left pinned
to the original node that it was pinned to since the shard locations cannot be determined at all.
@param settings Job settings
@param currentInstance Partition number
@param resource Configured write resource
@param log Logger to use
@return The RestRepository to be used by the partition writer | [
"Creates",
"a",
"RestRepository",
"for",
"use",
"with",
"a",
"multi",
"-",
"index",
"resource",
"pattern",
".",
"The",
"client",
"is",
"left",
"pinned",
"to",
"the",
"original",
"node",
"that",
"it",
"was",
"pinned",
"to",
"since",
"the",
"shard",
"locations",
"cannot",
"be",
"determined",
"at",
"all",
"."
] | train | https://github.com/elastic/elasticsearch-hadoop/blob/f3acaba268ff96efae8eb946088c748c777c22cc/mr/src/main/java/org/elasticsearch/hadoop/rest/RestService.java#L732-L744 |
lightblueseas/file-worker | src/main/java/de/alpharogroup/file/read/ReadFileExtensions.java | ReadFileExtensions.readFromFile | public static String readFromFile(final File file, final Charset encoding) throws IOException
{
return inputStream2String(StreamExtensions.getInputStream(file), encoding);
} | java | public static String readFromFile(final File file, final Charset encoding) throws IOException
{
return inputStream2String(StreamExtensions.getInputStream(file), encoding);
} | [
"public",
"static",
"String",
"readFromFile",
"(",
"final",
"File",
"file",
",",
"final",
"Charset",
"encoding",
")",
"throws",
"IOException",
"{",
"return",
"inputStream2String",
"(",
"StreamExtensions",
".",
"getInputStream",
"(",
"file",
")",
",",
"encoding",
")",
";",
"}"
] | Read from file.
@param file
the file
@param encoding
the encoding
@return the string
@throws IOException
Signals that an I/O exception has occurred. | [
"Read",
"from",
"file",
"."
] | train | https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/read/ReadFileExtensions.java#L184-L187 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/persist/LockFile.java | LockFile.closeRAF | private final void closeRAF() throws LockFile.UnexpectedFileIOException {
if (raf != null) {
try {
raf.close();
} catch (IOException ex) {
throw new UnexpectedFileIOException(this, "closeRAF", ex);
} finally {
raf = null;
}
}
} | java | private final void closeRAF() throws LockFile.UnexpectedFileIOException {
if (raf != null) {
try {
raf.close();
} catch (IOException ex) {
throw new UnexpectedFileIOException(this, "closeRAF", ex);
} finally {
raf = null;
}
}
} | [
"private",
"final",
"void",
"closeRAF",
"(",
")",
"throws",
"LockFile",
".",
"UnexpectedFileIOException",
"{",
"if",
"(",
"raf",
"!=",
"null",
")",
"{",
"try",
"{",
"raf",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"UnexpectedFileIOException",
"(",
"this",
",",
"\"closeRAF\"",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"raf",
"=",
"null",
";",
"}",
"}",
"}"
] | Closes this object's {@link #raf RandomAccessFile}. <p>
As a side-effect, the associated <tt>FileChannel</tt> object, if any,
is closed as well.
@throws UnexpectedFileIOException if an <tt>IOException</tt> is thrown | [
"Closes",
"this",
"object",
"s",
"{",
"@link",
"#raf",
"RandomAccessFile",
"}",
".",
"<p",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/persist/LockFile.java#L870-L881 |
openengsb/openengsb | components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java | XLinkUtils.setValueOfModel | public static void setValueOfModel(Object model, OpenEngSBModelEntry entry, Object value) throws
NoSuchFieldException,
IllegalArgumentException,
IllegalAccessException {
Class clazz = model.getClass();
Field field = clazz.getDeclaredField(entry.getKey());
field.setAccessible(true);
field.set(model, value);
} | java | public static void setValueOfModel(Object model, OpenEngSBModelEntry entry, Object value) throws
NoSuchFieldException,
IllegalArgumentException,
IllegalAccessException {
Class clazz = model.getClass();
Field field = clazz.getDeclaredField(entry.getKey());
field.setAccessible(true);
field.set(model, value);
} | [
"public",
"static",
"void",
"setValueOfModel",
"(",
"Object",
"model",
",",
"OpenEngSBModelEntry",
"entry",
",",
"Object",
"value",
")",
"throws",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"Class",
"clazz",
"=",
"model",
".",
"getClass",
"(",
")",
";",
"Field",
"field",
"=",
"clazz",
".",
"getDeclaredField",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"model",
",",
"value",
")",
";",
"}"
] | Sets the value, of the field defined in the OpenEngSBModelEntry, the the given model,
with reflection. | [
"Sets",
"the",
"value",
"of",
"the",
"field",
"defined",
"in",
"the",
"OpenEngSBModelEntry",
"the",
"the",
"given",
"model",
"with",
"reflection",
"."
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/services/src/main/java/org/openengsb/core/services/xlink/XLinkUtils.java#L120-L128 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/locale/InternalLocaleBuilder.java | InternalLocaleBuilder.removePrivateuseVariant | static String removePrivateuseVariant(String privuseVal) {
StringTokenIterator itr = new StringTokenIterator(privuseVal, LanguageTag.SEP);
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
int prefixStart = -1;
boolean sawPrivuseVar = false;
while (!itr.isDone()) {
if (prefixStart != -1) {
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
sawPrivuseVar = true;
break;
}
if (AsciiUtil.caseIgnoreMatch(itr.current(), LanguageTag.PRIVUSE_VARIANT_PREFIX)) {
prefixStart = itr.currentStart();
}
itr.next();
}
if (!sawPrivuseVar) {
return privuseVal;
}
assert(prefixStart == 0 || prefixStart > 1);
return (prefixStart == 0) ? null : privuseVal.substring(0, prefixStart -1);
} | java | static String removePrivateuseVariant(String privuseVal) {
StringTokenIterator itr = new StringTokenIterator(privuseVal, LanguageTag.SEP);
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
int prefixStart = -1;
boolean sawPrivuseVar = false;
while (!itr.isDone()) {
if (prefixStart != -1) {
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
sawPrivuseVar = true;
break;
}
if (AsciiUtil.caseIgnoreMatch(itr.current(), LanguageTag.PRIVUSE_VARIANT_PREFIX)) {
prefixStart = itr.currentStart();
}
itr.next();
}
if (!sawPrivuseVar) {
return privuseVal;
}
assert(prefixStart == 0 || prefixStart > 1);
return (prefixStart == 0) ? null : privuseVal.substring(0, prefixStart -1);
} | [
"static",
"String",
"removePrivateuseVariant",
"(",
"String",
"privuseVal",
")",
"{",
"StringTokenIterator",
"itr",
"=",
"new",
"StringTokenIterator",
"(",
"privuseVal",
",",
"LanguageTag",
".",
"SEP",
")",
";",
"// Note: privateuse value \"abc-lvariant\" is unchanged",
"// because no subtags after \"lvariant\".",
"int",
"prefixStart",
"=",
"-",
"1",
";",
"boolean",
"sawPrivuseVar",
"=",
"false",
";",
"while",
"(",
"!",
"itr",
".",
"isDone",
"(",
")",
")",
"{",
"if",
"(",
"prefixStart",
"!=",
"-",
"1",
")",
"{",
"// Note: privateuse value \"abc-lvariant\" is unchanged",
"// because no subtags after \"lvariant\".",
"sawPrivuseVar",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"AsciiUtil",
".",
"caseIgnoreMatch",
"(",
"itr",
".",
"current",
"(",
")",
",",
"LanguageTag",
".",
"PRIVUSE_VARIANT_PREFIX",
")",
")",
"{",
"prefixStart",
"=",
"itr",
".",
"currentStart",
"(",
")",
";",
"}",
"itr",
".",
"next",
"(",
")",
";",
"}",
"if",
"(",
"!",
"sawPrivuseVar",
")",
"{",
"return",
"privuseVal",
";",
"}",
"assert",
"(",
"prefixStart",
"==",
"0",
"||",
"prefixStart",
">",
"1",
")",
";",
"return",
"(",
"prefixStart",
"==",
"0",
")",
"?",
"null",
":",
"privuseVal",
".",
"substring",
"(",
"0",
",",
"prefixStart",
"-",
"1",
")",
";",
"}"
] | /*
Remove special private use subtag sequence identified by "lvariant"
and return the rest. Only used by LocaleExtensions | [
"/",
"*",
"Remove",
"special",
"private",
"use",
"subtag",
"sequence",
"identified",
"by",
"lvariant",
"and",
"return",
"the",
"rest",
".",
"Only",
"used",
"by",
"LocaleExtensions"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/locale/InternalLocaleBuilder.java#L513-L539 |
FudanNLP/fnlp | fnlp-core/src/main/java/org/fnlp/nlp/langmodel/lda/LdaGibbsSampler.java | LdaGibbsSampler.sampleFullConditional | private int sampleFullConditional(int m, int n) {
// remove z_i from the count variables
int topic = z[m][n];
word_topic_matrix[documents[m][n]][topic]--;
nd[m][topic]--;
nwsum[topic]--;
ndsum[m]--;
// do multinomial sampling via cumulative method:
float[] p = new float[K];
for (int k = 0; k < K; k++) {
p[k] = (word_topic_matrix[documents[m][n]][k] + beta) / (nwsum[k] + V * beta)
* (nd[m][k] + alpha) / (ndsum[m] + K * alpha);
}
topic = drawFromProbability(p);
// add newly estimated z_i to count variables
word_topic_matrix[documents[m][n]][topic]++;
nd[m][topic]++;
nwsum[topic]++;
ndsum[m]++;
return topic;
} | java | private int sampleFullConditional(int m, int n) {
// remove z_i from the count variables
int topic = z[m][n];
word_topic_matrix[documents[m][n]][topic]--;
nd[m][topic]--;
nwsum[topic]--;
ndsum[m]--;
// do multinomial sampling via cumulative method:
float[] p = new float[K];
for (int k = 0; k < K; k++) {
p[k] = (word_topic_matrix[documents[m][n]][k] + beta) / (nwsum[k] + V * beta)
* (nd[m][k] + alpha) / (ndsum[m] + K * alpha);
}
topic = drawFromProbability(p);
// add newly estimated z_i to count variables
word_topic_matrix[documents[m][n]][topic]++;
nd[m][topic]++;
nwsum[topic]++;
ndsum[m]++;
return topic;
} | [
"private",
"int",
"sampleFullConditional",
"(",
"int",
"m",
",",
"int",
"n",
")",
"{",
"// remove z_i from the count variables\r",
"int",
"topic",
"=",
"z",
"[",
"m",
"]",
"[",
"n",
"]",
";",
"word_topic_matrix",
"[",
"documents",
"[",
"m",
"]",
"[",
"n",
"]",
"]",
"[",
"topic",
"]",
"--",
";",
"nd",
"[",
"m",
"]",
"[",
"topic",
"]",
"--",
";",
"nwsum",
"[",
"topic",
"]",
"--",
";",
"ndsum",
"[",
"m",
"]",
"--",
";",
"// do multinomial sampling via cumulative method:\r",
"float",
"[",
"]",
"p",
"=",
"new",
"float",
"[",
"K",
"]",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"K",
";",
"k",
"++",
")",
"{",
"p",
"[",
"k",
"]",
"=",
"(",
"word_topic_matrix",
"[",
"documents",
"[",
"m",
"]",
"[",
"n",
"]",
"]",
"[",
"k",
"]",
"+",
"beta",
")",
"/",
"(",
"nwsum",
"[",
"k",
"]",
"+",
"V",
"*",
"beta",
")",
"*",
"(",
"nd",
"[",
"m",
"]",
"[",
"k",
"]",
"+",
"alpha",
")",
"/",
"(",
"ndsum",
"[",
"m",
"]",
"+",
"K",
"*",
"alpha",
")",
";",
"}",
"topic",
"=",
"drawFromProbability",
"(",
"p",
")",
";",
"// add newly estimated z_i to count variables\r",
"word_topic_matrix",
"[",
"documents",
"[",
"m",
"]",
"[",
"n",
"]",
"]",
"[",
"topic",
"]",
"++",
";",
"nd",
"[",
"m",
"]",
"[",
"topic",
"]",
"++",
";",
"nwsum",
"[",
"topic",
"]",
"++",
";",
"ndsum",
"[",
"m",
"]",
"++",
";",
"return",
"topic",
";",
"}"
] | Sample a topic z_i from the full conditional distribution: p(z_i = j |
z_-i, w) = (n_-i,j(w_i) + beta)/(n_-i,j(.) + W * beta) * (n_-i,j(d_i) +
alpha)/(n_-i,.(d_i) + K * alpha)
@param m
document
@param n
word | [
"Sample",
"a",
"topic",
"z_i",
"from",
"the",
"full",
"conditional",
"distribution",
":",
"p",
"(",
"z_i",
"=",
"j",
"|",
"z_",
"-",
"i",
"w",
")",
"=",
"(",
"n_",
"-",
"i",
"j",
"(",
"w_i",
")",
"+",
"beta",
")",
"/",
"(",
"n_",
"-",
"i",
"j",
"(",
".",
")",
"+",
"W",
"*",
"beta",
")",
"*",
"(",
"n_",
"-",
"i",
"j",
"(",
"d_i",
")",
"+",
"alpha",
")",
"/",
"(",
"n_",
"-",
"i",
".",
"(",
"d_i",
")",
"+",
"K",
"*",
"alpha",
")"
] | train | https://github.com/FudanNLP/fnlp/blob/ce258f3e4a5add2ba0b5e4cbac7cab2190af6659/fnlp-core/src/main/java/org/fnlp/nlp/langmodel/lda/LdaGibbsSampler.java#L255-L280 |
Netflix/eureka | eureka-client/src/main/java/com/netflix/discovery/shared/Applications.java | Applications.getNextIndex | public AtomicLong getNextIndex(String virtualHostname, boolean secure) {
Map<String, VipIndexSupport> index = (secure) ? secureVirtualHostNameAppMap : virtualHostNameAppMap;
return Optional.ofNullable(index.get(virtualHostname.toUpperCase(Locale.ROOT)))
.map(VipIndexSupport::getRoundRobinIndex)
.orElse(null);
} | java | public AtomicLong getNextIndex(String virtualHostname, boolean secure) {
Map<String, VipIndexSupport> index = (secure) ? secureVirtualHostNameAppMap : virtualHostNameAppMap;
return Optional.ofNullable(index.get(virtualHostname.toUpperCase(Locale.ROOT)))
.map(VipIndexSupport::getRoundRobinIndex)
.orElse(null);
} | [
"public",
"AtomicLong",
"getNextIndex",
"(",
"String",
"virtualHostname",
",",
"boolean",
"secure",
")",
"{",
"Map",
"<",
"String",
",",
"VipIndexSupport",
">",
"index",
"=",
"(",
"secure",
")",
"?",
"secureVirtualHostNameAppMap",
":",
"virtualHostNameAppMap",
";",
"return",
"Optional",
".",
"ofNullable",
"(",
"index",
".",
"get",
"(",
"virtualHostname",
".",
"toUpperCase",
"(",
"Locale",
".",
"ROOT",
")",
")",
")",
".",
"map",
"(",
"VipIndexSupport",
"::",
"getRoundRobinIndex",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}"
] | Gets the next round-robin index for the given virtual host name. This
index is reset after every registry fetch cycle.
@param virtualHostname
the virtual host name.
@param secure
indicates whether it is a secure request or a non-secure
request.
@return AtomicLong value representing the next round-robin index. | [
"Gets",
"the",
"next",
"round",
"-",
"robin",
"index",
"for",
"the",
"given",
"virtual",
"host",
"name",
".",
"This",
"index",
"is",
"reset",
"after",
"every",
"registry",
"fetch",
"cycle",
"."
] | train | https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-client/src/main/java/com/netflix/discovery/shared/Applications.java#L338-L343 |
attribyte/wpdb | src/main/java/org/attribyte/wp/model/User.java | User.withMetadata | public User withMetadata(final List<Meta> metadata) {
return new User(id, username, displayName, slug, email, createTimestamp, url, metadata);
} | java | public User withMetadata(final List<Meta> metadata) {
return new User(id, username, displayName, slug, email, createTimestamp, url, metadata);
} | [
"public",
"User",
"withMetadata",
"(",
"final",
"List",
"<",
"Meta",
">",
"metadata",
")",
"{",
"return",
"new",
"User",
"(",
"id",
",",
"username",
",",
"displayName",
",",
"slug",
",",
"email",
",",
"createTimestamp",
",",
"url",
",",
"metadata",
")",
";",
"}"
] | Creates a user with added metadata.
@param metadata The metadata.
@return The user with metadata added. | [
"Creates",
"a",
"user",
"with",
"added",
"metadata",
"."
] | train | https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/model/User.java#L147-L149 |
jenkinsci/artifactory-plugin | src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java | Maven3Builder.copyClassWorldsFile | private FilePath copyClassWorldsFile(FilePath ws, URL resource) {
try {
FilePath remoteClassworlds =
ws.createTextTempFile("classworlds", "conf", "");
remoteClassworlds.copyFrom(resource);
return remoteClassworlds;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | private FilePath copyClassWorldsFile(FilePath ws, URL resource) {
try {
FilePath remoteClassworlds =
ws.createTextTempFile("classworlds", "conf", "");
remoteClassworlds.copyFrom(resource);
return remoteClassworlds;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"private",
"FilePath",
"copyClassWorldsFile",
"(",
"FilePath",
"ws",
",",
"URL",
"resource",
")",
"{",
"try",
"{",
"FilePath",
"remoteClassworlds",
"=",
"ws",
".",
"createTextTempFile",
"(",
"\"classworlds\"",
",",
"\"conf\"",
",",
"\"\"",
")",
";",
"remoteClassworlds",
".",
"copyFrom",
"(",
"resource",
")",
";",
"return",
"remoteClassworlds",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Copies a classworlds file to a temporary location either on the local filesystem or on a slave depending on the
node type.
@return The path of the classworlds.conf file | [
"Copies",
"a",
"classworlds",
"file",
"to",
"a",
"temporary",
"location",
"either",
"on",
"the",
"local",
"filesystem",
"or",
"on",
"a",
"slave",
"depending",
"on",
"the",
"node",
"type",
"."
] | train | https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java#L284-L293 |
kirgor/enklib | common/src/main/java/com/kirgor/enklib/common/NamingUtils.java | NamingUtils.snakeToCamel | public static String snakeToCamel(String snake, boolean upper) {
StringBuilder sb = new StringBuilder();
boolean firstWord = true;
for (String word : snake.split("_")) {
if (!word.isEmpty()) {
if (firstWord && !upper) {
sb.append(word.toLowerCase());
} else {
sb.append(Character.toUpperCase(word.charAt(0))).append(word.substring(1).toLowerCase());
}
firstWord = false;
}
}
return sb.toString();
} | java | public static String snakeToCamel(String snake, boolean upper) {
StringBuilder sb = new StringBuilder();
boolean firstWord = true;
for (String word : snake.split("_")) {
if (!word.isEmpty()) {
if (firstWord && !upper) {
sb.append(word.toLowerCase());
} else {
sb.append(Character.toUpperCase(word.charAt(0))).append(word.substring(1).toLowerCase());
}
firstWord = false;
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"snakeToCamel",
"(",
"String",
"snake",
",",
"boolean",
"upper",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"firstWord",
"=",
"true",
";",
"for",
"(",
"String",
"word",
":",
"snake",
".",
"split",
"(",
"\"_\"",
")",
")",
"{",
"if",
"(",
"!",
"word",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"firstWord",
"&&",
"!",
"upper",
")",
"{",
"sb",
".",
"append",
"(",
"word",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"Character",
".",
"toUpperCase",
"(",
"word",
".",
"charAt",
"(",
"0",
")",
")",
")",
".",
"append",
"(",
"word",
".",
"substring",
"(",
"1",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"firstWord",
"=",
"false",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Converts snake case string (lower or upper) to camel case,
for example 'hello_world' or 'HELLO_WORLD' -> 'helloWorld' or 'HelloWorld'.
@param snake Input string.
@param upper True if result snake cased string should be upper cased like 'HelloWorld'. | [
"Converts",
"snake",
"case",
"string",
"(",
"lower",
"or",
"upper",
")",
"to",
"camel",
"case",
"for",
"example",
"hello_world",
"or",
"HELLO_WORLD",
"-",
">",
"helloWorld",
"or",
"HelloWorld",
"."
] | train | https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/common/src/main/java/com/kirgor/enklib/common/NamingUtils.java#L82-L96 |
keenon/loglinear | src/main/java/com/github/keenon/loglinear/model/NDArrayDoubles.java | NDArrayDoubles.setAssignmentValue | public void setAssignmentValue(int[] assignment, double value) {
assert !Double.isNaN(value);
values[getTableAccessOffset(assignment)] = value;
} | java | public void setAssignmentValue(int[] assignment, double value) {
assert !Double.isNaN(value);
values[getTableAccessOffset(assignment)] = value;
} | [
"public",
"void",
"setAssignmentValue",
"(",
"int",
"[",
"]",
"assignment",
",",
"double",
"value",
")",
"{",
"assert",
"!",
"Double",
".",
"isNaN",
"(",
"value",
")",
";",
"values",
"[",
"getTableAccessOffset",
"(",
"assignment",
")",
"]",
"=",
"value",
";",
"}"
] | Set a single value in the factor table.
@param assignment a list of variable settings, in the same order as the neighbors array of the factor
@param value the value to put into the factor table | [
"Set",
"a",
"single",
"value",
"in",
"the",
"factor",
"table",
"."
] | train | https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/NDArrayDoubles.java#L71-L74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.