repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 192 | func_name stringlengths 5 108 | whole_func_string stringlengths 75 3.91k | language stringclasses 1
value | func_code_string stringlengths 75 3.91k | func_code_tokens listlengths 21 629 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 647 | split_name stringclasses 1
value | func_code_url stringlengths 111 306 |
|---|---|---|---|---|---|---|---|---|---|---|
reactor/reactor-netty | src/main/java/reactor/netty/http/server/ConnectionInfo.java | ConnectionInfo.newConnectionInfo | static ConnectionInfo newConnectionInfo(Channel c) {
SocketChannel channel = (SocketChannel) c;
InetSocketAddress hostAddress = channel.localAddress();
InetSocketAddress remoteAddress = getRemoteAddress(channel);
String scheme = channel.pipeline().get(SslHandler.class) != null ? "https" : "http";
return new ConnectionInfo(hostAddress, remoteAddress, scheme);
} | java | static ConnectionInfo newConnectionInfo(Channel c) {
SocketChannel channel = (SocketChannel) c;
InetSocketAddress hostAddress = channel.localAddress();
InetSocketAddress remoteAddress = getRemoteAddress(channel);
String scheme = channel.pipeline().get(SslHandler.class) != null ? "https" : "http";
return new ConnectionInfo(hostAddress, remoteAddress, scheme);
} | [
"static",
"ConnectionInfo",
"newConnectionInfo",
"(",
"Channel",
"c",
")",
"{",
"SocketChannel",
"channel",
"=",
"(",
"SocketChannel",
")",
"c",
";",
"InetSocketAddress",
"hostAddress",
"=",
"channel",
".",
"localAddress",
"(",
")",
";",
"InetSocketAddress",
"remo... | Retrieve the connection information from the current connection directly
@param c the current channel
@return the connection information | [
"Retrieve",
"the",
"connection",
"information",
"from",
"the",
"current",
"connection",
"directly"
] | train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/http/server/ConnectionInfo.java#L77-L83 |
VoltDB/voltdb | third_party/java/src/com/google_voltpatches/common/collect/Iterables.java | Iterables.getLast | @Nullable
public static <T> T getLast(Iterable<? extends T> iterable, @Nullable T defaultValue) {
if (iterable instanceof Collection) {
Collection<? extends T> c = Collections2.cast(iterable);
if (c.isEmpty()) {
return defaultValue;
} else if (iterable instanceof List) {
return getLastInNonemptyList(Lists.cast(iterable));
}
}
return Iterators.getLast(iterable.iterator(), defaultValue);
} | java | @Nullable
public static <T> T getLast(Iterable<? extends T> iterable, @Nullable T defaultValue) {
if (iterable instanceof Collection) {
Collection<? extends T> c = Collections2.cast(iterable);
if (c.isEmpty()) {
return defaultValue;
} else if (iterable instanceof List) {
return getLastInNonemptyList(Lists.cast(iterable));
}
}
return Iterators.getLast(iterable.iterator(), defaultValue);
} | [
"@",
"Nullable",
"public",
"static",
"<",
"T",
">",
"T",
"getLast",
"(",
"Iterable",
"<",
"?",
"extends",
"T",
">",
"iterable",
",",
"@",
"Nullable",
"T",
"defaultValue",
")",
"{",
"if",
"(",
"iterable",
"instanceof",
"Collection",
")",
"{",
"Collection"... | Returns the last element of {@code iterable} or {@code defaultValue} if
the iterable is empty. If {@code iterable} is a {@link List} with
{@link RandomAccess} support, then this operation is guaranteed to be {@code O(1)}.
@param defaultValue the value to return if {@code iterable} is empty
@return the last element of {@code iterable} or the default value
@since 3.0 | [
"Returns",
"the",
"last",
"element",
"of",
"{",
"@code",
"iterable",
"}",
"or",
"{",
"@code",
"defaultValue",
"}",
"if",
"the",
"iterable",
"is",
"empty",
".",
"If",
"{",
"@code",
"iterable",
"}",
"is",
"a",
"{",
"@link",
"List",
"}",
"with",
"{",
"@... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/collect/Iterables.java#L785-L797 |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java | ThreeDHashMap.size | public int size(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 == null ) {
return 0;
}
// existence check on inner map1
final HashMap<K3, V> innerMap2 = innerMap1.get(secondKey);
if( innerMap2 == null ) {
return 0;
}
return innerMap2.size();
} | java | public int size(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 == null ) {
return 0;
}
// existence check on inner map1
final HashMap<K3, V> innerMap2 = innerMap1.get(secondKey);
if( innerMap2 == null ) {
return 0;
}
return innerMap2.size();
} | [
"public",
"int",
"size",
"(",
"final",
"K1",
"firstKey",
",",
"final",
"K2",
"secondKey",
")",
"{",
"// existence check on inner map",
"final",
"HashMap",
"<",
"K2",
",",
"HashMap",
"<",
"K3",
",",
"V",
">",
">",
"innerMap1",
"=",
"map",
".",
"get",
"(",... | Returns the number of key-value mappings in this map for the third key.
@param firstKey
the first key
@param secondKey
the second key
@return Returns the number of key-value mappings in this map for the third key. | [
"Returns",
"the",
"number",
"of",
"key",
"-",
"value",
"mappings",
"in",
"this",
"map",
"for",
"the",
"third",
"key",
"."
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java#L226-L239 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/ws/kernel/service/util/SecureAction.java | SecureAction.createThread | public Thread createThread(final Runnable target, final String name, final ClassLoader contextLoader) {
if (System.getSecurityManager() == null)
return createThread0(target, name, contextLoader);
return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
@Override
public Thread run() {
return createThread0(target, name, contextLoader);
}
}, controlContext);
} | java | public Thread createThread(final Runnable target, final String name, final ClassLoader contextLoader) {
if (System.getSecurityManager() == null)
return createThread0(target, name, contextLoader);
return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
@Override
public Thread run() {
return createThread0(target, name, contextLoader);
}
}, controlContext);
} | [
"public",
"Thread",
"createThread",
"(",
"final",
"Runnable",
"target",
",",
"final",
"String",
"name",
",",
"final",
"ClassLoader",
"contextLoader",
")",
"{",
"if",
"(",
"System",
".",
"getSecurityManager",
"(",
")",
"==",
"null",
")",
"return",
"createThread... | Creates a new Thread from a Runnable. Same as calling
new Thread(target,name).setContextClassLoader(contextLoader).
@param target the Runnable to create the Thread from.
@param name The name of the Thread.
@param contextLoader the context class loader for the thread
@return The new Thread | [
"Creates",
"a",
"new",
"Thread",
"from",
"a",
"Runnable",
".",
"Same",
"as",
"calling",
"new",
"Thread",
"(",
"target",
"name",
")",
".",
"setContextClassLoader",
"(",
"contextLoader",
")",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/ws/kernel/service/util/SecureAction.java#L427-L436 |
deeplearning4j/deeplearning4j | datavec/datavec-spark/src/main/java/org/datavec/spark/storage/SparkStorageUtils.java | SparkStorageUtils.saveMapFile | public static void saveMapFile(String path, JavaRDD<List<Writable>> rdd) {
saveMapFile(path, rdd, DEFAULT_MAP_FILE_INTERVAL, null);
} | java | public static void saveMapFile(String path, JavaRDD<List<Writable>> rdd) {
saveMapFile(path, rdd, DEFAULT_MAP_FILE_INTERVAL, null);
} | [
"public",
"static",
"void",
"saveMapFile",
"(",
"String",
"path",
",",
"JavaRDD",
"<",
"List",
"<",
"Writable",
">",
">",
"rdd",
")",
"{",
"saveMapFile",
"(",
"path",
",",
"rdd",
",",
"DEFAULT_MAP_FILE_INTERVAL",
",",
"null",
")",
";",
"}"
] | Save a {@code JavaRDD<List<Writable>>} to a Hadoop {@link org.apache.hadoop.io.MapFile}. Each record is
given a <i>unique and contiguous</i> {@link LongWritable} key, and values are stored as
{@link RecordWritable} instances.<br>
<b>Note 1</b>: If contiguous keys are not required, using a sequence file instead is preferable from a performance
point of view. Contiguous keys are often only required for non-Spark use cases, such as with
{@link org.datavec.hadoop.records.reader.mapfile.MapFileRecordReader}<br>
<b>Note 2</b>: This use a MapFile interval of {@link #DEFAULT_MAP_FILE_INTERVAL}, which is usually suitable for
use cases such as {@link org.datavec.hadoop.records.reader.mapfile.MapFileRecordReader}. Use
{@link #saveMapFile(String, JavaRDD, int, Integer)} or {@link #saveMapFile(String, JavaRDD, Configuration, Integer)}
to customize this. <br>
<p>
Use {@link #restoreMapFile(String, JavaSparkContext)} to restore values saved with this method.
@param path Path to save the MapFile
@param rdd RDD to save
@see #saveMapFileSequences(String, JavaRDD)
@see #saveSequenceFile(String, JavaRDD) | [
"Save",
"a",
"{",
"@code",
"JavaRDD<List<Writable",
">>",
"}",
"to",
"a",
"Hadoop",
"{",
"@link",
"org",
".",
"apache",
".",
"hadoop",
".",
"io",
".",
"MapFile",
"}",
".",
"Each",
"record",
"is",
"given",
"a",
"<i",
">",
"unique",
"and",
"contiguous<",... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/storage/SparkStorageUtils.java#L189-L191 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/watch/WatchUtil.java | WatchUtil.createModify | public static WatchMonitor createModify(File file, int maxDepth, Watcher watcher) {
return createModify(file.toPath(), 0, watcher);
} | java | public static WatchMonitor createModify(File file, int maxDepth, Watcher watcher) {
return createModify(file.toPath(), 0, watcher);
} | [
"public",
"static",
"WatchMonitor",
"createModify",
"(",
"File",
"file",
",",
"int",
"maxDepth",
",",
"Watcher",
"watcher",
")",
"{",
"return",
"createModify",
"(",
"file",
".",
"toPath",
"(",
")",
",",
"0",
",",
"watcher",
")",
";",
"}"
] | 创建并初始化监听,监听修改事件
@param file 被监听文件
@param maxDepth 当监听目录时,监听目录的最大深度,当设置值为1(或小于1)时,表示不递归监听子目录
@param watcher {@link Watcher}
@return {@link WatchMonitor}
@since 4.5.2 | [
"创建并初始化监听,监听修改事件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/watch/WatchUtil.java#L325-L327 |
rapidpro/expressions | java/src/main/java/io/rapidpro/expressions/functions/ExcelFunctions.java | ExcelFunctions._if | public static Object _if(EvaluationContext ctx, Object logicalTest, @IntegerDefault(0) Object valueIfTrue, @BooleanDefault(false) Object valueIfFalse) {
return Conversions.toBoolean(logicalTest, ctx) ? valueIfTrue : valueIfFalse;
} | java | public static Object _if(EvaluationContext ctx, Object logicalTest, @IntegerDefault(0) Object valueIfTrue, @BooleanDefault(false) Object valueIfFalse) {
return Conversions.toBoolean(logicalTest, ctx) ? valueIfTrue : valueIfFalse;
} | [
"public",
"static",
"Object",
"_if",
"(",
"EvaluationContext",
"ctx",
",",
"Object",
"logicalTest",
",",
"@",
"IntegerDefault",
"(",
"0",
")",
"Object",
"valueIfTrue",
",",
"@",
"BooleanDefault",
"(",
"false",
")",
"Object",
"valueIfFalse",
")",
"{",
"return",... | Returns one value if the condition evaluates to TRUE, and another value if it evaluates to FALSE | [
"Returns",
"one",
"value",
"if",
"the",
"condition",
"evaluates",
"to",
"TRUE",
"and",
"another",
"value",
"if",
"it",
"evaluates",
"to",
"FALSE"
] | train | https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/java/src/main/java/io/rapidpro/expressions/functions/ExcelFunctions.java#L527-L529 |
jmapper-framework/jmapper-core | JMapper Framework/src/main/java/com/googlecode/jmapper/JMapper.java | JMapper.getDestination | public D getDestination(final S source,final MappingType mtSource){
return getDestination(source,NullPointerControl.SOURCE,mtSource);
} | java | public D getDestination(final S source,final MappingType mtSource){
return getDestination(source,NullPointerControl.SOURCE,mtSource);
} | [
"public",
"D",
"getDestination",
"(",
"final",
"S",
"source",
",",
"final",
"MappingType",
"mtSource",
")",
"{",
"return",
"getDestination",
"(",
"source",
",",
"NullPointerControl",
".",
"SOURCE",
",",
"mtSource",
")",
";",
"}"
] | This method returns a new instance of Destination Class with this setting:
<table summary = "">
<tr>
<td><code>NullPointerControl</code></td><td><code>SOURCE</code></td>
</tr><tr>
<td><code>MappingType</code> of Destination</td><td><code>ALL_FIELDS</code></td>
</tr><tr>
<td><code>MappingType</code> of Source</td><td>mtSource</td>
</tr>
</table>
@param source instance that contains the data
@param mtSource type of mapping
@return new instance of destination
@see NullPointerControl
@see MappingType | [
"This",
"method",
"returns",
"a",
"new",
"instance",
"of",
"Destination",
"Class",
"with",
"this",
"setting",
":",
"<table",
"summary",
"=",
">",
"<tr",
">",
"<td",
">",
"<code",
">",
"NullPointerControl<",
"/",
"code",
">",
"<",
"/",
"td",
">",
"<td",
... | train | https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/JMapper.java#L201-L203 |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java | SVSConsumerAuditor.auditRetrieveValueSetEvent | public void auditRetrieveValueSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String valueSetUniqueId, String valueSetName,
String valueSetVersion,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.RetrieveValueSet(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(EventUtils.getAddressForUrl(repositoryEndpointUri, false), null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(getHumanRequestor())) {
importEvent.addHumanRequestorActiveParticipant(getHumanRequestor(), null, null, userRoles);
}
importEvent.addValueSetParticipantObject(valueSetUniqueId, valueSetName, valueSetVersion);
audit(importEvent);
} | java | public void auditRetrieveValueSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String valueSetUniqueId, String valueSetName,
String valueSetVersion,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.RetrieveValueSet(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(EventUtils.getAddressForUrl(repositoryEndpointUri, false), null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(getHumanRequestor())) {
importEvent.addHumanRequestorActiveParticipant(getHumanRequestor(), null, null, userRoles);
}
importEvent.addValueSetParticipantObject(valueSetUniqueId, valueSetName, valueSetVersion);
audit(importEvent);
} | [
"public",
"void",
"auditRetrieveValueSetEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryEndpointUri",
",",
"String",
"valueSetUniqueId",
",",
"String",
"valueSetName",
",",
"String",
"valueSetVersion",
",",
"List",
"<",
"CodedValueType",
... | Audits an ITI-48 Retrieve Value Set event for SVS Consumer actors.
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The Web service endpoint URI for the SVS repository
@param valueSetUniqueId unique id (OID) of the returned value set
@param valueSetName name associated with the unique id (OID) of the returned value set
@param valueSetVersion version of the returned value set
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Audits",
"an",
"ITI",
"-",
"48",
"Retrieve",
"Value",
"Set",
"event",
"for",
"SVS",
"Consumer",
"actors",
"."
] | train | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java#L59-L78 |
apache/incubator-gobblin | gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterUtils.java | GobblinClusterUtils.getJobStateFilePath | public static Path getJobStateFilePath(boolean usingStateStore, Path appWorkPath, String jobId) {
final Path jobStateFilePath;
// the state store uses a path of the form workdir/_jobstate/job_id/job_id.job.state while old method stores the file
// in the app work dir.
if (usingStateStore) {
jobStateFilePath = new Path(appWorkPath, GobblinClusterConfigurationKeys.JOB_STATE_DIR_NAME
+ Path.SEPARATOR + jobId + Path.SEPARATOR + jobId + "."
+ AbstractJobLauncher.JOB_STATE_FILE_NAME);
} else {
jobStateFilePath = new Path(appWorkPath, jobId + "." + AbstractJobLauncher.JOB_STATE_FILE_NAME);
}
log.info("job state file path: " + jobStateFilePath);
return jobStateFilePath;
} | java | public static Path getJobStateFilePath(boolean usingStateStore, Path appWorkPath, String jobId) {
final Path jobStateFilePath;
// the state store uses a path of the form workdir/_jobstate/job_id/job_id.job.state while old method stores the file
// in the app work dir.
if (usingStateStore) {
jobStateFilePath = new Path(appWorkPath, GobblinClusterConfigurationKeys.JOB_STATE_DIR_NAME
+ Path.SEPARATOR + jobId + Path.SEPARATOR + jobId + "."
+ AbstractJobLauncher.JOB_STATE_FILE_NAME);
} else {
jobStateFilePath = new Path(appWorkPath, jobId + "." + AbstractJobLauncher.JOB_STATE_FILE_NAME);
}
log.info("job state file path: " + jobStateFilePath);
return jobStateFilePath;
} | [
"public",
"static",
"Path",
"getJobStateFilePath",
"(",
"boolean",
"usingStateStore",
",",
"Path",
"appWorkPath",
",",
"String",
"jobId",
")",
"{",
"final",
"Path",
"jobStateFilePath",
";",
"// the state store uses a path of the form workdir/_jobstate/job_id/job_id.job.state wh... | Generate the path to the job.state file
@param usingStateStore is a state store being used to store the job.state content
@param appWorkPath work directory
@param jobId job id
@return a {@link Path} referring to the job.state | [
"Generate",
"the",
"path",
"to",
"the",
"job",
".",
"state",
"file"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterUtils.java#L90-L107 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolygon.java | MapPolygon.intersects | @Override
@Pure
public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
if (boundsIntersects(rectangle)) {
final Path2d p = toPath2D();
return p.intersects(rectangle);
}
return false;
} | java | @Override
@Pure
public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
if (boundsIntersects(rectangle)) {
final Path2d p = toPath2D();
return p.intersects(rectangle);
}
return false;
} | [
"@",
"Override",
"@",
"Pure",
"public",
"boolean",
"intersects",
"(",
"Shape2D",
"<",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
"extends",
"Rectangle2afp",
"<",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
">",
">",
"re... | Replies if this element has an intersection
with the specified rectangle.
@return <code>true</code> if this MapElement is intersecting the specified area,
otherwise <code>false</code> | [
"Replies",
"if",
"this",
"element",
"has",
"an",
"intersection",
"with",
"the",
"specified",
"rectangle",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolygon.java#L138-L146 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxGroup.java | BoxGroup.addMembership | public BoxGroupMembership.Info addMembership(BoxUser user, Role role) {
BoxAPIConnection api = this.getAPI();
JsonObject requestJSON = new JsonObject();
requestJSON.add("user", new JsonObject().add("id", user.getID()));
requestJSON.add("group", new JsonObject().add("id", this.getID()));
if (role != null) {
requestJSON.add("role", role.toJSONString());
}
URL url = ADD_MEMBERSHIP_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxGroupMembership membership = new BoxGroupMembership(api, responseJSON.get("id").asString());
return membership.new Info(responseJSON);
} | java | public BoxGroupMembership.Info addMembership(BoxUser user, Role role) {
BoxAPIConnection api = this.getAPI();
JsonObject requestJSON = new JsonObject();
requestJSON.add("user", new JsonObject().add("id", user.getID()));
requestJSON.add("group", new JsonObject().add("id", this.getID()));
if (role != null) {
requestJSON.add("role", role.toJSONString());
}
URL url = ADD_MEMBERSHIP_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxGroupMembership membership = new BoxGroupMembership(api, responseJSON.get("id").asString());
return membership.new Info(responseJSON);
} | [
"public",
"BoxGroupMembership",
".",
"Info",
"addMembership",
"(",
"BoxUser",
"user",
",",
"Role",
"role",
")",
"{",
"BoxAPIConnection",
"api",
"=",
"this",
".",
"getAPI",
"(",
")",
";",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
";",
... | Adds a member to this group with the specified role.
@param user the member to be added to this group.
@param role the role of the user in this group. Can be null to assign the default role.
@return info about the new group membership. | [
"Adds",
"a",
"member",
"to",
"this",
"group",
"with",
"the",
"specified",
"role",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxGroup.java#L254-L272 |
algermissen/hawkj | src/main/java/net/jalg/hawkj/HawkWwwAuthenticateContext.java | HawkWwwAuthenticateContext.generateHmac | private String generateHmac() throws HawkException {
String baseString = getBaseString();
Mac mac;
try {
mac = Mac.getInstance(getAlgorithm().getMacName());
} catch (NoSuchAlgorithmException e) {
throw new HawkException("Unknown algorithm "
+ getAlgorithm().getMacName(), e);
}
SecretKeySpec secret_key = new SecretKeySpec(getKey().getBytes(
Charsets.UTF_8), getAlgorithm().getMacName());
try {
mac.init(secret_key);
} catch (InvalidKeyException e) {
throw new HawkException("Key is invalid ", e);
}
return new String(Base64.encodeBase64(mac.doFinal(baseString
.getBytes(Charsets.UTF_8))), Charsets.UTF_8);
} | java | private String generateHmac() throws HawkException {
String baseString = getBaseString();
Mac mac;
try {
mac = Mac.getInstance(getAlgorithm().getMacName());
} catch (NoSuchAlgorithmException e) {
throw new HawkException("Unknown algorithm "
+ getAlgorithm().getMacName(), e);
}
SecretKeySpec secret_key = new SecretKeySpec(getKey().getBytes(
Charsets.UTF_8), getAlgorithm().getMacName());
try {
mac.init(secret_key);
} catch (InvalidKeyException e) {
throw new HawkException("Key is invalid ", e);
}
return new String(Base64.encodeBase64(mac.doFinal(baseString
.getBytes(Charsets.UTF_8))), Charsets.UTF_8);
} | [
"private",
"String",
"generateHmac",
"(",
")",
"throws",
"HawkException",
"{",
"String",
"baseString",
"=",
"getBaseString",
"(",
")",
";",
"Mac",
"mac",
";",
"try",
"{",
"mac",
"=",
"Mac",
".",
"getInstance",
"(",
"getAlgorithm",
"(",
")",
".",
"getMacNam... | Generate an HMAC from the context ts parameter.
@return
@throws HawkException | [
"Generate",
"an",
"HMAC",
"from",
"the",
"context",
"ts",
"parameter",
"."
] | train | https://github.com/algermissen/hawkj/blob/f798a20f058474bcfe761f7c5c02afee17326c71/src/main/java/net/jalg/hawkj/HawkWwwAuthenticateContext.java#L205-L227 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java | ReflectionUtil.invokeAccessibly | public static Object invokeAccessibly(Object instance, Method method, Object[] parameters) {
return SecurityActions.invokeAccessibly(instance, method, parameters);
} | java | public static Object invokeAccessibly(Object instance, Method method, Object[] parameters) {
return SecurityActions.invokeAccessibly(instance, method, parameters);
} | [
"public",
"static",
"Object",
"invokeAccessibly",
"(",
"Object",
"instance",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"parameters",
")",
"{",
"return",
"SecurityActions",
".",
"invokeAccessibly",
"(",
"instance",
",",
"method",
",",
"parameters",
")",
... | Invokes a method using reflection, in an accessible manner (by using {@link Method#setAccessible(boolean)}
@param instance instance on which to execute the method
@param method method to execute
@param parameters parameters | [
"Invokes",
"a",
"method",
"using",
"reflection",
"in",
"an",
"accessible",
"manner",
"(",
"by",
"using",
"{",
"@link",
"Method#setAccessible",
"(",
"boolean",
")",
"}"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L180-L182 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/stats/Counters.java | Counters.dotProduct | public static <E> double dotProduct(Counter<E> c, double[] a, Index<E> idx) {
double dotProd = 0;
for (Map.Entry<E, Double> entry : c.entrySet()) {
int keyIdx = idx.indexOf(entry.getKey());
if (keyIdx == -1) {
continue;
}
dotProd += entry.getValue() * a[keyIdx];
}
return dotProd;
} | java | public static <E> double dotProduct(Counter<E> c, double[] a, Index<E> idx) {
double dotProd = 0;
for (Map.Entry<E, Double> entry : c.entrySet()) {
int keyIdx = idx.indexOf(entry.getKey());
if (keyIdx == -1) {
continue;
}
dotProd += entry.getValue() * a[keyIdx];
}
return dotProd;
} | [
"public",
"static",
"<",
"E",
">",
"double",
"dotProduct",
"(",
"Counter",
"<",
"E",
">",
"c",
",",
"double",
"[",
"]",
"a",
",",
"Index",
"<",
"E",
">",
"idx",
")",
"{",
"double",
"dotProd",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",... | Returns the product of Counter c and double[] a, using Index idx to map
entries in C onto a.
@return The product of c and a. | [
"Returns",
"the",
"product",
"of",
"Counter",
"c",
"and",
"double",
"[]",
"a",
"using",
"Index",
"idx",
"to",
"map",
"entries",
"in",
"C",
"onto",
"a",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/stats/Counters.java#L1051-L1061 |
square/spoon | spoon-runner/src/main/java/com/squareup/spoon/html/HtmlUtils.java | HtmlUtils.getScreenshot | static Screenshot getScreenshot(File screenshot, File output) {
String relativePath = createRelativeUri(screenshot, output);
String caption = screenshot.getName();
return new Screenshot(relativePath, caption);
} | java | static Screenshot getScreenshot(File screenshot, File output) {
String relativePath = createRelativeUri(screenshot, output);
String caption = screenshot.getName();
return new Screenshot(relativePath, caption);
} | [
"static",
"Screenshot",
"getScreenshot",
"(",
"File",
"screenshot",
",",
"File",
"output",
")",
"{",
"String",
"relativePath",
"=",
"createRelativeUri",
"(",
"screenshot",
",",
"output",
")",
";",
"String",
"caption",
"=",
"screenshot",
".",
"getName",
"(",
")... | Get a HTML representation of a screenshot with respect to {@code output} directory. | [
"Get",
"a",
"HTML",
"representation",
"of",
"a",
"screenshot",
"with",
"respect",
"to",
"{"
] | train | https://github.com/square/spoon/blob/ebd51fbc1498f6bdcb61aa1281bbac2af99117b3/spoon-runner/src/main/java/com/squareup/spoon/html/HtmlUtils.java#L124-L128 |
icode/ameba | src/main/java/ameba/feature/AmebaFeature.java | AmebaFeature.subscribeSystemEvent | protected <E extends Event> Listener subscribeSystemEvent(Class<E> eventClass, final Class<? extends Listener<E>> listenerClass) {
Listener<E> listener = locator.createAndInitialize(listenerClass);
SystemEventBus.subscribe(eventClass, listener);
return listener;
} | java | protected <E extends Event> Listener subscribeSystemEvent(Class<E> eventClass, final Class<? extends Listener<E>> listenerClass) {
Listener<E> listener = locator.createAndInitialize(listenerClass);
SystemEventBus.subscribe(eventClass, listener);
return listener;
} | [
"protected",
"<",
"E",
"extends",
"Event",
">",
"Listener",
"subscribeSystemEvent",
"(",
"Class",
"<",
"E",
">",
"eventClass",
",",
"final",
"Class",
"<",
"?",
"extends",
"Listener",
"<",
"E",
">",
">",
"listenerClass",
")",
"{",
"Listener",
"<",
"E",
">... | <p>subscribeSystemEvent.</p>
@param eventClass a {@link java.lang.Class} object.
@param listenerClass a {@link java.lang.Class} object.
@return a {@link ameba.event.Listener} object.
@since 0.1.6e
@param <E> a E object. | [
"<p",
">",
"subscribeSystemEvent",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/feature/AmebaFeature.java#L156-L160 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java | CheckSumUtils.getMD5Checksum | public static String getMD5Checksum(InputStream is) throws IOException {
byte[] digest = null;
try {
MessageDigest md = MessageDigest.getInstance(JawrConstant.MD5_ALGORITHM);
InputStream digestIs = new DigestInputStream(is, md);
// read stream to EOF as normal...
while (digestIs.read() != -1) {
}
digest = md.digest();
} catch (NoSuchAlgorithmException e) {
throw new BundlingProcessException("MD5 algorithm needs to be installed", e);
}
return new BigInteger(1, digest).toString(16);
} | java | public static String getMD5Checksum(InputStream is) throws IOException {
byte[] digest = null;
try {
MessageDigest md = MessageDigest.getInstance(JawrConstant.MD5_ALGORITHM);
InputStream digestIs = new DigestInputStream(is, md);
// read stream to EOF as normal...
while (digestIs.read() != -1) {
}
digest = md.digest();
} catch (NoSuchAlgorithmException e) {
throw new BundlingProcessException("MD5 algorithm needs to be installed", e);
}
return new BigInteger(1, digest).toString(16);
} | [
"public",
"static",
"String",
"getMD5Checksum",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"digest",
"=",
"null",
";",
"try",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"JawrConstant",
".",
... | Returns the MD5 Checksum of the input stream
@param is
the input stream
@return the Checksum of the input stream
@throws IOException
if an IO exception occurs | [
"Returns",
"the",
"MD5",
"Checksum",
"of",
"the",
"input",
"stream"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/CheckSumUtils.java#L220-L236 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/common/lib/utils/CsvFiles.java | CsvFiles.getCsvDataMapArray | public static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent)
throws IOException {
final Map<String, String[]> result = Maps.newHashMap();
new CsvReader(fileName, headerPresent)
.processReader(
(header, line, lineNumber) ->
result.put(
line[0],
Arrays.asList(line)
.subList(1, line.length)
.toArray(new String[line.length - 1])));
return result;
} | java | public static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent)
throws IOException {
final Map<String, String[]> result = Maps.newHashMap();
new CsvReader(fileName, headerPresent)
.processReader(
(header, line, lineNumber) ->
result.put(
line[0],
Arrays.asList(line)
.subList(1, line.length)
.toArray(new String[line.length - 1])));
return result;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"getCsvDataMapArray",
"(",
"String",
"fileName",
",",
"boolean",
"headerPresent",
")",
"throws",
"IOException",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"resul... | Returns a {@code Map<String, String[]>} mapping of the first column to an
array of the rest of the columns.
@param fileName the CSV file to load
@param headerPresent {@code true} if the fist line is the header
@return a {@code Map<String, String[]>} mapping of the first column to an
array of the rest of the columns
@throws IllegalArgumentException if there is fewer than 2 columns in
the CSV
@throws IOException if there was an exception reading the file | [
"Returns",
"a",
"{",
"@code",
"Map<String",
"String",
"[]",
">",
"}",
"mapping",
"of",
"the",
"first",
"column",
"to",
"an",
"array",
"of",
"the",
"rest",
"of",
"the",
"columns",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/common/lib/utils/CsvFiles.java#L96-L108 |
gilberto-torrezan/viacep | src/main/java/com/github/gilbertotorrezan/viacep/gwt/ViaCEPGWTClient.java | ViaCEPGWTClient.getEnderecos | public void getEnderecos(String uf, String localidade, String logradouro, final MethodCallback<List<ViaCEPEndereco>> callback){
if (uf == null || uf.length() != 2){
callback.onFailure(null, new IllegalArgumentException("UF inválida - deve conter 2 caracteres: " + uf));
return;
}
if (localidade == null || localidade.length() < 3){
callback.onFailure(null, new IllegalArgumentException("Localidade inválida - deve conter pelo menos 3 caracteres: " + localidade));
return;
}
if (logradouro == null || logradouro.length() < 3){
callback.onFailure(null, new IllegalArgumentException("Logradouro inválido - deve conter pelo menos 3 caracteres: " + logradouro));
return;
}
ViaCEPGWTService service = getService();
service.getEnderecos(uf, localidade, logradouro, callback);
} | java | public void getEnderecos(String uf, String localidade, String logradouro, final MethodCallback<List<ViaCEPEndereco>> callback){
if (uf == null || uf.length() != 2){
callback.onFailure(null, new IllegalArgumentException("UF inválida - deve conter 2 caracteres: " + uf));
return;
}
if (localidade == null || localidade.length() < 3){
callback.onFailure(null, new IllegalArgumentException("Localidade inválida - deve conter pelo menos 3 caracteres: " + localidade));
return;
}
if (logradouro == null || logradouro.length() < 3){
callback.onFailure(null, new IllegalArgumentException("Logradouro inválido - deve conter pelo menos 3 caracteres: " + logradouro));
return;
}
ViaCEPGWTService service = getService();
service.getEnderecos(uf, localidade, logradouro, callback);
} | [
"public",
"void",
"getEnderecos",
"(",
"String",
"uf",
",",
"String",
"localidade",
",",
"String",
"logradouro",
",",
"final",
"MethodCallback",
"<",
"List",
"<",
"ViaCEPEndereco",
">",
">",
"callback",
")",
"{",
"if",
"(",
"uf",
"==",
"null",
"||",
"uf",
... | Executa a consulta de endereços a partir da UF, localidade e logradouro
@param uf Unidade Federativa. Precisa ter 2 caracteres.
@param localidade Localidade (p.e. município). Precisa ter ao menos 3 caracteres.
@param logradouro Logradouro (p.e. rua, avenida, estrada). Precisa ter ao menos 3 caracteres.
@param callback O retorno da chamada ao webservice. Erros de validação de campos e de conexão são tratados no callback. | [
"Executa",
"a",
"consulta",
"de",
"endereços",
"a",
"partir",
"da",
"UF",
"localidade",
"e",
"logradouro"
] | train | https://github.com/gilberto-torrezan/viacep/blob/96f203f72accb970e20a14792f0ea0b1b6553e3f/src/main/java/com/github/gilbertotorrezan/viacep/gwt/ViaCEPGWTClient.java#L116-L132 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/markdown/MarkdownParser.java | MarkdownParser.isNotSymbol | private boolean isNotSymbol(String text, int index, char c) {
if (index >= 0 && index < text.length()) {
return text.charAt(index) != c;
}
return true;
} | java | private boolean isNotSymbol(String text, int index, char c) {
if (index >= 0 && index < text.length()) {
return text.charAt(index) != c;
}
return true;
} | [
"private",
"boolean",
"isNotSymbol",
"(",
"String",
"text",
",",
"int",
"index",
",",
"char",
"c",
")",
"{",
"if",
"(",
"index",
">=",
"0",
"&&",
"index",
"<",
"text",
".",
"length",
"(",
")",
")",
"{",
"return",
"text",
".",
"charAt",
"(",
"index"... | Checking if symbol is not eq to c
@param text
@param index
@param c
@return | [
"Checking",
"if",
"symbol",
"is",
"not",
"eq",
"to",
"c"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/markdown/MarkdownParser.java#L396-L402 |
Stratio/stratio-cassandra | src/java/com/stratio/cassandra/index/query/Search.java | Search.fromJson | public static Search fromJson(String json) {
try {
return JsonSerializer.fromString(json, Search.class);
} catch (Exception e) {
String message = String.format("Unparseable JSON search: %s", e.getMessage());
Log.error(e, message);
throw new IllegalArgumentException(message, e);
}
} | java | public static Search fromJson(String json) {
try {
return JsonSerializer.fromString(json, Search.class);
} catch (Exception e) {
String message = String.format("Unparseable JSON search: %s", e.getMessage());
Log.error(e, message);
throw new IllegalArgumentException(message, e);
}
} | [
"public",
"static",
"Search",
"fromJson",
"(",
"String",
"json",
")",
"{",
"try",
"{",
"return",
"JsonSerializer",
".",
"fromString",
"(",
"json",
",",
"Search",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"message",
... | Returns a new {@link Search} from the specified JSON {@code String}.
@param json A JSON {@code String} representing a {@link Search}.
@return The {@link Search} represented by the specified JSON {@code String}. | [
"Returns",
"a",
"new",
"{",
"@link",
"Search",
"}",
"from",
"the",
"specified",
"JSON",
"{",
"@code",
"String",
"}",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/com/stratio/cassandra/index/query/Search.java#L73-L81 |
evernote/evernote-sdk-android | library/src/main/java/com/evernote/client/android/EvernoteUtil.java | EvernoteUtil.bytesToHex | public static String bytesToHex(byte[] bytes, boolean withSpaces) {
StringBuilder sb = new StringBuilder();
for (byte hashByte : bytes) {
int intVal = 0xff & hashByte;
if (intVal < 0x10) {
sb.append('0');
}
sb.append(Integer.toHexString(intVal));
if (withSpaces) {
sb.append(' ');
}
}
return sb.toString();
} | java | public static String bytesToHex(byte[] bytes, boolean withSpaces) {
StringBuilder sb = new StringBuilder();
for (byte hashByte : bytes) {
int intVal = 0xff & hashByte;
if (intVal < 0x10) {
sb.append('0');
}
sb.append(Integer.toHexString(intVal));
if (withSpaces) {
sb.append(' ');
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"bytesToHex",
"(",
"byte",
"[",
"]",
"bytes",
",",
"boolean",
"withSpaces",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"byte",
"hashByte",
":",
"bytes",
")",
"{",
"int",
"intVal"... | Takes the provided byte array and converts it into a hexadecimal string
with two characters per byte.
@param withSpaces if true, include a space character between each hex-rendered
byte for readability. | [
"Takes",
"the",
"provided",
"byte",
"array",
"and",
"converts",
"it",
"into",
"a",
"hexadecimal",
"string",
"with",
"two",
"characters",
"per",
"byte",
"."
] | train | https://github.com/evernote/evernote-sdk-android/blob/fc59be643e85c4f59d562d1bfe76563997aa73cf/library/src/main/java/com/evernote/client/android/EvernoteUtil.java#L170-L183 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/CertPath.java | CertPath.writeReplace | protected Object writeReplace() throws ObjectStreamException {
try {
return new CertPathRep(type, getEncoded());
} catch (CertificateException ce) {
NotSerializableException nse =
new NotSerializableException
("java.security.cert.CertPath: " + type);
nse.initCause(ce);
throw nse;
}
} | java | protected Object writeReplace() throws ObjectStreamException {
try {
return new CertPathRep(type, getEncoded());
} catch (CertificateException ce) {
NotSerializableException nse =
new NotSerializableException
("java.security.cert.CertPath: " + type);
nse.initCause(ce);
throw nse;
}
} | [
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"ObjectStreamException",
"{",
"try",
"{",
"return",
"new",
"CertPathRep",
"(",
"type",
",",
"getEncoded",
"(",
")",
")",
";",
"}",
"catch",
"(",
"CertificateException",
"ce",
")",
"{",
"NotSerializable... | Replaces the {@code CertPath} to be serialized with a
{@code CertPathRep} object.
@return the {@code CertPathRep} to be serialized
@throws ObjectStreamException if a {@code CertPathRep} object
representing this certification path could not be created | [
"Replaces",
"the",
"{",
"@code",
"CertPath",
"}",
"to",
"be",
"serialized",
"with",
"a",
"{",
"@code",
"CertPathRep",
"}",
"object",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/CertPath.java#L285-L295 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/utils/KerasLayerUtils.java | KerasLayerUtils.removeDefaultWeights | public static void removeDefaultWeights(Map<String, INDArray> weights, KerasLayerConfiguration conf) {
if (weights.size() > 2) {
Set<String> paramNames = weights.keySet();
paramNames.remove(conf.getKERAS_PARAM_NAME_W());
paramNames.remove(conf.getKERAS_PARAM_NAME_B());
String unknownParamNames = paramNames.toString();
log.warn("Attemping to set weights for unknown parameters: "
+ unknownParamNames.substring(1, unknownParamNames.length() - 1));
}
} | java | public static void removeDefaultWeights(Map<String, INDArray> weights, KerasLayerConfiguration conf) {
if (weights.size() > 2) {
Set<String> paramNames = weights.keySet();
paramNames.remove(conf.getKERAS_PARAM_NAME_W());
paramNames.remove(conf.getKERAS_PARAM_NAME_B());
String unknownParamNames = paramNames.toString();
log.warn("Attemping to set weights for unknown parameters: "
+ unknownParamNames.substring(1, unknownParamNames.length() - 1));
}
} | [
"public",
"static",
"void",
"removeDefaultWeights",
"(",
"Map",
"<",
"String",
",",
"INDArray",
">",
"weights",
",",
"KerasLayerConfiguration",
"conf",
")",
"{",
"if",
"(",
"weights",
".",
"size",
"(",
")",
">",
"2",
")",
"{",
"Set",
"<",
"String",
">",
... | Remove weights from config after weight setting.
@param weights layer weights
@param conf Keras layer configuration | [
"Remove",
"weights",
"from",
"config",
"after",
"weight",
"setting",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/utils/KerasLayerUtils.java#L610-L619 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java | CompressedSequentialWriter.seekToChunkStart | private void seekToChunkStart()
{
if (getOnDiskFilePointer() != chunkOffset)
{
try
{
out.seek(chunkOffset);
}
catch (IOException e)
{
throw new FSReadError(e, getPath());
}
}
} | java | private void seekToChunkStart()
{
if (getOnDiskFilePointer() != chunkOffset)
{
try
{
out.seek(chunkOffset);
}
catch (IOException e)
{
throw new FSReadError(e, getPath());
}
}
} | [
"private",
"void",
"seekToChunkStart",
"(",
")",
"{",
"if",
"(",
"getOnDiskFilePointer",
"(",
")",
"!=",
"chunkOffset",
")",
"{",
"try",
"{",
"out",
".",
"seek",
"(",
"chunkOffset",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"n... | Seek to the offset where next compressed data chunk should be stored. | [
"Seek",
"to",
"the",
"offset",
"where",
"next",
"compressed",
"data",
"chunk",
"should",
"be",
"stored",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java#L243-L256 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.updateClosedListEntityRoleAsync | public Observable<OperationStatus> updateClosedListEntityRoleAsync(UUID appId, String versionId, UUID entityId, UUID roleId, UpdateClosedListEntityRoleOptionalParameter updateClosedListEntityRoleOptionalParameter) {
return updateClosedListEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, updateClosedListEntityRoleOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> updateClosedListEntityRoleAsync(UUID appId, String versionId, UUID entityId, UUID roleId, UpdateClosedListEntityRoleOptionalParameter updateClosedListEntityRoleOptionalParameter) {
return updateClosedListEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, updateClosedListEntityRoleOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"updateClosedListEntityRoleAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"UUID",
"roleId",
",",
"UpdateClosedListEntityRoleOptionalParameter",
"updateClosedListEntityRoleOptionalPar... | Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity ID.
@param roleId The entity role ID.
@param updateClosedListEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Update",
"an",
"entity",
"role",
"for",
"a",
"given",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L11679-L11686 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java | MarshallUtil.marshallCollection | public static <E> void marshallCollection(Collection<E> collection, ObjectOutput out) throws IOException {
marshallCollection(collection, out, ObjectOutput::writeObject);
} | java | public static <E> void marshallCollection(Collection<E> collection, ObjectOutput out) throws IOException {
marshallCollection(collection, out, ObjectOutput::writeObject);
} | [
"public",
"static",
"<",
"E",
">",
"void",
"marshallCollection",
"(",
"Collection",
"<",
"E",
">",
"collection",
",",
"ObjectOutput",
"out",
")",
"throws",
"IOException",
"{",
"marshallCollection",
"(",
"collection",
",",
"out",
",",
"ObjectOutput",
"::",
"wri... | Marshall a {@link Collection}.
<p>
This method supports {@code null} {@code collection}.
@param collection {@link Collection} to marshal.
@param out {@link ObjectOutput} to write.
@param <E> Collection's element type.
@throws IOException If any of the usual Input/Output related exceptions occur. | [
"Marshall",
"a",
"{",
"@link",
"Collection",
"}",
".",
"<p",
">",
"This",
"method",
"supports",
"{",
"@code",
"null",
"}",
"{",
"@code",
"collection",
"}",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L229-L231 |
apereo/cas | core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java | AbstractCasWebflowConfigurer.createClonedActionState | public void createClonedActionState(final Flow flow, final String actionStateId, final String actionStateIdToClone) {
val generateServiceTicket = getState(flow, actionStateIdToClone, ActionState.class);
val consentTicketAction = createActionState(flow, actionStateId);
cloneActionState(generateServiceTicket, consentTicketAction);
} | java | public void createClonedActionState(final Flow flow, final String actionStateId, final String actionStateIdToClone) {
val generateServiceTicket = getState(flow, actionStateIdToClone, ActionState.class);
val consentTicketAction = createActionState(flow, actionStateId);
cloneActionState(generateServiceTicket, consentTicketAction);
} | [
"public",
"void",
"createClonedActionState",
"(",
"final",
"Flow",
"flow",
",",
"final",
"String",
"actionStateId",
",",
"final",
"String",
"actionStateIdToClone",
")",
"{",
"val",
"generateServiceTicket",
"=",
"getState",
"(",
"flow",
",",
"actionStateIdToClone",
"... | Clone and create action state.
@param flow the flow
@param actionStateId the action state id
@param actionStateIdToClone the action state id to clone | [
"Clone",
"and",
"create",
"action",
"state",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java#L711-L715 |
diffplug/durian | src/com/diffplug/common/base/StringPrinter.java | StringPrinter.toWriter | public Writer toWriter() {
return new Writer() {
@Override
public Writer append(char c) {
consumer.accept(new String(new char[]{c}));
return this;
}
@Override
public Writer append(CharSequence csq) {
if (csq instanceof String) {
consumer.accept((String) csq);
} else {
consumer.accept(toStringSafely(csq));
}
return this;
}
@Override
public Writer append(CharSequence csq, int start, int end) {
if (csq instanceof String) {
consumer.accept(((String) csq).substring(start, end));
} else {
consumer.accept(toStringSafely(csq.subSequence(start, end)));
}
return this;
}
private String toStringSafely(CharSequence csq) {
String asString = csq.toString();
if (asString.length() == csq.length()) {
return asString;
} else {
// It's pretty easy to implement CharSequence.toString() incorrectly
// http://stackoverflow.com/a/15870428/1153071
// but for String, we know we won't have them, thus the fast-path above
Errors.log().accept(new IllegalArgumentException(csq.getClass() + " did not implement toString() correctly."));
char[] chars = new char[csq.length()];
for (int i = 0; i < chars.length; ++i) {
chars[i] = csq.charAt(i);
}
return new String(chars);
}
}
@Override
public void close() throws IOException {}
@Override
public void flush() throws IOException {}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
consumer.accept(new String(cbuf, off, len));
}
@Override
public void write(String str) {
consumer.accept(str);
}
@Override
public void write(String str, int off, int len) {
consumer.accept(str.substring(off, off + len));
}
};
} | java | public Writer toWriter() {
return new Writer() {
@Override
public Writer append(char c) {
consumer.accept(new String(new char[]{c}));
return this;
}
@Override
public Writer append(CharSequence csq) {
if (csq instanceof String) {
consumer.accept((String) csq);
} else {
consumer.accept(toStringSafely(csq));
}
return this;
}
@Override
public Writer append(CharSequence csq, int start, int end) {
if (csq instanceof String) {
consumer.accept(((String) csq).substring(start, end));
} else {
consumer.accept(toStringSafely(csq.subSequence(start, end)));
}
return this;
}
private String toStringSafely(CharSequence csq) {
String asString = csq.toString();
if (asString.length() == csq.length()) {
return asString;
} else {
// It's pretty easy to implement CharSequence.toString() incorrectly
// http://stackoverflow.com/a/15870428/1153071
// but for String, we know we won't have them, thus the fast-path above
Errors.log().accept(new IllegalArgumentException(csq.getClass() + " did not implement toString() correctly."));
char[] chars = new char[csq.length()];
for (int i = 0; i < chars.length; ++i) {
chars[i] = csq.charAt(i);
}
return new String(chars);
}
}
@Override
public void close() throws IOException {}
@Override
public void flush() throws IOException {}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
consumer.accept(new String(cbuf, off, len));
}
@Override
public void write(String str) {
consumer.accept(str);
}
@Override
public void write(String str, int off, int len) {
consumer.accept(str.substring(off, off + len));
}
};
} | [
"public",
"Writer",
"toWriter",
"(",
")",
"{",
"return",
"new",
"Writer",
"(",
")",
"{",
"@",
"Override",
"public",
"Writer",
"append",
"(",
"char",
"c",
")",
"{",
"consumer",
".",
"accept",
"(",
"new",
"String",
"(",
"new",
"char",
"[",
"]",
"{",
... | Creates a Writer which passes its content to this StringPrinter. | [
"Creates",
"a",
"Writer",
"which",
"passes",
"its",
"content",
"to",
"this",
"StringPrinter",
"."
] | train | https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/StringPrinter.java#L161-L227 |
unic/neba | core/src/main/java/io/neba/core/resourcemodels/registration/ModelRegistry.java | ModelRegistry.resolveModelSources | private Collection<LookupResult> resolveModelSources(Resource resource, Class<?> compatibleType, boolean resolveMostSpecific) {
Collection<LookupResult> sources = new ArrayList<>(64);
for (final String resourceType : mappableTypeHierarchyOf(resource)) {
Collection<OsgiModelSource<?>> allSourcesForType = this.typeNameToModelSourcesMap.get(resourceType);
Collection<OsgiModelSource<?>> sourcesForCompatibleType = filter(allSourcesForType, compatibleType);
if (sourcesForCompatibleType != null && !sourcesForCompatibleType.isEmpty()) {
sources.addAll(sourcesForCompatibleType.stream().map(source -> new LookupResult(source, resourceType)).collect(Collectors.toList()));
if (resolveMostSpecific) {
break;
}
}
}
return unmodifiableCollection(sources);
} | java | private Collection<LookupResult> resolveModelSources(Resource resource, Class<?> compatibleType, boolean resolveMostSpecific) {
Collection<LookupResult> sources = new ArrayList<>(64);
for (final String resourceType : mappableTypeHierarchyOf(resource)) {
Collection<OsgiModelSource<?>> allSourcesForType = this.typeNameToModelSourcesMap.get(resourceType);
Collection<OsgiModelSource<?>> sourcesForCompatibleType = filter(allSourcesForType, compatibleType);
if (sourcesForCompatibleType != null && !sourcesForCompatibleType.isEmpty()) {
sources.addAll(sourcesForCompatibleType.stream().map(source -> new LookupResult(source, resourceType)).collect(Collectors.toList()));
if (resolveMostSpecific) {
break;
}
}
}
return unmodifiableCollection(sources);
} | [
"private",
"Collection",
"<",
"LookupResult",
">",
"resolveModelSources",
"(",
"Resource",
"resource",
",",
"Class",
"<",
"?",
">",
"compatibleType",
",",
"boolean",
"resolveMostSpecific",
")",
"{",
"Collection",
"<",
"LookupResult",
">",
"sources",
"=",
"new",
... | Finds all {@link OsgiModelSource model sources} representing models for the given
{@link Resource}.
@param resource must not be <code>null</code>.
@param compatibleType can be <code>null</code>. If provided, only models
compatible to the given type are returned.
@param resolveMostSpecific whether to resolve only the most specific models.
@return never <code>null</code> but rather an empty collection. | [
"Finds",
"all",
"{",
"@link",
"OsgiModelSource",
"model",
"sources",
"}",
"representing",
"models",
"for",
"the",
"given",
"{",
"@link",
"Resource",
"}",
"."
] | train | https://github.com/unic/neba/blob/4d762e60112a1fcb850926a56a9843d5aa424c4b/core/src/main/java/io/neba/core/resourcemodels/registration/ModelRegistry.java#L404-L417 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.appendUtf8Lines | public static <T> File appendUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
return appendLines(list, file, CharsetUtil.CHARSET_UTF_8);
} | java | public static <T> File appendUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
return appendLines(list, file, CharsetUtil.CHARSET_UTF_8);
} | [
"public",
"static",
"<",
"T",
">",
"File",
"appendUtf8Lines",
"(",
"Collection",
"<",
"T",
">",
"list",
",",
"File",
"file",
")",
"throws",
"IORuntimeException",
"{",
"return",
"appendLines",
"(",
"list",
",",
"file",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8"... | 将列表写入文件,追加模式
@param <T> 集合元素类型
@param list 列表
@param file 文件
@return 目标文件
@throws IORuntimeException IO异常
@since 3.1.2 | [
"将列表写入文件,追加模式"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2939-L2941 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/aspera/transfer/TransferListener.java | TransferListener.isNewSession | private boolean isNewSession(String xferId, String sessionId) {
List<String> currentSessions = transactionSessions.get(xferId);
if(currentSessions == null) {
List<String> sessions = new ArrayList<String>();
sessions.add(sessionId);
transactionSessions.put(xferId, sessions);
return true;
} else if (!currentSessions.contains(sessionId)) {
currentSessions.add(sessionId);
return true;
} else {
return false;
}
} | java | private boolean isNewSession(String xferId, String sessionId) {
List<String> currentSessions = transactionSessions.get(xferId);
if(currentSessions == null) {
List<String> sessions = new ArrayList<String>();
sessions.add(sessionId);
transactionSessions.put(xferId, sessions);
return true;
} else if (!currentSessions.contains(sessionId)) {
currentSessions.add(sessionId);
return true;
} else {
return false;
}
} | [
"private",
"boolean",
"isNewSession",
"(",
"String",
"xferId",
",",
"String",
"sessionId",
")",
"{",
"List",
"<",
"String",
">",
"currentSessions",
"=",
"transactionSessions",
".",
"get",
"(",
"xferId",
")",
";",
"if",
"(",
"currentSessions",
"==",
"null",
"... | Return true if new session for transaction
@param xferId
@param sessionId
@return boolean | [
"Return",
"true",
"if",
"new",
"session",
"for",
"transaction"
] | train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/aspera/transfer/TransferListener.java#L312-L327 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java | NetworkWatchersInner.getNextHopAsync | public Observable<NextHopResultInner> getNextHopAsync(String resourceGroupName, String networkWatcherName, NextHopParameters parameters) {
return getNextHopWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).map(new Func1<ServiceResponse<NextHopResultInner>, NextHopResultInner>() {
@Override
public NextHopResultInner call(ServiceResponse<NextHopResultInner> response) {
return response.body();
}
});
} | java | public Observable<NextHopResultInner> getNextHopAsync(String resourceGroupName, String networkWatcherName, NextHopParameters parameters) {
return getNextHopWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).map(new Func1<ServiceResponse<NextHopResultInner>, NextHopResultInner>() {
@Override
public NextHopResultInner call(ServiceResponse<NextHopResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NextHopResultInner",
">",
"getNextHopAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkWatcherName",
",",
"NextHopParameters",
"parameters",
")",
"{",
"return",
"getNextHopWithServiceResponseAsync",
"(",
"resourceGroupName",
",... | Gets the next hop from the specified VM.
@param resourceGroupName The name of the resource group.
@param networkWatcherName The name of the network watcher.
@param parameters Parameters that define the source and destination endpoint.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Gets",
"the",
"next",
"hop",
"from",
"the",
"specified",
"VM",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java#L1153-L1160 |
UrielCh/ovh-java-sdk | ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java | ApiOvhSms.serviceName_users_login_incoming_GET | public ArrayList<Long> serviceName_users_login_incoming_GET(String serviceName, String login, String sender, String tag) throws IOException {
String qPath = "/sms/{serviceName}/users/{login}/incoming";
StringBuilder sb = path(qPath, serviceName, login);
query(sb, "sender", sender);
query(sb, "tag", tag);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | java | public ArrayList<Long> serviceName_users_login_incoming_GET(String serviceName, String login, String sender, String tag) throws IOException {
String qPath = "/sms/{serviceName}/users/{login}/incoming";
StringBuilder sb = path(qPath, serviceName, login);
query(sb, "sender", sender);
query(sb, "tag", tag);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | [
"public",
"ArrayList",
"<",
"Long",
">",
"serviceName_users_login_incoming_GET",
"(",
"String",
"serviceName",
",",
"String",
"login",
",",
"String",
"sender",
",",
"String",
"tag",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/sms/{serviceName}/use... | Sms received associated to the sms user
REST: GET /sms/{serviceName}/users/{login}/incoming
@param tag [required] Filter the value of tag property (=)
@param sender [required] Filter the value of sender property (=)
@param serviceName [required] The internal name of your SMS offer
@param login [required] The sms user login | [
"Sms",
"received",
"associated",
"to",
"the",
"sms",
"user"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java#L1021-L1028 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CurrencyDisplayNames.java | CurrencyDisplayNames.getInstance | public static CurrencyDisplayNames getInstance(ULocale locale, boolean noSubstitute) {
return CurrencyData.provider.getInstance(locale, !noSubstitute);
} | java | public static CurrencyDisplayNames getInstance(ULocale locale, boolean noSubstitute) {
return CurrencyData.provider.getInstance(locale, !noSubstitute);
} | [
"public",
"static",
"CurrencyDisplayNames",
"getInstance",
"(",
"ULocale",
"locale",
",",
"boolean",
"noSubstitute",
")",
"{",
"return",
"CurrencyData",
".",
"provider",
".",
"getInstance",
"(",
"locale",
",",
"!",
"noSubstitute",
")",
";",
"}"
] | Return an instance of CurrencyDisplayNames that provides information
localized for display in the provided locale. If noSubstitute is false,
this behaves like {@link #getInstance(ULocale)}. Otherwise, 1) if there
is no supporting data for the locale at all, there is no fallback through
the default locale or root, and null is returned, and 2) if there is data
for the locale, but not data for the requested ISO code, null is returned
from those APIs instead of a substitute value.
@param locale the locale into which to localize the names
@param noSubstitute if true, do not return substitute values.
@return a CurrencyDisplayNames | [
"Return",
"an",
"instance",
"of",
"CurrencyDisplayNames",
"that",
"provides",
"information",
"localized",
"for",
"display",
"in",
"the",
"provided",
"locale",
".",
"If",
"noSubstitute",
"is",
"false",
"this",
"behaves",
"like",
"{",
"@link",
"#getInstance",
"(",
... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CurrencyDisplayNames.java#L69-L71 |
bazaarvoice/ostrich | core/src/main/java/com/bazaarvoice/ostrich/pool/ServicePoolBuilder.java | ServicePoolBuilder.withPartitionContextAnnotationsFrom | public ServicePoolBuilder<S> withPartitionContextAnnotationsFrom(Class<? extends S> annotatedServiceClass) {
checkNotNull(annotatedServiceClass);
_partitionContextSupplier = new AnnotationPartitionContextSupplier(_serviceType, annotatedServiceClass);
return this;
} | java | public ServicePoolBuilder<S> withPartitionContextAnnotationsFrom(Class<? extends S> annotatedServiceClass) {
checkNotNull(annotatedServiceClass);
_partitionContextSupplier = new AnnotationPartitionContextSupplier(_serviceType, annotatedServiceClass);
return this;
} | [
"public",
"ServicePoolBuilder",
"<",
"S",
">",
"withPartitionContextAnnotationsFrom",
"(",
"Class",
"<",
"?",
"extends",
"S",
">",
"annotatedServiceClass",
")",
"{",
"checkNotNull",
"(",
"annotatedServiceClass",
")",
";",
"_partitionContextSupplier",
"=",
"new",
"Anno... | Uses {@link PartitionKey} annotations from the specified class to generate partition context in the built proxy.
<p>
NOTE: This is only useful if building a proxy with {@link #buildProxy(com.bazaarvoice.ostrich.RetryPolicy)}. If
partition context is necessary with a normal service pool, then can be provided directly by calling
{@link com.bazaarvoice.ostrich.ServicePool#execute(com.bazaarvoice.ostrich.PartitionContext,
com.bazaarvoice.ostrich.RetryPolicy, com.bazaarvoice.ostrich.ServiceCallback)}.
@param annotatedServiceClass A service class with {@link PartitionKey} annotations.
@return this | [
"Uses",
"{",
"@link",
"PartitionKey",
"}",
"annotations",
"from",
"the",
"specified",
"class",
"to",
"generate",
"partition",
"context",
"in",
"the",
"built",
"proxy",
".",
"<p",
">",
"NOTE",
":",
"This",
"is",
"only",
"useful",
"if",
"building",
"a",
"pro... | train | https://github.com/bazaarvoice/ostrich/blob/13591867870ab23445253f11fc872662a8028191/core/src/main/java/com/bazaarvoice/ostrich/pool/ServicePoolBuilder.java#L211-L215 |
satoshi-kimura/samurai-dao | src/main/java/ognl/DefaultMemberAccess.java | DefaultMemberAccess.isAccessible | public boolean isAccessible(Map context, Object target, Member member, String propertyName)
{
int modifiers = member.getModifiers();
boolean result = Modifier.isPublic(modifiers);
if (!result) {
if (Modifier.isPrivate(modifiers)) {
result = getAllowPrivateAccess();
} else {
if (Modifier.isProtected(modifiers)) {
result = getAllowProtectedAccess();
} else {
result = getAllowPackageProtectedAccess();
}
}
}
return result;
} | java | public boolean isAccessible(Map context, Object target, Member member, String propertyName)
{
int modifiers = member.getModifiers();
boolean result = Modifier.isPublic(modifiers);
if (!result) {
if (Modifier.isPrivate(modifiers)) {
result = getAllowPrivateAccess();
} else {
if (Modifier.isProtected(modifiers)) {
result = getAllowProtectedAccess();
} else {
result = getAllowPackageProtectedAccess();
}
}
}
return result;
} | [
"public",
"boolean",
"isAccessible",
"(",
"Map",
"context",
",",
"Object",
"target",
",",
"Member",
"member",
",",
"String",
"propertyName",
")",
"{",
"int",
"modifiers",
"=",
"member",
".",
"getModifiers",
"(",
")",
";",
"boolean",
"result",
"=",
"Modifier"... | Returns true if the given member is accessible or can be made accessible
by this object. | [
"Returns",
"true",
"if",
"the",
"given",
"member",
"is",
"accessible",
"or",
"can",
"be",
"made",
"accessible",
"by",
"this",
"object",
"."
] | train | https://github.com/satoshi-kimura/samurai-dao/blob/321729d8928f8e83eede6cb08e4bd7f7a24e9b94/src/main/java/ognl/DefaultMemberAccess.java#L133-L150 |
HubSpot/Singularity | SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java | SingularityClient.getCoolDownSingularityRequests | public Collection<SingularityRequestParent> getCoolDownSingularityRequests() {
final Function<String, String> requestUri = (host) -> String.format(REQUESTS_GET_COOLDOWN_FORMAT, getApiBase(host));
return getCollection(requestUri, "COOLDOWN requests", REQUESTS_COLLECTION);
} | java | public Collection<SingularityRequestParent> getCoolDownSingularityRequests() {
final Function<String, String> requestUri = (host) -> String.format(REQUESTS_GET_COOLDOWN_FORMAT, getApiBase(host));
return getCollection(requestUri, "COOLDOWN requests", REQUESTS_COLLECTION);
} | [
"public",
"Collection",
"<",
"SingularityRequestParent",
">",
"getCoolDownSingularityRequests",
"(",
")",
"{",
"final",
"Function",
"<",
"String",
",",
"String",
">",
"requestUri",
"=",
"(",
"host",
")",
"-",
">",
"String",
".",
"format",
"(",
"REQUESTS_GET_COOL... | Get all requests that has been set to a COOLDOWN state by singularity
@return
All {@link SingularityRequestParent} instances that their state is COOLDOWN | [
"Get",
"all",
"requests",
"that",
"has",
"been",
"set",
"to",
"a",
"COOLDOWN",
"state",
"by",
"singularity"
] | train | https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java#L790-L794 |
josueeduardo/snappy | plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/JarWriter.java | JarWriter.writeEntry | private void writeEntry(JarEntry entry, EntryWriter entryWriter) throws IOException {
String parent = entry.getName();
if (parent.endsWith("/")) {
parent = parent.substring(0, parent.length() - 1);
}
if (parent.lastIndexOf("/") != -1) {
parent = parent.substring(0, parent.lastIndexOf("/") + 1);
if (parent.length() > 0) {
writeEntry(new JarEntry(parent), null);
}
}
if (this.writtenEntries.add(entry.getName())) {
this.jarOutput.putNextEntry(entry);
if (entryWriter != null) {
entryWriter.write(this.jarOutput);
}
this.jarOutput.closeEntry();
}
} | java | private void writeEntry(JarEntry entry, EntryWriter entryWriter) throws IOException {
String parent = entry.getName();
if (parent.endsWith("/")) {
parent = parent.substring(0, parent.length() - 1);
}
if (parent.lastIndexOf("/") != -1) {
parent = parent.substring(0, parent.lastIndexOf("/") + 1);
if (parent.length() > 0) {
writeEntry(new JarEntry(parent), null);
}
}
if (this.writtenEntries.add(entry.getName())) {
this.jarOutput.putNextEntry(entry);
if (entryWriter != null) {
entryWriter.write(this.jarOutput);
}
this.jarOutput.closeEntry();
}
} | [
"private",
"void",
"writeEntry",
"(",
"JarEntry",
"entry",
",",
"EntryWriter",
"entryWriter",
")",
"throws",
"IOException",
"{",
"String",
"parent",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"if",
"(",
"parent",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
... | Perform the actual write of a {@link JarEntry}. All other {@code write} method
delegate to this one.
@param entry the entry to write
@param entryWriter the entry writer or {@code null} if there is no content
@throws IOException in case of I/O errors | [
"Perform",
"the",
"actual",
"write",
"of",
"a",
"{",
"@link",
"JarEntry",
"}",
".",
"All",
"other",
"{",
"@code",
"write",
"}",
"method",
"delegate",
"to",
"this",
"one",
"."
] | train | https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/JarWriter.java#L232-L251 |
danieldk/dictomaton | src/main/java/eu/danieldk/dictomaton/State.java | State.addTransition | public void addTransition(Character c, State s) {
transitions.put(c, s);
d_recomputeHash = true;
} | java | public void addTransition(Character c, State s) {
transitions.put(c, s);
d_recomputeHash = true;
} | [
"public",
"void",
"addTransition",
"(",
"Character",
"c",
",",
"State",
"s",
")",
"{",
"transitions",
".",
"put",
"(",
"c",
",",
"s",
")",
";",
"d_recomputeHash",
"=",
"true",
";",
"}"
] | Add a transition to the state. If a transition with the provided character already
exists, it will be replaced.
@param c The transition character.
@param s The to-state. | [
"Add",
"a",
"transition",
"to",
"the",
"state",
".",
"If",
"a",
"transition",
"with",
"the",
"provided",
"character",
"already",
"exists",
"it",
"will",
"be",
"replaced",
"."
] | train | https://github.com/danieldk/dictomaton/blob/c0a3ae2d407ebd88023ea2d0f02a4882b0492df0/src/main/java/eu/danieldk/dictomaton/State.java#L45-L48 |
cesarferreira/AndroidQuickUtils | library/src/main/java/quickutils/core/adapters/BindableAdapter.java | BindableAdapter.bindDropDownView | public void bindDropDownView(T item, int position, View view) {
bindView(item, position, view);
} | java | public void bindDropDownView(T item, int position, View view) {
bindView(item, position, view);
} | [
"public",
"void",
"bindDropDownView",
"(",
"T",
"item",
",",
"int",
"position",
",",
"View",
"view",
")",
"{",
"bindView",
"(",
"item",
",",
"position",
",",
"view",
")",
";",
"}"
] | Bind the data for the specified {@code position} to the drop-down view. | [
"Bind",
"the",
"data",
"for",
"the",
"specified",
"{"
] | train | https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/adapters/BindableAdapter.java#L64-L66 |
apache/incubator-atlas | webapp/src/main/java/org/apache/atlas/web/service/AtlasZookeeperSecurityProperties.java | AtlasZookeeperSecurityProperties.parseAcl | public static ACL parseAcl(String aclString) {
String[] aclComponents = getComponents(aclString, "acl", "scheme:id");
return new ACL(ZooDefs.Perms.ALL, new Id(aclComponents[0], aclComponents[1]));
} | java | public static ACL parseAcl(String aclString) {
String[] aclComponents = getComponents(aclString, "acl", "scheme:id");
return new ACL(ZooDefs.Perms.ALL, new Id(aclComponents[0], aclComponents[1]));
} | [
"public",
"static",
"ACL",
"parseAcl",
"(",
"String",
"aclString",
")",
"{",
"String",
"[",
"]",
"aclComponents",
"=",
"getComponents",
"(",
"aclString",
",",
"\"acl\"",
",",
"\"scheme:id\"",
")",
";",
"return",
"new",
"ACL",
"(",
"ZooDefs",
".",
"Perms",
... | Get an {@link ACL} by parsing input string.
@param aclString A string of the form scheme:id
@return {@link ACL} with the perms set to {@link org.apache.zookeeper.ZooDefs.Perms#ALL} and scheme and id
taken from configuration values. | [
"Get",
"an",
"{"
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/webapp/src/main/java/org/apache/atlas/web/service/AtlasZookeeperSecurityProperties.java#L47-L50 |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/recognizer/JDBCDriverURLRecognizerEngine.java | JDBCDriverURLRecognizerEngine.getDriverClassName | public static String getDriverClassName(final String url) {
for (Entry<String, String> entry : URL_PREFIX_AND_DRIVER_CLASS_NAME_MAPPER.entrySet()) {
if (url.startsWith(entry.getKey())) {
return entry.getValue();
}
}
throw new ShardingException("Cannot resolve JDBC url `%s`. Please implements `%s` and add to SPI.", url, JDBCDriverURLRecognizer.class.getName());
} | java | public static String getDriverClassName(final String url) {
for (Entry<String, String> entry : URL_PREFIX_AND_DRIVER_CLASS_NAME_MAPPER.entrySet()) {
if (url.startsWith(entry.getKey())) {
return entry.getValue();
}
}
throw new ShardingException("Cannot resolve JDBC url `%s`. Please implements `%s` and add to SPI.", url, JDBCDriverURLRecognizer.class.getName());
} | [
"public",
"static",
"String",
"getDriverClassName",
"(",
"final",
"String",
"url",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"URL_PREFIX_AND_DRIVER_CLASS_NAME_MAPPER",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"url... | Get JDBC driver class name.
@param url JDBC URL
@return driver class name | [
"Get",
"JDBC",
"driver",
"class",
"name",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/recognizer/JDBCDriverURLRecognizerEngine.java#L59-L66 |
ksclarke/vertx-pairtree | src/main/java/info/freelibrary/pairtree/PairtreeUtils.java | PairtreeUtils.mapToID | public static String mapToID(final String aBasePath, final String aPtPath) throws InvalidPathException {
return mapToID(removeBasePath(aBasePath, aPtPath));
} | java | public static String mapToID(final String aBasePath, final String aPtPath) throws InvalidPathException {
return mapToID(removeBasePath(aBasePath, aPtPath));
} | [
"public",
"static",
"String",
"mapToID",
"(",
"final",
"String",
"aBasePath",
",",
"final",
"String",
"aPtPath",
")",
"throws",
"InvalidPathException",
"{",
"return",
"mapToID",
"(",
"removeBasePath",
"(",
"aBasePath",
",",
"aPtPath",
")",
")",
";",
"}"
] | Maps the supplied base path to an ID using the supplied Pairtree path.
@param aBasePath A base path to use for the mapping
@param aPtPath A Pairtree path to map to an ID
@return The ID that is a result of the mapping
@throws InvalidPathException If there is trouble mapping the path | [
"Maps",
"the",
"supplied",
"base",
"path",
"to",
"an",
"ID",
"using",
"the",
"supplied",
"Pairtree",
"path",
"."
] | train | https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeUtils.java#L198-L200 |
leadware/jpersistence-tools | jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java | JPAGenericDAORulesBasedImpl.addProperties | protected void addProperties(Root<T> root, Set<String> properties) {
// Si le conteneur est vide
if(properties == null || properties.size() == 0) return;
// Parcours du conteneur
for (String property : properties) {
// Si la ppt est nulle ou vide
if(property == null || property.trim().length() == 0) continue;
// On split
String[] hierarchicalPaths = property.split("\\.");
// Le fetch de depart
FetchParent<?, ?> fetch = root;
// Parcours de la liste
for (String path : hierarchicalPaths) {
// Si la propriete est vide
if(path == null || path.trim().isEmpty()) continue;
// chargement de cette hierarchie
fetch = fetch.fetch(path.trim(), JoinType.LEFT);
}
}
} | java | protected void addProperties(Root<T> root, Set<String> properties) {
// Si le conteneur est vide
if(properties == null || properties.size() == 0) return;
// Parcours du conteneur
for (String property : properties) {
// Si la ppt est nulle ou vide
if(property == null || property.trim().length() == 0) continue;
// On split
String[] hierarchicalPaths = property.split("\\.");
// Le fetch de depart
FetchParent<?, ?> fetch = root;
// Parcours de la liste
for (String path : hierarchicalPaths) {
// Si la propriete est vide
if(path == null || path.trim().isEmpty()) continue;
// chargement de cette hierarchie
fetch = fetch.fetch(path.trim(), JoinType.LEFT);
}
}
} | [
"protected",
"void",
"addProperties",
"(",
"Root",
"<",
"T",
">",
"root",
",",
"Set",
"<",
"String",
">",
"properties",
")",
"{",
"// Si le conteneur est vide\r",
"if",
"(",
"properties",
"==",
"null",
"||",
"properties",
".",
"size",
"(",
")",
"==",
"0",
... | Methode d'ajout des Proprietes a charger a la requete de recherche
@param root Entités objet du from
@param properties Conteneur de propriétés | [
"Methode",
"d",
"ajout",
"des",
"Proprietes",
"a",
"charger",
"a",
"la",
"requete",
"de",
"recherche"
] | train | https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java#L741-L768 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.java | OWLObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLObjectPropertyAssertionAxiomImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLObjectPropertyAssertionAxiomImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLObjectPropertyAssertionAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"... | Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.java#L78-L81 |
Crab2died/Excel4J | src/main/java/com/github/crab2died/ExcelUtils.java | ExcelUtils.exportObjects2Excel | public void exportObjects2Excel(List<?> data, List<String> header, String targetPath)
throws IOException {
try (OutputStream fos = new FileOutputStream(targetPath);
Workbook workbook = exportExcelBySimpleHandler(data, header, null, true)) {
workbook.write(fos);
}
} | java | public void exportObjects2Excel(List<?> data, List<String> header, String targetPath)
throws IOException {
try (OutputStream fos = new FileOutputStream(targetPath);
Workbook workbook = exportExcelBySimpleHandler(data, header, null, true)) {
workbook.write(fos);
}
} | [
"public",
"void",
"exportObjects2Excel",
"(",
"List",
"<",
"?",
">",
"data",
",",
"List",
"<",
"String",
">",
"header",
",",
"String",
"targetPath",
")",
"throws",
"IOException",
"{",
"try",
"(",
"OutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
... | 无模板、无注解的数据(形如{@code List[?]}、{@code List[List[?]]}、{@code List[Object[]]})导出
@param data 待导出数据
@param header 设置表头信息
@param targetPath 生成的Excel输出全路径
@throws IOException 异常
@author Crab2Died | [
"无模板、无注解的数据",
"(",
"形如",
"{",
"@code",
"List",
"[",
"?",
"]",
"}",
"、",
"{",
"@code",
"List",
"[",
"List",
"[",
"?",
"]]",
"}",
"、",
"{",
"@code",
"List",
"[",
"Object",
"[]",
"]",
"}",
")",
"导出"
] | train | https://github.com/Crab2died/Excel4J/blob/2ab0a3b8226a69ff868c3ead6e724f3a774f5f77/src/main/java/com/github/crab2died/ExcelUtils.java#L1305-L1312 |
threerings/nenya | core/src/main/java/com/threerings/media/util/LinePath.java | LinePath.getTranslatedInstance | public Path getTranslatedInstance (int x, int y)
{
if (_source == null) {
return new LinePath(null, new Point(_dest.x + x, _dest.y + y),
_duration);
} else {
return new LinePath(_source.x + x, _source.y + y, _dest.x + x,
_dest.y + y, _duration);
}
} | java | public Path getTranslatedInstance (int x, int y)
{
if (_source == null) {
return new LinePath(null, new Point(_dest.x + x, _dest.y + y),
_duration);
} else {
return new LinePath(_source.x + x, _source.y + y, _dest.x + x,
_dest.y + y, _duration);
}
} | [
"public",
"Path",
"getTranslatedInstance",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"_source",
"==",
"null",
")",
"{",
"return",
"new",
"LinePath",
"(",
"null",
",",
"new",
"Point",
"(",
"_dest",
".",
"x",
"+",
"x",
",",
"_dest",
".",... | Return a copy of the path, translated by the specified amounts. | [
"Return",
"a",
"copy",
"of",
"the",
"path",
"translated",
"by",
"the",
"specified",
"amounts",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/LinePath.java#L66-L75 |
opengeospatial/teamengine | teamengine-core/src/main/java/com/occamlab/te/parsers/XmlErrorHandler.java | XmlErrorHandler.addError | private void addError(short severity, SAXParseException spex) {
if (spex.getLineNumber() > 0) {
buf.append("Line " + spex.getLineNumber() + " - ");
}
buf.append(spex.getMessage() + "\n");
ValidationError error = new ValidationError(severity, buf.toString());
errors.add(error);
buf.setLength(0);
} | java | private void addError(short severity, SAXParseException spex) {
if (spex.getLineNumber() > 0) {
buf.append("Line " + spex.getLineNumber() + " - ");
}
buf.append(spex.getMessage() + "\n");
ValidationError error = new ValidationError(severity, buf.toString());
errors.add(error);
buf.setLength(0);
} | [
"private",
"void",
"addError",
"(",
"short",
"severity",
",",
"SAXParseException",
"spex",
")",
"{",
"if",
"(",
"spex",
".",
"getLineNumber",
"(",
")",
">",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"\"Line \"",
"+",
"spex",
".",
"getLineNumber",
"(",
... | Adds a validation error based on a <code>SAXParseException</code>.
@param severity
the severity of the error
@param spex
the <code>SAXParseException</code> raised while validating the
XML source | [
"Adds",
"a",
"validation",
"error",
"based",
"on",
"a",
"<code",
">",
"SAXParseException<",
"/",
"code",
">",
"."
] | train | https://github.com/opengeospatial/teamengine/blob/b6b890214b6784bbe19460bf753bdf28a9514bee/teamengine-core/src/main/java/com/occamlab/te/parsers/XmlErrorHandler.java#L130-L138 |
joniles/mpxj | src/main/java/net/sf/mpxj/ProjectCalendar.java | ProjectCalendar.getDuration | public Duration getDuration(Date startDate, Date endDate)
{
Calendar cal = DateHelper.popCalendar(startDate);
int days = getDaysInRange(startDate, endDate);
int duration = 0;
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (days > 0)
{
if (isWorkingDate(cal.getTime(), day) == true)
{
++duration;
}
--days;
day = day.getNextDay();
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
}
DateHelper.pushCalendar(cal);
return (Duration.getInstance(duration, TimeUnit.DAYS));
} | java | public Duration getDuration(Date startDate, Date endDate)
{
Calendar cal = DateHelper.popCalendar(startDate);
int days = getDaysInRange(startDate, endDate);
int duration = 0;
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (days > 0)
{
if (isWorkingDate(cal.getTime(), day) == true)
{
++duration;
}
--days;
day = day.getNextDay();
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
}
DateHelper.pushCalendar(cal);
return (Duration.getInstance(duration, TimeUnit.DAYS));
} | [
"public",
"Duration",
"getDuration",
"(",
"Date",
"startDate",
",",
"Date",
"endDate",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"startDate",
")",
";",
"int",
"days",
"=",
"getDaysInRange",
"(",
"startDate",
",",
"endDate",
")"... | This method is provided to allow an absolute period of time
represented by start and end dates into a duration in working
days based on this calendar instance. This method takes account
of any exceptions defined for this calendar.
@param startDate start of the period
@param endDate end of the period
@return new Duration object | [
"This",
"method",
"is",
"provided",
"to",
"allow",
"an",
"absolute",
"period",
"of",
"time",
"represented",
"by",
"start",
"and",
"end",
"dates",
"into",
"a",
"duration",
"in",
"working",
"days",
"based",
"on",
"this",
"calendar",
"instance",
".",
"This",
... | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L327-L348 |
spring-projects/spring-mobile | spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/SiteSwitcherRequestFilter.java | SiteSwitcherRequestFilter.urlPath | private void urlPath() throws ServletException {
SiteUrlFactory normalSiteUrlFactory = new NormalSitePathUrlFactory(mobilePath, tabletPath, rootPath);
SiteUrlFactory mobileSiteUrlFactory = null;
SiteUrlFactory tabletSiteUrlFactory = null;
if (mobilePath != null) {
mobileSiteUrlFactory = new MobileSitePathUrlFactory(mobilePath, tabletPath, rootPath);
}
if (tabletPath != null) {
tabletSiteUrlFactory = new TabletSitePathUrlFactory(tabletPath, mobilePath, rootPath);
}
this.siteSwitcherHandler = new StandardSiteSwitcherHandler(normalSiteUrlFactory, mobileSiteUrlFactory,
tabletSiteUrlFactory, new StandardSitePreferenceHandler(new CookieSitePreferenceRepository()), null);
} | java | private void urlPath() throws ServletException {
SiteUrlFactory normalSiteUrlFactory = new NormalSitePathUrlFactory(mobilePath, tabletPath, rootPath);
SiteUrlFactory mobileSiteUrlFactory = null;
SiteUrlFactory tabletSiteUrlFactory = null;
if (mobilePath != null) {
mobileSiteUrlFactory = new MobileSitePathUrlFactory(mobilePath, tabletPath, rootPath);
}
if (tabletPath != null) {
tabletSiteUrlFactory = new TabletSitePathUrlFactory(tabletPath, mobilePath, rootPath);
}
this.siteSwitcherHandler = new StandardSiteSwitcherHandler(normalSiteUrlFactory, mobileSiteUrlFactory,
tabletSiteUrlFactory, new StandardSitePreferenceHandler(new CookieSitePreferenceRepository()), null);
} | [
"private",
"void",
"urlPath",
"(",
")",
"throws",
"ServletException",
"{",
"SiteUrlFactory",
"normalSiteUrlFactory",
"=",
"new",
"NormalSitePathUrlFactory",
"(",
"mobilePath",
",",
"tabletPath",
",",
"rootPath",
")",
";",
"SiteUrlFactory",
"mobileSiteUrlFactory",
"=",
... | Configures a site switcher that redirects to a path on the current domain for normal site requests that either
originate from a mobile or tablet device, or indicate a mobile or tablet site preference.
Uses a {@link CookieSitePreferenceRepository} that saves a cookie that is stored on the root path. | [
"Configures",
"a",
"site",
"switcher",
"that",
"redirects",
"to",
"a",
"path",
"on",
"the",
"current",
"domain",
"for",
"normal",
"site",
"requests",
"that",
"either",
"originate",
"from",
"a",
"mobile",
"or",
"tablet",
"device",
"or",
"indicate",
"a",
"mobi... | train | https://github.com/spring-projects/spring-mobile/blob/a402cbcaf208e24288b957f44c9984bd6e8bf064/spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/SiteSwitcherRequestFilter.java#L283-L295 |
perwendel/spark | src/main/java/spark/utils/MimeParse.java | MimeParse.bestMatch | public static String bestMatch(Collection<String> supported, String header) {
List<ParseResults> parseResults = new LinkedList<>();
List<FitnessAndQuality> weightedMatches = new LinkedList<>();
for (String r : header.split(",")) {
parseResults.add(parseMediaRange(r));
}
for (String s : supported) {
FitnessAndQuality fitnessAndQuality = fitnessAndQualityParsed(s, parseResults);
fitnessAndQuality.mimeType = s;
weightedMatches.add(fitnessAndQuality);
}
Collections.sort(weightedMatches);
FitnessAndQuality lastOne = weightedMatches.get(weightedMatches.size() - 1);
return Float.compare(lastOne.quality, 0) != 0 ? lastOne.mimeType : NO_MIME_TYPE;
} | java | public static String bestMatch(Collection<String> supported, String header) {
List<ParseResults> parseResults = new LinkedList<>();
List<FitnessAndQuality> weightedMatches = new LinkedList<>();
for (String r : header.split(",")) {
parseResults.add(parseMediaRange(r));
}
for (String s : supported) {
FitnessAndQuality fitnessAndQuality = fitnessAndQualityParsed(s, parseResults);
fitnessAndQuality.mimeType = s;
weightedMatches.add(fitnessAndQuality);
}
Collections.sort(weightedMatches);
FitnessAndQuality lastOne = weightedMatches.get(weightedMatches.size() - 1);
return Float.compare(lastOne.quality, 0) != 0 ? lastOne.mimeType : NO_MIME_TYPE;
} | [
"public",
"static",
"String",
"bestMatch",
"(",
"Collection",
"<",
"String",
">",
"supported",
",",
"String",
"header",
")",
"{",
"List",
"<",
"ParseResults",
">",
"parseResults",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"List",
"<",
"FitnessAndQuality... | Finds best match
@param supported the supported types
@param header the header
@return the best match | [
"Finds",
"best",
"match"
] | train | https://github.com/perwendel/spark/blob/080fb1f9d6e580f6742e9589044c7420d3157b8b/src/main/java/spark/utils/MimeParse.java#L173-L189 |
pmwmedia/tinylog | tinylog-impl/src/main/java/org/tinylog/core/MessageFormatter.java | MessageFormatter.getFormatter | private Format getFormatter(final String pattern, final Object argument) {
if (pattern.indexOf('|') != -1) {
int start = pattern.indexOf('{');
if (start >= 0 && start < pattern.lastIndexOf('}')) {
return new ChoiceFormat(format(pattern, new Object[] { argument }));
} else {
return new ChoiceFormat(pattern);
}
} else {
return new DecimalFormat(pattern, symbols);
}
} | java | private Format getFormatter(final String pattern, final Object argument) {
if (pattern.indexOf('|') != -1) {
int start = pattern.indexOf('{');
if (start >= 0 && start < pattern.lastIndexOf('}')) {
return new ChoiceFormat(format(pattern, new Object[] { argument }));
} else {
return new ChoiceFormat(pattern);
}
} else {
return new DecimalFormat(pattern, symbols);
}
} | [
"private",
"Format",
"getFormatter",
"(",
"final",
"String",
"pattern",
",",
"final",
"Object",
"argument",
")",
"{",
"if",
"(",
"pattern",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"{",
"int",
"start",
"=",
"pattern",
".",
"indexOf",
... | Gets the format object for a pattern of a placeholder. {@link ChoiceFormat} and {@link DecimalFormat} are
supported.
@param pattern
Pattern of placeholder
@param argument
Replacement for placeholder
@return Format object | [
"Gets",
"the",
"format",
"object",
"for",
"a",
"pattern",
"of",
"a",
"placeholder",
".",
"{",
"@link",
"ChoiceFormat",
"}",
"and",
"{",
"@link",
"DecimalFormat",
"}",
"are",
"supported",
"."
] | train | https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/MessageFormatter.java#L132-L143 |
chhh/MSFTBX | MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java | Base64Slow.encodeToString | public static String encodeToString(byte[] bytes, boolean lineBreaks) {
try {
return new String(encode(bytes, lineBreaks), "ASCII");
} catch (UnsupportedEncodingException iex) {
// ASCII should be supported
throw new RuntimeException(iex);
}
} | java | public static String encodeToString(byte[] bytes, boolean lineBreaks) {
try {
return new String(encode(bytes, lineBreaks), "ASCII");
} catch (UnsupportedEncodingException iex) {
// ASCII should be supported
throw new RuntimeException(iex);
}
} | [
"public",
"static",
"String",
"encodeToString",
"(",
"byte",
"[",
"]",
"bytes",
",",
"boolean",
"lineBreaks",
")",
"{",
"try",
"{",
"return",
"new",
"String",
"(",
"encode",
"(",
"bytes",
",",
"lineBreaks",
")",
",",
"\"ASCII\"",
")",
";",
"}",
"catch",
... | Encode bytes in Base64.
@param bytes The data to encode.
@param lineBreaks Whether to insert line breaks every 76 characters in the output.
@return String with Base64 encoded data.
@since ostermillerutils 1.04.00 | [
"Encode",
"bytes",
"in",
"Base64",
"."
] | train | https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/base64/Base64Slow.java#L278-L285 |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ListLayoutExample.java | ListLayoutExample.addExample | private void addExample(final String heading, final ListLayout layout) {
add(new WHeading(HeadingLevel.H2, heading));
WPanel panel = new WPanel();
panel.setLayout(layout);
add(panel);
for (String item : EXAMPLE_ITEMS) {
panel.add(new WText(item));
}
add(new WHorizontalRule());
} | java | private void addExample(final String heading, final ListLayout layout) {
add(new WHeading(HeadingLevel.H2, heading));
WPanel panel = new WPanel();
panel.setLayout(layout);
add(panel);
for (String item : EXAMPLE_ITEMS) {
panel.add(new WText(item));
}
add(new WHorizontalRule());
} | [
"private",
"void",
"addExample",
"(",
"final",
"String",
"heading",
",",
"final",
"ListLayout",
"layout",
")",
"{",
"add",
"(",
"new",
"WHeading",
"(",
"HeadingLevel",
".",
"H2",
",",
"heading",
")",
")",
";",
"WPanel",
"panel",
"=",
"new",
"WPanel",
"("... | Adds an example to the set of examples.
@param heading the heading for the example
@param layout the layout for the panel | [
"Adds",
"an",
"example",
"to",
"the",
"set",
"of",
"examples",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ListLayoutExample.java#L55-L64 |
xmlunit/xmlunit | xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLUnit.java | XMLUnit.buildDocument | public static Document buildDocument(DocumentBuilder withBuilder,
Reader fromReader) throws SAXException, IOException {
return buildDocument(withBuilder, new InputSource(fromReader));
} | java | public static Document buildDocument(DocumentBuilder withBuilder,
Reader fromReader) throws SAXException, IOException {
return buildDocument(withBuilder, new InputSource(fromReader));
} | [
"public",
"static",
"Document",
"buildDocument",
"(",
"DocumentBuilder",
"withBuilder",
",",
"Reader",
"fromReader",
")",
"throws",
"SAXException",
",",
"IOException",
"{",
"return",
"buildDocument",
"(",
"withBuilder",
",",
"new",
"InputSource",
"(",
"fromReader",
... | Utility method to build a Document using a specific DocumentBuilder
and reading characters from a specific Reader.
@param withBuilder
@param fromReader
@return Document built
@throws SAXException
@throws IOException | [
"Utility",
"method",
"to",
"build",
"a",
"Document",
"using",
"a",
"specific",
"DocumentBuilder",
"and",
"reading",
"characters",
"from",
"a",
"specific",
"Reader",
"."
] | train | https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLUnit.java#L359-L362 |
FINRAOS/JTAF-ExtWebDriver | src/main/java/org/finra/jtaf/ewd/utils/ScreenshotUtils.java | ScreenshotUtils.takeScreenshotOfElement | public static void takeScreenshotOfElement(IElement element, File toSaveAs) throws IOException, WidgetException {
for(int i = 0; i < 10; i++) { //Loop up to 10x to ensure a clean screenshot was taken
log.info("Taking screen shot of locator " + element.getByLocator() + " ... attempt #" + (i+1));
//Scroll to element
element.scrollTo();
//Take picture of the page
WebDriver wd = SessionManager.getInstance().getCurrentSession().getWrappedDriver();
File screenshot;
boolean isRemote = false;
if(!(wd instanceof RemoteWebDriver)) {
screenshot = ((TakesScreenshot) wd).getScreenshotAs(OutputType.FILE);
}
else {
Augmenter augmenter = new Augmenter();
screenshot = ((TakesScreenshot) augmenter.augment(wd)).getScreenshotAs(OutputType.FILE);
isRemote = true;
}
BufferedImage fullImage = ImageIO.read(screenshot);
WebElement ele = element.getWebElement();
//Parse out the picture of the element
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
int eleHeight = ele.getSize().getHeight();
int x;
int y;
if(isRemote) {
x = ((Locatable)ele).getCoordinates().inViewPort().getX();
y = ((Locatable)ele).getCoordinates().inViewPort().getY();
}
else {
x = point.getX();
y = point.getY();
}
log.debug("Screenshot coordinates x: "+x+", y: "+y);
BufferedImage eleScreenshot = fullImage.getSubimage(x, y, eleWidth, eleHeight);
ImageIO.write(eleScreenshot, "png", screenshot);
//Ensure clean snapshot (sometimes WebDriver takes bad pictures and they turn out all black)
if(!isBlack(ImageIO.read(screenshot))) {
FileUtils.copyFile(screenshot, toSaveAs);
break;
}
}
} | java | public static void takeScreenshotOfElement(IElement element, File toSaveAs) throws IOException, WidgetException {
for(int i = 0; i < 10; i++) { //Loop up to 10x to ensure a clean screenshot was taken
log.info("Taking screen shot of locator " + element.getByLocator() + " ... attempt #" + (i+1));
//Scroll to element
element.scrollTo();
//Take picture of the page
WebDriver wd = SessionManager.getInstance().getCurrentSession().getWrappedDriver();
File screenshot;
boolean isRemote = false;
if(!(wd instanceof RemoteWebDriver)) {
screenshot = ((TakesScreenshot) wd).getScreenshotAs(OutputType.FILE);
}
else {
Augmenter augmenter = new Augmenter();
screenshot = ((TakesScreenshot) augmenter.augment(wd)).getScreenshotAs(OutputType.FILE);
isRemote = true;
}
BufferedImage fullImage = ImageIO.read(screenshot);
WebElement ele = element.getWebElement();
//Parse out the picture of the element
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
int eleHeight = ele.getSize().getHeight();
int x;
int y;
if(isRemote) {
x = ((Locatable)ele).getCoordinates().inViewPort().getX();
y = ((Locatable)ele).getCoordinates().inViewPort().getY();
}
else {
x = point.getX();
y = point.getY();
}
log.debug("Screenshot coordinates x: "+x+", y: "+y);
BufferedImage eleScreenshot = fullImage.getSubimage(x, y, eleWidth, eleHeight);
ImageIO.write(eleScreenshot, "png", screenshot);
//Ensure clean snapshot (sometimes WebDriver takes bad pictures and they turn out all black)
if(!isBlack(ImageIO.read(screenshot))) {
FileUtils.copyFile(screenshot, toSaveAs);
break;
}
}
} | [
"public",
"static",
"void",
"takeScreenshotOfElement",
"(",
"IElement",
"element",
",",
"File",
"toSaveAs",
")",
"throws",
"IOException",
",",
"WidgetException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"//Loo... | *
You can use this method to take your control pictures. Note that the file should be a png.
@param element
@param toSaveAs
@throws IOException
@throws WidgetException | [
"*",
"You",
"can",
"use",
"this",
"method",
"to",
"take",
"your",
"control",
"pictures",
".",
"Note",
"that",
"the",
"file",
"should",
"be",
"a",
"png",
"."
] | train | https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/utils/ScreenshotUtils.java#L61-L108 |
Netflix/eureka | eureka-client/src/main/java/com/netflix/discovery/shared/Applications.java | Applications.addInstanceToMap | private void addInstanceToMap(InstanceInfo info, String vipAddresses, Map<String, VipIndexSupport> vipMap) {
if (vipAddresses != null) {
String[] vipAddressArray = vipAddresses.toUpperCase(Locale.ROOT).split(",");
for (String vipAddress : vipAddressArray) {
VipIndexSupport vis = vipMap.computeIfAbsent(vipAddress, k -> new VipIndexSupport());
vis.instances.add(info);
}
}
} | java | private void addInstanceToMap(InstanceInfo info, String vipAddresses, Map<String, VipIndexSupport> vipMap) {
if (vipAddresses != null) {
String[] vipAddressArray = vipAddresses.toUpperCase(Locale.ROOT).split(",");
for (String vipAddress : vipAddressArray) {
VipIndexSupport vis = vipMap.computeIfAbsent(vipAddress, k -> new VipIndexSupport());
vis.instances.add(info);
}
}
} | [
"private",
"void",
"addInstanceToMap",
"(",
"InstanceInfo",
"info",
",",
"String",
"vipAddresses",
",",
"Map",
"<",
"String",
",",
"VipIndexSupport",
">",
"vipMap",
")",
"{",
"if",
"(",
"vipAddresses",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"vipAddressA... | Add the instance to the given map based if the vip address matches with
that of the instance. Note that an instance can be mapped to multiple vip
addresses. | [
"Add",
"the",
"instance",
"to",
"the",
"given",
"map",
"based",
"if",
"the",
"vip",
"address",
"matches",
"with",
"that",
"of",
"the",
"instance",
".",
"Note",
"that",
"an",
"instance",
"can",
"be",
"mapped",
"to",
"multiple",
"vip",
"addresses",
"."
] | train | https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-client/src/main/java/com/netflix/discovery/shared/Applications.java#L375-L383 |
buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.getSeverity | private Severity getSeverity(Attributes attributes, Severity defaultSeverity) throws RuleException {
String severity = attributes.getString(SEVERITY);
if (severity == null) {
return defaultSeverity;
}
Severity value = Severity.fromValue(severity.toLowerCase());
return value != null ? value : defaultSeverity;
} | java | private Severity getSeverity(Attributes attributes, Severity defaultSeverity) throws RuleException {
String severity = attributes.getString(SEVERITY);
if (severity == null) {
return defaultSeverity;
}
Severity value = Severity.fromValue(severity.toLowerCase());
return value != null ? value : defaultSeverity;
} | [
"private",
"Severity",
"getSeverity",
"(",
"Attributes",
"attributes",
",",
"Severity",
"defaultSeverity",
")",
"throws",
"RuleException",
"{",
"String",
"severity",
"=",
"attributes",
".",
"getString",
"(",
"SEVERITY",
")",
";",
"if",
"(",
"severity",
"==",
"nu... | Extract the optional severity of a rule.
@param attributes
The attributes of the rule.
@param defaultSeverity
The default severity to use if no severity is specified.
@return The severity. | [
"Extract",
"the",
"optional",
"severity",
"of",
"a",
"rule",
"."
] | train | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L323-L330 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.setPerspective | public Matrix4d setPerspective(double fovy, double aspect, double zNear, double zFar, boolean zZeroToOne) {
double h = Math.tan(fovy * 0.5);
m00 = 1.0 / (h * aspect);
m01 = 0.0;
m02 = 0.0;
m03 = 0.0;
m10 = 0.0;
m11 = 1.0 / h;
m12 = 0.0;
m13 = 0.0;
m20 = 0.0;
m21 = 0.0;
boolean farInf = zFar > 0 && Double.isInfinite(zFar);
boolean nearInf = zNear > 0 && Double.isInfinite(zNear);
if (farInf) {
// See: "Infinite Projection Matrix" (http://www.terathon.com/gdc07_lengyel.pdf)
double e = 1E-6;
m22 = e - 1.0;
m32 = (e - (zZeroToOne ? 1.0 : 2.0)) * zNear;
} else if (nearInf) {
double e = 1E-6;
m22 = (zZeroToOne ? 0.0 : 1.0) - e;
m32 = ((zZeroToOne ? 1.0 : 2.0) - e) * zFar;
} else {
m22 = (zZeroToOne ? zFar : zFar + zNear) / (zNear - zFar);
m32 = (zZeroToOne ? zFar : zFar + zFar) * zNear / (zNear - zFar);
}
m23 = -1.0;
m30 = 0.0;
m31 = 0.0;
m33 = 0.0;
properties = PROPERTY_PERSPECTIVE;
return this;
} | java | public Matrix4d setPerspective(double fovy, double aspect, double zNear, double zFar, boolean zZeroToOne) {
double h = Math.tan(fovy * 0.5);
m00 = 1.0 / (h * aspect);
m01 = 0.0;
m02 = 0.0;
m03 = 0.0;
m10 = 0.0;
m11 = 1.0 / h;
m12 = 0.0;
m13 = 0.0;
m20 = 0.0;
m21 = 0.0;
boolean farInf = zFar > 0 && Double.isInfinite(zFar);
boolean nearInf = zNear > 0 && Double.isInfinite(zNear);
if (farInf) {
// See: "Infinite Projection Matrix" (http://www.terathon.com/gdc07_lengyel.pdf)
double e = 1E-6;
m22 = e - 1.0;
m32 = (e - (zZeroToOne ? 1.0 : 2.0)) * zNear;
} else if (nearInf) {
double e = 1E-6;
m22 = (zZeroToOne ? 0.0 : 1.0) - e;
m32 = ((zZeroToOne ? 1.0 : 2.0) - e) * zFar;
} else {
m22 = (zZeroToOne ? zFar : zFar + zNear) / (zNear - zFar);
m32 = (zZeroToOne ? zFar : zFar + zFar) * zNear / (zNear - zFar);
}
m23 = -1.0;
m30 = 0.0;
m31 = 0.0;
m33 = 0.0;
properties = PROPERTY_PERSPECTIVE;
return this;
} | [
"public",
"Matrix4d",
"setPerspective",
"(",
"double",
"fovy",
",",
"double",
"aspect",
",",
"double",
"zNear",
",",
"double",
"zFar",
",",
"boolean",
"zZeroToOne",
")",
"{",
"double",
"h",
"=",
"Math",
".",
"tan",
"(",
"fovy",
"*",
"0.5",
")",
";",
"m... | Set this matrix to be a symmetric perspective projection frustum transformation for a right-handed coordinate system
using the given NDC z range.
<p>
In order to apply the perspective projection transformation to an existing transformation,
use {@link #perspective(double, double, double, double, boolean) perspective()}.
@see #perspective(double, double, double, double, boolean)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Double#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Double#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Double#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Double#POSITIVE_INFINITY}.
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this | [
"Set",
"this",
"matrix",
"to",
"be",
"a",
"symmetric",
"perspective",
"projection",
"frustum",
"transformation",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"using",
"the",
"given",
"NDC",
"z",
"range",
".",
"<p",
">",
"In",
"order",
"to",
... | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L12572-L12605 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java | DBInitializerHelper.getObjectScript | public static String getObjectScript(String objectName, boolean multiDb, String dialect, WorkspaceEntry wsEntry)
throws RepositoryConfigurationException, IOException
{
String scripts = prepareScripts(wsEntry, dialect);
String sql = null;
for (String query : JDBCUtils.splitWithSQLDelimiter(scripts))
{
String q = JDBCUtils.cleanWhitespaces(query);
if (q.contains(objectName))
{
if (sql != null)
{
throw new RepositoryConfigurationException("Can't find unique script for object creation. Object name: "
+ objectName);
}
sql = q;
}
}
if (sql != null)
{
return sql;
}
throw new RepositoryConfigurationException("Script for object creation is not found. Object name: " + objectName);
} | java | public static String getObjectScript(String objectName, boolean multiDb, String dialect, WorkspaceEntry wsEntry)
throws RepositoryConfigurationException, IOException
{
String scripts = prepareScripts(wsEntry, dialect);
String sql = null;
for (String query : JDBCUtils.splitWithSQLDelimiter(scripts))
{
String q = JDBCUtils.cleanWhitespaces(query);
if (q.contains(objectName))
{
if (sql != null)
{
throw new RepositoryConfigurationException("Can't find unique script for object creation. Object name: "
+ objectName);
}
sql = q;
}
}
if (sql != null)
{
return sql;
}
throw new RepositoryConfigurationException("Script for object creation is not found. Object name: " + objectName);
} | [
"public",
"static",
"String",
"getObjectScript",
"(",
"String",
"objectName",
",",
"boolean",
"multiDb",
",",
"String",
"dialect",
",",
"WorkspaceEntry",
"wsEntry",
")",
"throws",
"RepositoryConfigurationException",
",",
"IOException",
"{",
"String",
"scripts",
"=",
... | Returns SQL script for create objects such as index, primary of foreign key. | [
"Returns",
"SQL",
"script",
"for",
"create",
"objects",
"such",
"as",
"index",
"primary",
"of",
"foreign",
"key",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java#L303-L330 |
jmeetsma/Iglu-Util | src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java | StringSupport.writeToOutputStream | public static void writeToOutputStream(String s, OutputStream output, String encoding) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(s));
PrintStream writer;
if (encoding != null) {
writer = new PrintStream(output, true, encoding);
}
else {
writer = new PrintStream(output, true);
}
String line;
while ((line = reader.readLine()) != null) {
writer.println(line);
}
} | java | public static void writeToOutputStream(String s, OutputStream output, String encoding) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(s));
PrintStream writer;
if (encoding != null) {
writer = new PrintStream(output, true, encoding);
}
else {
writer = new PrintStream(output, true);
}
String line;
while ((line = reader.readLine()) != null) {
writer.println(line);
}
} | [
"public",
"static",
"void",
"writeToOutputStream",
"(",
"String",
"s",
",",
"OutputStream",
"output",
",",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"s",
")... | Writes the contents of a string to an output stream.
@param s
@param output
@param encoding
@throws IOException | [
"Writes",
"the",
"contents",
"of",
"a",
"string",
"to",
"an",
"output",
"stream",
"."
] | train | https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L483-L496 |
dadoonet/elasticsearch-beyonder | src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java | IndexElasticsearchUpdater.isIndexExist | @Deprecated
public static boolean isIndexExist(Client client, String index) {
return client.admin().indices().prepareExists(index).get().isExists();
} | java | @Deprecated
public static boolean isIndexExist(Client client, String index) {
return client.admin().indices().prepareExists(index).get().isExists();
} | [
"@",
"Deprecated",
"public",
"static",
"boolean",
"isIndexExist",
"(",
"Client",
"client",
",",
"String",
"index",
")",
"{",
"return",
"client",
".",
"admin",
"(",
")",
".",
"indices",
"(",
")",
".",
"prepareExists",
"(",
"index",
")",
".",
"get",
"(",
... | Check if an index already exists
@param client Elasticsearch client
@param index Index name
@return true if index already exists | [
"Check",
"if",
"an",
"index",
"already",
"exists"
] | train | https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L172-L175 |
azkaban/azkaban | az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopSecureHiveWrapper.java | HadoopSecureHiveWrapper.populateHiveConf | private static void populateHiveConf(HiveConf hiveConf, String[] args) {
if (args == null) {
return;
}
int index = 0;
for (; index < args.length; index++) {
if ("-hiveconf".equals(args[index])) {
String hiveConfParam = stripSingleDoubleQuote(args[++index]);
String[] tokens = hiveConfParam.split("=");
if (tokens.length == 2) {
String name = tokens[0];
String value = tokens[1];
logger.info("Setting: " + name + "=" + value + " to hiveConf");
hiveConf.set(name, value);
} else {
logger.warn("Invalid hiveconf: " + hiveConfParam);
}
}
}
} | java | private static void populateHiveConf(HiveConf hiveConf, String[] args) {
if (args == null) {
return;
}
int index = 0;
for (; index < args.length; index++) {
if ("-hiveconf".equals(args[index])) {
String hiveConfParam = stripSingleDoubleQuote(args[++index]);
String[] tokens = hiveConfParam.split("=");
if (tokens.length == 2) {
String name = tokens[0];
String value = tokens[1];
logger.info("Setting: " + name + "=" + value + " to hiveConf");
hiveConf.set(name, value);
} else {
logger.warn("Invalid hiveconf: " + hiveConfParam);
}
}
}
} | [
"private",
"static",
"void",
"populateHiveConf",
"(",
"HiveConf",
"hiveConf",
",",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
"==",
"null",
")",
"{",
"return",
";",
"}",
"int",
"index",
"=",
"0",
";",
"for",
"(",
";",
"index",
"<",
"a... | Extract hiveconf from command line arguments and populate them into
HiveConf
An example: -hiveconf 'zipcode=10', -hiveconf hive.root.logger=INFO,console | [
"Extract",
"hiveconf",
"from",
"command",
"line",
"arguments",
"and",
"populate",
"them",
"into",
"HiveConf"
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopSecureHiveWrapper.java#L210-L232 |
elki-project/elki | addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/AbstractXTreeNode.java | AbstractXTreeNode.integrityCheckParameters | @Override
protected void integrityCheckParameters(N parent, int index) {
// test if mbr is correctly set
SpatialEntry entry = parent.getEntry(index);
HyperBoundingBox mbr = computeMBR();
if(/*entry.getMBR() == null && */ mbr == null) {
return;
}
if(!SpatialUtil.equals(entry, mbr)) {
String soll = mbr.toString();
String ist = (new HyperBoundingBox(entry)).toString();
throw new RuntimeException("Wrong MBR in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + soll + ",\n ist: " + ist);
}
if(isSuperNode() && isLeaf()) {
throw new RuntimeException("Node " + toString() + " is a supernode and a leaf");
}
if(isSuperNode() && !parent.isSuperNode() && parent.getCapacity() >= getCapacity()) {
throw new RuntimeException("Supernode " + toString() + " has capacity " + getCapacity() + "; its non-super parent node has capacity " + parent.getCapacity());
}
} | java | @Override
protected void integrityCheckParameters(N parent, int index) {
// test if mbr is correctly set
SpatialEntry entry = parent.getEntry(index);
HyperBoundingBox mbr = computeMBR();
if(/*entry.getMBR() == null && */ mbr == null) {
return;
}
if(!SpatialUtil.equals(entry, mbr)) {
String soll = mbr.toString();
String ist = (new HyperBoundingBox(entry)).toString();
throw new RuntimeException("Wrong MBR in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + soll + ",\n ist: " + ist);
}
if(isSuperNode() && isLeaf()) {
throw new RuntimeException("Node " + toString() + " is a supernode and a leaf");
}
if(isSuperNode() && !parent.isSuperNode() && parent.getCapacity() >= getCapacity()) {
throw new RuntimeException("Supernode " + toString() + " has capacity " + getCapacity() + "; its non-super parent node has capacity " + parent.getCapacity());
}
} | [
"@",
"Override",
"protected",
"void",
"integrityCheckParameters",
"(",
"N",
"parent",
",",
"int",
"index",
")",
"{",
"// test if mbr is correctly set",
"SpatialEntry",
"entry",
"=",
"parent",
".",
"getEntry",
"(",
"index",
")",
";",
"HyperBoundingBox",
"mbr",
"=",... | Tests, if the parameters of the entry representing this node, are correctly
set. Subclasses may need to overwrite this method.
@param parent the parent holding the entry representing this node
@param index the index of the entry in the parents child array | [
"Tests",
"if",
"the",
"parameters",
"of",
"the",
"entry",
"representing",
"this",
"node",
"are",
"correctly",
"set",
".",
"Subclasses",
"may",
"need",
"to",
"overwrite",
"this",
"method",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/AbstractXTreeNode.java#L282-L302 |
knowm/XChange | xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseMarketDataServiceRaw.java | CoinbaseMarketDataServiceRaw.getCoinbaseBuyPrice | public CoinbasePrice getCoinbaseBuyPrice(BigDecimal quantity, String currency)
throws IOException {
return coinbase.getBuyPrice(quantity, currency);
} | java | public CoinbasePrice getCoinbaseBuyPrice(BigDecimal quantity, String currency)
throws IOException {
return coinbase.getBuyPrice(quantity, currency);
} | [
"public",
"CoinbasePrice",
"getCoinbaseBuyPrice",
"(",
"BigDecimal",
"quantity",
",",
"String",
"currency",
")",
"throws",
"IOException",
"{",
"return",
"coinbase",
".",
"getBuyPrice",
"(",
"quantity",
",",
"currency",
")",
";",
"}"
] | Unauthenticated resource that tells you the total price to buy some quantity of Bitcoin.
@param quantity The quantity of Bitcoin you would like to buy (default is 1 if null).
@param currency Default is USD. Right now this is the only value allowed.
@return The price in the desired {@code currency} to buy the given {@code quantity} BTC.
@throws IOException
@see <a
href="https://coinbase.com/api/doc/1.0/prices/buy.html">coinbase.com/api/doc/1.0/prices/buy.html</a> | [
"Unauthenticated",
"resource",
"that",
"tells",
"you",
"the",
"total",
"price",
"to",
"buy",
"some",
"quantity",
"of",
"Bitcoin",
"."
] | train | https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseMarketDataServiceRaw.java#L76-L80 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/renderer/font/MalisisFont.java | MalisisFont.getStringHeight | public float getStringHeight(String text, FontOptions options)
{
StringWalker walker = new StringWalker(text, options);
walker.walkToEnd();
return walker.lineHeight();
} | java | public float getStringHeight(String text, FontOptions options)
{
StringWalker walker = new StringWalker(text, options);
walker.walkToEnd();
return walker.lineHeight();
} | [
"public",
"float",
"getStringHeight",
"(",
"String",
"text",
",",
"FontOptions",
"options",
")",
"{",
"StringWalker",
"walker",
"=",
"new",
"StringWalker",
"(",
"text",
",",
"options",
")",
";",
"walker",
".",
"walkToEnd",
"(",
")",
";",
"return",
"walker",
... | Gets the rendering height of strings.
@return the string height | [
"Gets",
"the",
"rendering",
"height",
"of",
"strings",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L472-L477 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/TopoGraph.java | TopoGraph.querySegmentXY | void querySegmentXY(int half_edge, SegmentBuffer outBuffer) {
outBuffer.createLine();
Segment seg = outBuffer.get();
Point2D pt = new Point2D();
getHalfEdgeFromXY(half_edge, pt);
seg.setStartXY(pt);
getHalfEdgeToXY(half_edge, pt);
seg.setEndXY(pt);
} | java | void querySegmentXY(int half_edge, SegmentBuffer outBuffer) {
outBuffer.createLine();
Segment seg = outBuffer.get();
Point2D pt = new Point2D();
getHalfEdgeFromXY(half_edge, pt);
seg.setStartXY(pt);
getHalfEdgeToXY(half_edge, pt);
seg.setEndXY(pt);
} | [
"void",
"querySegmentXY",
"(",
"int",
"half_edge",
",",
"SegmentBuffer",
"outBuffer",
")",
"{",
"outBuffer",
".",
"createLine",
"(",
")",
";",
"Segment",
"seg",
"=",
"outBuffer",
".",
"get",
"(",
")",
";",
"Point2D",
"pt",
"=",
"new",
"Point2D",
"(",
")"... | Queries segment for the edge (only xy coordinates, no attributes) | [
"Queries",
"segment",
"for",
"the",
"edge",
"(",
"only",
"xy",
"coordinates",
"no",
"attributes",
")"
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/TopoGraph.java#L2490-L2498 |
JOML-CI/JOML | src/org/joml/Matrix4x3d.java | Matrix4x3d.setLookAlong | public Matrix4x3d setLookAlong(Vector3dc dir, Vector3dc up) {
return setLookAlong(dir.x(), dir.y(), dir.z(), up.x(), up.y(), up.z());
} | java | public Matrix4x3d setLookAlong(Vector3dc dir, Vector3dc up) {
return setLookAlong(dir.x(), dir.y(), dir.z(), up.x(), up.y(), up.z());
} | [
"public",
"Matrix4x3d",
"setLookAlong",
"(",
"Vector3dc",
"dir",
",",
"Vector3dc",
"up",
")",
"{",
"return",
"setLookAlong",
"(",
"dir",
".",
"x",
"(",
")",
",",
"dir",
".",
"y",
"(",
")",
",",
"dir",
".",
"z",
"(",
")",
",",
"up",
".",
"x",
"(",... | Set this matrix to a rotation transformation to make <code>-z</code>
point along <code>dir</code>.
<p>
This is equivalent to calling
{@link #setLookAt(Vector3dc, Vector3dc, Vector3dc) setLookAt()}
with <code>eye = (0, 0, 0)</code> and <code>center = dir</code>.
<p>
In order to apply the lookalong transformation to any previous existing transformation,
use {@link #lookAlong(Vector3dc, Vector3dc)}.
@see #setLookAlong(Vector3dc, Vector3dc)
@see #lookAlong(Vector3dc, Vector3dc)
@param dir
the direction in space to look along
@param up
the direction of 'up'
@return this | [
"Set",
"this",
"matrix",
"to",
"a",
"rotation",
"transformation",
"to",
"make",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"point",
"along",
"<code",
">",
"dir<",
"/",
"code",
">",
".",
"<p",
">",
"This",
"is",
"equivalent",
"to",
"calling",
"{",
"@l... | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3d.java#L7985-L7987 |
google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getFieldNode | public FieldDeclaration getFieldNode(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | java | public FieldDeclaration getFieldNode(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | [
"public",
"FieldDeclaration",
"getFieldNode",
"(",
"String",
"name",
",",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",... | Returns the Procyon field definition for a specified variable,
or null if not found. | [
"Returns",
"the",
"Procyon",
"field",
"definition",
"for",
"a",
"specified",
"variable",
"or",
"null",
"if",
"not",
"found",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L143-L154 |
jenkinsci/jenkins | core/src/main/java/jenkins/model/Jenkins.java | Jenkins.isDisplayNameUnique | boolean isDisplayNameUnique(String displayName, String currentJobName) {
Collection<TopLevelItem> itemCollection = items.values();
// if there are a lot of projects, we'll have to store their
// display names in a HashSet or something for a quick check
for(TopLevelItem item : itemCollection) {
if(item.getName().equals(currentJobName)) {
// we won't compare the candidate displayName against the current
// item. This is to prevent an validation warning if the user
// sets the displayName to what the existing display name is
continue;
}
else if(displayName.equals(item.getDisplayName())) {
return false;
}
}
return true;
} | java | boolean isDisplayNameUnique(String displayName, String currentJobName) {
Collection<TopLevelItem> itemCollection = items.values();
// if there are a lot of projects, we'll have to store their
// display names in a HashSet or something for a quick check
for(TopLevelItem item : itemCollection) {
if(item.getName().equals(currentJobName)) {
// we won't compare the candidate displayName against the current
// item. This is to prevent an validation warning if the user
// sets the displayName to what the existing display name is
continue;
}
else if(displayName.equals(item.getDisplayName())) {
return false;
}
}
return true;
} | [
"boolean",
"isDisplayNameUnique",
"(",
"String",
"displayName",
",",
"String",
"currentJobName",
")",
"{",
"Collection",
"<",
"TopLevelItem",
">",
"itemCollection",
"=",
"items",
".",
"values",
"(",
")",
";",
"// if there are a lot of projects, we'll have to store their",... | This method checks all existing jobs to see if displayName is
unique. It does not check the displayName against the displayName of the
job that the user is configuring though to prevent a validation warning
if the user sets the displayName to what it currently is.
@param displayName
@param currentJobName | [
"This",
"method",
"checks",
"all",
"existing",
"jobs",
"to",
"see",
"if",
"displayName",
"is",
"unique",
".",
"It",
"does",
"not",
"check",
"the",
"displayName",
"against",
"the",
"displayName",
"of",
"the",
"job",
"that",
"the",
"user",
"is",
"configuring",... | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/model/Jenkins.java#L4776-L4794 |
alkacon/opencms-core | src/org/opencms/ade/configuration/CmsADEManager.java | CmsADEManager.elementToJson | protected JSONObject elementToJson(CmsContainerElementBean element, Set<String> excludeSettings) {
JSONObject data = null;
try {
data = new JSONObject();
data.put(FavListProp.ELEMENT.name().toLowerCase(), element.getId().toString());
if (element.getFormatterId() != null) {
data.put(FavListProp.FORMATTER.name().toLowerCase(), element.getFormatterId().toString());
}
JSONObject properties = new JSONObject();
for (Map.Entry<String, String> entry : element.getIndividualSettings().entrySet()) {
String settingKey = entry.getKey();
if (!excludeSettings.contains(settingKey)) {
properties.put(entry.getKey(), entry.getValue());
}
}
data.put(FavListProp.PROPERTIES.name().toLowerCase(), properties);
} catch (JSONException e) {
// should never happen
if (!LOG.isDebugEnabled()) {
LOG.warn(e.getLocalizedMessage());
}
LOG.debug(e.getLocalizedMessage(), e);
return null;
}
return data;
} | java | protected JSONObject elementToJson(CmsContainerElementBean element, Set<String> excludeSettings) {
JSONObject data = null;
try {
data = new JSONObject();
data.put(FavListProp.ELEMENT.name().toLowerCase(), element.getId().toString());
if (element.getFormatterId() != null) {
data.put(FavListProp.FORMATTER.name().toLowerCase(), element.getFormatterId().toString());
}
JSONObject properties = new JSONObject();
for (Map.Entry<String, String> entry : element.getIndividualSettings().entrySet()) {
String settingKey = entry.getKey();
if (!excludeSettings.contains(settingKey)) {
properties.put(entry.getKey(), entry.getValue());
}
}
data.put(FavListProp.PROPERTIES.name().toLowerCase(), properties);
} catch (JSONException e) {
// should never happen
if (!LOG.isDebugEnabled()) {
LOG.warn(e.getLocalizedMessage());
}
LOG.debug(e.getLocalizedMessage(), e);
return null;
}
return data;
} | [
"protected",
"JSONObject",
"elementToJson",
"(",
"CmsContainerElementBean",
"element",
",",
"Set",
"<",
"String",
">",
"excludeSettings",
")",
"{",
"JSONObject",
"data",
"=",
"null",
";",
"try",
"{",
"data",
"=",
"new",
"JSONObject",
"(",
")",
";",
"data",
"... | Converts the given element to JSON.<p>
@param element the element to convert
@param excludeSettings the keys of settings which should not be written to the JSON
@return the JSON representation | [
"Converts",
"the",
"given",
"element",
"to",
"JSON",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L1344-L1370 |
NessComputing/components-ness-jms | src/main/java/com/nesscomputing/jms/JmsRunnableFactory.java | JmsRunnableFactory.createQueueTextMessageListener | public QueueConsumer createQueueTextMessageListener(final String topic, final ConsumerCallback<String> messageCallback)
{
Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
return new QueueConsumer(connectionFactory, jmsConfig, topic, new TextMessageConsumerCallback(messageCallback));
} | java | public QueueConsumer createQueueTextMessageListener(final String topic, final ConsumerCallback<String> messageCallback)
{
Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
return new QueueConsumer(connectionFactory, jmsConfig, topic, new TextMessageConsumerCallback(messageCallback));
} | [
"public",
"QueueConsumer",
"createQueueTextMessageListener",
"(",
"final",
"String",
"topic",
",",
"final",
"ConsumerCallback",
"<",
"String",
">",
"messageCallback",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"connectionFactory",
"!=",
"null",
",",
"\"connect... | Creates a new {@link QueueConsumer}. For every text message received, the callback
is invoked with the contents of the text message as string. | [
"Creates",
"a",
"new",
"{"
] | train | https://github.com/NessComputing/components-ness-jms/blob/29e0d320ada3a1a375483437a9f3ff629822b714/src/main/java/com/nesscomputing/jms/JmsRunnableFactory.java#L154-L158 |
RestComm/media-core | rtp/src/main/java/org/restcomm/media/core/rtcp/RtcpPacketFactory.java | RtcpPacketFactory.buildBye | public static RtcpPacket buildBye(RtpStatistics statistics) {
// TODO Validate padding
boolean padding = false;
// Build the initial report packet
RtcpReport report;
if(statistics.hasSent()) {
report = buildSenderReport(statistics, padding);
} else {
report = buildReceiverReport(statistics, padding);
}
// Build the SDES packet containing the CNAME
RtcpSdes sdes = buildSdes(statistics, padding);
// Build the BYE
RtcpBye bye = new RtcpBye(padding);
bye.addSsrc(statistics.getSsrc());
// Build the compound packet
return new RtcpPacket(report, sdes, bye);
} | java | public static RtcpPacket buildBye(RtpStatistics statistics) {
// TODO Validate padding
boolean padding = false;
// Build the initial report packet
RtcpReport report;
if(statistics.hasSent()) {
report = buildSenderReport(statistics, padding);
} else {
report = buildReceiverReport(statistics, padding);
}
// Build the SDES packet containing the CNAME
RtcpSdes sdes = buildSdes(statistics, padding);
// Build the BYE
RtcpBye bye = new RtcpBye(padding);
bye.addSsrc(statistics.getSsrc());
// Build the compound packet
return new RtcpPacket(report, sdes, bye);
} | [
"public",
"static",
"RtcpPacket",
"buildBye",
"(",
"RtpStatistics",
"statistics",
")",
"{",
"// TODO Validate padding",
"boolean",
"padding",
"=",
"false",
";",
"// Build the initial report packet",
"RtcpReport",
"report",
";",
"if",
"(",
"statistics",
".",
"hasSent",
... | Builds a packet containing an RTCP BYE message.
@param statistics
The statistics of the RTP session
@return The RTCP packet | [
"Builds",
"a",
"packet",
"containing",
"an",
"RTCP",
"BYE",
"message",
"."
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/rtp/src/main/java/org/restcomm/media/core/rtcp/RtcpPacketFactory.java#L218-L239 |
digitalpetri/modbus | modbus-codec/src/main/java/com/digitalpetri/modbus/codec/Modbus.java | Modbus.releaseSharedResources | public static void releaseSharedResources(long timeout, TimeUnit unit) throws InterruptedException {
sharedExecutor().awaitTermination(timeout, unit);
sharedEventLoop().shutdownGracefully().await(timeout, unit);
sharedWheelTimer().stop();
} | java | public static void releaseSharedResources(long timeout, TimeUnit unit) throws InterruptedException {
sharedExecutor().awaitTermination(timeout, unit);
sharedEventLoop().shutdownGracefully().await(timeout, unit);
sharedWheelTimer().stop();
} | [
"public",
"static",
"void",
"releaseSharedResources",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"sharedExecutor",
"(",
")",
".",
"awaitTermination",
"(",
"timeout",
",",
"unit",
")",
";",
"sharedEventLoop",
"(",
... | Shutdown/stop any shared resources that me be in use, blocking until finished or interrupted.
@param timeout the duration to wait.
@param unit the {@link TimeUnit} of the {@code timeout} duration. | [
"Shutdown",
"/",
"stop",
"any",
"shared",
"resources",
"that",
"me",
"be",
"in",
"use",
"blocking",
"until",
"finished",
"or",
"interrupted",
"."
] | train | https://github.com/digitalpetri/modbus/blob/66281d811e64dfcdf8c8a8d0e85cdd80ae809a19/modbus-codec/src/main/java/com/digitalpetri/modbus/codec/Modbus.java#L71-L75 |
wcm-io/wcm-io-handler | commons/src/main/java/io/wcm/handler/commons/dom/AbstractHtmlElementFactory.java | AbstractHtmlElementFactory.createImage | public Image createImage(String src, int width, int height) {
return this.add(new Image(src, width, height));
} | java | public Image createImage(String src, int width, int height) {
return this.add(new Image(src, width, height));
} | [
"public",
"Image",
"createImage",
"(",
"String",
"src",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"this",
".",
"add",
"(",
"new",
"Image",
"(",
"src",
",",
"width",
",",
"height",
")",
")",
";",
"}"
] | Creates and adds imgage (img) element.
@param src Html "src" attribute.
@param width Html "width" attribute.
@param height Html "height" attribute.
@return Html element. | [
"Creates",
"and",
"adds",
"imgage",
"(",
"img",
")",
"element",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/commons/src/main/java/io/wcm/handler/commons/dom/AbstractHtmlElementFactory.java#L148-L150 |
wisdom-framework/wisdom | core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java | BundlePackager.mergeExtraHeaders | private static Properties mergeExtraHeaders(File baseDir, Properties properties) throws IOException {
File extra = new File(baseDir, EXTRA_HEADERS_FILE);
return Instructions.merge(properties, extra);
} | java | private static Properties mergeExtraHeaders(File baseDir, Properties properties) throws IOException {
File extra = new File(baseDir, EXTRA_HEADERS_FILE);
return Instructions.merge(properties, extra);
} | [
"private",
"static",
"Properties",
"mergeExtraHeaders",
"(",
"File",
"baseDir",
",",
"Properties",
"properties",
")",
"throws",
"IOException",
"{",
"File",
"extra",
"=",
"new",
"File",
"(",
"baseDir",
",",
"EXTRA_HEADERS_FILE",
")",
";",
"return",
"Instructions",
... | If a bundle has added extra headers, they are added to the bundle manifest.
@param baseDir the project directory
@param properties the current set of properties in which the read metadata are written
@return the merged set of properties | [
"If",
"a",
"bundle",
"has",
"added",
"extra",
"headers",
"they",
"are",
"added",
"to",
"the",
"bundle",
"manifest",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java#L148-L151 |
btaz/data-util | src/main/java/com/btaz/util/writer/HtmlTableWriter.java | HtmlTableWriter.writeTop | private void writeTop() throws IOException {
// setup output HTML file
File outputFile = new File(outputDirectory, createFilename(currentPageNumber));
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputFile, false), Charset.forName(encoding)));
// write header
Map<String,Object> map = new HashMap<String,Object>();
map.put("pageTitle", pageTitle);
if(pageHeader != null && pageHeader.length() > 0) {
map.put("header", "<h1>" + pageHeader + "</h1>");
} else {
map.put("header","");
}
if(pageDescription != null && pageDescription.length() > 0) {
map.put("description", "<p>" + pageDescription + "</p>");
} else {
map.put("description", "");
}
String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl");
String output = Template.transform(template, map);
writer.write(output);
} | java | private void writeTop() throws IOException {
// setup output HTML file
File outputFile = new File(outputDirectory, createFilename(currentPageNumber));
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputFile, false), Charset.forName(encoding)));
// write header
Map<String,Object> map = new HashMap<String,Object>();
map.put("pageTitle", pageTitle);
if(pageHeader != null && pageHeader.length() > 0) {
map.put("header", "<h1>" + pageHeader + "</h1>");
} else {
map.put("header","");
}
if(pageDescription != null && pageDescription.length() > 0) {
map.put("description", "<p>" + pageDescription + "</p>");
} else {
map.put("description", "");
}
String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl");
String output = Template.transform(template, map);
writer.write(output);
} | [
"private",
"void",
"writeTop",
"(",
")",
"throws",
"IOException",
"{",
"// setup output HTML file",
"File",
"outputFile",
"=",
"new",
"File",
"(",
"outputDirectory",
",",
"createFilename",
"(",
"currentPageNumber",
")",
")",
";",
"writer",
"=",
"new",
"BufferedWri... | Write the top part of the HTML document
@throws IOException exception | [
"Write",
"the",
"top",
"part",
"of",
"the",
"HTML",
"document"
] | train | https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L142-L165 |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.getStoreStats | public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java | public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | [
"public",
"EtcdStoreStatsResponse",
"getStoreStats",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"EtcdStoreStatsRequest",
"(",
"this",
".",
"client",
",",
"retryHandler",
")",
".",
"send",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOExceptio... | Get the Store Statistics of Etcd
@return vEtcdStoreStatsResponse | [
"Get",
"the",
"Store",
"Statistics",
"of",
"Etcd"
] | train | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L171-L177 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsUnion.java | VarOptItemsUnion.markMovingGadgetCoercer | private VarOptItemsSketch<T> markMovingGadgetCoercer() {
final int resultK = gadget_.getHRegionCount() + gadget_.getRRegionCount();
int resultH = 0;
int resultR = 0;
int nextRPos = resultK; // = (resultK+1)-1, to fill R region from back to front
final ArrayList<T> data = new ArrayList<>(resultK + 1);
final ArrayList<Double> weights = new ArrayList<>(resultK + 1);
// Need arrays filled to use set() and be able to fill from end forward.
// Ideally would create as arrays but trying to avoid forcing user to pass a Class<?>
for (int i = 0; i < (resultK + 1); ++i) {
data.add(null);
weights.add(null);
}
final VarOptItemsSamples<T> sketchSamples = gadget_.getSketchSamples();
// insert R region items, ignoring weights
// Currently (May 2017) this next block is unreachable; this coercer is used only in the
// pseudo-exact case in which case there are no items natively in R, only marked items in H
// that will be moved into R as part of the coercion process.
Iterator<VarOptItemsSamples<T>.WeightedSample> sketchIterator;
sketchIterator = sketchSamples.getRIterator();
while (sketchIterator.hasNext()) {
final VarOptItemsSamples<T>.WeightedSample ws = sketchIterator.next();
data.set(nextRPos, ws.getItem());
weights.set(nextRPos, -1.0);
++resultR;
--nextRPos;
}
double transferredWeight = 0;
// insert H region items
sketchIterator = sketchSamples.getHIterator();
while (sketchIterator.hasNext()) {
final VarOptItemsSamples<T>.WeightedSample ws = sketchIterator.next();
if (ws.getMark()) {
data.set(nextRPos, ws.getItem());
weights.set(nextRPos, -1.0);
transferredWeight += ws.getWeight();
++resultR;
--nextRPos;
} else {
data.set(resultH, ws.getItem());
weights.set(resultH, ws.getWeight());
++resultH;
}
}
assert (resultH + resultR) == resultK;
assert Math.abs(transferredWeight - outerTauNumer) < 1e-10;
final double resultRWeight = gadget_.getTotalWtR() + transferredWeight;
final long resultN = n_;
// explicitly set values for the gap
data.set(resultH, null);
weights.set(resultH, -1.0);
// create sketch with the new values
return newInstanceFromUnionResult(data, weights, resultK, resultN, resultH, resultR, resultRWeight);
} | java | private VarOptItemsSketch<T> markMovingGadgetCoercer() {
final int resultK = gadget_.getHRegionCount() + gadget_.getRRegionCount();
int resultH = 0;
int resultR = 0;
int nextRPos = resultK; // = (resultK+1)-1, to fill R region from back to front
final ArrayList<T> data = new ArrayList<>(resultK + 1);
final ArrayList<Double> weights = new ArrayList<>(resultK + 1);
// Need arrays filled to use set() and be able to fill from end forward.
// Ideally would create as arrays but trying to avoid forcing user to pass a Class<?>
for (int i = 0; i < (resultK + 1); ++i) {
data.add(null);
weights.add(null);
}
final VarOptItemsSamples<T> sketchSamples = gadget_.getSketchSamples();
// insert R region items, ignoring weights
// Currently (May 2017) this next block is unreachable; this coercer is used only in the
// pseudo-exact case in which case there are no items natively in R, only marked items in H
// that will be moved into R as part of the coercion process.
Iterator<VarOptItemsSamples<T>.WeightedSample> sketchIterator;
sketchIterator = sketchSamples.getRIterator();
while (sketchIterator.hasNext()) {
final VarOptItemsSamples<T>.WeightedSample ws = sketchIterator.next();
data.set(nextRPos, ws.getItem());
weights.set(nextRPos, -1.0);
++resultR;
--nextRPos;
}
double transferredWeight = 0;
// insert H region items
sketchIterator = sketchSamples.getHIterator();
while (sketchIterator.hasNext()) {
final VarOptItemsSamples<T>.WeightedSample ws = sketchIterator.next();
if (ws.getMark()) {
data.set(nextRPos, ws.getItem());
weights.set(nextRPos, -1.0);
transferredWeight += ws.getWeight();
++resultR;
--nextRPos;
} else {
data.set(resultH, ws.getItem());
weights.set(resultH, ws.getWeight());
++resultH;
}
}
assert (resultH + resultR) == resultK;
assert Math.abs(transferredWeight - outerTauNumer) < 1e-10;
final double resultRWeight = gadget_.getTotalWtR() + transferredWeight;
final long resultN = n_;
// explicitly set values for the gap
data.set(resultH, null);
weights.set(resultH, -1.0);
// create sketch with the new values
return newInstanceFromUnionResult(data, weights, resultK, resultN, resultH, resultR, resultRWeight);
} | [
"private",
"VarOptItemsSketch",
"<",
"T",
">",
"markMovingGadgetCoercer",
"(",
")",
"{",
"final",
"int",
"resultK",
"=",
"gadget_",
".",
"getHRegionCount",
"(",
")",
"+",
"gadget_",
".",
"getRRegionCount",
"(",
")",
";",
"int",
"resultH",
"=",
"0",
";",
"i... | This coercer directly transfers marked items from the gadget's H into the result's R.
Deciding whether that is a valid thing to do is the responsibility of the caller. Currently,
this is only used for a subcase of pseudo-exact, but later it might be used by other
subcases as well.
@return A sketch derived from the gadget, with marked items moved to the reservoir | [
"This",
"coercer",
"directly",
"transfers",
"marked",
"items",
"from",
"the",
"gadget",
"s",
"H",
"into",
"the",
"result",
"s",
"R",
".",
"Deciding",
"whether",
"that",
"is",
"a",
"valid",
"thing",
"to",
"do",
"is",
"the",
"responsibility",
"of",
"the",
... | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsUnion.java#L476-L538 |
alkacon/opencms-core | src/org/opencms/main/CmsShellCommands.java | CmsShellCommands.exportResourcesAndUserdata | public void exportResourcesAndUserdata(String exportFile, String pathList) throws Exception {
exportResourcesAndUserdata(exportFile, pathList, false);
} | java | public void exportResourcesAndUserdata(String exportFile, String pathList) throws Exception {
exportResourcesAndUserdata(exportFile, pathList, false);
} | [
"public",
"void",
"exportResourcesAndUserdata",
"(",
"String",
"exportFile",
",",
"String",
"pathList",
")",
"throws",
"Exception",
"{",
"exportResourcesAndUserdata",
"(",
"exportFile",
",",
"pathList",
",",
"false",
")",
";",
"}"
] | Exports a list of resources from the current site root and the user data to a ZIP file.<p>
The resource names in the list must be separated with a ";".<p>
@param exportFile the name (absolute path) of the ZIP file to export to
@param pathList the list of resource to export, separated with a ";"
@throws Exception if something goes wrong | [
"Exports",
"a",
"list",
"of",
"resources",
"from",
"the",
"current",
"site",
"root",
"and",
"the",
"user",
"data",
"to",
"a",
"ZIP",
"file",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsShellCommands.java#L723-L726 |
mojohaus/jaxb2-maven-plugin | src/main/java/org/codehaus/mojo/jaxb2/shared/arguments/ArgumentBuilder.java | ArgumentBuilder.withFlag | public ArgumentBuilder withFlag(final boolean addFlag, final String flag) {
// Bail out?
if (!addFlag) {
return this;
}
// Check sanity
Validate.notEmpty(flag, "flag");
Validate.isTrue(!AbstractJaxbMojo.CONTAINS_WHITESPACE.matcher(flag).matches(),
"Flags cannot contain whitespace. Got: [" + flag + "]");
// Trim, and add the flag as an argument.
final String trimmed = flag.trim();
Validate.notEmpty(trimmed, "flag");
// Prepend the DASH if required
final String toAdd = trimmed.charAt(0) != DASH ? DASH + trimmed : trimmed;
// Assign the argument only if not already set.
if (getIndexForFlag(toAdd) == NOT_FOUND) {
synchronized (lock) {
arguments.add(toAdd);
}
}
// All done.
return this;
} | java | public ArgumentBuilder withFlag(final boolean addFlag, final String flag) {
// Bail out?
if (!addFlag) {
return this;
}
// Check sanity
Validate.notEmpty(flag, "flag");
Validate.isTrue(!AbstractJaxbMojo.CONTAINS_WHITESPACE.matcher(flag).matches(),
"Flags cannot contain whitespace. Got: [" + flag + "]");
// Trim, and add the flag as an argument.
final String trimmed = flag.trim();
Validate.notEmpty(trimmed, "flag");
// Prepend the DASH if required
final String toAdd = trimmed.charAt(0) != DASH ? DASH + trimmed : trimmed;
// Assign the argument only if not already set.
if (getIndexForFlag(toAdd) == NOT_FOUND) {
synchronized (lock) {
arguments.add(toAdd);
}
}
// All done.
return this;
} | [
"public",
"ArgumentBuilder",
"withFlag",
"(",
"final",
"boolean",
"addFlag",
",",
"final",
"String",
"flag",
")",
"{",
"// Bail out?",
"if",
"(",
"!",
"addFlag",
")",
"{",
"return",
"this",
";",
"}",
"// Check sanity",
"Validate",
".",
"notEmpty",
"(",
"flag... | <p>Adds a flag on the form {@code -someflag} to the list of arguments contained within this ArgumentBuilder.
If the {@code flag} argument does not start with a dash ('-'), one will be prepended.</p>
<p>Typical usage:</p>
<pre><code>
argumentBuilder
.withFlag(someBooleanParameter, "foobar")
.withFlag(someOtherBooleanParameter, "gnat")
.withFlag(someThirdBooleanParameter, "gnu")
....
</code></pre>
@param addFlag if {@code true}, the flag will be added to the underlying list of arguments
within this ArgumentBuilder.
@param flag The flag/argument to add. The flag must be a complete word, implying it
cannot contain whitespace.
@return This ArgumentBuilder, for chaining. | [
"<p",
">",
"Adds",
"a",
"flag",
"on",
"the",
"form",
"{",
"@code",
"-",
"someflag",
"}",
"to",
"the",
"list",
"of",
"arguments",
"contained",
"within",
"this",
"ArgumentBuilder",
".",
"If",
"the",
"{",
"@code",
"flag",
"}",
"argument",
"does",
"not",
"... | train | https://github.com/mojohaus/jaxb2-maven-plugin/blob/e3c4e47943b15282e5a6e850bbfb1588d8452a0a/src/main/java/org/codehaus/mojo/jaxb2/shared/arguments/ArgumentBuilder.java#L74-L102 |
ginere/ginere-base | src/main/java/eu/ginere/base/util/properties/old/GlobalFileProperties.java | GlobalFileProperties.getPropertiesFilePath | public static String getPropertiesFilePath(String filePath) {
// Verificamos is esta definida una propiedad Global para los ficheros de properties
String defaultPath=System.getProperty(GlobalFileProperties.class.getName()+".DefaultPath");
if (defaultPath!=null){
return getFilePath(defaultPath,filePath);
} else {
return filePath;
}
} | java | public static String getPropertiesFilePath(String filePath) {
// Verificamos is esta definida una propiedad Global para los ficheros de properties
String defaultPath=System.getProperty(GlobalFileProperties.class.getName()+".DefaultPath");
if (defaultPath!=null){
return getFilePath(defaultPath,filePath);
} else {
return filePath;
}
} | [
"public",
"static",
"String",
"getPropertiesFilePath",
"(",
"String",
"filePath",
")",
"{",
"// Verificamos is esta definida una propiedad Global para los ficheros de properties\r",
"String",
"defaultPath",
"=",
"System",
".",
"getProperty",
"(",
"GlobalFileProperties",
".",
"c... | Utiliza el valor de la JVM GlobalFileProperties.class.getName()+".DefaultPath"
para obtener el path de la propiedad
@param filePath
@return | [
"Utiliza",
"el",
"valor",
"de",
"la",
"JVM",
"GlobalFileProperties",
".",
"class",
".",
"getName",
"()",
"+",
".",
"DefaultPath",
"para",
"obtener",
"el",
"path",
"de",
"la",
"propiedad"
] | train | https://github.com/ginere/ginere-base/blob/b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24/src/main/java/eu/ginere/base/util/properties/old/GlobalFileProperties.java#L45-L54 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java | Utils.combinePaths | public static String combinePaths(String first, String... other) {
return Paths.get(first, other).toString();
} | java | public static String combinePaths(String first, String... other) {
return Paths.get(first, other).toString();
} | [
"public",
"static",
"String",
"combinePaths",
"(",
"String",
"first",
",",
"String",
"...",
"other",
")",
"{",
"return",
"Paths",
".",
"get",
"(",
"first",
",",
"other",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Combine two or more paths
@param first parent directory path
@param other children
@return combined path | [
"Combine",
"two",
"or",
"more",
"paths"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java#L294-L296 |
Codearte/catch-exception | catch-exception/src/main/java/com/googlecode/catchexception/apis/CatchExceptionHamcrestMatchers.java | CatchExceptionHamcrestMatchers.hasMessageThat | public static <T extends Exception> org.hamcrest.Matcher<T> hasMessageThat(
Matcher<String> stringMatcher) {
return new ExceptionMessageMatcher<>(stringMatcher);
} | java | public static <T extends Exception> org.hamcrest.Matcher<T> hasMessageThat(
Matcher<String> stringMatcher) {
return new ExceptionMessageMatcher<>(stringMatcher);
} | [
"public",
"static",
"<",
"T",
"extends",
"Exception",
">",
"org",
".",
"hamcrest",
".",
"Matcher",
"<",
"T",
">",
"hasMessageThat",
"(",
"Matcher",
"<",
"String",
">",
"stringMatcher",
")",
"{",
"return",
"new",
"ExceptionMessageMatcher",
"<>",
"(",
"stringM... | EXAMPLES:
<code>assertThat(caughtException(), hasMessageThat(is("Index: 9, Size: 9")));
assertThat(caughtException(), hasMessageThat(containsString("Index: 9"))); // using JUnitMatchers
assertThat(caughtException(), hasMessageThat(containsPattern("Index: \\d+"))); // using Mockito's Find</code>
@param <T>
the exception subclass
@param stringMatcher
a string matcher
@return Returns a matcher that matches an exception if the given string
matcher matches the exception message. | [
"EXAMPLES",
":",
"<code",
">",
"assertThat",
"(",
"caughtException",
"()",
"hasMessageThat",
"(",
"is",
"(",
"Index",
":",
"9",
"Size",
":",
"9",
")))",
";",
"assertThat",
"(",
"caughtException",
"()",
"hasMessageThat",
"(",
"containsString",
"(",
"Index",
"... | train | https://github.com/Codearte/catch-exception/blob/8cfb1c0a68661ef622011484ff0061b41796b165/catch-exception/src/main/java/com/googlecode/catchexception/apis/CatchExceptionHamcrestMatchers.java#L88-L91 |
micrometer-metrics/micrometer | micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java | Tags.of | public static Tags of(String key, String value) {
return new Tags(new Tag[]{Tag.of(key, value)});
} | java | public static Tags of(String key, String value) {
return new Tags(new Tag[]{Tag.of(key, value)});
} | [
"public",
"static",
"Tags",
"of",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"new",
"Tags",
"(",
"new",
"Tag",
"[",
"]",
"{",
"Tag",
".",
"of",
"(",
"key",
",",
"value",
")",
"}",
")",
";",
"}"
] | Return a new {@code Tags} instance containing tags constructed from the specified key/value pair.
@param key the tag key to add
@param value the tag value to add
@return a new {@code Tags} instance | [
"Return",
"a",
"new",
"{",
"@code",
"Tags",
"}",
"instance",
"containing",
"tags",
"constructed",
"from",
"the",
"specified",
"key",
"/",
"value",
"pair",
"."
] | train | https://github.com/micrometer-metrics/micrometer/blob/127fa3265325cc894f368312ed8890b76a055d88/micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java#L235-L237 |
mapfish/mapfish-print | core/src/main/java/org/mapfish/print/map/tiled/TileCacheInformation.java | TileCacheInformation.createBufferedImage | @Nonnull
public BufferedImage createBufferedImage(final int imageWidth, final int imageHeight) {
return new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_4BYTE_ABGR);
} | java | @Nonnull
public BufferedImage createBufferedImage(final int imageWidth, final int imageHeight) {
return new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_4BYTE_ABGR);
} | [
"@",
"Nonnull",
"public",
"BufferedImage",
"createBufferedImage",
"(",
"final",
"int",
"imageWidth",
",",
"final",
"int",
"imageHeight",
")",
"{",
"return",
"new",
"BufferedImage",
"(",
"imageWidth",
",",
"imageHeight",
",",
"BufferedImage",
".",
"TYPE_4BYTE_ABGR",
... | Create a buffered image with the correct image bands etc... for the tiles being loaded.
@param imageWidth width of the image to create
@param imageHeight height of the image to create. | [
"Create",
"a",
"buffered",
"image",
"with",
"the",
"correct",
"image",
"bands",
"etc",
"...",
"for",
"the",
"tiles",
"being",
"loaded",
"."
] | train | https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/TileCacheInformation.java#L134-L137 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.fill | public static void fill(DMatrixD1 a, double value)
{
Arrays.fill(a.data, 0, a.getNumElements(), value);
} | java | public static void fill(DMatrixD1 a, double value)
{
Arrays.fill(a.data, 0, a.getNumElements(), value);
} | [
"public",
"static",
"void",
"fill",
"(",
"DMatrixD1",
"a",
",",
"double",
"value",
")",
"{",
"Arrays",
".",
"fill",
"(",
"a",
".",
"data",
",",
"0",
",",
"a",
".",
"getNumElements",
"(",
")",
",",
"value",
")",
";",
"}"
] | <p>
Sets every element in the matrix to the specified value.<br>
<br>
a<sub>ij</sub> = value
<p>
@param a A matrix whose elements are about to be set. Modified.
@param value The value each element will have. | [
"<p",
">",
"Sets",
"every",
"element",
"in",
"the",
"matrix",
"to",
"the",
"specified",
"value",
".",
"<br",
">",
"<br",
">",
"a<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"value",
"<p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L2549-L2552 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/hessenberg/TridiagonalHelper_DDRB.java | TridiagonalHelper_DDRB.computeV_blockVector | public static void computeV_blockVector( final int blockLength ,
final DSubmatrixD1 A ,
final double gammas[] ,
final DSubmatrixD1 V )
{
int blockHeight = Math.min(blockLength,A.row1-A.row0);
if( blockHeight <= 1 )
return;
int width = A.col1-A.col0;
int num = Math.min(width-1,blockHeight);
for( int i = 0; i < num; i++ ) {
double gamma = gammas[A.row0+i];
// compute y
computeY(blockLength,A,V,i,gamma);
// compute v from y
computeRowOfV(blockLength,A,V,i,gamma);
}
} | java | public static void computeV_blockVector( final int blockLength ,
final DSubmatrixD1 A ,
final double gammas[] ,
final DSubmatrixD1 V )
{
int blockHeight = Math.min(blockLength,A.row1-A.row0);
if( blockHeight <= 1 )
return;
int width = A.col1-A.col0;
int num = Math.min(width-1,blockHeight);
for( int i = 0; i < num; i++ ) {
double gamma = gammas[A.row0+i];
// compute y
computeY(blockLength,A,V,i,gamma);
// compute v from y
computeRowOfV(blockLength,A,V,i,gamma);
}
} | [
"public",
"static",
"void",
"computeV_blockVector",
"(",
"final",
"int",
"blockLength",
",",
"final",
"DSubmatrixD1",
"A",
",",
"final",
"double",
"gammas",
"[",
"]",
",",
"final",
"DSubmatrixD1",
"V",
")",
"{",
"int",
"blockHeight",
"=",
"Math",
".",
"min",... | <p>
Given an already computed tridiagonal decomposition, compute the V row block vector.<br>
<br>
y(:) = A*u<br>
v(i) = y - (1/2)*γ*(y^T*u)*u
</p> | [
"<p",
">",
"Given",
"an",
"already",
"computed",
"tridiagonal",
"decomposition",
"compute",
"the",
"V",
"row",
"block",
"vector",
".",
"<br",
">",
"<br",
">",
"y",
"(",
":",
")",
"=",
"A",
"*",
"u<br",
">",
"v",
"(",
"i",
")",
"=",
"y",
"-",
"(",... | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/hessenberg/TridiagonalHelper_DDRB.java#L143-L163 |
ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java | Ajax.loadLink | public static Promise loadLink(final String rel, final String url) {
GQuery link = $("link[rel='" + rel + "'][href^='" + url + "']");
if (link.isEmpty()) {
return new PromiseFunction() {
public void f(final Deferred dfd) {
GQuery link = $("<link rel='" + rel + "' href='" + url + "'/>");
link.on("load", new Function() {
public void f() {
// load event is fired before the imported stuff has actually
// being ready, we delay it to be sure it is ready.
new Timer() {
public void run() {
dfd.resolve();
}
}.schedule(100);
}
});
$(document.getHead()).append(link);
}
};
} else {
return Deferred().resolve().promise();
}
} | java | public static Promise loadLink(final String rel, final String url) {
GQuery link = $("link[rel='" + rel + "'][href^='" + url + "']");
if (link.isEmpty()) {
return new PromiseFunction() {
public void f(final Deferred dfd) {
GQuery link = $("<link rel='" + rel + "' href='" + url + "'/>");
link.on("load", new Function() {
public void f() {
// load event is fired before the imported stuff has actually
// being ready, we delay it to be sure it is ready.
new Timer() {
public void run() {
dfd.resolve();
}
}.schedule(100);
}
});
$(document.getHead()).append(link);
}
};
} else {
return Deferred().resolve().promise();
}
} | [
"public",
"static",
"Promise",
"loadLink",
"(",
"final",
"String",
"rel",
",",
"final",
"String",
"url",
")",
"{",
"GQuery",
"link",
"=",
"$",
"(",
"\"link[rel='\"",
"+",
"rel",
"+",
"\"'][href^='\"",
"+",
"url",
"+",
"\"']\"",
")",
";",
"if",
"(",
"li... | Load an external resource using the link tag element.
It is appended to the head of the document.
@param rel Specifies the relationship between the current document and the linked document.
@param url Specifies the location of the linked document
@return a Promise which will be resolved when the external resource has been loaded. | [
"Load",
"an",
"external",
"resource",
"using",
"the",
"link",
"tag",
"element",
".",
"It",
"is",
"appended",
"to",
"the",
"head",
"of",
"the",
"document",
"."
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java#L473-L496 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.fromHSB | public static Vector4f fromHSB(float hue, float saturation, float brightness) {
float r = 0;
float g = 0;
float b = 0;
if (saturation == 0) {
r = g = b = brightness;
} else {
final float h = (hue - GenericMath.floor(hue)) * 6;
final float f = h - GenericMath.floor(h);
final float p = brightness * (1 - saturation);
final float q = brightness * (1 - saturation * f);
final float t = brightness * (1 - saturation * (1 - f));
switch ((int) h) {
case 0:
r = brightness;
g = t;
b = p;
break;
case 1:
r = q;
g = brightness;
b = p;
break;
case 2:
r = p;
g = brightness;
b = t;
break;
case 3:
r = p;
g = q;
b = brightness;
break;
case 4:
r = t;
g = p;
b = brightness;
break;
case 5:
r = brightness;
g = p;
b = q;
break;
}
}
return new Vector4f(r, g, b, 1);
} | java | public static Vector4f fromHSB(float hue, float saturation, float brightness) {
float r = 0;
float g = 0;
float b = 0;
if (saturation == 0) {
r = g = b = brightness;
} else {
final float h = (hue - GenericMath.floor(hue)) * 6;
final float f = h - GenericMath.floor(h);
final float p = brightness * (1 - saturation);
final float q = brightness * (1 - saturation * f);
final float t = brightness * (1 - saturation * (1 - f));
switch ((int) h) {
case 0:
r = brightness;
g = t;
b = p;
break;
case 1:
r = q;
g = brightness;
b = p;
break;
case 2:
r = p;
g = brightness;
b = t;
break;
case 3:
r = p;
g = q;
b = brightness;
break;
case 4:
r = t;
g = p;
b = brightness;
break;
case 5:
r = brightness;
g = p;
b = q;
break;
}
}
return new Vector4f(r, g, b, 1);
} | [
"public",
"static",
"Vector4f",
"fromHSB",
"(",
"float",
"hue",
",",
"float",
"saturation",
",",
"float",
"brightness",
")",
"{",
"float",
"r",
"=",
"0",
";",
"float",
"g",
"=",
"0",
";",
"float",
"b",
"=",
"0",
";",
"if",
"(",
"saturation",
"==",
... | Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model. The <code>saturation</code> and <code>brightness</code> components
should be floating-point values between zero and one (numbers in the range [0, 1]). The <code>hue</code> component can be any floating-point number. Alpha will be 1.
@param hue The hue component of the color
@param saturation The saturation of the color
@param brightness The brightness of the color
@return The color as a 4 float vector | [
"Converts",
"the",
"components",
"of",
"a",
"color",
"as",
"specified",
"by",
"the",
"HSB",
"model",
"to",
"an",
"equivalent",
"set",
"of",
"values",
"for",
"the",
"default",
"RGB",
"model",
".",
"The",
"<code",
">",
"saturation<",
"/",
"code",
">",
"and... | train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L303-L349 |
codeborne/mobileid | src/com/codeborne/security/mobileid/MobileIDAuthenticator.java | MobileIDAuthenticator.startLogin | public MobileIDSession startLogin(String personalCode, String countryCode) {
return startLogin(personalCode, countryCode, null);
} | java | public MobileIDSession startLogin(String personalCode, String countryCode) {
return startLogin(personalCode, countryCode, null);
} | [
"public",
"MobileIDSession",
"startLogin",
"(",
"String",
"personalCode",
",",
"String",
"countryCode",
")",
"{",
"return",
"startLogin",
"(",
"personalCode",
",",
"countryCode",
",",
"null",
")",
";",
"}"
] | Initiates the login session. Note: returned session already contains user's info, but the authenticity is not yet verified.
@param personalCode user's personal code
@param countryCode two letter country code, eg EE
@throws AuthenticationException is authentication unsuccessful
@return MobileIDSession instance containing CHALLENGE ID that should be shown to the user | [
"Initiates",
"the",
"login",
"session",
".",
"Note",
":",
"returned",
"session",
"already",
"contains",
"user",
"s",
"info",
"but",
"the",
"authenticity",
"is",
"not",
"yet",
"verified",
"."
] | train | https://github.com/codeborne/mobileid/blob/27447009922f7a1f80c956c2ee5e9ff7a17d7bfc/src/com/codeborne/security/mobileid/MobileIDAuthenticator.java#L102-L104 |
js-lib-com/commons | src/main/java/js/util/Classes.java | Classes.setFieldValue | public static void setFieldValue(Object object, String fieldName, Object value)
{
Params.notNull(object, "Object instance or class");
Params.notNull(fieldName, "Field name");
if(object instanceof Class<?>) {
setFieldValue(null, (Class<?>)object, fieldName, value);
}
else {
setFieldValue(object, object.getClass(), fieldName, value);
}
} | java | public static void setFieldValue(Object object, String fieldName, Object value)
{
Params.notNull(object, "Object instance or class");
Params.notNull(fieldName, "Field name");
if(object instanceof Class<?>) {
setFieldValue(null, (Class<?>)object, fieldName, value);
}
else {
setFieldValue(object, object.getClass(), fieldName, value);
}
} | [
"public",
"static",
"void",
"setFieldValue",
"(",
"Object",
"object",
",",
"String",
"fieldName",
",",
"Object",
"value",
")",
"{",
"Params",
".",
"notNull",
"(",
"object",
",",
"\"Object instance or class\"",
")",
";",
"Params",
".",
"notNull",
"(",
"fieldNam... | Set instance or class field value. Try to set field value throwing exception if field not found. If
<code>object</code> argument is a class, named field should be static; otherwise exception is thrown.
<p>
This setter tries to adapt <code>value</code> to field type: if <code>value</code> is a string and field type is
not, delegates {@link Converter#asObject(String, Class)}. Anyway, if <code>value</code> is not a string it should
be assignable to field type otherwise bug error is thrown.
@param object instance or class to set field value to,
@param fieldName field name,
@param value field value.
@throws IllegalArgumentException if <code>object</code> or <code>fieldName</code> argument is null.
@throws NoSuchBeingException if field not found.
@throws BugError if object is null and field is not static or if object is not null and field is static.
@throws BugError if value is not assignable to field type. | [
"Set",
"instance",
"or",
"class",
"field",
"value",
".",
"Try",
"to",
"set",
"field",
"value",
"throwing",
"exception",
"if",
"field",
"not",
"found",
".",
"If",
"<code",
">",
"object<",
"/",
"code",
">",
"argument",
"is",
"a",
"class",
"named",
"field",... | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Classes.java#L865-L875 |
pmlopes/yoke | framework/src/main/java/com/jetdrone/vertx/yoke/MimeType.java | MimeType.getMime | public static String getMime(@NotNull String file, String defaultMimeType) {
int sep = file.lastIndexOf('.');
if (sep != -1) {
String extension = file.substring(sep + 1, file.length());
String mime = mimes.get(extension);
if (mime != null) {
return mime;
}
}
return defaultMimeType;
} | java | public static String getMime(@NotNull String file, String defaultMimeType) {
int sep = file.lastIndexOf('.');
if (sep != -1) {
String extension = file.substring(sep + 1, file.length());
String mime = mimes.get(extension);
if (mime != null) {
return mime;
}
}
return defaultMimeType;
} | [
"public",
"static",
"String",
"getMime",
"(",
"@",
"NotNull",
"String",
"file",
",",
"String",
"defaultMimeType",
")",
"{",
"int",
"sep",
"=",
"file",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"sep",
"!=",
"-",
"1",
")",
"{",
"String",
... | Returns a mime type string by parsing the file extension of a file string. If the extension is not found or
unknown the default value is returned.
@param file path to a file with extension
@param defaultMimeType what to return if not found
@return mime type | [
"Returns",
"a",
"mime",
"type",
"string",
"by",
"parsing",
"the",
"file",
"extension",
"of",
"a",
"file",
"string",
".",
"If",
"the",
"extension",
"is",
"not",
"found",
"or",
"unknown",
"the",
"default",
"value",
"is",
"returned",
"."
] | train | https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/MimeType.java#L76-L89 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/MediaservicesInner.java | MediaservicesInner.createOrUpdate | public MediaServiceInner createOrUpdate(String resourceGroupName, String accountName, MediaServiceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body();
} | java | public MediaServiceInner createOrUpdate(String resourceGroupName, String accountName, MediaServiceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().body();
} | [
"public",
"MediaServiceInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"MediaServiceInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"param... | Create or update a Media Services account.
Creates or updates a Media Services account.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param parameters The request parameters
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the MediaServiceInner object if successful. | [
"Create",
"or",
"update",
"a",
"Media",
"Services",
"account",
".",
"Creates",
"or",
"updates",
"a",
"Media",
"Services",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/MediaservicesInner.java#L333-L335 |
overturetool/overture | core/typechecker/src/main/java/org/overture/typechecker/visitor/AbstractTypeCheckVisitor.java | AbstractTypeCheckVisitor.typeCheckLet | protected PType typeCheckLet(INode node, LinkedList<PDefinition> localDefs,
INode body, TypeCheckInfo question) throws AnalysisException
{
// Each local definition is in scope for later local definitions...
Environment local = question.env;
for (PDefinition d : localDefs)
{
if (d instanceof AExplicitFunctionDefinition)
{
// Functions' names are in scope in their bodies, whereas
// simple variable declarations aren't
local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative
question.assistantFactory.createPDefinitionAssistant().implicitDefinitions(d, local);
question.assistantFactory.createPDefinitionAssistant().typeResolve(d, THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
if (question.env.isVDMPP())
{
SClassDefinition cdef = question.env.findClassDefinition();
// question.assistantFactory.createPDefinitionAssistant().setClassDefinition(d, cdef);
d.setClassDefinition(cdef);
d.setAccess(question.assistantFactory.createPAccessSpecifierAssistant().getStatic(d, true));
}
d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
} else
{
question.assistantFactory.createPDefinitionAssistant().implicitDefinitions(d, local);
question.assistantFactory.createPDefinitionAssistant().typeResolve(d, THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope));
local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative
}
}
PType r = body.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, null, question.constraint, null));
local.unusedCheck(question.env);
return r;
} | java | protected PType typeCheckLet(INode node, LinkedList<PDefinition> localDefs,
INode body, TypeCheckInfo question) throws AnalysisException
{
// Each local definition is in scope for later local definitions...
Environment local = question.env;
for (PDefinition d : localDefs)
{
if (d instanceof AExplicitFunctionDefinition)
{
// Functions' names are in scope in their bodies, whereas
// simple variable declarations aren't
local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative
question.assistantFactory.createPDefinitionAssistant().implicitDefinitions(d, local);
question.assistantFactory.createPDefinitionAssistant().typeResolve(d, THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
if (question.env.isVDMPP())
{
SClassDefinition cdef = question.env.findClassDefinition();
// question.assistantFactory.createPDefinitionAssistant().setClassDefinition(d, cdef);
d.setClassDefinition(cdef);
d.setAccess(question.assistantFactory.createPAccessSpecifierAssistant().getStatic(d, true));
}
d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
} else
{
question.assistantFactory.createPDefinitionAssistant().implicitDefinitions(d, local);
question.assistantFactory.createPDefinitionAssistant().typeResolve(d, THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers));
d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope));
local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative
}
}
PType r = body.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, null, question.constraint, null));
local.unusedCheck(question.env);
return r;
} | [
"protected",
"PType",
"typeCheckLet",
"(",
"INode",
"node",
",",
"LinkedList",
"<",
"PDefinition",
">",
"localDefs",
",",
"INode",
"body",
",",
"TypeCheckInfo",
"question",
")",
"throws",
"AnalysisException",
"{",
"// Each local definition is in scope for later local defi... | Type checks a let node
@param node
@param localDefs
@param body
@param question
@return
@throws AnalysisException | [
"Type",
"checks",
"a",
"let",
"node"
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/typechecker/src/main/java/org/overture/typechecker/visitor/AbstractTypeCheckVisitor.java#L192-L231 |
httl/httl | httl/src/main/java/httl/spi/codecs/json/JSONArray.java | JSONArray.getBoolean | public boolean getBoolean(int index, boolean def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Boolean ? ((Boolean) tmp)
.booleanValue() : def;
} | java | public boolean getBoolean(int index, boolean def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Boolean ? ((Boolean) tmp)
.booleanValue() : def;
} | [
"public",
"boolean",
"getBoolean",
"(",
"int",
"index",
",",
"boolean",
"def",
")",
"{",
"Object",
"tmp",
"=",
"mArray",
".",
"get",
"(",
"index",
")",
";",
"return",
"tmp",
"!=",
"null",
"&&",
"tmp",
"instanceof",
"Boolean",
"?",
"(",
"(",
"Boolean",
... | get boolean value.
@param index index.
@param def default value.
@return value or default value. | [
"get",
"boolean",
"value",
"."
] | train | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/spi/codecs/json/JSONArray.java#L49-L53 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/ScreenField.java | ScreenField.doCommand | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions)
{
if (this.getScreenFieldView() != null)
{
if (MenuConstants.SELECT.equalsIgnoreCase(strCommand))
if ((iCommandOptions & ScreenConstants.USE_NEW_WINDOW) == ScreenConstants.USE_NEW_WINDOW)
strCommand = MenuConstants.SELECT_DONT_CLOSE; // Special - Click select w/shift = don't close
return this.getScreenFieldView().doCommand(strCommand); // Give my view the first shot.
}
return false; // Not processed, BasePanels and above will override
} | java | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions)
{
if (this.getScreenFieldView() != null)
{
if (MenuConstants.SELECT.equalsIgnoreCase(strCommand))
if ((iCommandOptions & ScreenConstants.USE_NEW_WINDOW) == ScreenConstants.USE_NEW_WINDOW)
strCommand = MenuConstants.SELECT_DONT_CLOSE; // Special - Click select w/shift = don't close
return this.getScreenFieldView().doCommand(strCommand); // Give my view the first shot.
}
return false; // Not processed, BasePanels and above will override
} | [
"public",
"boolean",
"doCommand",
"(",
"String",
"strCommand",
",",
"ScreenField",
"sourceSField",
",",
"int",
"iCommandOptions",
")",
"{",
"if",
"(",
"this",
".",
"getScreenFieldView",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"MenuConstants",
".",
"SELE... | Process the command.
<br />Step 1 - Process the command if possible and return true if processed.
<br />Step 2 - If I can't process, pass to all children (with me as the source).
<br />Step 3 - If children didn't process, pass to parent (with me as the source).
<br />Note: Never pass to a parent or child that matches the source (to avoid an endless loop).
@param strCommand The command to process.
@param sourceSField The source screen field (to avoid echos).
@param iCommandOptions If this command creates a new screen, create in a new window?
@return true if success. | [
"Process",
"the",
"command",
".",
"<br",
"/",
">",
"Step",
"1",
"-",
"Process",
"the",
"command",
"if",
"possible",
"and",
"return",
"true",
"if",
"processed",
".",
"<br",
"/",
">",
"Step",
"2",
"-",
"If",
"I",
"can",
"t",
"process",
"pass",
"to",
... | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/ScreenField.java#L269-L279 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java | DynamoDBMapper.untransformAttributes | protected Map<String, AttributeValue> untransformAttributes(Class<?> clazz, Map<String, AttributeValue> attributeValues) {
Method hashKeyGetter = reflector.getHashKeyGetter(clazz);
String hashKeyName = reflector.getAttributeName(hashKeyGetter);
Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
String rangeKeyName = rangeKeyGetter == null ? null : reflector.getAttributeName(rangeKeyGetter);
return untransformAttributes(hashKeyName, rangeKeyName, attributeValues);
} | java | protected Map<String, AttributeValue> untransformAttributes(Class<?> clazz, Map<String, AttributeValue> attributeValues) {
Method hashKeyGetter = reflector.getHashKeyGetter(clazz);
String hashKeyName = reflector.getAttributeName(hashKeyGetter);
Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
String rangeKeyName = rangeKeyGetter == null ? null : reflector.getAttributeName(rangeKeyGetter);
return untransformAttributes(hashKeyName, rangeKeyName, attributeValues);
} | [
"protected",
"Map",
"<",
"String",
",",
"AttributeValue",
">",
"untransformAttributes",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Map",
"<",
"String",
",",
"AttributeValue",
">",
"attributeValues",
")",
"{",
"Method",
"hashKeyGetter",
"=",
"reflector",
".",
... | By default, just calls {@link #untransformAttributes(String, String, Map)}.
@param clazz
@param attributeValues
@return the decrypted attribute values | [
"By",
"default",
"just",
"calls",
"{"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java#L1347-L1353 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.