repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 188 | func_name stringlengths 7 127 | whole_func_string stringlengths 77 3.91k | language stringclasses 1
value | func_code_string stringlengths 77 3.91k | func_code_tokens listlengths 20 745 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 477 | split_name stringclasses 1
value | func_code_url stringlengths 111 288 |
|---|---|---|---|---|---|---|---|---|---|---|
google/closure-compiler | src/com/google/javascript/refactoring/ApplySuggestedFixes.java | ApplySuggestedFixes.applyCodeReplacements | public static String applyCodeReplacements(Iterable<CodeReplacement> replacements, String code) {
List<CodeReplacement> sortedReplacements = ORDER_CODE_REPLACEMENTS.sortedCopy(replacements);
validateNoOverlaps(sortedReplacements);
StringBuilder sb = new StringBuilder();
int lastIndex = 0;
for (CodeReplacement replacement : sortedReplacements) {
sb.append(code, lastIndex, replacement.getStartPosition());
sb.append(replacement.getNewContent());
lastIndex = replacement.getEndPosition();
}
if (lastIndex <= code.length()) {
sb.append(code, lastIndex, code.length());
}
return sb.toString();
} | java | public static String applyCodeReplacements(Iterable<CodeReplacement> replacements, String code) {
List<CodeReplacement> sortedReplacements = ORDER_CODE_REPLACEMENTS.sortedCopy(replacements);
validateNoOverlaps(sortedReplacements);
StringBuilder sb = new StringBuilder();
int lastIndex = 0;
for (CodeReplacement replacement : sortedReplacements) {
sb.append(code, lastIndex, replacement.getStartPosition());
sb.append(replacement.getNewContent());
lastIndex = replacement.getEndPosition();
}
if (lastIndex <= code.length()) {
sb.append(code, lastIndex, code.length());
}
return sb.toString();
} | [
"public",
"static",
"String",
"applyCodeReplacements",
"(",
"Iterable",
"<",
"CodeReplacement",
">",
"replacements",
",",
"String",
"code",
")",
"{",
"List",
"<",
"CodeReplacement",
">",
"sortedReplacements",
"=",
"ORDER_CODE_REPLACEMENTS",
".",
"sortedCopy",
"(",
"... | Applies the provided set of code replacements to the code and returns the transformed code.
The code replacements may not have any overlap. | [
"Applies",
"the",
"provided",
"set",
"of",
"code",
"replacements",
"to",
"the",
"code",
"and",
"returns",
"the",
"transformed",
"code",
".",
"The",
"code",
"replacements",
"may",
"not",
"have",
"any",
"overlap",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/refactoring/ApplySuggestedFixes.java#L146-L161 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/ByteArrayUtil.java | ByteArrayUtil.putLongBE | public static void putLongBE(final byte[] array, final int offset, final long value) {
array[offset + 7] = (byte) (value );
array[offset + 6] = (byte) (value >>> 8);
array[offset + 5] = (byte) (value >>> 16);
array[offset + 4] = (byte) (value >>> 24);
array[offset + 3] = (byte) (value >>> 32);
array[offset + 2] = (byte) (value >>> 40);
array[offset + 1] = (byte) (value >>> 48);
array[offset ] = (byte) (value >>> 56);
} | java | public static void putLongBE(final byte[] array, final int offset, final long value) {
array[offset + 7] = (byte) (value );
array[offset + 6] = (byte) (value >>> 8);
array[offset + 5] = (byte) (value >>> 16);
array[offset + 4] = (byte) (value >>> 24);
array[offset + 3] = (byte) (value >>> 32);
array[offset + 2] = (byte) (value >>> 40);
array[offset + 1] = (byte) (value >>> 48);
array[offset ] = (byte) (value >>> 56);
} | [
"public",
"static",
"void",
"putLongBE",
"(",
"final",
"byte",
"[",
"]",
"array",
",",
"final",
"int",
"offset",
",",
"final",
"long",
"value",
")",
"{",
"array",
"[",
"offset",
"+",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
")",
";",
"array",... | Put the source <i>long</i> into the destination byte array starting at the given offset
in big endian order.
There is no bounds checking.
@param array destination byte array
@param offset destination starting point
@param value source <i>long</i> | [
"Put",
"the",
"source",
"<i",
">",
"long<",
"/",
"i",
">",
"into",
"the",
"destination",
"byte",
"array",
"starting",
"at",
"the",
"given",
"offset",
"in",
"big",
"endian",
"order",
".",
"There",
"is",
"no",
"bounds",
"checking",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/ByteArrayUtil.java#L182-L191 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLAlpnNegotiator.java | SSLAlpnNegotiator.tryToRegisterAlpnNegotiator | protected ThirdPartyAlpnNegotiator tryToRegisterAlpnNegotiator(SSLEngine engine, SSLConnectionLink link, boolean useAlpn) {
if (isNativeAlpnActive()) {
if (useAlpn) {
registerNativeAlpn(engine);
}
} else if (isIbmAlpnActive()) {
registerIbmAlpn(engine, useAlpn);
} else if (this.isJettyAlpnActive() && useAlpn) {
return registerJettyAlpn(engine, link);
} else if (this.isGrizzlyAlpnActive() && useAlpn) {
return registerGrizzlyAlpn(engine, link);
}
return null;
} | java | protected ThirdPartyAlpnNegotiator tryToRegisterAlpnNegotiator(SSLEngine engine, SSLConnectionLink link, boolean useAlpn) {
if (isNativeAlpnActive()) {
if (useAlpn) {
registerNativeAlpn(engine);
}
} else if (isIbmAlpnActive()) {
registerIbmAlpn(engine, useAlpn);
} else if (this.isJettyAlpnActive() && useAlpn) {
return registerJettyAlpn(engine, link);
} else if (this.isGrizzlyAlpnActive() && useAlpn) {
return registerGrizzlyAlpn(engine, link);
}
return null;
} | [
"protected",
"ThirdPartyAlpnNegotiator",
"tryToRegisterAlpnNegotiator",
"(",
"SSLEngine",
"engine",
",",
"SSLConnectionLink",
"link",
",",
"boolean",
"useAlpn",
")",
"{",
"if",
"(",
"isNativeAlpnActive",
"(",
")",
")",
"{",
"if",
"(",
"useAlpn",
")",
"{",
"registe... | Check for the Java 9 ALPN API, IBM's ALPNJSSEExt, jetty-alpn, and grizzly-npn; if any are present, set up the connection for ALPN.
Order of preference is Java 9 ALPN API, IBM's ALPNJSSEExt, jetty-alpn, then grizzly-npn.
@param SSLEngine
@param SSLConnectionLink
@param useAlpn true if alpn should be used
@return ThirdPartyAlpnNegotiator used for this connection,
or null if ALPN is not available or the Java 9 / IBM provider was used | [
"Check",
"for",
"the",
"Java",
"9",
"ALPN",
"API",
"IBM",
"s",
"ALPNJSSEExt",
"jetty",
"-",
"alpn",
"and",
"grizzly",
"-",
"npn",
";",
"if",
"any",
"are",
"present",
"set",
"up",
"the",
"connection",
"for",
"ALPN",
".",
"Order",
"of",
"preference",
"is... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLAlpnNegotiator.java#L202-L215 |
datastax/java-driver | core/src/main/java/com/datastax/oss/driver/internal/core/channel/DriverChannel.java | DriverChannel.setKeyspace | public Future<Void> setKeyspace(CqlIdentifier newKeyspace) {
Promise<Void> promise = channel.eventLoop().newPromise();
channel.pipeline().fireUserEventTriggered(new SetKeyspaceEvent(newKeyspace, promise));
return promise;
} | java | public Future<Void> setKeyspace(CqlIdentifier newKeyspace) {
Promise<Void> promise = channel.eventLoop().newPromise();
channel.pipeline().fireUserEventTriggered(new SetKeyspaceEvent(newKeyspace, promise));
return promise;
} | [
"public",
"Future",
"<",
"Void",
">",
"setKeyspace",
"(",
"CqlIdentifier",
"newKeyspace",
")",
"{",
"Promise",
"<",
"Void",
">",
"promise",
"=",
"channel",
".",
"eventLoop",
"(",
")",
".",
"newPromise",
"(",
")",
";",
"channel",
".",
"pipeline",
"(",
")"... | Switches the underlying Cassandra connection to a new keyspace (as if a {@code USE ...}
statement was issued).
<p>The future will complete once the change is effective. Only one change may run at a given
time, concurrent attempts will fail.
<p>Changing the keyspace is inherently thread-unsafe: if other queries are running at the same
time, the keyspace they will use is unpredictable. | [
"Switches",
"the",
"underlying",
"Cassandra",
"connection",
"to",
"a",
"new",
"keyspace",
"(",
"as",
"if",
"a",
"{",
"@code",
"USE",
"...",
"}",
"statement",
"was",
"issued",
")",
"."
] | train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/core/src/main/java/com/datastax/oss/driver/internal/core/channel/DriverChannel.java#L109-L113 |
xcesco/kripton | kripton-core/src/main/java/com/abubusoft/kripton/common/DynamicByteBufferHelper.java | DynamicByteBufferHelper.insertDoubleInto | public static byte[] insertDoubleInto(byte[] array, int index, double value) {
byte[] holder = new byte[4];
doubleTo(holder, 0, value);
return insert(array, index, holder);
} | java | public static byte[] insertDoubleInto(byte[] array, int index, double value) {
byte[] holder = new byte[4];
doubleTo(holder, 0, value);
return insert(array, index, holder);
} | [
"public",
"static",
"byte",
"[",
"]",
"insertDoubleInto",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"index",
",",
"double",
"value",
")",
"{",
"byte",
"[",
"]",
"holder",
"=",
"new",
"byte",
"[",
"4",
"]",
";",
"doubleTo",
"(",
"holder",
",",
"0"... | Insert double into.
@param array the array
@param index the index
@param value the value
@return the byte[] | [
"Insert",
"double",
"into",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-core/src/main/java/com/abubusoft/kripton/common/DynamicByteBufferHelper.java#L927-L932 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java | JCudaDriver.cuGraphicsResourceGetMappedPointer | public static int cuGraphicsResourceGetMappedPointer( CUdeviceptr pDevPtr, long pSize[], CUgraphicsResource resource )
{
return checkResult(cuGraphicsResourceGetMappedPointerNative(pDevPtr, pSize, resource));
} | java | public static int cuGraphicsResourceGetMappedPointer( CUdeviceptr pDevPtr, long pSize[], CUgraphicsResource resource )
{
return checkResult(cuGraphicsResourceGetMappedPointerNative(pDevPtr, pSize, resource));
} | [
"public",
"static",
"int",
"cuGraphicsResourceGetMappedPointer",
"(",
"CUdeviceptr",
"pDevPtr",
",",
"long",
"pSize",
"[",
"]",
",",
"CUgraphicsResource",
"resource",
")",
"{",
"return",
"checkResult",
"(",
"cuGraphicsResourceGetMappedPointerNative",
"(",
"pDevPtr",
","... | Get a device pointer through which to access a mapped graphics resource.
<pre>
CUresult cuGraphicsResourceGetMappedPointer (
CUdeviceptr* pDevPtr,
size_t* pSize,
CUgraphicsResource resource )
</pre>
<div>
<p>Get a device pointer through which to
access a mapped graphics resource. Returns in <tt>*pDevPtr</tt> a
pointer through which the mapped graphics resource <tt>resource</tt>
may be accessed. Returns in <tt>pSize</tt> the size of the memory in
bytes which may be accessed from that pointer. The value set in <tt>pPointer</tt> may change every time that <tt>resource</tt> is
mapped.
</p>
<p>If <tt>resource</tt> is not a buffer
then it cannot be accessed via a pointer and CUDA_ERROR_NOT_MAPPED_AS_POINTER
is returned. If <tt>resource</tt> is not mapped then CUDA_ERROR_NOT_MAPPED
is returned. *
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param pDevPtr Returned pointer through which resource may be accessed
@param pSize Returned size of the buffer accessible starting at *pPointer
@param resource Mapped resource to access
@return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE,
CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPEDCUDA_ERROR_NOT_MAPPED_AS_POINTER
@see JCudaDriver#cuGraphicsMapResources
@see JCudaDriver#cuGraphicsSubResourceGetMappedArray | [
"Get",
"a",
"device",
"pointer",
"through",
"which",
"to",
"access",
"a",
"mapped",
"graphics",
"resource",
"."
] | train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L15961-L15964 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/StreamRecord.java | StreamRecord.withNewImage | public StreamRecord withNewImage(java.util.Map<String, AttributeValue> newImage) {
setNewImage(newImage);
return this;
} | java | public StreamRecord withNewImage(java.util.Map<String, AttributeValue> newImage) {
setNewImage(newImage);
return this;
} | [
"public",
"StreamRecord",
"withNewImage",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"AttributeValue",
">",
"newImage",
")",
"{",
"setNewImage",
"(",
"newImage",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The item in the DynamoDB table as it appeared after it was modified.
</p>
@param newImage
The item in the DynamoDB table as it appeared after it was modified.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"item",
"in",
"the",
"DynamoDB",
"table",
"as",
"it",
"appeared",
"after",
"it",
"was",
"modified",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/StreamRecord.java#L239-L242 |
b3log/latke | latke-core/src/main/java/org/b3log/latke/plugin/PluginManager.java | PluginManager.setPluginProps | private static void setPluginProps(final String pluginDirName, final AbstractPlugin plugin, final Properties props) throws Exception {
final String author = props.getProperty(Plugin.PLUGIN_AUTHOR);
final String name = props.getProperty(Plugin.PLUGIN_NAME);
final String version = props.getProperty(Plugin.PLUGIN_VERSION);
final String types = props.getProperty(Plugin.PLUGIN_TYPES);
LOGGER.log(Level.TRACE, "Plugin[name={0}, author={1}, version={2}, types={3}]", name, author, version, types);
plugin.setAuthor(author);
plugin.setName(name);
plugin.setId(name + "_" + version);
plugin.setVersion(version);
plugin.setDir(pluginDirName);
plugin.readLangs();
// try to find the setting config.json
final File settingFile = Latkes.getWebFile("/plugins/" + pluginDirName + "/config.json");
if (null != settingFile && settingFile.exists()) {
try {
final String config = FileUtils.readFileToString(settingFile);
final JSONObject jsonObject = new JSONObject(config);
plugin.setSetting(jsonObject);
} catch (final IOException ie) {
LOGGER.log(Level.ERROR, "reading the config of the plugin[" + name + "] failed", ie);
} catch (final JSONException e) {
LOGGER.log(Level.ERROR, "convert the config of the plugin[" + name + "] to json failed", e);
}
}
Arrays.stream(types.split(",")).map(PluginType::valueOf).forEach(plugin::addType);
} | java | private static void setPluginProps(final String pluginDirName, final AbstractPlugin plugin, final Properties props) throws Exception {
final String author = props.getProperty(Plugin.PLUGIN_AUTHOR);
final String name = props.getProperty(Plugin.PLUGIN_NAME);
final String version = props.getProperty(Plugin.PLUGIN_VERSION);
final String types = props.getProperty(Plugin.PLUGIN_TYPES);
LOGGER.log(Level.TRACE, "Plugin[name={0}, author={1}, version={2}, types={3}]", name, author, version, types);
plugin.setAuthor(author);
plugin.setName(name);
plugin.setId(name + "_" + version);
plugin.setVersion(version);
plugin.setDir(pluginDirName);
plugin.readLangs();
// try to find the setting config.json
final File settingFile = Latkes.getWebFile("/plugins/" + pluginDirName + "/config.json");
if (null != settingFile && settingFile.exists()) {
try {
final String config = FileUtils.readFileToString(settingFile);
final JSONObject jsonObject = new JSONObject(config);
plugin.setSetting(jsonObject);
} catch (final IOException ie) {
LOGGER.log(Level.ERROR, "reading the config of the plugin[" + name + "] failed", ie);
} catch (final JSONException e) {
LOGGER.log(Level.ERROR, "convert the config of the plugin[" + name + "] to json failed", e);
}
}
Arrays.stream(types.split(",")).map(PluginType::valueOf).forEach(plugin::addType);
} | [
"private",
"static",
"void",
"setPluginProps",
"(",
"final",
"String",
"pluginDirName",
",",
"final",
"AbstractPlugin",
"plugin",
",",
"final",
"Properties",
"props",
")",
"throws",
"Exception",
"{",
"final",
"String",
"author",
"=",
"props",
".",
"getProperty",
... | Sets the specified plugin's properties from the specified properties file under the specified plugin directory.
@param pluginDirName the specified plugin directory
@param plugin the specified plugin
@param props the specified properties file
@throws Exception exception | [
"Sets",
"the",
"specified",
"plugin",
"s",
"properties",
"from",
"the",
"specified",
"properties",
"file",
"under",
"the",
"specified",
"plugin",
"directory",
"."
] | train | https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/b3log/latke/plugin/PluginManager.java#L250-L282 |
google/error-prone | check_api/src/main/java/com/google/errorprone/matchers/Matchers.java | Matchers.isSame | public static <T extends Tree> Matcher<T> isSame(final Tree t) {
return new Matcher<T>() {
@Override
public boolean matches(T tree, VisitorState state) {
return tree == t;
}
};
} | java | public static <T extends Tree> Matcher<T> isSame(final Tree t) {
return new Matcher<T>() {
@Override
public boolean matches(T tree, VisitorState state) {
return tree == t;
}
};
} | [
"public",
"static",
"<",
"T",
"extends",
"Tree",
">",
"Matcher",
"<",
"T",
">",
"isSame",
"(",
"final",
"Tree",
"t",
")",
"{",
"return",
"new",
"Matcher",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"T",
"tre... | Matches an AST node which is the same object reference as the given node. | [
"Matches",
"an",
"AST",
"node",
"which",
"is",
"the",
"same",
"object",
"reference",
"as",
"the",
"given",
"node",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L191-L198 |
RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.addListener | public void addListener(ValidationObject object, String name, SetterListener listener) {
m_validationEngine.addListener(object, name, this, listener);
} | java | public void addListener(ValidationObject object, String name, SetterListener listener) {
m_validationEngine.addListener(object, name, this, listener);
} | [
"public",
"void",
"addListener",
"(",
"ValidationObject",
"object",
",",
"String",
"name",
",",
"SetterListener",
"listener",
")",
"{",
"m_validationEngine",
".",
"addListener",
"(",
"object",
",",
"name",
",",
"this",
",",
"listener",
")",
";",
"}"
] | Add a setter listener to a field.
@param object
@param name
@param listener | [
"Add",
"a",
"setter",
"listener",
"to",
"a",
"field",
"."
] | train | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L115-L117 |
lotaris/rox-client-java | rox-client-java/src/main/java/com/lotaris/rox/common/config/Configuration.java | Configuration.getUid | public String getUid(String category, String projectName, String projectVersion, boolean force) {
String uid = null;
if (!force) {
uid = readUid(new File(uidDirectory, "latest"));
}
// Check if the UID was already used for the ROX client and projec/version
if (uid != null && uidAlreadyUsed(category, projectName, uid)) {
uid = null;
}
// Generate UID and store it
if (uid == null) {
uid = generateUid();
writeUid(new File(uidDirectory, "latest"), uid);
}
writeUid(getUidFile(category, projectName, projectVersion), uid);
return uid;
} | java | public String getUid(String category, String projectName, String projectVersion, boolean force) {
String uid = null;
if (!force) {
uid = readUid(new File(uidDirectory, "latest"));
}
// Check if the UID was already used for the ROX client and projec/version
if (uid != null && uidAlreadyUsed(category, projectName, uid)) {
uid = null;
}
// Generate UID and store it
if (uid == null) {
uid = generateUid();
writeUid(new File(uidDirectory, "latest"), uid);
}
writeUid(getUidFile(category, projectName, projectVersion), uid);
return uid;
} | [
"public",
"String",
"getUid",
"(",
"String",
"category",
",",
"String",
"projectName",
",",
"String",
"projectVersion",
",",
"boolean",
"force",
")",
"{",
"String",
"uid",
"=",
"null",
";",
"if",
"(",
"!",
"force",
")",
"{",
"uid",
"=",
"readUid",
"(",
... | Generate a UID or retrieve the latest if it is valid depending the context given
by the category, project name and project version
@param category The category
@param projectName The project name
@param projectVersion The project version
@param force Force the generation of a new UID
@return The valid UID | [
"Generate",
"a",
"UID",
"or",
"retrieve",
"the",
"latest",
"if",
"it",
"is",
"valid",
"depending",
"the",
"context",
"given",
"by",
"the",
"category",
"project",
"name",
"and",
"project",
"version"
] | train | https://github.com/lotaris/rox-client-java/blob/1b33f7560347c382c59a40c4037d175ab8127fde/rox-client-java/src/main/java/com/lotaris/rox/common/config/Configuration.java#L422-L443 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/script/el/tokens/ExpressionToken.java | ExpressionToken.listUpdate | protected final void listUpdate(List list, int index, Object value) {
Object converted = value;
if(list.size() > index) {
Object o = list.get(index);
// can only convert types when there is an item in the currently requested place
if(o != null) {
Class itemType = o.getClass();
converted = ParseUtils.convertType(value, itemType);
}
list.set(index, value);
} else {
// @note: not sure that this is the right thing. Question is whether or not to insert nulls here to fill list up to "index"
// @update: List doesn't guarantee that implementations will accept nulls. So, we can't rely on that as a solution.
// @update: this is an unfortunate but necessary solution...unless the List has enough elements to
// accomodate the new item at a particular index, this must be an error case. The reasons are this:
// 1) can't fill the list with nulls, List implementations are allowed to disallow them
// 2) can't just do an "add" to the list -- in processing [0] and [1] on an empty list, [1] may get processed first.
// this will go into list slot [0]. then, [0] gets processed and simply overwrites the previous because it's
// already in the list
// 3) can't go to a mixed approach because there's no metadata about what has been done and no time to build
// something that is apt to be complicated and exposed to the user
// so...
// the ultimate 8.1sp2 functionality is to simply disallow updating a value in a list that doesn't exist. that
// being said, it is still possible to simply add to the list. if {actionForm.list[42]} inserts into the 42'nd
// item, {actionForm.list} will just do an append on POST since there is no index specified. this fix does
// not break backwards compatability because it will work on full lists and is completely broken now on empty
// lists, so changing this just gives a better exception message that "ArrayIndexOutOfBounds". :)
//
// September 2, 2003
// ekoneil@apache.com
//
String msg = "An error occurred setting a value at index \"" +
index +
"\" because the list is " +
(list != null ? (" of size " + list.size()) : "null") + ". " +
"Be sure to allocate enough items in the List to accomodate any updates which may occur against the list.";
LOGGER.error(msg);
throw new RuntimeException(msg);
}
} | java | protected final void listUpdate(List list, int index, Object value) {
Object converted = value;
if(list.size() > index) {
Object o = list.get(index);
// can only convert types when there is an item in the currently requested place
if(o != null) {
Class itemType = o.getClass();
converted = ParseUtils.convertType(value, itemType);
}
list.set(index, value);
} else {
// @note: not sure that this is the right thing. Question is whether or not to insert nulls here to fill list up to "index"
// @update: List doesn't guarantee that implementations will accept nulls. So, we can't rely on that as a solution.
// @update: this is an unfortunate but necessary solution...unless the List has enough elements to
// accomodate the new item at a particular index, this must be an error case. The reasons are this:
// 1) can't fill the list with nulls, List implementations are allowed to disallow them
// 2) can't just do an "add" to the list -- in processing [0] and [1] on an empty list, [1] may get processed first.
// this will go into list slot [0]. then, [0] gets processed and simply overwrites the previous because it's
// already in the list
// 3) can't go to a mixed approach because there's no metadata about what has been done and no time to build
// something that is apt to be complicated and exposed to the user
// so...
// the ultimate 8.1sp2 functionality is to simply disallow updating a value in a list that doesn't exist. that
// being said, it is still possible to simply add to the list. if {actionForm.list[42]} inserts into the 42'nd
// item, {actionForm.list} will just do an append on POST since there is no index specified. this fix does
// not break backwards compatability because it will work on full lists and is completely broken now on empty
// lists, so changing this just gives a better exception message that "ArrayIndexOutOfBounds". :)
//
// September 2, 2003
// ekoneil@apache.com
//
String msg = "An error occurred setting a value at index \"" +
index +
"\" because the list is " +
(list != null ? (" of size " + list.size()) : "null") + ". " +
"Be sure to allocate enough items in the List to accomodate any updates which may occur against the list.";
LOGGER.error(msg);
throw new RuntimeException(msg);
}
} | [
"protected",
"final",
"void",
"listUpdate",
"(",
"List",
"list",
",",
"int",
"index",
",",
"Object",
"value",
")",
"{",
"Object",
"converted",
"=",
"value",
";",
"if",
"(",
"list",
".",
"size",
"(",
")",
">",
"index",
")",
"{",
"Object",
"o",
"=",
... | Update a {@link List} with the Object <code>value</code> at <code>index</code>.
@param list the List
@param index the index
@param value the new value | [
"Update",
"a",
"{"
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/script/el/tokens/ExpressionToken.java#L134-L176 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java | StructureInterfaceList.addNcsEquivalent | public void addNcsEquivalent(StructureInterface interfaceNew, StructureInterface interfaceRef) {
this.add(interfaceNew);
if (clustersNcs == null) {
clustersNcs = new ArrayList<>();
}
if (interfaceRef == null) {
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
return;
}
Optional<StructureInterfaceCluster> clusterRef =
clustersNcs.stream().
filter(r->r.getMembers().stream().
anyMatch(c -> c.equals(interfaceRef))).
findFirst();
if (clusterRef.isPresent()) {
clusterRef.get().addMember(interfaceNew);
return;
}
logger.warn("The specified reference interface, if not null, should have been added to this set previously. " +
"Creating new cluster and adding both interfaces. This is likely a bug.");
this.add(interfaceRef);
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceRef);
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
} | java | public void addNcsEquivalent(StructureInterface interfaceNew, StructureInterface interfaceRef) {
this.add(interfaceNew);
if (clustersNcs == null) {
clustersNcs = new ArrayList<>();
}
if (interfaceRef == null) {
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
return;
}
Optional<StructureInterfaceCluster> clusterRef =
clustersNcs.stream().
filter(r->r.getMembers().stream().
anyMatch(c -> c.equals(interfaceRef))).
findFirst();
if (clusterRef.isPresent()) {
clusterRef.get().addMember(interfaceNew);
return;
}
logger.warn("The specified reference interface, if not null, should have been added to this set previously. " +
"Creating new cluster and adding both interfaces. This is likely a bug.");
this.add(interfaceRef);
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceRef);
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
} | [
"public",
"void",
"addNcsEquivalent",
"(",
"StructureInterface",
"interfaceNew",
",",
"StructureInterface",
"interfaceRef",
")",
"{",
"this",
".",
"add",
"(",
"interfaceNew",
")",
";",
"if",
"(",
"clustersNcs",
"==",
"null",
")",
"{",
"clustersNcs",
"=",
"new",
... | Add an interface to the list, possibly defining it as NCS-equivalent to an interface already in the list.
Used to build up the NCS clustering.
@param interfaceNew
an interface to be added to the list.
@param interfaceRef
interfaceNew will be added to the cluster which contains interfaceRef.
If interfaceRef is null, new cluster will be created for interfaceNew.
@since 5.0.0 | [
"Add",
"an",
"interface",
"to",
"the",
"list",
"possibly",
"defining",
"it",
"as",
"NCS",
"-",
"equivalent",
"to",
"an",
"interface",
"already",
"in",
"the",
"list",
".",
"Used",
"to",
"build",
"up",
"the",
"NCS",
"clustering",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java#L279-L311 |
basho/riak-java-client | src/main/java/com/basho/riak/client/core/query/UserMetadata/RiakUserMetadata.java | RiakUserMetadata.put | public void put(String key, String value, Charset charset)
{
BinaryValue wrappedKey = BinaryValue.unsafeCreate(key.getBytes(charset));
BinaryValue wrappedValue = BinaryValue.unsafeCreate(value.getBytes(charset));
meta.put(wrappedKey, wrappedValue);
} | java | public void put(String key, String value, Charset charset)
{
BinaryValue wrappedKey = BinaryValue.unsafeCreate(key.getBytes(charset));
BinaryValue wrappedValue = BinaryValue.unsafeCreate(value.getBytes(charset));
meta.put(wrappedKey, wrappedValue);
} | [
"public",
"void",
"put",
"(",
"String",
"key",
",",
"String",
"value",
",",
"Charset",
"charset",
")",
"{",
"BinaryValue",
"wrappedKey",
"=",
"BinaryValue",
".",
"unsafeCreate",
"(",
"key",
".",
"getBytes",
"(",
"charset",
")",
")",
";",
"BinaryValue",
"wr... | Set a user metadata entry.
<p>
This method and its {@link RiakUserMetadata#get(java.lang.String, java.nio.charset.Charset) }
counterpart use the supplied {@code Charset} to convert the {@code String}s.
</p>
@param key the key for the user metadata entry as a {@code String} encoded using the supplied {@code Charset}
@param value the value for the entry as a {@code String} encoded using the supplied {@code Charset} | [
"Set",
"a",
"user",
"metadata",
"entry",
".",
"<p",
">",
"This",
"method",
"and",
"its",
"{",
"@link",
"RiakUserMetadata#get",
"(",
"java",
".",
"lang",
".",
"String",
"java",
".",
"nio",
".",
"charset",
".",
"Charset",
")",
"}",
"counterpart",
"use",
... | train | https://github.com/basho/riak-java-client/blob/bed6cd60f360bacf1b873ab92dd74f2526651e71/src/main/java/com/basho/riak/client/core/query/UserMetadata/RiakUserMetadata.java#L180-L185 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java | ConfigurationsInner.updateAsync | public Observable<Void> updateAsync(String resourceGroupName, String clusterName, String configurationName, Map<String, String> parameters) {
return updateWithServiceResponseAsync(resourceGroupName, clusterName, configurationName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> updateAsync(String resourceGroupName, String clusterName, String configurationName, Map<String, String> parameters) {
return updateWithServiceResponseAsync(resourceGroupName, clusterName, configurationName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"String",
"configurationName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"return",
"updateWithServiceRespon... | Configures the HTTP settings on the specified cluster. This API is deprecated, please use UpdateGatewaySettings in cluster endpoint instead.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param configurationName The name of the cluster configuration.
@param parameters The cluster configurations.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Configures",
"the",
"HTTP",
"settings",
"on",
"the",
"specified",
"cluster",
".",
"This",
"API",
"is",
"deprecated",
"please",
"use",
"UpdateGatewaySettings",
"in",
"cluster",
"endpoint",
"instead",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java#L202-L209 |
aws/aws-sdk-java | aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutIntegrationResponseResult.java | PutIntegrationResponseResult.withResponseParameters | public PutIntegrationResponseResult withResponseParameters(java.util.Map<String, String> responseParameters) {
setResponseParameters(responseParameters);
return this;
} | java | public PutIntegrationResponseResult withResponseParameters(java.util.Map<String, String> responseParameters) {
setResponseParameters(responseParameters);
return this;
} | [
"public",
"PutIntegrationResponseResult",
"withResponseParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseParameters",
")",
"{",
"setResponseParameters",
"(",
"responseParameters",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A key-value map specifying response parameters that are passed to the method response from the back end. The key
is a method response header parameter name and the mapped value is an integration response header value, a static
value enclosed within a pair of single quotes, or a JSON expression from the integration response body. The
mapping key must match the pattern of <code>method.response.header.{name}</code>, where <code>name</code> is a
valid and unique header name. The mapped non-static value must match the pattern of
<code>integration.response.header.{name}</code> or <code>integration.response.body.{JSON-expression}</code>,
where <code>name</code> is a valid and unique response header name and <code>JSON-expression</code> is a valid
JSON expression without the <code>$</code> prefix.
</p>
@param responseParameters
A key-value map specifying response parameters that are passed to the method response from the back end.
The key is a method response header parameter name and the mapped value is an integration response header
value, a static value enclosed within a pair of single quotes, or a JSON expression from the integration
response body. The mapping key must match the pattern of <code>method.response.header.{name}</code>, where
<code>name</code> is a valid and unique header name. The mapped non-static value must match the pattern of
<code>integration.response.header.{name}</code> or
<code>integration.response.body.{JSON-expression}</code>, where <code>name</code> is a valid and unique
response header name and <code>JSON-expression</code> is a valid JSON expression without the
<code>$</code> prefix.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"key",
"-",
"value",
"map",
"specifying",
"response",
"parameters",
"that",
"are",
"passed",
"to",
"the",
"method",
"response",
"from",
"the",
"back",
"end",
".",
"The",
"key",
"is",
"a",
"method",
"response",
"header",
"parameter",
"name",... | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutIntegrationResponseResult.java#L284-L287 |
hivemq/hivemq-spi | src/main/java/com/hivemq/spi/util/DefaultSslEngineUtil.java | DefaultSslEngineUtil.getSupportedCipherSuites | @ReadOnly
public List<String> getSupportedCipherSuites() throws SslException {
try {
final SSLEngine engine = getDefaultSslEngine();
return ImmutableList.copyOf(engine.getSupportedCipherSuites());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new SslException("Not able to get list of supported cipher suites from JVM", e);
}
} | java | @ReadOnly
public List<String> getSupportedCipherSuites() throws SslException {
try {
final SSLEngine engine = getDefaultSslEngine();
return ImmutableList.copyOf(engine.getSupportedCipherSuites());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new SslException("Not able to get list of supported cipher suites from JVM", e);
}
} | [
"@",
"ReadOnly",
"public",
"List",
"<",
"String",
">",
"getSupportedCipherSuites",
"(",
")",
"throws",
"SslException",
"{",
"try",
"{",
"final",
"SSLEngine",
"engine",
"=",
"getDefaultSslEngine",
"(",
")",
";",
"return",
"ImmutableList",
".",
"copyOf",
"(",
"e... | Returns a list of all supported Cipher Suites of the JVM.
@return a list of all supported cipher suites of the JVM
@throws SslException | [
"Returns",
"a",
"list",
"of",
"all",
"supported",
"Cipher",
"Suites",
"of",
"the",
"JVM",
"."
] | train | https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/util/DefaultSslEngineUtil.java#L43-L54 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java | GenericSignatureParser.compareSignatures | public static boolean compareSignatures(String plainSignature, String genericSignature) {
GenericSignatureParser plainParser = new GenericSignatureParser(plainSignature);
GenericSignatureParser genericParser = new GenericSignatureParser(genericSignature);
return plainParser.getNumParameters() == genericParser.getNumParameters();
} | java | public static boolean compareSignatures(String plainSignature, String genericSignature) {
GenericSignatureParser plainParser = new GenericSignatureParser(plainSignature);
GenericSignatureParser genericParser = new GenericSignatureParser(genericSignature);
return plainParser.getNumParameters() == genericParser.getNumParameters();
} | [
"public",
"static",
"boolean",
"compareSignatures",
"(",
"String",
"plainSignature",
",",
"String",
"genericSignature",
")",
"{",
"GenericSignatureParser",
"plainParser",
"=",
"new",
"GenericSignatureParser",
"(",
"plainSignature",
")",
";",
"GenericSignatureParser",
"gen... | Compare a plain method signature to the a generic method Signature and
return true if they match | [
"Compare",
"a",
"plain",
"method",
"signature",
"to",
"the",
"a",
"generic",
"method",
"Signature",
"and",
"return",
"true",
"if",
"they",
"match"
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java#L245-L250 |
opsbears/owc-dic | src/main/java/com/opsbears/webcomponents/dic/InjectionConfiguration.java | InjectionConfiguration.define | public <T> void define(Class<T> classDefinition, Map<String, Object> namedParameterValues) {
injectorConfiguration = injectorConfiguration.withDefined(classDefinition);
namedParameterValues.forEach((key, value) -> {
injectorConfiguration = injectorConfiguration.withNamedParameterValue(classDefinition, key, value);
});
} | java | public <T> void define(Class<T> classDefinition, Map<String, Object> namedParameterValues) {
injectorConfiguration = injectorConfiguration.withDefined(classDefinition);
namedParameterValues.forEach((key, value) -> {
injectorConfiguration = injectorConfiguration.withNamedParameterValue(classDefinition, key, value);
});
} | [
"public",
"<",
"T",
">",
"void",
"define",
"(",
"Class",
"<",
"T",
">",
"classDefinition",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"namedParameterValues",
")",
"{",
"injectorConfiguration",
"=",
"injectorConfiguration",
".",
"withDefined",
"(",
"classDe... | Allows the dependency injector to use the specified class and specifies values for some or all parameters. (Only
works if the class in question is compiled with `-parameters`.)
@param classDefinition The class to use.
@param namedParameterValues Values for the specified parameters. | [
"Allows",
"the",
"dependency",
"injector",
"to",
"use",
"the",
"specified",
"class",
"and",
"specifies",
"values",
"for",
"some",
"or",
"all",
"parameters",
".",
"(",
"Only",
"works",
"if",
"the",
"class",
"in",
"question",
"is",
"compiled",
"with",
"-",
"... | train | https://github.com/opsbears/owc-dic/blob/eb254ca993b26c299292a01598b358a31f323566/src/main/java/com/opsbears/webcomponents/dic/InjectionConfiguration.java#L60-L66 |
grpc/grpc-java | netty/src/main/java/io/grpc/netty/NettyServerBuilder.java | NettyServerBuilder.maxConnectionIdle | public NettyServerBuilder maxConnectionIdle(long maxConnectionIdle, TimeUnit timeUnit) {
checkArgument(maxConnectionIdle > 0L, "max connection idle must be positive");
maxConnectionIdleInNanos = timeUnit.toNanos(maxConnectionIdle);
if (maxConnectionIdleInNanos >= AS_LARGE_AS_INFINITE) {
maxConnectionIdleInNanos = MAX_CONNECTION_IDLE_NANOS_DISABLED;
}
if (maxConnectionIdleInNanos < MIN_MAX_CONNECTION_IDLE_NANO) {
maxConnectionIdleInNanos = MIN_MAX_CONNECTION_IDLE_NANO;
}
return this;
} | java | public NettyServerBuilder maxConnectionIdle(long maxConnectionIdle, TimeUnit timeUnit) {
checkArgument(maxConnectionIdle > 0L, "max connection idle must be positive");
maxConnectionIdleInNanos = timeUnit.toNanos(maxConnectionIdle);
if (maxConnectionIdleInNanos >= AS_LARGE_AS_INFINITE) {
maxConnectionIdleInNanos = MAX_CONNECTION_IDLE_NANOS_DISABLED;
}
if (maxConnectionIdleInNanos < MIN_MAX_CONNECTION_IDLE_NANO) {
maxConnectionIdleInNanos = MIN_MAX_CONNECTION_IDLE_NANO;
}
return this;
} | [
"public",
"NettyServerBuilder",
"maxConnectionIdle",
"(",
"long",
"maxConnectionIdle",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"checkArgument",
"(",
"maxConnectionIdle",
">",
"0L",
",",
"\"max connection idle must be positive\"",
")",
";",
"maxConnectionIdleInNanos",
"=",
... | Sets a custom max connection idle time, connection being idle for longer than which will be
gracefully terminated. Idleness duration is defined since the most recent time the number of
outstanding RPCs became zero or the connection establishment. An unreasonably small value might
be increased. {@code Long.MAX_VALUE} nano seconds or an unreasonably large value will disable
max connection idle.
@since 1.4.0 | [
"Sets",
"a",
"custom",
"max",
"connection",
"idle",
"time",
"connection",
"being",
"idle",
"for",
"longer",
"than",
"which",
"will",
"be",
"gracefully",
"terminated",
".",
"Idleness",
"duration",
"is",
"defined",
"since",
"the",
"most",
"recent",
"time",
"the"... | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java#L413-L423 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeCheck.java | FlowTypeCheck.checkIfElse | private Environment checkIfElse(Stmt.IfElse stmt, Environment environment, EnclosingScope scope) {
// Check condition and apply variable retypings.
Environment trueEnvironment = checkCondition(stmt.getCondition(), true, environment);
Environment falseEnvironment = checkCondition(stmt.getCondition(), false, environment);
// Update environments for true and false branches
if (stmt.hasFalseBranch()) {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
falseEnvironment = checkBlock(stmt.getFalseBranch(), falseEnvironment, scope);
} else {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
}
// Join results back together
return FlowTypeUtils.union(trueEnvironment, falseEnvironment);
} | java | private Environment checkIfElse(Stmt.IfElse stmt, Environment environment, EnclosingScope scope) {
// Check condition and apply variable retypings.
Environment trueEnvironment = checkCondition(stmt.getCondition(), true, environment);
Environment falseEnvironment = checkCondition(stmt.getCondition(), false, environment);
// Update environments for true and false branches
if (stmt.hasFalseBranch()) {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
falseEnvironment = checkBlock(stmt.getFalseBranch(), falseEnvironment, scope);
} else {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
}
// Join results back together
return FlowTypeUtils.union(trueEnvironment, falseEnvironment);
} | [
"private",
"Environment",
"checkIfElse",
"(",
"Stmt",
".",
"IfElse",
"stmt",
",",
"Environment",
"environment",
",",
"EnclosingScope",
"scope",
")",
"{",
"// Check condition and apply variable retypings.",
"Environment",
"trueEnvironment",
"=",
"checkCondition",
"(",
"stm... | Type check an if-statement. To do this, we check the environment through both
sides of condition expression. Each can produce a different environment in
the case that runtime type tests are used. These potentially updated
environments are then passed through the true and false blocks which, in
turn, produce updated environments. Finally, these two environments are
joined back together. The following illustrates:
<pre>
// Environment
function f(int|null x) -> int:
// {x : int|null}
if x is null:
// {x : null}
return 0
// {x : int}
else:
// {x : int}
x = x + 1
// {x : int}
// --------------------------------------------------
// {x : int} o {x : int} => {x : int}
return x
</pre>
Here, we see that the type of <code>x</code> is initially
<code>int|null</code> before the first statement of the function body. On the
true branch of the type test this is updated to <code>null</code>, whilst on
the false branch it is updated to <code>int</code>. Finally, the type of
<code>x</code> at the end of each block is <code>int</code> and, hence, its
type after the if-statement is <code>int</code>.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return
@throws ResolveError
If a named type within this statement cannot be resolved within
the enclosing project. | [
"Type",
"check",
"an",
"if",
"-",
"statement",
".",
"To",
"do",
"this",
"we",
"check",
"the",
"environment",
"through",
"both",
"sides",
"of",
"condition",
"expression",
".",
"Each",
"can",
"produce",
"a",
"different",
"environment",
"in",
"the",
"case",
"... | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L574-L587 |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/impl/ServiceManagerResourceRestServiceImpl.java | ServiceManagerResourceRestServiceImpl.provision | @Override
public ResourceInstanceDTO provision(final String templateName, final ProvisionResourceParametersDTO parameters)
{
final Map<String, String> metadata = ResourceKVP.toMap(parameters.metadata);
ResourceInstanceEntity entity = service.newInstance(templateName, metadata);
return getInstanceById(entity.getId());
} | java | @Override
public ResourceInstanceDTO provision(final String templateName, final ProvisionResourceParametersDTO parameters)
{
final Map<String, String> metadata = ResourceKVP.toMap(parameters.metadata);
ResourceInstanceEntity entity = service.newInstance(templateName, metadata);
return getInstanceById(entity.getId());
} | [
"@",
"Override",
"public",
"ResourceInstanceDTO",
"provision",
"(",
"final",
"String",
"templateName",
",",
"final",
"ProvisionResourceParametersDTO",
"parameters",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"metadata",
"=",
"ResourceKVP",
".",
"... | N.B. no {@link Transactional} annotation because the inner service does transaction management
@param templateName
@param parameters
@return | [
"N",
".",
"B",
".",
"no",
"{",
"@link",
"Transactional",
"}",
"annotation",
"because",
"the",
"inner",
"service",
"does",
"transaction",
"management"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/impl/ServiceManagerResourceRestServiceImpl.java#L77-L85 |
cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/TransactionEdit.java | TransactionEdit.createCheckpoint | public static TransactionEdit createCheckpoint(long writePointer, long parentWritePointer) {
return new TransactionEdit(writePointer, 0L, State.CHECKPOINT, 0L, null, 0L, false, null, null, 0L,
parentWritePointer, null);
} | java | public static TransactionEdit createCheckpoint(long writePointer, long parentWritePointer) {
return new TransactionEdit(writePointer, 0L, State.CHECKPOINT, 0L, null, 0L, false, null, null, 0L,
parentWritePointer, null);
} | [
"public",
"static",
"TransactionEdit",
"createCheckpoint",
"(",
"long",
"writePointer",
",",
"long",
"parentWritePointer",
")",
"{",
"return",
"new",
"TransactionEdit",
"(",
"writePointer",
",",
"0L",
",",
"State",
".",
"CHECKPOINT",
",",
"0L",
",",
"null",
",",... | Creates a new instance in the {@link State#CHECKPOINT} state. | [
"Creates",
"a",
"new",
"instance",
"in",
"the",
"{"
] | train | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/TransactionEdit.java#L294-L297 |
puniverse/galaxy | src/main/java/co/paralleluniverse/galaxy/Grid.java | Grid.getInstance | public static Grid getInstance(String configFile, Properties properties) throws InterruptedException {
return getInstance(configFile == null ? null : new FileSystemResource(configFile), (Object) properties);
} | java | public static Grid getInstance(String configFile, Properties properties) throws InterruptedException {
return getInstance(configFile == null ? null : new FileSystemResource(configFile), (Object) properties);
} | [
"public",
"static",
"Grid",
"getInstance",
"(",
"String",
"configFile",
",",
"Properties",
"properties",
")",
"throws",
"InterruptedException",
"{",
"return",
"getInstance",
"(",
"configFile",
"==",
"null",
"?",
"null",
":",
"new",
"FileSystemResource",
"(",
"conf... | Retrieves the grid instance, as defined in the given configuration file.
@param configFile The name of the configuration file containing the grid definition.
@param properties A {@link Properties Properties} object containing the grid's properties to be injected into placeholders
in the configuration file.
This parameter is helpful when you want to use the same xml configuration with different properties for different
instances.
@return The grid instance. | [
"Retrieves",
"the",
"grid",
"instance",
"as",
"defined",
"in",
"the",
"given",
"configuration",
"file",
"."
] | train | https://github.com/puniverse/galaxy/blob/1d077532c4a5bcd6c52ff670770c31e98420ff63/src/main/java/co/paralleluniverse/galaxy/Grid.java#L73-L75 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/view/facelets/tag/ui/DebugPhaseListener.java | DebugPhaseListener.createFieldDebugInfo | public static void createFieldDebugInfo(FacesContext facesContext,
final String field, Object oldValue,
Object newValue, String clientId)
{
if ((oldValue == null && newValue == null)
|| (oldValue != null && oldValue.equals(newValue)))
{
// nothing changed - NOTE that this is a difference to the method in
// UIInput, because in UIInput every call to this method comes from
// setSubmittedValue or setLocalValue and here every call comes
// from the VisitCallback of the PhaseListener.
return;
}
// convert Array values into a more readable format
if (oldValue != null && oldValue.getClass().isArray())
{
oldValue = Arrays.deepToString((Object[]) oldValue);
}
if (newValue != null && newValue.getClass().isArray())
{
newValue = Arrays.deepToString((Object[]) newValue);
}
// NOTE that the call stack does not make much sence here
// create the debug-info array
// structure:
// - 0: phase
// - 1: old value
// - 2: new value
// - 3: StackTraceElement List
// NOTE that we cannot create a class here to encapsulate this data,
// because this is not on the spec and the class would not be available in impl.
Object[] debugInfo = new Object[4];
debugInfo[0] = facesContext.getCurrentPhaseId();
debugInfo[1] = oldValue;
debugInfo[2] = newValue;
debugInfo[3] = null; // here we have no call stack (only in UIInput)
// add the debug info
getFieldDebugInfos(field, clientId).add(debugInfo);
} | java | public static void createFieldDebugInfo(FacesContext facesContext,
final String field, Object oldValue,
Object newValue, String clientId)
{
if ((oldValue == null && newValue == null)
|| (oldValue != null && oldValue.equals(newValue)))
{
// nothing changed - NOTE that this is a difference to the method in
// UIInput, because in UIInput every call to this method comes from
// setSubmittedValue or setLocalValue and here every call comes
// from the VisitCallback of the PhaseListener.
return;
}
// convert Array values into a more readable format
if (oldValue != null && oldValue.getClass().isArray())
{
oldValue = Arrays.deepToString((Object[]) oldValue);
}
if (newValue != null && newValue.getClass().isArray())
{
newValue = Arrays.deepToString((Object[]) newValue);
}
// NOTE that the call stack does not make much sence here
// create the debug-info array
// structure:
// - 0: phase
// - 1: old value
// - 2: new value
// - 3: StackTraceElement List
// NOTE that we cannot create a class here to encapsulate this data,
// because this is not on the spec and the class would not be available in impl.
Object[] debugInfo = new Object[4];
debugInfo[0] = facesContext.getCurrentPhaseId();
debugInfo[1] = oldValue;
debugInfo[2] = newValue;
debugInfo[3] = null; // here we have no call stack (only in UIInput)
// add the debug info
getFieldDebugInfos(field, clientId).add(debugInfo);
} | [
"public",
"static",
"void",
"createFieldDebugInfo",
"(",
"FacesContext",
"facesContext",
",",
"final",
"String",
"field",
",",
"Object",
"oldValue",
",",
"Object",
"newValue",
",",
"String",
"clientId",
")",
"{",
"if",
"(",
"(",
"oldValue",
"==",
"null",
"&&",... | Creates the field debug-info for the given field, which changed
from oldValue to newValue in the given component.
ATTENTION: this method is duplicate in UIInput.
@param facesContext
@param field
@param oldValue
@param newValue
@param clientId | [
"Creates",
"the",
"field",
"debug",
"-",
"info",
"for",
"the",
"given",
"field",
"which",
"changed",
"from",
"oldValue",
"to",
"newValue",
"in",
"the",
"given",
"component",
".",
"ATTENTION",
":",
"this",
"method",
"is",
"duplicate",
"in",
"UIInput",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/view/facelets/tag/ui/DebugPhaseListener.java#L112-L154 |
apache/spark | sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java | UnsafeMapData.pointTo | public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
// Read the numBytes of key array from the first 8 bytes.
final long keyArraySize = Platform.getLong(baseObject, baseOffset);
assert keyArraySize >= 0 : "keyArraySize (" + keyArraySize + ") should >= 0";
assert keyArraySize <= Integer.MAX_VALUE :
"keyArraySize (" + keyArraySize + ") should <= Integer.MAX_VALUE";
final int valueArraySize = sizeInBytes - (int)keyArraySize - 8;
assert valueArraySize >= 0 : "valueArraySize (" + valueArraySize + ") should >= 0";
keys.pointTo(baseObject, baseOffset + 8, (int)keyArraySize);
values.pointTo(baseObject, baseOffset + 8 + keyArraySize, valueArraySize);
assert keys.numElements() == values.numElements();
this.baseObject = baseObject;
this.baseOffset = baseOffset;
this.sizeInBytes = sizeInBytes;
} | java | public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
// Read the numBytes of key array from the first 8 bytes.
final long keyArraySize = Platform.getLong(baseObject, baseOffset);
assert keyArraySize >= 0 : "keyArraySize (" + keyArraySize + ") should >= 0";
assert keyArraySize <= Integer.MAX_VALUE :
"keyArraySize (" + keyArraySize + ") should <= Integer.MAX_VALUE";
final int valueArraySize = sizeInBytes - (int)keyArraySize - 8;
assert valueArraySize >= 0 : "valueArraySize (" + valueArraySize + ") should >= 0";
keys.pointTo(baseObject, baseOffset + 8, (int)keyArraySize);
values.pointTo(baseObject, baseOffset + 8 + keyArraySize, valueArraySize);
assert keys.numElements() == values.numElements();
this.baseObject = baseObject;
this.baseOffset = baseOffset;
this.sizeInBytes = sizeInBytes;
} | [
"public",
"void",
"pointTo",
"(",
"Object",
"baseObject",
",",
"long",
"baseOffset",
",",
"int",
"sizeInBytes",
")",
"{",
"// Read the numBytes of key array from the first 8 bytes.",
"final",
"long",
"keyArraySize",
"=",
"Platform",
".",
"getLong",
"(",
"baseObject",
... | Update this UnsafeMapData to point to different backing data.
@param baseObject the base object
@param baseOffset the offset within the base object
@param sizeInBytes the size of this map's backing data, in bytes | [
"Update",
"this",
"UnsafeMapData",
"to",
"point",
"to",
"different",
"backing",
"data",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java#L81-L98 |
grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.hasProperty | public static boolean hasProperty(ClassNode classNode, String propertyName) {
if (classNode == null || !StringUtils.hasText(propertyName)) {
return false;
}
final MethodNode method = classNode.getMethod(GrailsNameUtils.getGetterName(propertyName), Parameter.EMPTY_ARRAY);
if (method != null) return true;
// check read-only field with setter
if( classNode.getField(propertyName) != null && !classNode.getMethods(GrailsNameUtils.getSetterName(propertyName)).isEmpty()) {
return true;
}
for (PropertyNode pn : classNode.getProperties()) {
if (pn.getName().equals(propertyName) && !pn.isPrivate()) {
return true;
}
}
return false;
} | java | public static boolean hasProperty(ClassNode classNode, String propertyName) {
if (classNode == null || !StringUtils.hasText(propertyName)) {
return false;
}
final MethodNode method = classNode.getMethod(GrailsNameUtils.getGetterName(propertyName), Parameter.EMPTY_ARRAY);
if (method != null) return true;
// check read-only field with setter
if( classNode.getField(propertyName) != null && !classNode.getMethods(GrailsNameUtils.getSetterName(propertyName)).isEmpty()) {
return true;
}
for (PropertyNode pn : classNode.getProperties()) {
if (pn.getName().equals(propertyName) && !pn.isPrivate()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasProperty",
"(",
"ClassNode",
"classNode",
",",
"String",
"propertyName",
")",
"{",
"if",
"(",
"classNode",
"==",
"null",
"||",
"!",
"StringUtils",
".",
"hasText",
"(",
"propertyName",
")",
")",
"{",
"return",
"false",
";",
... | Returns whether a classNode has the specified property or not
@param classNode The ClassNode
@param propertyName The name of the property
@return true if the property exists in the ClassNode | [
"Returns",
"whether",
"a",
"classNode",
"has",
"the",
"specified",
"property",
"or",
"not"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L118-L138 |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/multi/spatial/DE9IM/DE9IMRelation.java | DE9IMRelation.getRCC8Relations | public static Type[] getRCC8Relations(GeometricShapeVariable gv1, GeometricShapeVariable gv2) {
return getRelations(gv1, gv2, true);
} | java | public static Type[] getRCC8Relations(GeometricShapeVariable gv1, GeometricShapeVariable gv2) {
return getRelations(gv1, gv2, true);
} | [
"public",
"static",
"Type",
"[",
"]",
"getRCC8Relations",
"(",
"GeometricShapeVariable",
"gv1",
",",
"GeometricShapeVariable",
"gv2",
")",
"{",
"return",
"getRelations",
"(",
"gv1",
",",
"gv2",
",",
"true",
")",
";",
"}"
] | Get the RCC8 relation(s) existing between two {@link GeometricShapeVariable}s.
@param gv1 The first {@link GeometricShapeVariable} (the source of the directed edge).
@param gv2 The second {@link GeometricShapeVariable} (the destination of the directed edge).
@return The RCC8 relation(s) existing between the two given {@link GeometricShapeVariable}s. | [
"Get",
"the",
"RCC8",
"relation",
"(",
"s",
")",
"existing",
"between",
"two",
"{"
] | train | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/multi/spatial/DE9IM/DE9IMRelation.java#L67-L69 |
ibm-bluemix-mobile-services/bms-clientsdk-android-core | lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java | AuthorizationProcessManager.createRegistrationParams | private HashMap<String, String> createRegistrationParams() {
registrationKeyPair = KeyPairUtility.generateRandomKeyPair();
JSONObject csrJSON = new JSONObject();
HashMap<String, String> params;
try {
DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap());
AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap());
csrJSON.put("deviceId", deviceData.getId());
csrJSON.put("deviceOs", "" + deviceData.getOS());
csrJSON.put("deviceModel", deviceData.getModel());
csrJSON.put("applicationId", applicationData.getId());
csrJSON.put("applicationVersion", applicationData.getVersion());
csrJSON.put("environment", "android");
String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON);
params = new HashMap<>(1);
params.put("CSR", csrValue);
return params;
} catch (Exception e) {
throw new RuntimeException("Failed to create registration params", e);
}
} | java | private HashMap<String, String> createRegistrationParams() {
registrationKeyPair = KeyPairUtility.generateRandomKeyPair();
JSONObject csrJSON = new JSONObject();
HashMap<String, String> params;
try {
DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap());
AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap());
csrJSON.put("deviceId", deviceData.getId());
csrJSON.put("deviceOs", "" + deviceData.getOS());
csrJSON.put("deviceModel", deviceData.getModel());
csrJSON.put("applicationId", applicationData.getId());
csrJSON.put("applicationVersion", applicationData.getVersion());
csrJSON.put("environment", "android");
String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON);
params = new HashMap<>(1);
params.put("CSR", csrValue);
return params;
} catch (Exception e) {
throw new RuntimeException("Failed to create registration params", e);
}
} | [
"private",
"HashMap",
"<",
"String",
",",
"String",
">",
"createRegistrationParams",
"(",
")",
"{",
"registrationKeyPair",
"=",
"KeyPairUtility",
".",
"generateRandomKeyPair",
"(",
")",
";",
"JSONObject",
"csrJSON",
"=",
"new",
"JSONObject",
"(",
")",
";",
"Hash... | Generate the params that will be used during the registration phase
@return Map with all the parameters | [
"Generate",
"the",
"params",
"that",
"will",
"be",
"used",
"during",
"the",
"registration",
"phase"
] | train | https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L163-L189 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java | ApiOvhEmailexchange.organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET | public ArrayList<Long> organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET(String organizationName, String exchangeService, String mailingListAddress) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account";
StringBuilder sb = path(qPath, organizationName, exchangeService, mailingListAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | java | public ArrayList<Long> organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET(String organizationName, String exchangeService, String mailingListAddress) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account";
StringBuilder sb = path(qPath, organizationName, exchangeService, mailingListAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | [
"public",
"ArrayList",
"<",
"Long",
">",
"organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET",
"(",
"String",
"organizationName",
",",
"String",
"exchangeService",
",",
"String",
"mailingListAddress",
")",
"throws",
"IOException",
"{",
"S... | Mailing list account member
REST: GET /email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param mailingListAddress [required] The mailing list address | [
"Mailing",
"list",
"account",
"member"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java#L1060-L1065 |
cloudfoundry/uaa | server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java | IdpMetadataGenerator.getServerURL | private String getServerURL(String entityBaseURL, String entityAlias, String processingURL) {
return getServerURL(entityBaseURL, entityAlias, processingURL, null);
} | java | private String getServerURL(String entityBaseURL, String entityAlias, String processingURL) {
return getServerURL(entityBaseURL, entityAlias, processingURL, null);
} | [
"private",
"String",
"getServerURL",
"(",
"String",
"entityBaseURL",
",",
"String",
"entityAlias",
",",
"String",
"processingURL",
")",
"{",
"return",
"getServerURL",
"(",
"entityBaseURL",
",",
"entityAlias",
",",
"processingURL",
",",
"null",
")",
";",
"}"
] | Creates URL at which the local server is capable of accepting incoming SAML messages.
@param entityBaseURL
entity ID
@param processingURL
local context at which processing filter is waiting
@return URL of local server | [
"Creates",
"URL",
"at",
"which",
"the",
"local",
"server",
"is",
"capable",
"of",
"accepting",
"incoming",
"SAML",
"messages",
"."
] | train | https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L499-L503 |
meertensinstituut/mtas | src/main/java/mtas/solr/handler/util/MtasSolrStatus.java | MtasSolrStatus.getBoolean | private final Boolean getBoolean(NamedList<Object> response, String... args) {
Object objectItem = response.findRecursive(args);
Boolean result = null;
if (objectItem != null && objectItem instanceof Boolean) {
result = (Boolean) objectItem;
}
return result;
} | java | private final Boolean getBoolean(NamedList<Object> response, String... args) {
Object objectItem = response.findRecursive(args);
Boolean result = null;
if (objectItem != null && objectItem instanceof Boolean) {
result = (Boolean) objectItem;
}
return result;
} | [
"private",
"final",
"Boolean",
"getBoolean",
"(",
"NamedList",
"<",
"Object",
">",
"response",
",",
"String",
"...",
"args",
")",
"{",
"Object",
"objectItem",
"=",
"response",
".",
"findRecursive",
"(",
"args",
")",
";",
"Boolean",
"result",
"=",
"null",
"... | Gets the boolean.
@param response
the response
@param args
the args
@return the boolean | [
"Gets",
"the",
"boolean",
"."
] | train | https://github.com/meertensinstituut/mtas/blob/f02ae730848616bd88b553efa7f9eddc32818e64/src/main/java/mtas/solr/handler/util/MtasSolrStatus.java#L642-L649 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/orders/OrderItemUrl.java | OrderItemUrl.updateItemDutyUrl | public static MozuUrl updateItemDutyUrl(Double dutyAmount, String orderId, String orderItemId, String responseFields, String updateMode, String version)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/items/{orderItemId}/dutyAmount/{dutyAmount}?updatemode={updateMode}&version={version}&responseFields={responseFields}");
formatter.formatUrl("dutyAmount", dutyAmount);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("orderItemId", orderItemId);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl updateItemDutyUrl(Double dutyAmount, String orderId, String orderItemId, String responseFields, String updateMode, String version)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/items/{orderItemId}/dutyAmount/{dutyAmount}?updatemode={updateMode}&version={version}&responseFields={responseFields}");
formatter.formatUrl("dutyAmount", dutyAmount);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("orderItemId", orderItemId);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"updateItemDutyUrl",
"(",
"Double",
"dutyAmount",
",",
"String",
"orderId",
",",
"String",
"orderItemId",
",",
"String",
"responseFields",
",",
"String",
"updateMode",
",",
"String",
"version",
")",
"{",
"UrlFormatter",
"formatter",
... | Get Resource Url for UpdateItemDuty
@param dutyAmount The amount added to the order item for duty fees.
@param orderId Unique identifier of the order.
@param orderItemId Unique identifier of the item to remove from the order.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param updateMode Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"UpdateItemDuty",
"@param",
"dutyAmount",
"The",
"amount",
"added",
"to",
"the",
"order",
"item",
"for",
"duty",
"fees",
"."
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/orders/OrderItemUrl.java#L121-L131 |
javagl/ND | nd-iteration/src/main/java/de/javagl/nd/iteration/tuples/j/LongTupleNeighborhoodIterables.java | LongTupleNeighborhoodIterables.mooreNeighborhoodIterable | public static Iterable<MutableLongTuple> mooreNeighborhoodIterable(
LongTuple center, int radius, Order order)
{
return mooreNeighborhoodIterable(center, radius, null, null, order);
} | java | public static Iterable<MutableLongTuple> mooreNeighborhoodIterable(
LongTuple center, int radius, Order order)
{
return mooreNeighborhoodIterable(center, radius, null, null, order);
} | [
"public",
"static",
"Iterable",
"<",
"MutableLongTuple",
">",
"mooreNeighborhoodIterable",
"(",
"LongTuple",
"center",
",",
"int",
"radius",
",",
"Order",
"order",
")",
"{",
"return",
"mooreNeighborhoodIterable",
"(",
"center",
",",
"radius",
",",
"null",
",",
"... | Creates an iterable that provides iterators for iterating over the
Moore neighborhood of the given center and the given radius.<br>
<br>
Also see <a href="../../package-summary.html#Neighborhoods">
Neighborhoods</a>
@param center The center of the Moore neighborhood
A copy of this tuple will be stored internally.
@param radius The radius of the Moore neighborhood
@param order The iteration {@link Order}
@return The iterable | [
"Creates",
"an",
"iterable",
"that",
"provides",
"iterators",
"for",
"iterating",
"over",
"the",
"Moore",
"neighborhood",
"of",
"the",
"given",
"center",
"and",
"the",
"given",
"radius",
".",
"<br",
">",
"<br",
">",
"Also",
"see",
"<a",
"href",
"=",
"..",
... | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-iteration/src/main/java/de/javagl/nd/iteration/tuples/j/LongTupleNeighborhoodIterables.java#L60-L64 |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/ResourceAdapterPresenter.java | ResourceAdapterPresenter.onCreateProperty | public void onCreateProperty(AddressTemplate address, ModelNode entity, String... names) {
List<String> args = new LinkedList<>();
args.add(0, selectedAdapter);
for (String name : names) {
args.add(name);
}
ResourceAddress fqAddress = address.resolve(statementContext, args);
entity.get(OP).set(ADD);
entity.get(ADDRESS).set(fqAddress);
dispatcher.execute(new DMRAction(entity), new SimpleCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
Console.error(Console.MESSAGES.failedToCreateResource(fqAddress.toString()),
response.getFailureDescription());
} else {
Console.info(Console.MESSAGES.successfullyAdded(fqAddress.toString()));
}
loadAdapter();
}
});
} | java | public void onCreateProperty(AddressTemplate address, ModelNode entity, String... names) {
List<String> args = new LinkedList<>();
args.add(0, selectedAdapter);
for (String name : names) {
args.add(name);
}
ResourceAddress fqAddress = address.resolve(statementContext, args);
entity.get(OP).set(ADD);
entity.get(ADDRESS).set(fqAddress);
dispatcher.execute(new DMRAction(entity), new SimpleCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
Console.error(Console.MESSAGES.failedToCreateResource(fqAddress.toString()),
response.getFailureDescription());
} else {
Console.info(Console.MESSAGES.successfullyAdded(fqAddress.toString()));
}
loadAdapter();
}
});
} | [
"public",
"void",
"onCreateProperty",
"(",
"AddressTemplate",
"address",
",",
"ModelNode",
"entity",
",",
"String",
"...",
"names",
")",
"{",
"List",
"<",
"String",
">",
"args",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"args",
".",
"add",
"(",
"0",... | /*public void onCreate(AddressTemplate address, String name, ModelNode entity) {
ResourceAddress fqAddress = address.resolve(statementContext, name);
entity.get(OP).set(ADD);
entity.get(ADDRESS).set(fqAddress);
dispatcher.execute(new DMRAction(entity), new SimpleCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
Console.error("Failed to create resource " + fqAddress, response.getFailureDescription());
} else {
Console.info("Successfully created " + fqAddress);
}
loadAdapter();
}
});
} | [
"/",
"*",
"public",
"void",
"onCreate",
"(",
"AddressTemplate",
"address",
"String",
"name",
"ModelNode",
"entity",
")",
"{"
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/ResourceAdapterPresenter.java#L175-L203 |
threerings/nenya | core/src/main/java/com/threerings/util/DirectionUtil.java | DirectionUtil.getFineDirection | public static int getFineDirection (Point a, Point b)
{
return getFineDirection(a.x, a.y, b.x, b.y);
} | java | public static int getFineDirection (Point a, Point b)
{
return getFineDirection(a.x, a.y, b.x, b.y);
} | [
"public",
"static",
"int",
"getFineDirection",
"(",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"return",
"getFineDirection",
"(",
"a",
".",
"x",
",",
"a",
".",
"y",
",",
"b",
".",
"x",
",",
"b",
".",
"y",
")",
";",
"}"
] | Returns which of the sixteen compass directions that point <code>b</code> lies in from
point <code>a</code> as one of the {@link DirectionCodes} direction constants.
<em>Note:</em> that the coordinates supplied are assumed to be logical (screen) rather than
cartesian coordinates and <code>NORTH</code> is considered to point toward the top of the
screen. | [
"Returns",
"which",
"of",
"the",
"sixteen",
"compass",
"directions",
"that",
"point",
"<code",
">",
"b<",
"/",
"code",
">",
"lies",
"in",
"from",
"point",
"<code",
">",
"a<",
"/",
"code",
">",
"as",
"one",
"of",
"the",
"{"
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/DirectionUtil.java#L230-L233 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/embeddings/KerasEmbedding.java | KerasEmbedding.getInputLengthFromConfig | private int getInputLengthFromConfig(Map<String, Object> layerConfig) throws InvalidKerasConfigurationException {
Map<String, Object> innerConfig = KerasLayerUtils.getInnerLayerConfigFromConfig(layerConfig, conf);
if (!innerConfig.containsKey(conf.getLAYER_FIELD_INPUT_LENGTH()))
throw new InvalidKerasConfigurationException(
"Keras Embedding layer config missing " + conf.getLAYER_FIELD_INPUT_LENGTH() + " field");
if (innerConfig.get(conf.getLAYER_FIELD_INPUT_LENGTH()) == null) {
return 0;
} else {
return (int) innerConfig.get(conf.getLAYER_FIELD_INPUT_LENGTH());
}
} | java | private int getInputLengthFromConfig(Map<String, Object> layerConfig) throws InvalidKerasConfigurationException {
Map<String, Object> innerConfig = KerasLayerUtils.getInnerLayerConfigFromConfig(layerConfig, conf);
if (!innerConfig.containsKey(conf.getLAYER_FIELD_INPUT_LENGTH()))
throw new InvalidKerasConfigurationException(
"Keras Embedding layer config missing " + conf.getLAYER_FIELD_INPUT_LENGTH() + " field");
if (innerConfig.get(conf.getLAYER_FIELD_INPUT_LENGTH()) == null) {
return 0;
} else {
return (int) innerConfig.get(conf.getLAYER_FIELD_INPUT_LENGTH());
}
} | [
"private",
"int",
"getInputLengthFromConfig",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"layerConfig",
")",
"throws",
"InvalidKerasConfigurationException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"innerConfig",
"=",
"KerasLayerUtils",
".",
"getInnerLayer... | Get Keras input length from Keras layer configuration. In Keras input_length, if present, denotes
the number of indices to embed per mini-batch, i.e. input will be of shape (mb, input_length)
and (mb, 1) else.
@param layerConfig dictionary containing Keras layer configuration
@return input length as int | [
"Get",
"Keras",
"input",
"length",
"from",
"Keras",
"layer",
"configuration",
".",
"In",
"Keras",
"input_length",
"if",
"present",
"denotes",
"the",
"number",
"of",
"indices",
"to",
"embed",
"per",
"mini",
"-",
"batch",
"i",
".",
"e",
".",
"input",
"will",... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/embeddings/KerasEmbedding.java#L211-L221 |
Azure/azure-sdk-for-java | batchai/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/batchai/v2018_03_01/implementation/FileServersInner.java | FileServersInner.beginCreate | public FileServerInner beginCreate(String resourceGroupName, String fileServerName, FileServerCreateParameters parameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, fileServerName, parameters).toBlocking().single().body();
} | java | public FileServerInner beginCreate(String resourceGroupName, String fileServerName, FileServerCreateParameters parameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, fileServerName, parameters).toBlocking().single().body();
} | [
"public",
"FileServerInner",
"beginCreate",
"(",
"String",
"resourceGroupName",
",",
"String",
"fileServerName",
",",
"FileServerCreateParameters",
"parameters",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"fileServerName",
",",
... | Creates a file server.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param fileServerName The name of the file server within the specified resource group. File server names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param parameters The parameters to provide for file server creation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the FileServerInner object if successful. | [
"Creates",
"a",
"file",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/batchai/v2018_03_01/implementation/FileServersInner.java#L196-L198 |
haifengl/smile | core/src/main/java/smile/regression/NeuralNetwork.java | NeuralNetwork.backpropagate | private void backpropagate(Layer upper, Layer lower) {
for (int i = 0; i <= lower.units; i++) {
double out = lower.output[i];
double err = 0;
for (int j = 0; j < upper.units; j++) {
err += upper.weight[j][i] * upper.error[j];
}
if (activationFunction==ActivationFunction.LOGISTIC_SIGMOID) {
lower.error[i] = out * (1.0 - out) * err;
}
else if (activationFunction==ActivationFunction.TANH){
lower.error[i] = (1-(out*out))*err;
}
}
} | java | private void backpropagate(Layer upper, Layer lower) {
for (int i = 0; i <= lower.units; i++) {
double out = lower.output[i];
double err = 0;
for (int j = 0; j < upper.units; j++) {
err += upper.weight[j][i] * upper.error[j];
}
if (activationFunction==ActivationFunction.LOGISTIC_SIGMOID) {
lower.error[i] = out * (1.0 - out) * err;
}
else if (activationFunction==ActivationFunction.TANH){
lower.error[i] = (1-(out*out))*err;
}
}
} | [
"private",
"void",
"backpropagate",
"(",
"Layer",
"upper",
",",
"Layer",
"lower",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"lower",
".",
"units",
";",
"i",
"++",
")",
"{",
"double",
"out",
"=",
"lower",
".",
"output",
"[",
"i",... | Propagates the errors back from a upper layer to the next lower layer.
@param upper the lower layer where errors are from.
@param lower the upper layer where errors are propagated back to. | [
"Propagates",
"the",
"errors",
"back",
"from",
"a",
"upper",
"layer",
"to",
"the",
"next",
"lower",
"layer",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/regression/NeuralNetwork.java#L496-L510 |
GenesysPureEngage/authentication-client-java | src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java | AuthenticationApi.signIn | public void signIn(String username, String password, Boolean saml) throws ApiException {
signInWithHttpInfo(username, password, saml);
} | java | public void signIn(String username, String password, Boolean saml) throws ApiException {
signInWithHttpInfo(username, password, saml);
} | [
"public",
"void",
"signIn",
"(",
"String",
"username",
",",
"String",
"password",
",",
"Boolean",
"saml",
")",
"throws",
"ApiException",
"{",
"signInWithHttpInfo",
"(",
"username",
",",
"password",
",",
"saml",
")",
";",
"}"
] | Perform form-based authentication.
Perform form-based authentication by submitting an agent's username and password.
@param username The agent's username, formatted as 'tenant\\username'. (required)
@param password The agent's password. (required)
@param saml Specifies whether to login using [Security Assertion Markup Language](https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language) (SAML). (optional)
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Perform",
"form",
"-",
"based",
"authentication",
".",
"Perform",
"form",
"-",
"based",
"authentication",
"by",
"submitting",
"an",
"agent'",
";",
"s",
"username",
"and",
"password",
"."
] | train | https://github.com/GenesysPureEngage/authentication-client-java/blob/eb0d58343ee42ebd3c037163c1137f611dfcbb3a/src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java#L1199-L1201 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.broadcastTransaction | public TransactionBroadcast broadcastTransaction(final Transaction tx, final int minConnections) {
// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up
// redownloading it from the network redundantly.
if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
log.info("Transaction source unknown, setting to SELF: {}", tx.getTxId());
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
}
final TransactionBroadcast broadcast = new TransactionBroadcast(this, tx);
broadcast.setMinConnections(minConnections);
// Send the TX to the wallet once we have a successful broadcast.
Futures.addCallback(broadcast.future(), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
runningBroadcasts.remove(broadcast);
// OK, now tell the wallet about the transaction. If the wallet created the transaction then
// it already knows and will ignore this. If it's a transaction we received from
// somebody else via a side channel and are now broadcasting, this will put it into the
// wallet now we know it's valid.
for (Wallet wallet : wallets) {
// Assumption here is there are no dependencies of the created transaction.
//
// We may end up with two threads trying to do this in parallel - the wallet will
// ignore whichever one loses the race.
try {
wallet.receivePending(transaction, null);
} catch (VerificationException e) {
throw new RuntimeException(e); // Cannot fail to verify a tx we created ourselves.
}
}
}
@Override
public void onFailure(Throwable throwable) {
// This can happen if we get a reject message from a peer.
runningBroadcasts.remove(broadcast);
}
}, MoreExecutors.directExecutor());
// Keep a reference to the TransactionBroadcast object. This is important because otherwise, the entire tree
// of objects we just created would become garbage if the user doesn't hold on to the returned future, and
// eventually be collected. This in turn could result in the transaction not being committed to the wallet
// at all.
runningBroadcasts.add(broadcast);
broadcast.broadcast();
return broadcast;
} | java | public TransactionBroadcast broadcastTransaction(final Transaction tx, final int minConnections) {
// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up
// redownloading it from the network redundantly.
if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
log.info("Transaction source unknown, setting to SELF: {}", tx.getTxId());
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
}
final TransactionBroadcast broadcast = new TransactionBroadcast(this, tx);
broadcast.setMinConnections(minConnections);
// Send the TX to the wallet once we have a successful broadcast.
Futures.addCallback(broadcast.future(), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
runningBroadcasts.remove(broadcast);
// OK, now tell the wallet about the transaction. If the wallet created the transaction then
// it already knows and will ignore this. If it's a transaction we received from
// somebody else via a side channel and are now broadcasting, this will put it into the
// wallet now we know it's valid.
for (Wallet wallet : wallets) {
// Assumption here is there are no dependencies of the created transaction.
//
// We may end up with two threads trying to do this in parallel - the wallet will
// ignore whichever one loses the race.
try {
wallet.receivePending(transaction, null);
} catch (VerificationException e) {
throw new RuntimeException(e); // Cannot fail to verify a tx we created ourselves.
}
}
}
@Override
public void onFailure(Throwable throwable) {
// This can happen if we get a reject message from a peer.
runningBroadcasts.remove(broadcast);
}
}, MoreExecutors.directExecutor());
// Keep a reference to the TransactionBroadcast object. This is important because otherwise, the entire tree
// of objects we just created would become garbage if the user doesn't hold on to the returned future, and
// eventually be collected. This in turn could result in the transaction not being committed to the wallet
// at all.
runningBroadcasts.add(broadcast);
broadcast.broadcast();
return broadcast;
} | [
"public",
"TransactionBroadcast",
"broadcastTransaction",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"int",
"minConnections",
")",
"{",
"// If we don't have a record of where this tx came from already, set it to be ourselves so Peer doesn't end up",
"// redownloading it from the ne... | <p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other
peers. Once all connected peers have announced the transaction, the future available via the
{@link TransactionBroadcast#future()} method will be completed. If anything goes
wrong the exception will be thrown when get() is called, or you can receive it via a callback on the
{@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the
result.</p>
<p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future
will complete as soon as the transaction was successfully written to that peer.</p>
<p>The transaction won't be sent until there are at least minConnections active connections available.
A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial
bringup of the peer group you can lower it.</p>
<p>The returned {@link TransactionBroadcast} object can be used to get progress feedback,
which is calculated by watching the transaction propagate across the network and be announced by peers.</p> | [
"<p",
">",
"Given",
"a",
"transaction",
"sends",
"it",
"un",
"-",
"announced",
"to",
"one",
"peer",
"and",
"then",
"waits",
"for",
"it",
"to",
"be",
"received",
"back",
"from",
"other",
"peers",
".",
"Once",
"all",
"connected",
"peers",
"have",
"announce... | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L2042-L2086 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorPalette.java | TerminalEmulatorPalette.get | public Color get(TextColor.ANSI color, boolean isForeground, boolean useBrightTones) {
if(useBrightTones) {
switch(color) {
case BLACK:
return brightBlack;
case BLUE:
return brightBlue;
case CYAN:
return brightCyan;
case DEFAULT:
return isForeground ? defaultBrightColor : defaultBackgroundColor;
case GREEN:
return brightGreen;
case MAGENTA:
return brightMagenta;
case RED:
return brightRed;
case WHITE:
return brightWhite;
case YELLOW:
return brightYellow;
}
}
else {
switch(color) {
case BLACK:
return normalBlack;
case BLUE:
return normalBlue;
case CYAN:
return normalCyan;
case DEFAULT:
return isForeground ? defaultColor : defaultBackgroundColor;
case GREEN:
return normalGreen;
case MAGENTA:
return normalMagenta;
case RED:
return normalRed;
case WHITE:
return normalWhite;
case YELLOW:
return normalYellow;
}
}
throw new IllegalArgumentException("Unknown text color " + color);
} | java | public Color get(TextColor.ANSI color, boolean isForeground, boolean useBrightTones) {
if(useBrightTones) {
switch(color) {
case BLACK:
return brightBlack;
case BLUE:
return brightBlue;
case CYAN:
return brightCyan;
case DEFAULT:
return isForeground ? defaultBrightColor : defaultBackgroundColor;
case GREEN:
return brightGreen;
case MAGENTA:
return brightMagenta;
case RED:
return brightRed;
case WHITE:
return brightWhite;
case YELLOW:
return brightYellow;
}
}
else {
switch(color) {
case BLACK:
return normalBlack;
case BLUE:
return normalBlue;
case CYAN:
return normalCyan;
case DEFAULT:
return isForeground ? defaultColor : defaultBackgroundColor;
case GREEN:
return normalGreen;
case MAGENTA:
return normalMagenta;
case RED:
return normalRed;
case WHITE:
return normalWhite;
case YELLOW:
return normalYellow;
}
}
throw new IllegalArgumentException("Unknown text color " + color);
} | [
"public",
"Color",
"get",
"(",
"TextColor",
".",
"ANSI",
"color",
",",
"boolean",
"isForeground",
",",
"boolean",
"useBrightTones",
")",
"{",
"if",
"(",
"useBrightTones",
")",
"{",
"switch",
"(",
"color",
")",
"{",
"case",
"BLACK",
":",
"return",
"brightBl... | Returns the AWT color from this palette given an ANSI color and two hints for if we are looking for a background
color and if we want to use the bright version.
@param color Which ANSI color we want to extract
@param isForeground Is this color we extract going to be used as a background color?
@param useBrightTones If true, we should return the bright version of the color
@return AWT color extracted from this palette for the input parameters | [
"Returns",
"the",
"AWT",
"color",
"from",
"this",
"palette",
"given",
"an",
"ANSI",
"color",
"and",
"two",
"hints",
"for",
"if",
"we",
"are",
"looking",
"for",
"a",
"background",
"color",
"and",
"if",
"we",
"want",
"to",
"use",
"the",
"bright",
"version"... | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/TerminalEmulatorPalette.java#L284-L330 |
sematext/ActionGenerator | ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java | JSONUtils.getElasticSearchBulkHeader | public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) {
StringBuilder builder = new StringBuilder();
builder.append("{\"index\":{\"_index\":\"");
builder.append(index);
builder.append("\",\"_type\":\"");
builder.append(type);
builder.append("\",\"_id\":\"");
builder.append(event.getId());
builder.append("\"}}");
return builder.toString();
} | java | public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) {
StringBuilder builder = new StringBuilder();
builder.append("{\"index\":{\"_index\":\"");
builder.append(index);
builder.append("\",\"_type\":\"");
builder.append(type);
builder.append("\",\"_id\":\"");
builder.append(event.getId());
builder.append("\"}}");
return builder.toString();
} | [
"public",
"static",
"String",
"getElasticSearchBulkHeader",
"(",
"SimpleDataEvent",
"event",
",",
"String",
"index",
",",
"String",
"type",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"{\\\"i... | Constructs ES bulk header for the document.
@param event
data event
@param index
index name
@param type
document type
@return ES bulk header | [
"Constructs",
"ES",
"bulk",
"header",
"for",
"the",
"document",
"."
] | train | https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java#L65-L75 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServersInner.java | ServersInner.updateAsync | public Observable<ServerInner> updateAsync(String resourceGroupName, String serverName, ServerUpdate parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | java | public Observable<ServerInner> updateAsync(String resourceGroupName, String serverName, ServerUpdate parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"ServerUpdate",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
... | Updates an existing server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for updating a server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerInner object | [
"Updates",
"an",
"existing",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServersInner.java#L393-L400 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/internal/crypto/S3CryptoModuleBase.java | S3CryptoModuleBase.newContentCryptoMaterial | private ContentCryptoMaterial newContentCryptoMaterial(
EncryptionMaterialsProvider kekMaterialProvider,
Provider provider, AmazonWebServiceRequest req) {
EncryptionMaterials kekMaterials = kekMaterialProvider.getEncryptionMaterials();
if (kekMaterials == null)
throw new SdkClientException("No material available from the encryption material provider");
return buildContentCryptoMaterial(kekMaterials, provider, req);
} | java | private ContentCryptoMaterial newContentCryptoMaterial(
EncryptionMaterialsProvider kekMaterialProvider,
Provider provider, AmazonWebServiceRequest req) {
EncryptionMaterials kekMaterials = kekMaterialProvider.getEncryptionMaterials();
if (kekMaterials == null)
throw new SdkClientException("No material available from the encryption material provider");
return buildContentCryptoMaterial(kekMaterials, provider, req);
} | [
"private",
"ContentCryptoMaterial",
"newContentCryptoMaterial",
"(",
"EncryptionMaterialsProvider",
"kekMaterialProvider",
",",
"Provider",
"provider",
",",
"AmazonWebServiceRequest",
"req",
")",
"{",
"EncryptionMaterials",
"kekMaterials",
"=",
"kekMaterialProvider",
".",
"getE... | Returns a non-null content encryption material generated with the given kek
material and security providers.
@throws SdkClientException if no encryption material can be found from
the given encryption material provider. | [
"Returns",
"a",
"non",
"-",
"null",
"content",
"encryption",
"material",
"generated",
"with",
"the",
"given",
"kek",
"material",
"and",
"security",
"providers",
"."
] | train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/internal/crypto/S3CryptoModuleBase.java#L485-L492 |
SonarSource/sonarqube | server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java | MyBatis.newScrollingSelectStatement | public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
} | java | public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
} | [
"public",
"PreparedStatement",
"newScrollingSelectStatement",
"(",
"DbSession",
"session",
",",
"String",
"sql",
")",
"{",
"int",
"fetchSize",
"=",
"database",
".",
"getDialect",
"(",
")",
".",
"getScrollDefaultFetchSize",
"(",
")",
";",
"return",
"newScrollingSelec... | Create a PreparedStatement for SELECT requests with scrolling of results | [
"Create",
"a",
"PreparedStatement",
"for",
"SELECT",
"requests",
"with",
"scrolling",
"of",
"results"
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java#L312-L315 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/Matrices.java | Matrices.getRotationJAMA | public static Matrix getRotationJAMA(Matrix4d transform) {
Matrix rot = new Matrix(3, 3);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rot.set(j, i, transform.getElement(i, j)); // transposed
}
}
return rot;
} | java | public static Matrix getRotationJAMA(Matrix4d transform) {
Matrix rot = new Matrix(3, 3);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rot.set(j, i, transform.getElement(i, j)); // transposed
}
}
return rot;
} | [
"public",
"static",
"Matrix",
"getRotationJAMA",
"(",
"Matrix4d",
"transform",
")",
"{",
"Matrix",
"rot",
"=",
"new",
"Matrix",
"(",
"3",
",",
"3",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
... | Convert a transformation matrix into a JAMA rotation matrix. Because the
JAMA matrix is a pre-multiplication matrix and the Vecmath matrix is a
post-multiplication one, the rotation matrix is transposed to ensure that
the transformation they produce is the same.
@param transform
Matrix4d with transposed rotation matrix
@return rotation matrix as JAMA object | [
"Convert",
"a",
"transformation",
"matrix",
"into",
"a",
"JAMA",
"rotation",
"matrix",
".",
"Because",
"the",
"JAMA",
"matrix",
"is",
"a",
"pre",
"-",
"multiplication",
"matrix",
"and",
"the",
"Vecmath",
"matrix",
"is",
"a",
"post",
"-",
"multiplication",
"o... | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/Matrices.java#L54-L63 |
languagetool-org/languagetool | languagetool-office-extension/src/main/java/org/languagetool/openoffice/ResultCache.java | ResultCache.removeRange | void removeRange(int firstParagraph, int lastParagraph) {
for(int i = 0; i < entries.size(); i++) {
if(entries.get(i).numberOfParagraph >= firstParagraph && entries.get(i).numberOfParagraph <= lastParagraph) {
entries.remove(i);
i--;
}
}
} | java | void removeRange(int firstParagraph, int lastParagraph) {
for(int i = 0; i < entries.size(); i++) {
if(entries.get(i).numberOfParagraph >= firstParagraph && entries.get(i).numberOfParagraph <= lastParagraph) {
entries.remove(i);
i--;
}
}
} | [
"void",
"removeRange",
"(",
"int",
"firstParagraph",
",",
"int",
"lastParagraph",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entries",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"entries",
".",
"get",
"(",
"i",
... | Remove all cache entries between firstParagraph and lastParagraph | [
"Remove",
"all",
"cache",
"entries",
"between",
"firstParagraph",
"and",
"lastParagraph"
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-office-extension/src/main/java/org/languagetool/openoffice/ResultCache.java#L67-L74 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/task_device_log.java | task_device_log.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
task_device_log_responses result = (task_device_log_responses) service.get_payload_formatter().string_to_resource(task_device_log_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.task_device_log_response_array);
}
task_device_log[] result_task_device_log = new task_device_log[result.task_device_log_response_array.length];
for(int i = 0; i < result.task_device_log_response_array.length; i++)
{
result_task_device_log[i] = result.task_device_log_response_array[i].task_device_log[0];
}
return result_task_device_log;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
task_device_log_responses result = (task_device_log_responses) service.get_payload_formatter().string_to_resource(task_device_log_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.task_device_log_response_array);
}
task_device_log[] result_task_device_log = new task_device_log[result.task_device_log_response_array.length];
for(int i = 0; i < result.task_device_log_response_array.length; i++)
{
result_task_device_log[i] = result.task_device_log_response_array[i].task_device_log[0];
}
return result_task_device_log;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"task_device_log_responses",
"result",
"=",
"(",
"task_device_log_responses",
")",
"service",
".",
"get_payloa... | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/task_device_log.java#L269-L286 |
census-instrumentation/opencensus-java | api/src/main/java/io/opencensus/trace/SpanId.java | SpanId.fromBytes | public static SpanId fromBytes(byte[] src, int srcOffset) {
Utils.checkNotNull(src, "src");
return new SpanId(BigendianEncoding.longFromByteArray(src, srcOffset));
} | java | public static SpanId fromBytes(byte[] src, int srcOffset) {
Utils.checkNotNull(src, "src");
return new SpanId(BigendianEncoding.longFromByteArray(src, srcOffset));
} | [
"public",
"static",
"SpanId",
"fromBytes",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"{",
"Utils",
".",
"checkNotNull",
"(",
"src",
",",
"\"src\"",
")",
";",
"return",
"new",
"SpanId",
"(",
"BigendianEncoding",
".",
"longFromByteArray",
"... | Returns a {@code SpanId} whose representation is copied from the {@code src} beginning at the
{@code srcOffset} offset.
@param src the buffer where the representation of the {@code SpanId} is copied.
@param srcOffset the offset in the buffer where the representation of the {@code SpanId}
begins.
@return a {@code SpanId} whose representation is copied from the buffer.
@throws NullPointerException if {@code src} is null.
@throws IndexOutOfBoundsException if {@code srcOffset+SpanId.SIZE} is greater than {@code
src.length}.
@since 0.5 | [
"Returns",
"a",
"{",
"@code",
"SpanId",
"}",
"whose",
"representation",
"is",
"copied",
"from",
"the",
"{",
"@code",
"src",
"}",
"beginning",
"at",
"the",
"{",
"@code",
"srcOffset",
"}",
"offset",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/api/src/main/java/io/opencensus/trace/SpanId.java#L85-L88 |
JodaOrg/joda-time | src/main/java/org/joda/time/Duration.java | Duration.withDurationAdded | public Duration withDurationAdded(long durationToAdd, int scalar) {
if (durationToAdd == 0 || scalar == 0) {
return this;
}
long add = FieldUtils.safeMultiply(durationToAdd, scalar);
long duration = FieldUtils.safeAdd(getMillis(), add);
return new Duration(duration);
} | java | public Duration withDurationAdded(long durationToAdd, int scalar) {
if (durationToAdd == 0 || scalar == 0) {
return this;
}
long add = FieldUtils.safeMultiply(durationToAdd, scalar);
long duration = FieldUtils.safeAdd(getMillis(), add);
return new Duration(duration);
} | [
"public",
"Duration",
"withDurationAdded",
"(",
"long",
"durationToAdd",
",",
"int",
"scalar",
")",
"{",
"if",
"(",
"durationToAdd",
"==",
"0",
"||",
"scalar",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"long",
"add",
"=",
"FieldUtils",
".",
"safeM... | Returns a new duration with this length plus that specified multiplied by the scalar.
This instance is immutable and is not altered.
<p>
If the addition is zero, this instance is returned.
@param durationToAdd the duration to add to this one
@param scalar the amount of times to add, such as -1 to subtract once
@return the new duration instance | [
"Returns",
"a",
"new",
"duration",
"with",
"this",
"length",
"plus",
"that",
"specified",
"multiplied",
"by",
"the",
"scalar",
".",
"This",
"instance",
"is",
"immutable",
"and",
"is",
"not",
"altered",
".",
"<p",
">",
"If",
"the",
"addition",
"is",
"zero",... | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Duration.java#L390-L397 |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/ParseContext.java | ParseContext.applyNewNode | final boolean applyNewNode(Parser<?> parser, String name) {
int physical = at;
int logical = step;
TreeNode latestChild = trace.getLatestChild();
trace.push(name);
if (parser.apply(this)) {
trace.setCurrentResult(result);
trace.pop();
return true;
}
if (stillThere(physical, logical)) expected(name);
trace.pop();
// On failure, the erroneous path shouldn't be counted in the parse tree.
trace.setLatestChild(latestChild);
return false;
} | java | final boolean applyNewNode(Parser<?> parser, String name) {
int physical = at;
int logical = step;
TreeNode latestChild = trace.getLatestChild();
trace.push(name);
if (parser.apply(this)) {
trace.setCurrentResult(result);
trace.pop();
return true;
}
if (stillThere(physical, logical)) expected(name);
trace.pop();
// On failure, the erroneous path shouldn't be counted in the parse tree.
trace.setLatestChild(latestChild);
return false;
} | [
"final",
"boolean",
"applyNewNode",
"(",
"Parser",
"<",
"?",
">",
"parser",
",",
"String",
"name",
")",
"{",
"int",
"physical",
"=",
"at",
";",
"int",
"logical",
"=",
"step",
";",
"TreeNode",
"latestChild",
"=",
"trace",
".",
"getLatestChild",
"(",
")",
... | Applies {@code parser} as a new tree node with {@code name}, and if fails, reports
"expecting $name". | [
"Applies",
"{"
] | train | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/ParseContext.java#L140-L155 |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.touchMessage | public MessageOptions touchMessage(String id, String reservationId) throws IOException {
return touchMessage(id, reservationId, null);
} | java | public MessageOptions touchMessage(String id, String reservationId) throws IOException {
return touchMessage(id, reservationId, null);
} | [
"public",
"MessageOptions",
"touchMessage",
"(",
"String",
"id",
",",
"String",
"reservationId",
")",
"throws",
"IOException",
"{",
"return",
"touchMessage",
"(",
"id",
",",
"reservationId",
",",
"null",
")",
";",
"}"
] | Touching a reserved message extends its timeout to the duration specified when the message was created.
@param id The ID of the message to delete.
@param reservationId This id is returned when you reserve a message and must be provided to delete a message that is reserved.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Touching",
"a",
"reserved",
"message",
"extends",
"its",
"timeout",
"to",
"the",
"duration",
"specified",
"when",
"the",
"message",
"was",
"created",
"."
] | train | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L222-L224 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwpolicylabel_appfwpolicy_binding.java | appfwpolicylabel_appfwpolicy_binding.count_filtered | public static long count_filtered(nitro_service service, String labelname, String filter) throws Exception{
appfwpolicylabel_appfwpolicy_binding obj = new appfwpolicylabel_appfwpolicy_binding();
obj.set_labelname(labelname);
options option = new options();
option.set_count(true);
option.set_filter(filter);
appfwpolicylabel_appfwpolicy_binding[] response = (appfwpolicylabel_appfwpolicy_binding[]) obj.getfiltered(service, option);
if (response != null) {
return response[0].__count;
}
return 0;
} | java | public static long count_filtered(nitro_service service, String labelname, String filter) throws Exception{
appfwpolicylabel_appfwpolicy_binding obj = new appfwpolicylabel_appfwpolicy_binding();
obj.set_labelname(labelname);
options option = new options();
option.set_count(true);
option.set_filter(filter);
appfwpolicylabel_appfwpolicy_binding[] response = (appfwpolicylabel_appfwpolicy_binding[]) obj.getfiltered(service, option);
if (response != null) {
return response[0].__count;
}
return 0;
} | [
"public",
"static",
"long",
"count_filtered",
"(",
"nitro_service",
"service",
",",
"String",
"labelname",
",",
"String",
"filter",
")",
"throws",
"Exception",
"{",
"appfwpolicylabel_appfwpolicy_binding",
"obj",
"=",
"new",
"appfwpolicylabel_appfwpolicy_binding",
"(",
"... | Use this API to count the filtered set of appfwpolicylabel_appfwpolicy_binding resources.
filter string should be in JSON format.eg: "port:80,servicetype:HTTP". | [
"Use",
"this",
"API",
"to",
"count",
"the",
"filtered",
"set",
"of",
"appfwpolicylabel_appfwpolicy_binding",
"resources",
".",
"filter",
"string",
"should",
"be",
"in",
"JSON",
"format",
".",
"eg",
":",
"port",
":",
"80",
"servicetype",
":",
"HTTP",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwpolicylabel_appfwpolicy_binding.java#L335-L346 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java | AbstractRegionPainter.getFocusPaint | public Paint getFocusPaint(Shape s, FocusType focusType, boolean useToolBarFocus) {
if (focusType == FocusType.OUTER_FOCUS) {
return useToolBarFocus ? outerToolBarFocus : outerFocus;
} else {
return useToolBarFocus ? innerToolBarFocus : innerFocus;
}
} | java | public Paint getFocusPaint(Shape s, FocusType focusType, boolean useToolBarFocus) {
if (focusType == FocusType.OUTER_FOCUS) {
return useToolBarFocus ? outerToolBarFocus : outerFocus;
} else {
return useToolBarFocus ? innerToolBarFocus : innerFocus;
}
} | [
"public",
"Paint",
"getFocusPaint",
"(",
"Shape",
"s",
",",
"FocusType",
"focusType",
",",
"boolean",
"useToolBarFocus",
")",
"{",
"if",
"(",
"focusType",
"==",
"FocusType",
".",
"OUTER_FOCUS",
")",
"{",
"return",
"useToolBarFocus",
"?",
"outerToolBarFocus",
":"... | Get the paint to use for a focus ring.
@param s the shape to paint.
@param focusType the focus type.
@param useToolBarFocus whether we should use the colors for a toolbar control.
@return the paint to use to paint the focus ring. | [
"Get",
"the",
"paint",
"to",
"use",
"for",
"a",
"focus",
"ring",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L175-L181 |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/dataprovider/MapCompositeDataProvider.java | MapCompositeDataProvider.addDataProvider | public void addDataProvider(K key, DataProvider<DPO> dataProvider) {
dataProviders.put(key, dataProvider);
} | java | public void addDataProvider(K key, DataProvider<DPO> dataProvider) {
dataProviders.put(key, dataProvider);
} | [
"public",
"void",
"addDataProvider",
"(",
"K",
"key",
",",
"DataProvider",
"<",
"DPO",
">",
"dataProvider",
")",
"{",
"dataProviders",
".",
"put",
"(",
"key",
",",
"dataProvider",
")",
";",
"}"
] | Adds the specified data provider with the specified key.
@param key Key associated to the data provider.
@param dataProvider Data provider associated to the key. | [
"Adds",
"the",
"specified",
"data",
"provider",
"with",
"the",
"specified",
"key",
"."
] | train | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/dataprovider/MapCompositeDataProvider.java#L56-L58 |
jmapper-framework/jmapper-core | JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java | Error.mapping | public static void mapping(String mappedFieldName, String mappedClassName){
throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException2length,mappedFieldName,mappedClassName));
} | java | public static void mapping(String mappedFieldName, String mappedClassName){
throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException2length,mappedFieldName,mappedClassName));
} | [
"public",
"static",
"void",
"mapping",
"(",
"String",
"mappedFieldName",
",",
"String",
"mappedClassName",
")",
"{",
"throw",
"new",
"MappingErrorException",
"(",
"MSG",
".",
"INSTANCE",
".",
"message",
"(",
"mappingErrorException2length",
",",
"mappedFieldName",
",... | Thrown when the length of classes and attribute parameter isn't the same.
@param mappedFieldName name of the mapped field
@param mappedClassName name of the mapped field's class | [
"Thrown",
"when",
"the",
"length",
"of",
"classes",
"and",
"attribute",
"parameter",
"isn",
"t",
"the",
"same",
"."
] | train | https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java#L463-L465 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/tools/manipulator/ReactionSchemeManipulator.java | ReactionSchemeManipulator.setScheme | private static IReactionScheme setScheme(IReaction reaction, IReactionSet reactionSet) {
IReactionScheme reactionScheme = reaction.getBuilder().newInstance(IReactionScheme.class);
IReactionSet reactConSet = extractSubsequentReaction(reaction, reactionSet);
if (reactConSet.getReactionCount() != 0) {
for (IReaction reactionInt : reactConSet.reactions()) {
reactionScheme.addReaction(reactionInt);
IReactionScheme newRScheme = setScheme(reactionInt, reactionSet);
if (newRScheme.getReactionCount() != 0 || newRScheme.getReactionSchemeCount() != 0) {
reactionScheme.add(newRScheme);
}
}
}
return reactionScheme;
} | java | private static IReactionScheme setScheme(IReaction reaction, IReactionSet reactionSet) {
IReactionScheme reactionScheme = reaction.getBuilder().newInstance(IReactionScheme.class);
IReactionSet reactConSet = extractSubsequentReaction(reaction, reactionSet);
if (reactConSet.getReactionCount() != 0) {
for (IReaction reactionInt : reactConSet.reactions()) {
reactionScheme.addReaction(reactionInt);
IReactionScheme newRScheme = setScheme(reactionInt, reactionSet);
if (newRScheme.getReactionCount() != 0 || newRScheme.getReactionSchemeCount() != 0) {
reactionScheme.add(newRScheme);
}
}
}
return reactionScheme;
} | [
"private",
"static",
"IReactionScheme",
"setScheme",
"(",
"IReaction",
"reaction",
",",
"IReactionSet",
"reactionSet",
")",
"{",
"IReactionScheme",
"reactionScheme",
"=",
"reaction",
".",
"getBuilder",
"(",
")",
".",
"newInstance",
"(",
"IReactionScheme",
".",
"clas... | Create a IReactionScheme given as a top a IReaction. If it doesn't exist any subsequent reaction
return null;
@param reaction The IReaction as a top
@param reactionSet The IReactionSet to extract a IReactionScheme
@return The IReactionScheme | [
"Create",
"a",
"IReactionScheme",
"given",
"as",
"a",
"top",
"a",
"IReaction",
".",
"If",
"it",
"doesn",
"t",
"exist",
"any",
"subsequent",
"reaction",
"return",
"null",
";"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/ReactionSchemeManipulator.java#L186-L200 |
alkacon/opencms-core | src/org/opencms/security/CmsPrincipal.java | CmsPrincipal.readPrincipalIncludingHistory | public static I_CmsPrincipal readPrincipalIncludingHistory(CmsObject cms, CmsUUID id) throws CmsException {
try {
// first try to read the principal as a user
return cms.readUser(id);
} catch (CmsException exc) {
// assume user does not exist
}
try {
// now try to read the principal as a group
return cms.readGroup(id);
} catch (CmsException exc) {
// assume group does not exist
}
try {
// at the end try to read the principal from the history
return cms.readHistoryPrincipal(id);
} catch (CmsException exc) {
// assume the principal does not exist at all
}
// invalid principal name was given
throw new CmsDbEntryNotFoundException(Messages.get().container(Messages.ERR_INVALID_PRINCIPAL_1, id));
} | java | public static I_CmsPrincipal readPrincipalIncludingHistory(CmsObject cms, CmsUUID id) throws CmsException {
try {
// first try to read the principal as a user
return cms.readUser(id);
} catch (CmsException exc) {
// assume user does not exist
}
try {
// now try to read the principal as a group
return cms.readGroup(id);
} catch (CmsException exc) {
// assume group does not exist
}
try {
// at the end try to read the principal from the history
return cms.readHistoryPrincipal(id);
} catch (CmsException exc) {
// assume the principal does not exist at all
}
// invalid principal name was given
throw new CmsDbEntryNotFoundException(Messages.get().container(Messages.ERR_INVALID_PRINCIPAL_1, id));
} | [
"public",
"static",
"I_CmsPrincipal",
"readPrincipalIncludingHistory",
"(",
"CmsObject",
"cms",
",",
"CmsUUID",
"id",
")",
"throws",
"CmsException",
"{",
"try",
"{",
"// first try to read the principal as a user",
"return",
"cms",
".",
"readUser",
"(",
"id",
")",
";",... | Utility function to read a principal by its id from the OpenCms database using the
provided OpenCms user context.<p>
@param cms the OpenCms user context to use when reading the principal
@param id the id of the principal to read
@return the principal read from the OpenCms database
@throws CmsException in case the principal could not be read | [
"Utility",
"function",
"to",
"read",
"a",
"principal",
"by",
"its",
"id",
"from",
"the",
"OpenCms",
"database",
"using",
"the",
"provided",
"OpenCms",
"user",
"context",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/security/CmsPrincipal.java#L338-L360 |
paypal/SeLion | codegen/src/main/java/com/paypal/selion/plugins/GUIObjectDetails.java | GUIObjectDetails.transformKeys | public static List<GUIObjectDetails> transformKeys(List<String> keys) {
return transformKeys(keys, TestPlatform.WEB);
} | java | public static List<GUIObjectDetails> transformKeys(List<String> keys) {
return transformKeys(keys, TestPlatform.WEB);
} | [
"public",
"static",
"List",
"<",
"GUIObjectDetails",
">",
"transformKeys",
"(",
"List",
"<",
"String",
">",
"keys",
")",
"{",
"return",
"transformKeys",
"(",
"keys",
",",
"TestPlatform",
".",
"WEB",
")",
";",
"}"
] | A overloaded version of transformKeys method which internally specifies {@link TestPlatform#WEB} as the
{@link TestPlatform}
@param keys
keys for which {@link GUIObjectDetails} is to be created.
@return the {@link List} of {@link GUIObjectDetails} | [
"A",
"overloaded",
"version",
"of",
"transformKeys",
"method",
"which",
"internally",
"specifies",
"{",
"@link",
"TestPlatform#WEB",
"}",
"as",
"the",
"{",
"@link",
"TestPlatform",
"}"
] | train | https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/codegen/src/main/java/com/paypal/selion/plugins/GUIObjectDetails.java#L124-L126 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java | Subtypes2.addSupertypeEdges | private void addSupertypeEdges(ClassVertex vertex, LinkedList<XClass> workList) {
XClass xclass = vertex.getXClass();
// Direct superclass
ClassDescriptor superclassDescriptor = xclass.getSuperclassDescriptor();
if (superclassDescriptor != null) {
addInheritanceEdge(vertex, superclassDescriptor, false, workList);
}
// Directly implemented interfaces
for (ClassDescriptor ifaceDesc : xclass.getInterfaceDescriptorList()) {
addInheritanceEdge(vertex, ifaceDesc, true, workList);
}
} | java | private void addSupertypeEdges(ClassVertex vertex, LinkedList<XClass> workList) {
XClass xclass = vertex.getXClass();
// Direct superclass
ClassDescriptor superclassDescriptor = xclass.getSuperclassDescriptor();
if (superclassDescriptor != null) {
addInheritanceEdge(vertex, superclassDescriptor, false, workList);
}
// Directly implemented interfaces
for (ClassDescriptor ifaceDesc : xclass.getInterfaceDescriptorList()) {
addInheritanceEdge(vertex, ifaceDesc, true, workList);
}
} | [
"private",
"void",
"addSupertypeEdges",
"(",
"ClassVertex",
"vertex",
",",
"LinkedList",
"<",
"XClass",
">",
"workList",
")",
"{",
"XClass",
"xclass",
"=",
"vertex",
".",
"getXClass",
"(",
")",
";",
"// Direct superclass",
"ClassDescriptor",
"superclassDescriptor",
... | Add supertype edges to the InheritanceGraph for given ClassVertex. If any
direct supertypes have not been processed, add them to the worklist.
@param vertex
a ClassVertex whose supertype edges need to be added
@param workList
work list of ClassVertexes that need to have their supertype
edges added | [
"Add",
"supertype",
"edges",
"to",
"the",
"InheritanceGraph",
"for",
"given",
"ClassVertex",
".",
"If",
"any",
"direct",
"supertypes",
"have",
"not",
"been",
"processed",
"add",
"them",
"to",
"the",
"worklist",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java#L1307-L1320 |
Stratio/deep-spark | deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java | JdbcNativeCellExtractor.transformElement | @Override
protected Cells transformElement(Map<String, Object> entity) {
return UtilJdbc.getCellsFromObject(entity, jdbcDeepJobConfig);
} | java | @Override
protected Cells transformElement(Map<String, Object> entity) {
return UtilJdbc.getCellsFromObject(entity, jdbcDeepJobConfig);
} | [
"@",
"Override",
"protected",
"Cells",
"transformElement",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"entity",
")",
"{",
"return",
"UtilJdbc",
".",
"getCellsFromObject",
"(",
"entity",
",",
"jdbcDeepJobConfig",
")",
";",
"}"
] | Transforms a database row represented as a Map into a Cells object.
@param entity Database row represented as a Map of column name:column value.
@return Cells object with database row data. | [
"Transforms",
"a",
"database",
"row",
"represented",
"as",
"a",
"Map",
"into",
"a",
"Cells",
"object",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/extractor/JdbcNativeCellExtractor.java#L48-L51 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java | OjbTagsHandler.createTorqueSchema | public String createTorqueSchema(Properties attributes) throws XDocletException
{
String dbName = (String)getDocletContext().getConfigParam(CONFIG_PARAM_DATABASENAME);
_torqueModel = new TorqueModelDef(dbName, _model);
return "";
} | java | public String createTorqueSchema(Properties attributes) throws XDocletException
{
String dbName = (String)getDocletContext().getConfigParam(CONFIG_PARAM_DATABASENAME);
_torqueModel = new TorqueModelDef(dbName, _model);
return "";
} | [
"public",
"String",
"createTorqueSchema",
"(",
"Properties",
"attributes",
")",
"throws",
"XDocletException",
"{",
"String",
"dbName",
"=",
"(",
"String",
")",
"getDocletContext",
"(",
")",
".",
"getConfigParam",
"(",
"CONFIG_PARAM_DATABASENAME",
")",
";",
"_torqueM... | Generates a torque schema for the model.
@param attributes The attributes of the tag
@return The property value
@exception XDocletException If an error occurs
@doc.tag type="content" | [
"Generates",
"a",
"torque",
"schema",
"for",
"the",
"model",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java#L1310-L1316 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java | DscConfigurationsInner.getContent | public String getContent(String resourceGroupName, String automationAccountName, String configurationName) {
return getContentWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).toBlocking().single().body();
} | java | public String getContent(String resourceGroupName, String automationAccountName, String configurationName) {
return getContentWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).toBlocking().single().body();
} | [
"public",
"String",
"getContent",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"configurationName",
")",
"{",
"return",
"getContentWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"configur... | Retrieve the configuration script identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the String object if successful. | [
"Retrieve",
"the",
"configuration",
"script",
"identified",
"by",
"configuration",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java#L571-L573 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTileTransitionModel.java | MapTileTransitionModel.updateTransitive | private void updateTransitive(Collection<Tile> resolved, Tile tile, Tile neighbor, GroupTransition transitive)
{
final String transitiveOut = transitive.getOut();
final Transition transition = new Transition(TransitionType.CENTER, transitiveOut, transitiveOut);
final Collection<TileRef> refs = getTiles(transition);
if (!refs.isEmpty())
{
final TileRef ref = refs.iterator().next();
// Replace user tile with the needed tile to solve transition (restored later)
final Tile newTile = map.createTile(ref.getSheet(), ref.getNumber(), tile.getX(), tile.getY());
map.setTile(newTile);
// Replace neighbor with the needed tile to solve transition
final Tile newTile2 = map.createTile(ref.getSheet(), ref.getNumber(), neighbor.getX(), neighbor.getY());
map.setTile(newTile2);
resolved.addAll(resolve(newTile2));
}
} | java | private void updateTransitive(Collection<Tile> resolved, Tile tile, Tile neighbor, GroupTransition transitive)
{
final String transitiveOut = transitive.getOut();
final Transition transition = new Transition(TransitionType.CENTER, transitiveOut, transitiveOut);
final Collection<TileRef> refs = getTiles(transition);
if (!refs.isEmpty())
{
final TileRef ref = refs.iterator().next();
// Replace user tile with the needed tile to solve transition (restored later)
final Tile newTile = map.createTile(ref.getSheet(), ref.getNumber(), tile.getX(), tile.getY());
map.setTile(newTile);
// Replace neighbor with the needed tile to solve transition
final Tile newTile2 = map.createTile(ref.getSheet(), ref.getNumber(), neighbor.getX(), neighbor.getY());
map.setTile(newTile2);
resolved.addAll(resolve(newTile2));
}
} | [
"private",
"void",
"updateTransitive",
"(",
"Collection",
"<",
"Tile",
">",
"resolved",
",",
"Tile",
"tile",
",",
"Tile",
"neighbor",
",",
"GroupTransition",
"transitive",
")",
"{",
"final",
"String",
"transitiveOut",
"=",
"transitive",
".",
"getOut",
"(",
")"... | Update the transitive between tile and its neighbor.
@param resolved The resolved tiles.
@param tile The tile reference.
@param neighbor The neighbor reference.
@param transitive The transitive involved. | [
"Update",
"the",
"transitive",
"between",
"tile",
"and",
"its",
"neighbor",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTileTransitionModel.java#L358-L376 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/util/Utils.java | Utils.normalize | public static String normalize(final String text, final Configuration config){
if(text != null && config.isNormalizeLabelText()){
return text.trim().replaceAll("[\n\r]", "").replaceAll("[\t ]+", " ");
}
return text;
} | java | public static String normalize(final String text, final Configuration config){
if(text != null && config.isNormalizeLabelText()){
return text.trim().replaceAll("[\n\r]", "").replaceAll("[\t ]+", " ");
}
return text;
} | [
"public",
"static",
"String",
"normalize",
"(",
"final",
"String",
"text",
",",
"final",
"Configuration",
"config",
")",
"{",
"if",
"(",
"text",
"!=",
"null",
"&&",
"config",
".",
"isNormalizeLabelText",
"(",
")",
")",
"{",
"return",
"text",
".",
"trim",
... | システム設定に従いラベルを正規化する。
@since 1.1
@param text セルのラベル
@param config システム設定
@return true:ラベルが一致する。 | [
"システム設定に従いラベルを正規化する。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/Utils.java#L256-L261 |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java | XDMAuditor.auditPortableMediaImport | public void auditPortableMediaImport(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | java | public void auditPortableMediaImport(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | [
"public",
"void",
"auditPortableMediaImport",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"submissionSetUniqueId",
",",
"String",
"patientId",
",",
"List",
"<",
"CodedValueType",
">",
"purposesOfUse",
")",
"{",
"if",
"(",
"!",
"isAuditorEnabled",
"... | Audits a PHI Import event for the IHE XDM Portable Media Importer
actor and ITI-32 Distribute Document Set on Media Transaction.
@param eventOutcome The event outcome indicator
@param submissionSetUniqueId The Unique ID of the Submission Set imported
@param patientId The ID of the Patient to which the Submission Set pertains | [
"Audits",
"a",
"PHI",
"Import",
"event",
"for",
"the",
"IHE",
"XDM",
"Portable",
"Media",
"Importer",
"actor",
"and",
"ITI",
"-",
"32",
"Distribute",
"Document",
"Set",
"on",
"Media",
"Transaction",
"."
] | train | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java#L53-L71 |
jenkinsci/jenkins | core/src/main/java/jenkins/model/Jenkins.java | Jenkins.doQuietDown | @RequirePOST
public HttpRedirect doQuietDown(@QueryParameter boolean block, @QueryParameter int timeout) throws InterruptedException, IOException {
synchronized (this) {
checkPermission(ADMINISTER);
isQuietingDown = true;
}
if (block) {
long waitUntil = timeout;
if (timeout > 0) waitUntil += System.currentTimeMillis();
while (isQuietingDown
&& (timeout <= 0 || System.currentTimeMillis() < waitUntil)
&& !RestartListener.isAllReady()) {
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
}
}
return new HttpRedirect(".");
} | java | @RequirePOST
public HttpRedirect doQuietDown(@QueryParameter boolean block, @QueryParameter int timeout) throws InterruptedException, IOException {
synchronized (this) {
checkPermission(ADMINISTER);
isQuietingDown = true;
}
if (block) {
long waitUntil = timeout;
if (timeout > 0) waitUntil += System.currentTimeMillis();
while (isQuietingDown
&& (timeout <= 0 || System.currentTimeMillis() < waitUntil)
&& !RestartListener.isAllReady()) {
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
}
}
return new HttpRedirect(".");
} | [
"@",
"RequirePOST",
"public",
"HttpRedirect",
"doQuietDown",
"(",
"@",
"QueryParameter",
"boolean",
"block",
",",
"@",
"QueryParameter",
"int",
"timeout",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"synchronized",
"(",
"this",
")",
"{",
"check... | Quiet down Jenkins - preparation for a restart
@param block Block until the system really quiets down and no builds are running
@param timeout If non-zero, only block up to the specified number of milliseconds | [
"Quiet",
"down",
"Jenkins",
"-",
"preparation",
"for",
"a",
"restart"
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/model/Jenkins.java#L3818-L3834 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/HTODDynacache.java | HTODDynacache.delCacheEntry | public void delCacheEntry(CacheEntry ce, int cause, int source, boolean fromDepIdTemplateInvalidation) {
this.invalidationBuffer.add(ce.id, HTODInvalidationBuffer.EXPLICIT_BUFFER, cause, source, fromDepIdTemplateInvalidation, !HTODInvalidationBuffer.FIRE_EVENT,
!HTODInvalidationBuffer.ALIAS_ID);
for (int i = 0; i < ce.aliasList.length; i++) {
this.invalidationBuffer.add(ce.aliasList[i], HTODInvalidationBuffer.EXPLICIT_BUFFER, cause, source, fromDepIdTemplateInvalidation, !HTODInvalidationBuffer.FIRE_EVENT,
HTODInvalidationBuffer.ALIAS_ID);;
}
} | java | public void delCacheEntry(CacheEntry ce, int cause, int source, boolean fromDepIdTemplateInvalidation) {
this.invalidationBuffer.add(ce.id, HTODInvalidationBuffer.EXPLICIT_BUFFER, cause, source, fromDepIdTemplateInvalidation, !HTODInvalidationBuffer.FIRE_EVENT,
!HTODInvalidationBuffer.ALIAS_ID);
for (int i = 0; i < ce.aliasList.length; i++) {
this.invalidationBuffer.add(ce.aliasList[i], HTODInvalidationBuffer.EXPLICIT_BUFFER, cause, source, fromDepIdTemplateInvalidation, !HTODInvalidationBuffer.FIRE_EVENT,
HTODInvalidationBuffer.ALIAS_ID);;
}
} | [
"public",
"void",
"delCacheEntry",
"(",
"CacheEntry",
"ce",
",",
"int",
"cause",
",",
"int",
"source",
",",
"boolean",
"fromDepIdTemplateInvalidation",
")",
"{",
"this",
".",
"invalidationBuffer",
".",
"add",
"(",
"ce",
".",
"id",
",",
"HTODInvalidationBuffer",
... | ***********************************************************************
delCacheEntry()
Delete cacheEntry from the disk. This also remove dependencies for all dataIds and templates
to the cacheEntry
*********************************************************************** | [
"***********************************************************************",
"delCacheEntry",
"()",
"Delete",
"cacheEntry",
"from",
"the",
"disk",
".",
"This",
"also",
"remove",
"dependencies",
"for",
"all",
"dataIds",
"and",
"templates",
"to",
"the",
"cacheEntry",
"*********... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/HTODDynacache.java#L664-L671 |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Codecs.java | Codecs.ofScalar | public static <A> Codec<A, AnyGene<A>> ofScalar(
final Supplier<? extends A> supplier,
final Predicate<? super A> validator
) {
return Codec.of(
Genotype.of(AnyChromosome.of(supplier, validator)),
gt -> gt.getGene().getAllele()
);
} | java | public static <A> Codec<A, AnyGene<A>> ofScalar(
final Supplier<? extends A> supplier,
final Predicate<? super A> validator
) {
return Codec.of(
Genotype.of(AnyChromosome.of(supplier, validator)),
gt -> gt.getGene().getAllele()
);
} | [
"public",
"static",
"<",
"A",
">",
"Codec",
"<",
"A",
",",
"AnyGene",
"<",
"A",
">",
">",
"ofScalar",
"(",
"final",
"Supplier",
"<",
"?",
"extends",
"A",
">",
"supplier",
",",
"final",
"Predicate",
"<",
"?",
"super",
"A",
">",
"validator",
")",
"{"... | Return a scala {@code Codec} with the given allele {@link Supplier} and
allele {@code validator}. The {@code supplier} is responsible for
creating new random alleles, and the {@code validator} can verify it.
<p>
The following example shows a codec which creates and verifies
{@code BigInteger} objects.
<pre>{@code
final Codec<BigInteger, AnyGene<BigInteger>> codec = Codecs.of(
// Create new random 'BigInteger' object.
() -> {
final byte[] data = new byte[100];
RandomRegistry.getRandom().nextBytes(data);
return new BigInteger(data);
},
// Verify that bit 7 is set. (For illustration purpose.)
bi -> bi.testBit(7)
);
}</pre>
@see AnyGene#of(Supplier, Predicate)
@see AnyChromosome#of(Supplier, Predicate)
@param <A> the allele type
@param supplier the allele-supplier which is used for creating new,
random alleles
@param validator the validator used for validating the created gene. This
predicate is used in the {@link AnyGene#isValid()} method.
@return a new {@code Codec} with the given parameters
@throws NullPointerException if one of the parameters is {@code null} | [
"Return",
"a",
"scala",
"{",
"@code",
"Codec",
"}",
"with",
"the",
"given",
"allele",
"{",
"@link",
"Supplier",
"}",
"and",
"allele",
"{",
"@code",
"validator",
"}",
".",
"The",
"{",
"@code",
"supplier",
"}",
"is",
"responsible",
"for",
"creating",
"new"... | train | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Codecs.java#L148-L156 |
ModeShape/modeshape | web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestRepositories.java | RestRepositories.addRepository | public Repository addRepository( String name,
HttpServletRequest request ) {
Repository repository = new Repository(name, request);
repositories.add(repository);
return repository;
} | java | public Repository addRepository( String name,
HttpServletRequest request ) {
Repository repository = new Repository(name, request);
repositories.add(repository);
return repository;
} | [
"public",
"Repository",
"addRepository",
"(",
"String",
"name",
",",
"HttpServletRequest",
"request",
")",
"{",
"Repository",
"repository",
"=",
"new",
"Repository",
"(",
"name",
",",
"request",
")",
";",
"repositories",
".",
"add",
"(",
"repository",
")",
";"... | Adds a repository to the list.
@param name a {@code non-null} string, the name of the repository.
@param request a {@link HttpServletRequest} instance
@return a {@link Repository} instance. | [
"Adds",
"a",
"repository",
"to",
"the",
"list",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestRepositories.java#L52-L57 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Document.java | Document.addProducer | public boolean addProducer() {
try {
return add(new Meta(Element.PRODUCER, getVersion()));
} catch (DocumentException de) {
throw new ExceptionConverter(de);
}
} | java | public boolean addProducer() {
try {
return add(new Meta(Element.PRODUCER, getVersion()));
} catch (DocumentException de) {
throw new ExceptionConverter(de);
}
} | [
"public",
"boolean",
"addProducer",
"(",
")",
"{",
"try",
"{",
"return",
"add",
"(",
"new",
"Meta",
"(",
"Element",
".",
"PRODUCER",
",",
"getVersion",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"DocumentException",
"de",
")",
"{",
"throw",
"new",
"... | Adds the producer to a Document.
@return <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise | [
"Adds",
"the",
"producer",
"to",
"a",
"Document",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Document.java#L606-L612 |
i-net-software/jlessc | src/com/inet/lib/less/CssMediaOutput.java | CssMediaOutput.startBlock | void startBlock( String[] selectors , StringBuilder output ) {
this.results.add( new CssRuleOutput( selectors, output, isReference ) );
} | java | void startBlock( String[] selectors , StringBuilder output ) {
this.results.add( new CssRuleOutput( selectors, output, isReference ) );
} | [
"void",
"startBlock",
"(",
"String",
"[",
"]",
"selectors",
",",
"StringBuilder",
"output",
")",
"{",
"this",
".",
"results",
".",
"add",
"(",
"new",
"CssRuleOutput",
"(",
"selectors",
",",
"output",
",",
"isReference",
")",
")",
";",
"}"
] | Start a block inside the media
@param selectors
the selectors
@param output
a buffer for the content of the rule. | [
"Start",
"a",
"block",
"inside",
"the",
"media"
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/CssMediaOutput.java#L107-L109 |
flow/commons | src/main/java/com/flowpowered/commons/map/impl/TTripleInt21ObjectHashMap.java | TTripleInt21ObjectHashMap.put | @Override
public T put(int x, int y, int z, T value) {
long key = Int21TripleHashed.key(x, y, z);
return map.put(key, value);
} | java | @Override
public T put(int x, int y, int z, T value) {
long key = Int21TripleHashed.key(x, y, z);
return map.put(key, value);
} | [
"@",
"Override",
"public",
"T",
"put",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"z",
",",
"T",
"value",
")",
"{",
"long",
"key",
"=",
"Int21TripleHashed",
".",
"key",
"(",
"x",
",",
"y",
",",
"z",
")",
";",
"return",
"map",
".",
"put",
"... | Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value.
(A map m is said to contain a mapping for a key k if and only if {@see #containsKey(int, int, int) m.containsKey(k)} would return <code>true</code>.)
@param x an <code>int</code> value
@param y an <code>int</code> value
@param z an <code>int</code> value
@return the previous value associated with <code>key(x, y, z)</code>, or no_entry_value if there was no mapping for <code>key(x, y, z)</code>. (A no_entry_value return can also indicate that
the map previously associated <code>null</code> with key, if the implementation supports <code>null</code> values.) | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
"(",
"optional",
"operation",
")",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"the",
"key",
"the",
"old",
"value",
"is",
"rep... | train | https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/map/impl/TTripleInt21ObjectHashMap.java#L82-L86 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeCheck.java | FlowTypeCheck.checkBreak | private Environment checkBreak(Stmt.Break stmt, Environment environment, EnclosingScope scope) {
// FIXME: need to check environment to the break destination
return FlowTypeUtils.BOTTOM;
} | java | private Environment checkBreak(Stmt.Break stmt, Environment environment, EnclosingScope scope) {
// FIXME: need to check environment to the break destination
return FlowTypeUtils.BOTTOM;
} | [
"private",
"Environment",
"checkBreak",
"(",
"Stmt",
".",
"Break",
"stmt",
",",
"Environment",
"environment",
",",
"EnclosingScope",
"scope",
")",
"{",
"// FIXME: need to check environment to the break destination",
"return",
"FlowTypeUtils",
".",
"BOTTOM",
";",
"}"
] | Type check a break statement. This requires propagating the current
environment to the block destination, to ensure that the actual types of all
variables at that point are precise.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return | [
"Type",
"check",
"a",
"break",
"statement",
".",
"This",
"requires",
"propagating",
"the",
"current",
"environment",
"to",
"the",
"block",
"destination",
"to",
"ensure",
"that",
"the",
"actual",
"types",
"of",
"all",
"variables",
"at",
"that",
"point",
"are",
... | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L464-L467 |
tvesalainen/util | util/src/main/java/org/vesalainen/navi/Navis.java | Navis.addLongitude | public static final double addLongitude(double longitude, double delta)
{
double gha = longitudeToGHA(longitude);
gha -= delta;
return ghaToLongitude(normalizeAngle(gha));
} | java | public static final double addLongitude(double longitude, double delta)
{
double gha = longitudeToGHA(longitude);
gha -= delta;
return ghaToLongitude(normalizeAngle(gha));
} | [
"public",
"static",
"final",
"double",
"addLongitude",
"(",
"double",
"longitude",
",",
"double",
"delta",
")",
"{",
"double",
"gha",
"=",
"longitudeToGHA",
"(",
"longitude",
")",
";",
"gha",
"-=",
"delta",
";",
"return",
"ghaToLongitude",
"(",
"normalizeAngle... | Adds delta to longitude. Positive delta is to east
@param longitude
@param delta
@return | [
"Adds",
"delta",
"to",
"longitude",
".",
"Positive",
"delta",
"is",
"to",
"east"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/navi/Navis.java#L232-L237 |
mfornos/humanize | humanize-icu/src/main/java/humanize/ICUHumanize.java | ICUHumanize.withinLocale | private static <T> T withinLocale(final Callable<T> operation, final Locale locale)
{
DefaultICUContext ctx = context.get();
Locale oldLocale = ctx.getLocale();
try
{
ctx.setLocale(locale);
return operation.call();
} catch (Exception e)
{
throw new RuntimeException(e);
} finally
{
ctx.setLocale(oldLocale);
context.set(ctx);
}
} | java | private static <T> T withinLocale(final Callable<T> operation, final Locale locale)
{
DefaultICUContext ctx = context.get();
Locale oldLocale = ctx.getLocale();
try
{
ctx.setLocale(locale);
return operation.call();
} catch (Exception e)
{
throw new RuntimeException(e);
} finally
{
ctx.setLocale(oldLocale);
context.set(ctx);
}
} | [
"private",
"static",
"<",
"T",
">",
"T",
"withinLocale",
"(",
"final",
"Callable",
"<",
"T",
">",
"operation",
",",
"final",
"Locale",
"locale",
")",
"{",
"DefaultICUContext",
"ctx",
"=",
"context",
".",
"get",
"(",
")",
";",
"Locale",
"oldLocale",
"=",
... | <p>
Wraps the given operation on a context with the specified locale.
</p>
@param operation
Operation to be performed
@param locale
Target locale
@return Result of the operation | [
"<p",
">",
"Wraps",
"the",
"given",
"operation",
"on",
"a",
"context",
"with",
"the",
"specified",
"locale",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-icu/src/main/java/humanize/ICUHumanize.java#L1777-L1794 |
spotbugs/spotbugs | eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java | FindbugsPlugin.readBugCollectionAndProject | private static void readBugCollectionAndProject(IProject project, IProgressMonitor monitor)
throws IOException, DocumentException, CoreException {
SortedBugCollection bugCollection;
IPath bugCollectionPath = getBugCollectionFile(project);
// Don't turn the path to an IFile because it isn't local to the
// project.
// see the javadoc for org.eclipse.core.runtime.Plugin
File bugCollectionFile = bugCollectionPath.toFile();
if (!bugCollectionFile.exists()) {
// throw new
// FileNotFoundException(bugCollectionFile.getLocation().toOSString());
getDefault().logInfo("creating new bug collection: " + bugCollectionPath.toOSString());
createDefaultEmptyBugCollection(project); // since we no longer
// throw, have to do this
// here
return;
}
UserPreferences prefs = getUserPreferences(project);
bugCollection = new SortedBugCollection();
bugCollection.getProject().setGuiCallback(new EclipseGuiCallback(project));
bugCollection.readXML(bugCollectionFile);
cacheBugCollectionAndProject(project, bugCollection, bugCollection.getProject());
} | java | private static void readBugCollectionAndProject(IProject project, IProgressMonitor monitor)
throws IOException, DocumentException, CoreException {
SortedBugCollection bugCollection;
IPath bugCollectionPath = getBugCollectionFile(project);
// Don't turn the path to an IFile because it isn't local to the
// project.
// see the javadoc for org.eclipse.core.runtime.Plugin
File bugCollectionFile = bugCollectionPath.toFile();
if (!bugCollectionFile.exists()) {
// throw new
// FileNotFoundException(bugCollectionFile.getLocation().toOSString());
getDefault().logInfo("creating new bug collection: " + bugCollectionPath.toOSString());
createDefaultEmptyBugCollection(project); // since we no longer
// throw, have to do this
// here
return;
}
UserPreferences prefs = getUserPreferences(project);
bugCollection = new SortedBugCollection();
bugCollection.getProject().setGuiCallback(new EclipseGuiCallback(project));
bugCollection.readXML(bugCollectionFile);
cacheBugCollectionAndProject(project, bugCollection, bugCollection.getProject());
} | [
"private",
"static",
"void",
"readBugCollectionAndProject",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
")",
"throws",
"IOException",
",",
"DocumentException",
",",
"CoreException",
"{",
"SortedBugCollection",
"bugCollection",
";",
"IPath",
"bugCollect... | Read saved bug collection and findbugs project from file. Will populate
the bug collection and findbugs project session properties if successful.
If there is no saved bug collection and project for the eclipse project,
then FileNotFoundException will be thrown.
@param project
the eclipse project
@param monitor
a progress monitor
@throws java.io.FileNotFoundException
the saved bug collection doesn't exist
@throws IOException
@throws DocumentException
@throws CoreException | [
"Read",
"saved",
"bug",
"collection",
"and",
"findbugs",
"project",
"from",
"file",
".",
"Will",
"populate",
"the",
"bug",
"collection",
"and",
"findbugs",
"project",
"session",
"properties",
"if",
"successful",
".",
"If",
"there",
"is",
"no",
"saved",
"bug",
... | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java#L703-L729 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.permuteWith | public MethodHandle permuteWith(MethodHandle target, String... permuteArgs) {
return MethodHandles.permuteArguments(target, methodType, to(permute(permuteArgs)));
} | java | public MethodHandle permuteWith(MethodHandle target, String... permuteArgs) {
return MethodHandles.permuteArguments(target, methodType, to(permute(permuteArgs)));
} | [
"public",
"MethodHandle",
"permuteWith",
"(",
"MethodHandle",
"target",
",",
"String",
"...",
"permuteArgs",
")",
"{",
"return",
"MethodHandles",
".",
"permuteArguments",
"(",
"target",
",",
"methodType",
",",
"to",
"(",
"permute",
"(",
"permuteArgs",
")",
")",
... | Produce a method handle permuting the arguments in this signature using
the given permute arguments and targeting the given java.lang.invoke.MethodHandle.
Example:
<pre>
Signature sig = Signature.returning(String.class).appendArg("a", int.class).appendArg("b", int.class);
MethodHandle handle = handleThatTakesOneInt();
MethodHandle newHandle = sig.permuteTo(handle, "b");
</pre>
@param target the method handle to target
@param permuteArgs the arguments to permute
@return a new handle that permutes appropriate positions based on the
given permute args | [
"Produce",
"a",
"method",
"handle",
"permuting",
"the",
"arguments",
"in",
"this",
"signature",
"using",
"the",
"given",
"permute",
"arguments",
"and",
"targeting",
"the",
"given",
"java",
".",
"lang",
".",
"invoke",
".",
"MethodHandle",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L730-L732 |
wcm-io/wcm-io-handler | media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java | DefaultRenditionHandler.getVirtualRendition | private RenditionMetadata getVirtualRendition(Set<RenditionMetadata> candidates,
long destWidth, long destHeight, double destRatio) {
// if ratio is defined get first rendition with matching ratio and same or bigger size
if (destRatio > 0) {
for (RenditionMetadata candidate : candidates) {
if (candidate.matches(destWidth, destHeight, 0, 0, destRatio)) {
return getVirtualRendition(candidate, destWidth, destHeight, destRatio);
}
}
}
// otherwise get first rendition which is same or bigger in width and height
else {
for (RenditionMetadata candidate : candidates) {
if (candidate.matches(destWidth, destHeight, 0, 0, 0d)) {
return getVirtualRendition(candidate, destWidth, destHeight, 0d);
}
}
}
// none found
return null;
} | java | private RenditionMetadata getVirtualRendition(Set<RenditionMetadata> candidates,
long destWidth, long destHeight, double destRatio) {
// if ratio is defined get first rendition with matching ratio and same or bigger size
if (destRatio > 0) {
for (RenditionMetadata candidate : candidates) {
if (candidate.matches(destWidth, destHeight, 0, 0, destRatio)) {
return getVirtualRendition(candidate, destWidth, destHeight, destRatio);
}
}
}
// otherwise get first rendition which is same or bigger in width and height
else {
for (RenditionMetadata candidate : candidates) {
if (candidate.matches(destWidth, destHeight, 0, 0, 0d)) {
return getVirtualRendition(candidate, destWidth, destHeight, 0d);
}
}
}
// none found
return null;
} | [
"private",
"RenditionMetadata",
"getVirtualRendition",
"(",
"Set",
"<",
"RenditionMetadata",
">",
"candidates",
",",
"long",
"destWidth",
",",
"long",
"destHeight",
",",
"double",
"destRatio",
")",
"{",
"// if ratio is defined get first rendition with matching ratio and same ... | Check if a rendition is available from which the required format can be downscaled from and returns
a virtual rendition in this case.
@param candidates Candidates
@param destWidth Destination width
@param destHeight Destination height
@param destRatio Destination ratio
@return Rendition or null | [
"Check",
"if",
"a",
"rendition",
"is",
"available",
"from",
"which",
"the",
"required",
"format",
"can",
"be",
"downscaled",
"from",
"and",
"returns",
"a",
"virtual",
"rendition",
"in",
"this",
"case",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java#L387-L409 |
netty/netty | codec/src/main/java/io/netty/handler/codec/HeadersUtils.java | HeadersUtils.getAsString | public static <K, V> String getAsString(Headers<K, V, ?> headers, K name) {
V orig = headers.get(name);
return orig != null ? orig.toString() : null;
} | java | public static <K, V> String getAsString(Headers<K, V, ?> headers, K name) {
V orig = headers.get(name);
return orig != null ? orig.toString() : null;
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"String",
"getAsString",
"(",
"Headers",
"<",
"K",
",",
"V",
",",
"?",
">",
"headers",
",",
"K",
"name",
")",
"{",
"V",
"orig",
"=",
"headers",
".",
"get",
"(",
"name",
")",
";",
"return",
"orig",
"!... | {@link Headers#get(Object)} and convert the result to a {@link String}.
@param headers the headers to get the {@code name} from
@param name the name of the header to retrieve
@return the first header value if the header is found. {@code null} if there's no such entry. | [
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/HeadersUtils.java#L63-L66 |
alkacon/opencms-core | src-modules/org/opencms/workplace/explorer/CmsTree.java | CmsTree.getNode | private String getNode(String path, String title, int type, boolean folder, CmsResourceState state, boolean grey) {
StringBuffer result = new StringBuffer(64);
String parent = CmsResource.getParentFolder(path);
result.append("parent.aC(\"");
// name
result.append(title);
result.append("\",");
// type
result.append(type);
result.append(",");
// folder
if (folder) {
result.append(1);
} else {
result.append(0);
}
result.append(",");
// hashcode of path
result.append(path.hashCode());
result.append(",");
// hashcode of parent path
result.append((parent != null) ? parent.hashCode() : 0);
result.append(",");
// resource state
result.append(state);
result.append(",");
// project status
if (grey) {
result.append(1);
} else {
result.append(0);
}
result.append(");\n");
return result.toString();
} | java | private String getNode(String path, String title, int type, boolean folder, CmsResourceState state, boolean grey) {
StringBuffer result = new StringBuffer(64);
String parent = CmsResource.getParentFolder(path);
result.append("parent.aC(\"");
// name
result.append(title);
result.append("\",");
// type
result.append(type);
result.append(",");
// folder
if (folder) {
result.append(1);
} else {
result.append(0);
}
result.append(",");
// hashcode of path
result.append(path.hashCode());
result.append(",");
// hashcode of parent path
result.append((parent != null) ? parent.hashCode() : 0);
result.append(",");
// resource state
result.append(state);
result.append(",");
// project status
if (grey) {
result.append(1);
} else {
result.append(0);
}
result.append(");\n");
return result.toString();
} | [
"private",
"String",
"getNode",
"(",
"String",
"path",
",",
"String",
"title",
",",
"int",
"type",
",",
"boolean",
"folder",
",",
"CmsResourceState",
"state",
",",
"boolean",
"grey",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"64",
... | Creates the output for a tree node.<p>
@param path the path of the resource represented by this tree node
@param title the resource name
@param type the resource type
@param folder if the resource is a folder
@param state the resource state
@param grey if true, the node is displayed in grey
@return the output for a tree node | [
"Creates",
"the",
"output",
"for",
"a",
"tree",
"node",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/explorer/CmsTree.java#L691-L726 |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonModelCoder.java | JsonModelCoder.encodeListNullToNull | public void encodeListNullToNull(Writer writer, List<? extends T> list) throws IOException {
if (list == null) {
writer.write("null");
writer.flush();
return;
}
JsonUtil.startArray(writer);
int size = list.size();
for (int i = 0; i < size; i++) {
encodeNullToNull(writer, list.get(i));
if (i + 1 < size) {
JsonUtil.addSeparator(writer);
}
}
JsonUtil.endArray(writer);
writer.flush();
} | java | public void encodeListNullToNull(Writer writer, List<? extends T> list) throws IOException {
if (list == null) {
writer.write("null");
writer.flush();
return;
}
JsonUtil.startArray(writer);
int size = list.size();
for (int i = 0; i < size; i++) {
encodeNullToNull(writer, list.get(i));
if (i + 1 < size) {
JsonUtil.addSeparator(writer);
}
}
JsonUtil.endArray(writer);
writer.flush();
} | [
"public",
"void",
"encodeListNullToNull",
"(",
"Writer",
"writer",
",",
"List",
"<",
"?",
"extends",
"T",
">",
"list",
")",
"throws",
"IOException",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"\"null\"",
")",
";",
"wri... | Encodes the given {@link List} of values into the JSON format, and writes it using the given writer.<br>
Writes "null" if null is given.
@param writer {@link Writer} to be used for writing value
@param list {@link List} of values to be encoded
@throws IOException | [
"Encodes",
"the",
"given",
"{",
"@link",
"List",
"}",
"of",
"values",
"into",
"the",
"JSON",
"format",
"and",
"writes",
"it",
"using",
"the",
"given",
"writer",
".",
"<br",
">",
"Writes",
"null",
"if",
"null",
"is",
"given",
"."
] | train | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonModelCoder.java#L355-L376 |
aws/aws-sdk-java | aws-java-sdk-emr/src/main/java/com/amazonaws/services/elasticmapreduce/util/StepFactory.java | StepFactory.newScriptRunnerStep | public HadoopJarStepConfig newScriptRunnerStep(String script, String... args) {
List<String> argsList = new ArrayList<String>();
argsList.add(script);
for (String arg : args) {
argsList.add(arg);
}
return new HadoopJarStepConfig()
.withJar("s3://" + bucket + "/libs/script-runner/script-runner.jar")
.withArgs(argsList);
} | java | public HadoopJarStepConfig newScriptRunnerStep(String script, String... args) {
List<String> argsList = new ArrayList<String>();
argsList.add(script);
for (String arg : args) {
argsList.add(arg);
}
return new HadoopJarStepConfig()
.withJar("s3://" + bucket + "/libs/script-runner/script-runner.jar")
.withArgs(argsList);
} | [
"public",
"HadoopJarStepConfig",
"newScriptRunnerStep",
"(",
"String",
"script",
",",
"String",
"...",
"args",
")",
"{",
"List",
"<",
"String",
">",
"argsList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"argsList",
".",
"add",
"(",
"scrip... | Runs a specified script on the master node of your cluster.
@param script
The script to run.
@param args
Arguments that get passed to the script.
@return HadoopJarStepConfig that can be passed to your job flow. | [
"Runs",
"a",
"specified",
"script",
"on",
"the",
"master",
"node",
"of",
"your",
"cluster",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-emr/src/main/java/com/amazonaws/services/elasticmapreduce/util/StepFactory.java#L132-L141 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.delegatedAccount_email_responder_GET | public OvhResponderAccount delegatedAccount_email_responder_GET(String email) throws IOException {
String qPath = "/email/domain/delegatedAccount/{email}/responder";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhResponderAccount.class);
} | java | public OvhResponderAccount delegatedAccount_email_responder_GET(String email) throws IOException {
String qPath = "/email/domain/delegatedAccount/{email}/responder";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhResponderAccount.class);
} | [
"public",
"OvhResponderAccount",
"delegatedAccount_email_responder_GET",
"(",
"String",
"email",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/delegatedAccount/{email}/responder\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
... | Get this object properties
REST: GET /email/domain/delegatedAccount/{email}/responder
@param email [required] Email | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L297-L302 |
killbilling/recurly-java-library | src/main/java/com/ning/billing/recurly/RecurlyClient.java | RecurlyClient.enterOfflinePayment | public Transaction enterOfflinePayment(final String invoiceId, final Transaction payment) {
return doPOST(Invoices.INVOICES_RESOURCE + "/" + invoiceId + "/transactions", payment, Transaction.class);
} | java | public Transaction enterOfflinePayment(final String invoiceId, final Transaction payment) {
return doPOST(Invoices.INVOICES_RESOURCE + "/" + invoiceId + "/transactions", payment, Transaction.class);
} | [
"public",
"Transaction",
"enterOfflinePayment",
"(",
"final",
"String",
"invoiceId",
",",
"final",
"Transaction",
"payment",
")",
"{",
"return",
"doPOST",
"(",
"Invoices",
".",
"INVOICES_RESOURCE",
"+",
"\"/\"",
"+",
"invoiceId",
"+",
"\"/transactions\"",
",",
"pa... | Enter an offline payment for a manual invoice (beta) - Recurly Enterprise Feature
@param invoiceId String Recurly Invoice ID
@param payment The external payment | [
"Enter",
"an",
"offline",
"payment",
"for",
"a",
"manual",
"invoice",
"(",
"beta",
")",
"-",
"Recurly",
"Enterprise",
"Feature"
] | train | https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L1342-L1344 |
motown-io/motown | utils/rest/src/main/java/io/motown/utils/rest/response/ResponseBuilder.java | ResponseBuilder.buildResponse | public static <T> Response<T> buildResponse(final HttpServletRequest request, final int offset, final int limit, final long total, final List<T> elements) {
checkArgument(offset >= 0);
checkArgument(limit >= 1);
checkArgument(total >= 0);
checkArgument(total == 0 || offset < total);
String requestUri = request.getRequestURI();
String queryString = request.getQueryString();
String href = requestUri + (!Strings.isNullOrEmpty(queryString) ? "?" + queryString : "");
NavigationItem previous = new NavigationItem(hasPreviousPage(offset) ? requestUri + String.format(QUERY_STRING_FORMAT, getPreviousPageOffset(offset, limit), limit) : "");
NavigationItem next = new NavigationItem(hasNextPage(offset, limit, total) ? requestUri + String.format(QUERY_STRING_FORMAT, getNextPageOffset(offset, limit, total), limit) : "");
NavigationItem first = new NavigationItem(requestUri + String.format(QUERY_STRING_FORMAT, getFirstPageOffset(), limit));
NavigationItem last = new NavigationItem(requestUri + String.format(QUERY_STRING_FORMAT, getLastPageOffset(total, limit), limit));
return new Response<>(href, previous, next, first, last, elements);
} | java | public static <T> Response<T> buildResponse(final HttpServletRequest request, final int offset, final int limit, final long total, final List<T> elements) {
checkArgument(offset >= 0);
checkArgument(limit >= 1);
checkArgument(total >= 0);
checkArgument(total == 0 || offset < total);
String requestUri = request.getRequestURI();
String queryString = request.getQueryString();
String href = requestUri + (!Strings.isNullOrEmpty(queryString) ? "?" + queryString : "");
NavigationItem previous = new NavigationItem(hasPreviousPage(offset) ? requestUri + String.format(QUERY_STRING_FORMAT, getPreviousPageOffset(offset, limit), limit) : "");
NavigationItem next = new NavigationItem(hasNextPage(offset, limit, total) ? requestUri + String.format(QUERY_STRING_FORMAT, getNextPageOffset(offset, limit, total), limit) : "");
NavigationItem first = new NavigationItem(requestUri + String.format(QUERY_STRING_FORMAT, getFirstPageOffset(), limit));
NavigationItem last = new NavigationItem(requestUri + String.format(QUERY_STRING_FORMAT, getLastPageOffset(total, limit), limit));
return new Response<>(href, previous, next, first, last, elements);
} | [
"public",
"static",
"<",
"T",
">",
"Response",
"<",
"T",
">",
"buildResponse",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"limit",
",",
"final",
"long",
"total",
",",
"final",
"List",
"<",
"T",
">",... | Build a {@link Response} from the request, offset, limit, total and list of elements.
@param request The {@link javax.servlet.http.HttpServletRequest} which was executed.
@param offset The offset of the results.
@param limit The maximum number of results.
@param total The total number of elements.
@param elements The list of elements.
@param <T> The type of elements in the list. This can be {@link io.motown.chargingstationconfiguration.viewmodel.persistence.entities.ChargingStationType} or {@link io.motown.chargingstationconfiguration.viewmodel.persistence.entities.Manufacturer}.
@return A Configuration Api response with the correct metadata.
@throws IllegalArgumentException when the {@code offset} is negative, the {@code limit} is lesser than or equal to 0, the {@code total} is negative and when {@code offset} is lesser than the {@code total} (only if {@code total} is greater than 0. | [
"Build",
"a",
"{",
"@link",
"Response",
"}",
"from",
"the",
"request",
"offset",
"limit",
"total",
"and",
"list",
"of",
"elements",
"."
] | train | https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/utils/rest/src/main/java/io/motown/utils/rest/response/ResponseBuilder.java#L45-L61 |
wdtinc/mapbox-vector-tile-java | src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/JtsAdapter.java | JtsAdapter.moveCursor | private static void moveCursor(Vec2d cursor, List<Integer> geomCmds, Vec2d mvtPos) {
// Delta, then zigzag
geomCmds.add(ZigZag.encode((int)mvtPos.x - (int)cursor.x));
geomCmds.add(ZigZag.encode((int)mvtPos.y - (int)cursor.y));
cursor.set(mvtPos);
} | java | private static void moveCursor(Vec2d cursor, List<Integer> geomCmds, Vec2d mvtPos) {
// Delta, then zigzag
geomCmds.add(ZigZag.encode((int)mvtPos.x - (int)cursor.x));
geomCmds.add(ZigZag.encode((int)mvtPos.y - (int)cursor.y));
cursor.set(mvtPos);
} | [
"private",
"static",
"void",
"moveCursor",
"(",
"Vec2d",
"cursor",
",",
"List",
"<",
"Integer",
">",
"geomCmds",
",",
"Vec2d",
"mvtPos",
")",
"{",
"// Delta, then zigzag",
"geomCmds",
".",
"add",
"(",
"ZigZag",
".",
"encode",
"(",
"(",
"int",
")",
"mvtPos"... | <p>Appends {@link ZigZag#encode(int)} of delta in x,y from {@code cursor} to {@code mvtPos} into the {@code geomCmds} buffer.</p>
<p>Afterwards, the {@code cursor} values are changed to match the {@code mvtPos} values.</p>
@param cursor MVT cursor position
@param geomCmds geometry command list
@param mvtPos next MVT cursor position | [
"<p",
">",
"Appends",
"{",
"@link",
"ZigZag#encode",
"(",
"int",
")",
"}",
"of",
"delta",
"in",
"x",
"y",
"from",
"{",
"@code",
"cursor",
"}",
"to",
"{",
"@code",
"mvtPos",
"}",
"into",
"the",
"{",
"@code",
"geomCmds",
"}",
"buffer",
".",
"<",
"/",... | train | https://github.com/wdtinc/mapbox-vector-tile-java/blob/e5e3df3fc2260709e289f972a1348c0a1ea30339/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/JtsAdapter.java#L600-L607 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java | IdentityPatchContext.createRollbackPatch | protected RollbackPatch createRollbackPatch(final String patchId, final Patch.PatchType patchType) {
// Process elements
final List<PatchElement> elements = new ArrayList<PatchElement>();
// Process layers
for (final PatchEntry entry : getLayers()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
// Process add-ons
for (final PatchEntry entry : getAddOns()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
final InstalledIdentity installedIdentity = modification.getUnmodifiedInstallationState();
final String name = installedIdentity.getIdentity().getName();
final IdentityImpl identity = new IdentityImpl(name, modification.getVersion());
if (patchType == Patch.PatchType.CUMULATIVE) {
identity.setPatchType(Patch.PatchType.CUMULATIVE);
identity.setResultingVersion(installedIdentity.getIdentity().getVersion());
} else if (patchType == Patch.PatchType.ONE_OFF) {
identity.setPatchType(Patch.PatchType.ONE_OFF);
}
final List<ContentModification> modifications = identityEntry.rollbackActions;
final Patch delegate = new PatchImpl(patchId, "rollback patch", identity, elements, modifications);
return new PatchImpl.RollbackPatchImpl(delegate, installedIdentity);
} | java | protected RollbackPatch createRollbackPatch(final String patchId, final Patch.PatchType patchType) {
// Process elements
final List<PatchElement> elements = new ArrayList<PatchElement>();
// Process layers
for (final PatchEntry entry : getLayers()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
// Process add-ons
for (final PatchEntry entry : getAddOns()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
final InstalledIdentity installedIdentity = modification.getUnmodifiedInstallationState();
final String name = installedIdentity.getIdentity().getName();
final IdentityImpl identity = new IdentityImpl(name, modification.getVersion());
if (patchType == Patch.PatchType.CUMULATIVE) {
identity.setPatchType(Patch.PatchType.CUMULATIVE);
identity.setResultingVersion(installedIdentity.getIdentity().getVersion());
} else if (patchType == Patch.PatchType.ONE_OFF) {
identity.setPatchType(Patch.PatchType.ONE_OFF);
}
final List<ContentModification> modifications = identityEntry.rollbackActions;
final Patch delegate = new PatchImpl(patchId, "rollback patch", identity, elements, modifications);
return new PatchImpl.RollbackPatchImpl(delegate, installedIdentity);
} | [
"protected",
"RollbackPatch",
"createRollbackPatch",
"(",
"final",
"String",
"patchId",
",",
"final",
"Patch",
".",
"PatchType",
"patchType",
")",
"{",
"// Process elements",
"final",
"List",
"<",
"PatchElement",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"Pat... | Create a rollback patch based on the recorded actions.
@param patchId the new patch id, depending on release or one-off
@param patchType the current patch identity
@return the rollback patch | [
"Create",
"a",
"rollback",
"patch",
"based",
"on",
"the",
"recorded",
"actions",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java#L608-L634 |
mailin-api/sendinblue-java-mvn | src/main/java/com/sendinblue/Sendinblue.java | Sendinblue.get_webhooks | public String get_webhooks(Map<String, String> data) {
String is_plat = data.get("is_plat");
String url;
if (EMPTY_STRING.equals(is_plat)) {
url = "webhook/";
}
else {
url = "webhook/is_plat/" + is_plat + "/";
}
return get(url, EMPTY_STRING);
} | java | public String get_webhooks(Map<String, String> data) {
String is_plat = data.get("is_plat");
String url;
if (EMPTY_STRING.equals(is_plat)) {
url = "webhook/";
}
else {
url = "webhook/is_plat/" + is_plat + "/";
}
return get(url, EMPTY_STRING);
} | [
"public",
"String",
"get_webhooks",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"data",
")",
"{",
"String",
"is_plat",
"=",
"data",
".",
"get",
"(",
"\"is_plat\"",
")",
";",
"String",
"url",
";",
"if",
"(",
"EMPTY_STRING",
".",
"equals",
"(",
"is_pl... | /*
To retrieve details of all webhooks.
@param {Object} data contains json objects as a key value pair from HashMap.
@options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all webhooks, use $is_plat="" [Optional] | [
"/",
"*",
"To",
"retrieve",
"details",
"of",
"all",
"webhooks",
"."
] | train | https://github.com/mailin-api/sendinblue-java-mvn/blob/3a186b004003450f18d619aa084adc8d75086183/src/main/java/com/sendinblue/Sendinblue.java#L699-L709 |
nmorel/gwt-jackson | gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/CreatorUtils.java | CreatorUtils.findFirstEncounteredAnnotationsOnAllHierarchy | public static <T extends Annotation> Optional<T> findFirstEncounteredAnnotationsOnAllHierarchy( RebindConfiguration configuration,
JClassType type, Class<T> annotation ) {
return findFirstEncounteredAnnotationsOnAllHierarchy( configuration, type, annotation, Optional.<JClassType>absent() );
} | java | public static <T extends Annotation> Optional<T> findFirstEncounteredAnnotationsOnAllHierarchy( RebindConfiguration configuration,
JClassType type, Class<T> annotation ) {
return findFirstEncounteredAnnotationsOnAllHierarchy( configuration, type, annotation, Optional.<JClassType>absent() );
} | [
"public",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"Optional",
"<",
"T",
">",
"findFirstEncounteredAnnotationsOnAllHierarchy",
"(",
"RebindConfiguration",
"configuration",
",",
"JClassType",
"type",
",",
"Class",
"<",
"T",
">",
"annotation",
")",
"{",
"re... | Browse all the hierarchy of the type and return the first corresponding annotation it found
@param type type
@param annotation annotation to find
@return the annotation if found, null otherwise
@param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object.
@param <T> a T object. | [
"Browse",
"all",
"the",
"hierarchy",
"of",
"the",
"type",
"and",
"return",
"the",
"first",
"corresponding",
"annotation",
"it",
"found"
] | train | https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/CreatorUtils.java#L55-L58 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/runtime/JCuda.java | JCuda.cudaMemcpy | public static int cudaMemcpy(Pointer dst, Pointer src, long count, int cudaMemcpyKind_kind)
{
return checkResult(cudaMemcpyNative(dst, src, count, cudaMemcpyKind_kind));
} | java | public static int cudaMemcpy(Pointer dst, Pointer src, long count, int cudaMemcpyKind_kind)
{
return checkResult(cudaMemcpyNative(dst, src, count, cudaMemcpyKind_kind));
} | [
"public",
"static",
"int",
"cudaMemcpy",
"(",
"Pointer",
"dst",
",",
"Pointer",
"src",
",",
"long",
"count",
",",
"int",
"cudaMemcpyKind_kind",
")",
"{",
"return",
"checkResult",
"(",
"cudaMemcpyNative",
"(",
"dst",
",",
"src",
",",
"count",
",",
"cudaMemcpy... | Copies data between host and device.
<pre>
cudaError_t cudaMemcpy (
void* dst,
const void* src,
size_t count,
cudaMemcpyKind kind )
</pre>
<div>
<p>Copies data between host and device.
Copies <tt>count</tt> bytes from the memory area pointed to by <tt>src</tt> to the memory area pointed to by <tt>dst</tt>, where <tt>kind</tt> is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice,
cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the
direction of the copy. The memory areas may not overlap. Calling
cudaMemcpy() with <tt>dst</tt> and <tt>src</tt> pointers that do not
match the direction of the copy results in an undefined behavior.
</p>
<div>
<span>Note:</span>
<ul>
<li>
<p>Note that this function may
also return error codes from previous, asynchronous launches.
</p>
</li>
<li>
<p>This function exhibits
synchronous behavior for most use cases.
</p>
</li>
</ul>
</div>
</p>
</div>
@param dst Destination memory address
@param src Source memory address
@param count Size in bytes to copy
@param kind Type of transfer
@return cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer,
cudaErrorInvalidMemcpyDirection
@see JCuda#cudaMemcpy2D
@see JCuda#cudaMemcpyToArray
@see JCuda#cudaMemcpy2DToArray
@see JCuda#cudaMemcpyFromArray
@see JCuda#cudaMemcpy2DFromArray
@see JCuda#cudaMemcpyArrayToArray
@see JCuda#cudaMemcpy2DArrayToArray
@see JCuda#cudaMemcpyToSymbol
@see JCuda#cudaMemcpyFromSymbol
@see JCuda#cudaMemcpyAsync
@see JCuda#cudaMemcpy2DAsync
@see JCuda#cudaMemcpyToArrayAsync
@see JCuda#cudaMemcpy2DToArrayAsync
@see JCuda#cudaMemcpyFromArrayAsync
@see JCuda#cudaMemcpy2DFromArrayAsync
@see JCuda#cudaMemcpyToSymbolAsync
@see JCuda#cudaMemcpyFromSymbolAsync | [
"Copies",
"data",
"between",
"host",
"and",
"device",
"."
] | train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/runtime/JCuda.java#L4611-L4614 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java | ToHTMLStream.addUniqueAttribute | public void addUniqueAttribute(String name, String value, int flags)
throws SAXException
{
try
{
final java.io.Writer writer = m_writer;
if ((flags & NO_BAD_CHARS) > 0 && m_htmlcharInfo.onlyQuotAmpLtGt)
{
// "flags" has indicated that the characters
// '>' '<' '&' and '"' are not in the value and
// m_htmlcharInfo has recorded that there are no other
// entities in the range 0 to 127 so we write out the
// value directly
writer.write(' ');
writer.write(name);
writer.write("=\"");
writer.write(value);
writer.write('"');
}
else if (
(flags & HTML_ATTREMPTY) > 0
&& (value.length() == 0 || value.equalsIgnoreCase(name)))
{
writer.write(' ');
writer.write(name);
}
else
{
writer.write(' ');
writer.write(name);
writer.write("=\"");
if ((flags & HTML_ATTRURL) > 0)
{
writeAttrURI(writer, value, m_specialEscapeURLs);
}
else
{
writeAttrString(writer, value, this.getEncoding());
}
writer.write('"');
}
} catch (IOException e) {
throw new SAXException(e);
}
} | java | public void addUniqueAttribute(String name, String value, int flags)
throws SAXException
{
try
{
final java.io.Writer writer = m_writer;
if ((flags & NO_BAD_CHARS) > 0 && m_htmlcharInfo.onlyQuotAmpLtGt)
{
// "flags" has indicated that the characters
// '>' '<' '&' and '"' are not in the value and
// m_htmlcharInfo has recorded that there are no other
// entities in the range 0 to 127 so we write out the
// value directly
writer.write(' ');
writer.write(name);
writer.write("=\"");
writer.write(value);
writer.write('"');
}
else if (
(flags & HTML_ATTREMPTY) > 0
&& (value.length() == 0 || value.equalsIgnoreCase(name)))
{
writer.write(' ');
writer.write(name);
}
else
{
writer.write(' ');
writer.write(name);
writer.write("=\"");
if ((flags & HTML_ATTRURL) > 0)
{
writeAttrURI(writer, value, m_specialEscapeURLs);
}
else
{
writeAttrString(writer, value, this.getEncoding());
}
writer.write('"');
}
} catch (IOException e) {
throw new SAXException(e);
}
} | [
"public",
"void",
"addUniqueAttribute",
"(",
"String",
"name",
",",
"String",
"value",
",",
"int",
"flags",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"final",
"java",
".",
"io",
".",
"Writer",
"writer",
"=",
"m_writer",
";",
"if",
"(",
"(",
"flags"... | This method is used to add an attribute to the currently open element.
The caller has guaranted that this attribute is unique, which means that it
not been seen before and will not be seen again.
@param name the qualified name of the attribute
@param value the value of the attribute which can contain only
ASCII printable characters characters in the range 32 to 127 inclusive.
@param flags the bit values of this integer give optimization information. | [
"This",
"method",
"is",
"used",
"to",
"add",
"an",
"attribute",
"to",
"the",
"currently",
"open",
"element",
".",
"The",
"caller",
"has",
"guaranted",
"that",
"this",
"attribute",
"is",
"unique",
"which",
"means",
"that",
"it",
"not",
"been",
"seen",
"befo... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java#L1930-L1974 |
codelibs/jcifs | src/main/java/jcifs/smb1/Config.java | Config.getBoolean | public static boolean getBoolean( String key, boolean def ) {
String b = getProperty( key );
if( b != null ) {
def = b.toLowerCase().equals( "true" );
}
return def;
} | java | public static boolean getBoolean( String key, boolean def ) {
String b = getProperty( key );
if( b != null ) {
def = b.toLowerCase().equals( "true" );
}
return def;
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"String",
"key",
",",
"boolean",
"def",
")",
"{",
"String",
"b",
"=",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"b",
"!=",
"null",
")",
"{",
"def",
"=",
"b",
".",
"toLowerCase",
"(",
")",
".",... | Retrieve a boolean value. If the property is not found, the value of <code>def</code> is returned. | [
"Retrieve",
"a",
"boolean",
"value",
".",
"If",
"the",
"property",
"is",
"not",
"found",
"the",
"value",
"of",
"<code",
">",
"def<",
"/",
"code",
">",
"is",
"returned",
"."
] | train | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/Config.java#L313-L319 |
aalmiray/Json-lib | src/main/java/net/sf/json/JsonConfig.java | JsonConfig.registerPropertyExclusions | public void registerPropertyExclusions( Class target, String[] properties ) {
if( target != null && properties != null && properties.length > 0 ) {
Set set = (Set) exclusionMap.get( target );
if( set == null ) {
set = new HashSet();
exclusionMap.put( target, set );
}
for( int i = 0; i < properties.length; i++ ) {
if( !set.contains( properties[i] ) ) {
set.add( properties[i] );
}
}
}
} | java | public void registerPropertyExclusions( Class target, String[] properties ) {
if( target != null && properties != null && properties.length > 0 ) {
Set set = (Set) exclusionMap.get( target );
if( set == null ) {
set = new HashSet();
exclusionMap.put( target, set );
}
for( int i = 0; i < properties.length; i++ ) {
if( !set.contains( properties[i] ) ) {
set.add( properties[i] );
}
}
}
} | [
"public",
"void",
"registerPropertyExclusions",
"(",
"Class",
"target",
",",
"String",
"[",
"]",
"properties",
")",
"{",
"if",
"(",
"target",
"!=",
"null",
"&&",
"properties",
"!=",
"null",
"&&",
"properties",
".",
"length",
">",
"0",
")",
"{",
"Set",
"s... | Registers exclusions for a target class.<br>
[Java -> JSON]
@param target the class to use as key
@param properties the properties to be excluded | [
"Registers",
"exclusions",
"for",
"a",
"target",
"class",
".",
"<br",
">",
"[",
"Java",
"-",
">",
";",
"JSON",
"]"
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JsonConfig.java#L886-L899 |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/SAXProcessor.java | SAXProcessor.charDistance | public int charDistance(char a, char b) {
return Math.abs(Character.getNumericValue(a) - Character.getNumericValue(b));
} | java | public int charDistance(char a, char b) {
return Math.abs(Character.getNumericValue(a) - Character.getNumericValue(b));
} | [
"public",
"int",
"charDistance",
"(",
"char",
"a",
",",
"char",
"b",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"Character",
".",
"getNumericValue",
"(",
"a",
")",
"-",
"Character",
".",
"getNumericValue",
"(",
"b",
")",
")",
";",
"}"
] | Compute the distance between the two chars based on the ASCII symbol codes.
@param a The first char.
@param b The second char.
@return The distance. | [
"Compute",
"the",
"distance",
"between",
"the",
"two",
"chars",
"based",
"on",
"the",
"ASCII",
"symbol",
"codes",
"."
] | train | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/SAXProcessor.java#L316-L318 |
eclipse/xtext-extras | org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/validation/ProxyAwareUIStrings.java | ProxyAwareUIStrings.appendTypeSignature | public StringBuilder appendTypeSignature(JvmType type, StringBuilder result) {
result.append(type.getSimpleName());
if(type instanceof JvmTypeParameterDeclarator) {
List<JvmTypeParameter> typeParameters = ((JvmTypeParameterDeclarator) type).getTypeParameters();
if (!typeParameters.isEmpty()) {
result.append("<");
for(int i = 0, size = typeParameters.size(); i < size; i++) {
if (i != 0) {
result.append(", ");
}
result.append(typeParameters.get(i).getName());
}
result.append(">");
}
}
return result;
} | java | public StringBuilder appendTypeSignature(JvmType type, StringBuilder result) {
result.append(type.getSimpleName());
if(type instanceof JvmTypeParameterDeclarator) {
List<JvmTypeParameter> typeParameters = ((JvmTypeParameterDeclarator) type).getTypeParameters();
if (!typeParameters.isEmpty()) {
result.append("<");
for(int i = 0, size = typeParameters.size(); i < size; i++) {
if (i != 0) {
result.append(", ");
}
result.append(typeParameters.get(i).getName());
}
result.append(">");
}
}
return result;
} | [
"public",
"StringBuilder",
"appendTypeSignature",
"(",
"JvmType",
"type",
",",
"StringBuilder",
"result",
")",
"{",
"result",
".",
"append",
"(",
"type",
".",
"getSimpleName",
"(",
")",
")",
";",
"if",
"(",
"type",
"instanceof",
"JvmTypeParameterDeclarator",
")"... | Returns the signature of the given type. If the type declares type parameters, the type
parameters are included but their bounds are omitted. That is, the type {@code X<T extends CharSequence>}
will be returned as {@code X<T>} | [
"Returns",
"the",
"signature",
"of",
"the",
"given",
"type",
".",
"If",
"the",
"type",
"declares",
"type",
"parameters",
"the",
"type",
"parameters",
"are",
"included",
"but",
"their",
"bounds",
"are",
"omitted",
".",
"That",
"is",
"the",
"type",
"{",
"@co... | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/validation/ProxyAwareUIStrings.java#L60-L76 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java | DocTreeScanner.visitSee | @Override
public R visitSee(SeeTree node, P p) {
return scan(node.getReference(), p);
} | java | @Override
public R visitSee(SeeTree node, P p) {
return scan(node.getReference(), p);
} | [
"@",
"Override",
"public",
"R",
"visitSee",
"(",
"SeeTree",
"node",
",",
"P",
"p",
")",
"{",
"return",
"scan",
"(",
"node",
".",
"getReference",
"(",
")",
",",
"p",
")",
";",
"}"
] | {@inheritDoc} This implementation scans the children in left to right order.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of scanning | [
"{",
"@inheritDoc",
"}",
"This",
"implementation",
"scans",
"the",
"children",
"in",
"left",
"to",
"right",
"order",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java#L372-L375 |
Impetus/Kundera | src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBClient.java | CouchDBClient.onDelete | private void onDelete(String schemaName, Object pKey, HttpResponse response, JsonObject jsonObject)
throws URISyntaxException, IOException, ClientProtocolException
{
URI uri;
String q;
JsonElement rev = jsonObject.get("_rev");
StringBuilder builder = new StringBuilder();
builder.append("rev=");
builder.append(rev.getAsString());
q = builder.toString();
uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR + pKey, q,
null);
HttpDelete delete = new HttpDelete(uri);
response = httpClient.execute(delete);
closeContent(response);
} | java | private void onDelete(String schemaName, Object pKey, HttpResponse response, JsonObject jsonObject)
throws URISyntaxException, IOException, ClientProtocolException
{
URI uri;
String q;
JsonElement rev = jsonObject.get("_rev");
StringBuilder builder = new StringBuilder();
builder.append("rev=");
builder.append(rev.getAsString());
q = builder.toString();
uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR + pKey, q,
null);
HttpDelete delete = new HttpDelete(uri);
response = httpClient.execute(delete);
closeContent(response);
} | [
"private",
"void",
"onDelete",
"(",
"String",
"schemaName",
",",
"Object",
"pKey",
",",
"HttpResponse",
"response",
",",
"JsonObject",
"jsonObject",
")",
"throws",
"URISyntaxException",
",",
"IOException",
",",
"ClientProtocolException",
"{",
"URI",
"uri",
";",
"S... | On delete.
@param schemaName
the schema name
@param pKey
the key
@param response
the response
@param jsonObject
the json object
@throws URISyntaxException
the URI syntax exception
@throws IOException
Signals that an I/O exception has occurred.
@throws ClientProtocolException
the client protocol exception | [
"On",
"delete",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBClient.java#L544-L564 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/HttpSender.java | HttpSender.followRedirections | private void followRedirections(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
HttpRedirectionValidator validator = requestConfig.getRedirectionValidator();
validator.notifyMessageReceived(message);
User requestingUser = getUser(message);
HttpMessage redirectMessage = message;
int maxRedirections = client.getParams().getIntParameter(HttpClientParams.MAX_REDIRECTS, 100);
for (int i = 0; i < maxRedirections && isRedirectionNeeded(redirectMessage.getResponseHeader().getStatusCode()); i++) {
URI newLocation = extractRedirectLocation(redirectMessage);
if (newLocation == null || !validator.isValid(newLocation)) {
return;
}
redirectMessage = redirectMessage.cloneAll();
redirectMessage.setRequestingUser(requestingUser);
redirectMessage.getRequestHeader().setURI(newLocation);
if (isRequestRewriteNeeded(redirectMessage)) {
redirectMessage.getRequestHeader().setMethod(HttpRequestHeader.GET);
redirectMessage.getRequestHeader().setHeader(HttpHeader.CONTENT_TYPE, null);
redirectMessage.getRequestHeader().setHeader(HttpHeader.CONTENT_LENGTH, null);
redirectMessage.setRequestBody("");
}
sendAndReceiveImpl(redirectMessage, requestConfig);
validator.notifyMessageReceived(redirectMessage);
// Update the response of the (original) message
message.setResponseHeader(redirectMessage.getResponseHeader());
message.setResponseBody(redirectMessage.getResponseBody());
}
} | java | private void followRedirections(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
HttpRedirectionValidator validator = requestConfig.getRedirectionValidator();
validator.notifyMessageReceived(message);
User requestingUser = getUser(message);
HttpMessage redirectMessage = message;
int maxRedirections = client.getParams().getIntParameter(HttpClientParams.MAX_REDIRECTS, 100);
for (int i = 0; i < maxRedirections && isRedirectionNeeded(redirectMessage.getResponseHeader().getStatusCode()); i++) {
URI newLocation = extractRedirectLocation(redirectMessage);
if (newLocation == null || !validator.isValid(newLocation)) {
return;
}
redirectMessage = redirectMessage.cloneAll();
redirectMessage.setRequestingUser(requestingUser);
redirectMessage.getRequestHeader().setURI(newLocation);
if (isRequestRewriteNeeded(redirectMessage)) {
redirectMessage.getRequestHeader().setMethod(HttpRequestHeader.GET);
redirectMessage.getRequestHeader().setHeader(HttpHeader.CONTENT_TYPE, null);
redirectMessage.getRequestHeader().setHeader(HttpHeader.CONTENT_LENGTH, null);
redirectMessage.setRequestBody("");
}
sendAndReceiveImpl(redirectMessage, requestConfig);
validator.notifyMessageReceived(redirectMessage);
// Update the response of the (original) message
message.setResponseHeader(redirectMessage.getResponseHeader());
message.setResponseBody(redirectMessage.getResponseBody());
}
} | [
"private",
"void",
"followRedirections",
"(",
"HttpMessage",
"message",
",",
"HttpRequestConfig",
"requestConfig",
")",
"throws",
"IOException",
"{",
"HttpRedirectionValidator",
"validator",
"=",
"requestConfig",
".",
"getRedirectionValidator",
"(",
")",
";",
"validator",... | Follows redirections using the response of the given {@code message}. The {@code validator} in the given request
configuration will be called for each redirection received. After the call to this method the given {@code message} will
have the contents of the last response received (possibly the response of a redirection).
<p>
The validator is notified of each message sent and received (first message and redirections followed, if any).
@param message the message that will be sent, must not be {@code null}
@param requestConfig the request configuration that contains the validator responsible for validation of redirections,
must not be {@code null}.
@throws IOException if an error occurred while sending the message or following the redirections
@see #isRedirectionNeeded(int) | [
"Follows",
"redirections",
"using",
"the",
"response",
"of",
"the",
"given",
"{",
"@code",
"message",
"}",
".",
"The",
"{",
"@code",
"validator",
"}",
"in",
"the",
"given",
"request",
"configuration",
"will",
"be",
"called",
"for",
"each",
"redirection",
"re... | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/HttpSender.java#L947-L978 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.