repository_name stringlengths 7 58 | func_path_in_repository stringlengths 11 204 | func_name stringlengths 5 103 | whole_func_string stringlengths 87 3.44k | language stringclasses 1
value | func_code_string stringlengths 87 3.44k | func_code_tokens listlengths 21 714 | func_documentation_string stringlengths 61 1.95k | func_documentation_tokens listlengths 1 482 | split_name stringclasses 1
value | func_code_url stringlengths 102 309 |
|---|---|---|---|---|---|---|---|---|---|---|
jayantk/jklol | src/com/jayantkrish/jklol/tensor/SparseTensor.java | SparseTensor.resizeIntoTable | private static SparseTensor resizeIntoTable(int[] dimensions, int[] dimensionSizes,
long[] keyNums, double[] values, int size) {
if (values.length == size) {
return new SparseTensor(dimensions, dimensionSizes, keyNums, values);
} else {
// Resize the result array to fit the actual number of result
// keyNums.
long[] shrunkResultKeyInts = ArrayUtils.copyOf(keyNums, size);
double[] shrunkResultValues = ArrayUtils.copyOf(values, size);
return new SparseTensor(dimensions, dimensionSizes, shrunkResultKeyInts, shrunkResultValues);
}
} | java | private static SparseTensor resizeIntoTable(int[] dimensions, int[] dimensionSizes,
long[] keyNums, double[] values, int size) {
if (values.length == size) {
return new SparseTensor(dimensions, dimensionSizes, keyNums, values);
} else {
// Resize the result array to fit the actual number of result
// keyNums.
long[] shrunkResultKeyInts = ArrayUtils.copyOf(keyNums, size);
double[] shrunkResultValues = ArrayUtils.copyOf(values, size);
return new SparseTensor(dimensions, dimensionSizes, shrunkResultKeyInts, shrunkResultValues);
}
} | [
"private",
"static",
"SparseTensor",
"resizeIntoTable",
"(",
"int",
"[",
"]",
"dimensions",
",",
"int",
"[",
"]",
"dimensionSizes",
",",
"long",
"[",
"]",
"keyNums",
",",
"double",
"[",
"]",
"values",
",",
"int",
"size",
")",
"{",
"if",
"(",
"values",
... | Takes the data structures for a {@code SparseTensor}, but
possibly with the wrong number of filled-in entries, resizes them
and constructs a {@code SparseTensor} with them.
@param keyNums
@param values
@param size
@return | [
"Takes",
"the",
"data",
"structures",
"for",
"a",
"{",
"@code",
"SparseTensor",
"}",
"but",
"possibly",
"with",
"the",
"wrong",
"number",
"of",
"filled",
"-",
"in",
"entries",
"resizes",
"them",
"and",
"constructs",
"a",
"{",
"@code",
"SparseTensor",
"}",
... | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/tensor/SparseTensor.java#L1354-L1365 |
codelibs/jcifs | src/main/java/jcifs/smb1/smb1/SmbTransport.java | SmbTransport.dfsPathSplit | void dfsPathSplit(String path, String[] result)
{
int ri = 0, rlast = result.length - 1;
int i = 0, b = 0, len = path.length();
do {
if (ri == rlast) {
result[rlast] = path.substring(b);
return;
}
if (i == len || path.charAt(i) == '\\') {
result[ri++] = path.substring(b, i);
b = i + 1;
}
} while (i++ < len);
while (ri < result.length) {
result[ri++] = "";
}
} | java | void dfsPathSplit(String path, String[] result)
{
int ri = 0, rlast = result.length - 1;
int i = 0, b = 0, len = path.length();
do {
if (ri == rlast) {
result[rlast] = path.substring(b);
return;
}
if (i == len || path.charAt(i) == '\\') {
result[ri++] = path.substring(b, i);
b = i + 1;
}
} while (i++ < len);
while (ri < result.length) {
result[ri++] = "";
}
} | [
"void",
"dfsPathSplit",
"(",
"String",
"path",
",",
"String",
"[",
"]",
"result",
")",
"{",
"int",
"ri",
"=",
"0",
",",
"rlast",
"=",
"result",
".",
"length",
"-",
"1",
";",
"int",
"i",
"=",
"0",
",",
"b",
"=",
"0",
",",
"len",
"=",
"path",
"... | /* Split DFS path like \fs1.example.com\root5\link2\foo\bar.txt into at
most 3 components (not including the first index which is always empty):
result[0] = ""
result[1] = "fs1.example.com"
result[2] = "root5"
result[3] = "link2\foo\bar.txt" | [
"/",
"*",
"Split",
"DFS",
"path",
"like",
"\\",
"fs1",
".",
"example",
".",
"com",
"\\",
"root5",
"\\",
"link2",
"\\",
"foo",
"\\",
"bar",
".",
"txt",
"into",
"at",
"most",
"3",
"components",
"(",
"not",
"including",
"the",
"first",
"index",
"which",... | train | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/smb1/SmbTransport.java#L684-L703 |
Netflix/servo | servo-core/src/main/java/com/netflix/servo/monitor/MaxGauge.java | MaxGauge.updateMax | private void updateMax(int idx, long v) {
AtomicLong current = max.getCurrent(idx);
long m = current.get();
while (v > m) {
if (current.compareAndSet(m, v)) {
break;
}
m = current.get();
}
} | java | private void updateMax(int idx, long v) {
AtomicLong current = max.getCurrent(idx);
long m = current.get();
while (v > m) {
if (current.compareAndSet(m, v)) {
break;
}
m = current.get();
}
} | [
"private",
"void",
"updateMax",
"(",
"int",
"idx",
",",
"long",
"v",
")",
"{",
"AtomicLong",
"current",
"=",
"max",
".",
"getCurrent",
"(",
"idx",
")",
";",
"long",
"m",
"=",
"current",
".",
"get",
"(",
")",
";",
"while",
"(",
"v",
">",
"m",
")",... | Update the max for the given index if the provided value is larger than the current max. | [
"Update",
"the",
"max",
"for",
"the",
"given",
"index",
"if",
"the",
"provided",
"value",
"is",
"larger",
"than",
"the",
"current",
"max",
"."
] | train | https://github.com/Netflix/servo/blob/d67b5afce8c50bd9e9e31c288dbf4b78fb2ac815/servo-core/src/main/java/com/netflix/servo/monitor/MaxGauge.java#L57-L66 |
j256/ormlite-core | src/main/java/com/j256/ormlite/table/TableUtils.java | TableUtils.clearTable | public static <T> int clearTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
String tableName = DatabaseTableConfig.extractTableName(databaseType, dataClass);
if (databaseType.isEntityNamesMustBeUpCase()) {
tableName = databaseType.upCaseEntityName(tableName);
}
return clearTable(connectionSource, tableName);
} | java | public static <T> int clearTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
String tableName = DatabaseTableConfig.extractTableName(databaseType, dataClass);
if (databaseType.isEntityNamesMustBeUpCase()) {
tableName = databaseType.upCaseEntityName(tableName);
}
return clearTable(connectionSource, tableName);
} | [
"public",
"static",
"<",
"T",
">",
"int",
"clearTable",
"(",
"ConnectionSource",
"connectionSource",
",",
"Class",
"<",
"T",
">",
"dataClass",
")",
"throws",
"SQLException",
"{",
"DatabaseType",
"databaseType",
"=",
"connectionSource",
".",
"getDatabaseType",
"(",... | Clear all data out of the table. For certain database types and with large sized tables, which may take a long
time. In some configurations, it may be faster to drop and re-create the table.
<p>
<b>WARNING:</b> This is [obviously] very destructive and is unrecoverable.
</p> | [
"Clear",
"all",
"data",
"out",
"of",
"the",
"table",
".",
"For",
"certain",
"database",
"types",
"and",
"with",
"large",
"sized",
"tables",
"which",
"may",
"take",
"a",
"long",
"time",
".",
"In",
"some",
"configurations",
"it",
"may",
"be",
"faster",
"to... | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L232-L239 |
MindscapeHQ/raygun4android | provider/src/main/java/com.mindscapehq.android.raygun4android/RaygunClient.java | RaygunClient.AttachExceptionHandler | @Deprecated public static void AttachExceptionHandler(List tags, Map userCustomData) {
UncaughtExceptionHandler oldHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(oldHandler instanceof RaygunUncaughtExceptionHandler)) {
RaygunClient.handler = new RaygunUncaughtExceptionHandler(oldHandler, tags, userCustomData);
Thread.setDefaultUncaughtExceptionHandler(RaygunClient.handler);
}
} | java | @Deprecated public static void AttachExceptionHandler(List tags, Map userCustomData) {
UncaughtExceptionHandler oldHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(oldHandler instanceof RaygunUncaughtExceptionHandler)) {
RaygunClient.handler = new RaygunUncaughtExceptionHandler(oldHandler, tags, userCustomData);
Thread.setDefaultUncaughtExceptionHandler(RaygunClient.handler);
}
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"AttachExceptionHandler",
"(",
"List",
"tags",
",",
"Map",
"userCustomData",
")",
"{",
"UncaughtExceptionHandler",
"oldHandler",
"=",
"Thread",
".",
"getDefaultUncaughtExceptionHandler",
"(",
")",
";",
"if",
"(",
"!",
... | Attaches a pre-built Raygun exception handler to the thread's DefaultUncaughtExceptionHandler.
This automatically sends any exceptions that reaches it to the Raygun API.
@param tags A list of tags that relate to the calling application's currently build or state.
These will be appended to all exception messages sent to Raygun.
@param userCustomData A set of key-value pairs that will be attached to each exception message
sent to Raygun. This can contain any extra data relating to the calling
application's state you would like to see.
@deprecated Call attachExceptionHandler(), then setUserCustomData(Map) instead | [
"Attaches",
"a",
"pre",
"-",
"built",
"Raygun",
"exception",
"handler",
"to",
"the",
"thread",
"s",
"DefaultUncaughtExceptionHandler",
".",
"This",
"automatically",
"sends",
"any",
"exceptions",
"that",
"reaches",
"it",
"to",
"the",
"Raygun",
"API",
"."
] | train | https://github.com/MindscapeHQ/raygun4android/blob/227231f9b8aca1cafa5b6518a388d128e37d35fe/provider/src/main/java/com.mindscapehq.android.raygun4android/RaygunClient.java#L310-L316 |
abel533/ECharts | src/main/java/com/github/abel533/echarts/Polar.java | Polar.radius | public Polar radius(Object width, Object height) {
radius = new Object[]{width, height};
return this;
} | java | public Polar radius(Object width, Object height) {
radius = new Object[]{width, height};
return this;
} | [
"public",
"Polar",
"radius",
"(",
"Object",
"width",
",",
"Object",
"height",
")",
"{",
"radius",
"=",
"new",
"Object",
"[",
"]",
"{",
"width",
",",
"height",
"}",
";",
"return",
"this",
";",
"}"
] | 半径,支持绝对值(px)和百分比,百分比计算比,min(width, height) / 2 * 75%,
传数组实现环形图,[内半径,外半径]
@param width
@param height
@return | [
"半径,支持绝对值(px)和百分比,百分比计算比,min",
"(",
"width",
"height",
")",
"/",
"2",
"*",
"75%,",
"传数组实现环形图,",
"[",
"内半径,外半径",
"]"
] | train | https://github.com/abel533/ECharts/blob/73e031e51b75e67480701404ccf16e76fd5aa278/src/main/java/com/github/abel533/echarts/Polar.java#L305-L308 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/component/selectMultiMenu/SelectMultiMenuRenderer.java | SelectMultiMenuRenderer.renderOption | protected void renderOption(ResponseWriter rw, SelectItem selectItem, String[] selectedOption, int index)
throws IOException {
String itemLabel = selectItem.getLabel();
final String description = selectItem.getDescription();
final Object itemValue = selectItem.getValue();
renderOption(rw, selectedOption, index, itemLabel, description, itemValue);
} | java | protected void renderOption(ResponseWriter rw, SelectItem selectItem, String[] selectedOption, int index)
throws IOException {
String itemLabel = selectItem.getLabel();
final String description = selectItem.getDescription();
final Object itemValue = selectItem.getValue();
renderOption(rw, selectedOption, index, itemLabel, description, itemValue);
} | [
"protected",
"void",
"renderOption",
"(",
"ResponseWriter",
"rw",
",",
"SelectItem",
"selectItem",
",",
"String",
"[",
"]",
"selectedOption",
",",
"int",
"index",
")",
"throws",
"IOException",
"{",
"String",
"itemLabel",
"=",
"selectItem",
".",
"getLabel",
"(",
... | Renders a single <option> tag. For some reason,
<code>SelectItem</code> and <code>UISelectItem</code> don't share a
common interface, so this method is repeated twice.
@param rw
The response writer
@param selectItem
The current SelectItem
@param selectedOption
the currently selected option
@throws IOException
thrown if something's wrong with the response writer | [
"Renders",
"a",
"single",
"<",
";",
"option>",
";",
"tag",
".",
"For",
"some",
"reason",
"<code",
">",
"SelectItem<",
"/",
"code",
">",
"and",
"<code",
">",
"UISelectItem<",
"/",
"code",
">",
"don",
"t",
"share",
"a",
"common",
"interface",
"so",
"... | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/selectMultiMenu/SelectMultiMenuRenderer.java#L590-L598 |
EasyinnovaSL/Tiff-Library-4J | src/main/java/com/easyinnova/tiff/model/IfdTags.java | IfdTags.addTag | public void addTag(String tagName, int[] tagValue) {
int id = TiffTags.getTagId(tagName);
TagValue tag = new TagValue(id, 3);
for (int i = 0; i < tagValue.length; i++) {
com.easyinnova.tiff.model.types.Short val = new com.easyinnova.tiff.model.types.Short(tagValue[i]);
tag.add(val);
}
addTag(tag);
} | java | public void addTag(String tagName, int[] tagValue) {
int id = TiffTags.getTagId(tagName);
TagValue tag = new TagValue(id, 3);
for (int i = 0; i < tagValue.length; i++) {
com.easyinnova.tiff.model.types.Short val = new com.easyinnova.tiff.model.types.Short(tagValue[i]);
tag.add(val);
}
addTag(tag);
} | [
"public",
"void",
"addTag",
"(",
"String",
"tagName",
",",
"int",
"[",
"]",
"tagValue",
")",
"{",
"int",
"id",
"=",
"TiffTags",
".",
"getTagId",
"(",
"tagName",
")",
";",
"TagValue",
"tag",
"=",
"new",
"TagValue",
"(",
"id",
",",
"3",
")",
";",
"fo... | Adds the tag.
@param tagName the tag name
@param tagValue the tag value | [
"Adds",
"the",
"tag",
"."
] | train | https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/IfdTags.java#L92-L100 |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/interval/DiscreteInterval.java | DiscreteInterval.plus | public DiscreteInterval plus(DiscreteInterval other) {
return new DiscreteInterval(this.min + other.min, this.max + other.max);
} | java | public DiscreteInterval plus(DiscreteInterval other) {
return new DiscreteInterval(this.min + other.min, this.max + other.max);
} | [
"public",
"DiscreteInterval",
"plus",
"(",
"DiscreteInterval",
"other",
")",
"{",
"return",
"new",
"DiscreteInterval",
"(",
"this",
".",
"min",
"+",
"other",
".",
"min",
",",
"this",
".",
"max",
"+",
"other",
".",
"max",
")",
";",
"}"
] | Returns an interval representing the addition of the
given interval with this one.
@param other interval to add to this one
@return interval sum | [
"Returns",
"an",
"interval",
"representing",
"the",
"addition",
"of",
"the",
"given",
"interval",
"with",
"this",
"one",
"."
] | train | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/interval/DiscreteInterval.java#L74-L76 |
apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/configuration/State.java | State.appendToListProp | public synchronized void appendToListProp(String key, String value) {
if (contains(key)) {
setProp(key, LIST_JOINER.join(getProp(key), value));
} else {
setProp(key, value);
}
} | java | public synchronized void appendToListProp(String key, String value) {
if (contains(key)) {
setProp(key, LIST_JOINER.join(getProp(key), value));
} else {
setProp(key, value);
}
} | [
"public",
"synchronized",
"void",
"appendToListProp",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"contains",
"(",
"key",
")",
")",
"{",
"setProp",
"(",
"key",
",",
"LIST_JOINER",
".",
"join",
"(",
"getProp",
"(",
"key",
")",
","... | Appends the input value to a list property that can be retrieved with {@link #getPropAsList}.
<p>
List properties are internally stored as comma separated strings. Adding a value that contains commas (for
example "a,b,c") will essentially add multiple values to the property ("a", "b", and "c"). This is
similar to the way that {@link org.apache.hadoop.conf.Configuration} works.
</p>
@param key property key
@param value property value (if it includes commas, it will be split by the commas). | [
"Appends",
"the",
"input",
"value",
"to",
"a",
"list",
"property",
"that",
"can",
"be",
"retrieved",
"with",
"{",
"@link",
"#getPropAsList",
"}",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/configuration/State.java#L228-L234 |
codelibs/jcifs | src/main/java/jcifs/smb1/smb1/SmbFile.java | SmbFile.getSecurity | public ACE[] getSecurity(boolean resolveSids) throws IOException {
int f;
ACE[] aces;
f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 );
/*
* NtTrans Query Security Desc Request / Response
*/
NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 );
NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse();
try {
send( request, response );
aces = response.securityDescriptor.aces;
if (aces != null)
processAces(aces, resolveSids);
} finally {
try {
close( f, 0L );
} catch(SmbException se) {
if (log.level >= 1)
se.printStackTrace(log);
}
}
return aces;
} | java | public ACE[] getSecurity(boolean resolveSids) throws IOException {
int f;
ACE[] aces;
f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 );
/*
* NtTrans Query Security Desc Request / Response
*/
NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 );
NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse();
try {
send( request, response );
aces = response.securityDescriptor.aces;
if (aces != null)
processAces(aces, resolveSids);
} finally {
try {
close( f, 0L );
} catch(SmbException se) {
if (log.level >= 1)
se.printStackTrace(log);
}
}
return aces;
} | [
"public",
"ACE",
"[",
"]",
"getSecurity",
"(",
"boolean",
"resolveSids",
")",
"throws",
"IOException",
"{",
"int",
"f",
";",
"ACE",
"[",
"]",
"aces",
";",
"f",
"=",
"open0",
"(",
"O_RDONLY",
",",
"READ_CONTROL",
",",
"0",
",",
"isDirectory",
"(",
")",
... | Return an array of Access Control Entry (ACE) objects representing
the security descriptor associated with this file or directory.
If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned.
@param resolveSids Attempt to resolve the SIDs within each ACE form
their numeric representation to their corresponding account names. | [
"Return",
"an",
"array",
"of",
"Access",
"Control",
"Entry",
"(",
"ACE",
")",
"objects",
"representing",
"the",
"security",
"descriptor",
"associated",
"with",
"this",
"file",
"or",
"directory",
".",
"If",
"no",
"DACL",
"is",
"present",
"null",
"is",
"return... | train | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/smb1/SmbFile.java#L2892-L2920 |
aboutsip/pkts | pkts-core/src/main/java/io/pkts/framer/SIPFramer.java | SIPFramer.frame | @Override
public SipPacket frame(final TransportPacket parent, final Buffer buffer) throws IOException {
if (parent == null) {
throw new IllegalArgumentException("The parent frame cannot be null");
}
final SipMessage sip = SipParser.frame(buffer);
if (sip.isRequest()) {
return new SipRequestPacketImpl(parent, sip.toRequest());
}
return new SipResponsePacketImpl(parent, sip.toResponse());
} | java | @Override
public SipPacket frame(final TransportPacket parent, final Buffer buffer) throws IOException {
if (parent == null) {
throw new IllegalArgumentException("The parent frame cannot be null");
}
final SipMessage sip = SipParser.frame(buffer);
if (sip.isRequest()) {
return new SipRequestPacketImpl(parent, sip.toRequest());
}
return new SipResponsePacketImpl(parent, sip.toResponse());
} | [
"@",
"Override",
"public",
"SipPacket",
"frame",
"(",
"final",
"TransportPacket",
"parent",
",",
"final",
"Buffer",
"buffer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Th... | {@inheritDoc}
Very basic way of framing a sip message. It makes a lot of assumption but
in the framing phase we are, well, just framing. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/aboutsip/pkts/blob/0f06bb0dac76c812187829f580a8d476ca99a1a1/pkts-core/src/main/java/io/pkts/framer/SIPFramer.java#L40-L53 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Waiter.java | Waiter.waitForView | public View waitForView(int id, int index, int timeout, boolean scroll){
Set<View> uniqueViewsMatchingId = new HashSet<View>();
long endTime = SystemClock.uptimeMillis() + timeout;
while (SystemClock.uptimeMillis() <= endTime) {
sleeper.sleep();
for (View view : viewFetcher.getAllViews(false)) {
Integer idOfView = Integer.valueOf(view.getId());
if (idOfView.equals(id)) {
uniqueViewsMatchingId.add(view);
if(uniqueViewsMatchingId.size() > index) {
return view;
}
}
}
if(scroll)
scroller.scrollDown();
}
return null;
} | java | public View waitForView(int id, int index, int timeout, boolean scroll){
Set<View> uniqueViewsMatchingId = new HashSet<View>();
long endTime = SystemClock.uptimeMillis() + timeout;
while (SystemClock.uptimeMillis() <= endTime) {
sleeper.sleep();
for (View view : viewFetcher.getAllViews(false)) {
Integer idOfView = Integer.valueOf(view.getId());
if (idOfView.equals(id)) {
uniqueViewsMatchingId.add(view);
if(uniqueViewsMatchingId.size() > index) {
return view;
}
}
}
if(scroll)
scroller.scrollDown();
}
return null;
} | [
"public",
"View",
"waitForView",
"(",
"int",
"id",
",",
"int",
"index",
",",
"int",
"timeout",
",",
"boolean",
"scroll",
")",
"{",
"Set",
"<",
"View",
">",
"uniqueViewsMatchingId",
"=",
"new",
"HashSet",
"<",
"View",
">",
"(",
")",
";",
"long",
"endTim... | Waits for a certain view.
@param view the id of the view to wait for
@param index the index of the {@link View}. {@code 0} if only one is available
@return the specified View | [
"Waits",
"for",
"a",
"certain",
"view",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L398-L420 |
protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/IOUtil.java | IOUtil.mergeFrom | static <T> void mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema,
boolean decodeNestedMessageAsGroup) throws IOException
{
final CodedInput input = new CodedInput(in, buf, decodeNestedMessageAsGroup);
schema.mergeFrom(input, message);
input.checkLastTagWas(0);
} | java | static <T> void mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema,
boolean decodeNestedMessageAsGroup) throws IOException
{
final CodedInput input = new CodedInput(in, buf, decodeNestedMessageAsGroup);
schema.mergeFrom(input, message);
input.checkLastTagWas(0);
} | [
"static",
"<",
"T",
">",
"void",
"mergeFrom",
"(",
"InputStream",
"in",
",",
"byte",
"[",
"]",
"buf",
",",
"T",
"message",
",",
"Schema",
"<",
"T",
">",
"schema",
",",
"boolean",
"decodeNestedMessageAsGroup",
")",
"throws",
"IOException",
"{",
"final",
"... | Merges the {@code message} from the {@link InputStream} with the supplied {@code buf} to use. | [
"Merges",
"the",
"{"
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/IOUtil.java#L62-L68 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3f.java | Capsule3f.setMedial1 | @Override
public void setMedial1(double x, double y, double z) {
this.medial1.set(x, y, z);
ensureAIsLowerPoint();
} | java | @Override
public void setMedial1(double x, double y, double z) {
this.medial1.set(x, y, z);
ensureAIsLowerPoint();
} | [
"@",
"Override",
"public",
"void",
"setMedial1",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"this",
".",
"medial1",
".",
"set",
"(",
"x",
",",
"y",
",",
"z",
")",
";",
"ensureAIsLowerPoint",
"(",
")",
";",
"}"
] | Set the first point of the capsule's segment.
@param x x xoordinate of the new first point for the capsule's segment..
@param y y xoordinate of the new first point for the capsule's segment..
@param z z xoordinate of the new first point for the capsule's segment.. | [
"Set",
"the",
"first",
"point",
"of",
"the",
"capsule",
"s",
"segment",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3f.java#L139-L143 |
cesarferreira/AndroidQuickUtils | library/src/main/java/quickutils/core/views/image/CompassImageView.java | CompassImageView.rotationUpdate | public void rotationUpdate(final float angleNew, final boolean animate) {
if (animate) {
if (Math.abs(angle0 - angleNew) > ANGLE_DELTA_THRESHOLD) {
angle0 = angleNew;
this.invalidate();
}
animationOn = true;
} else {
angle1 = angleNew;
angle2 = angleNew;
angle0 = angleNew;
angleLastDrawn = angleNew;
this.invalidate();
animationOn = false;
}
} | java | public void rotationUpdate(final float angleNew, final boolean animate) {
if (animate) {
if (Math.abs(angle0 - angleNew) > ANGLE_DELTA_THRESHOLD) {
angle0 = angleNew;
this.invalidate();
}
animationOn = true;
} else {
angle1 = angleNew;
angle2 = angleNew;
angle0 = angleNew;
angleLastDrawn = angleNew;
this.invalidate();
animationOn = false;
}
} | [
"public",
"void",
"rotationUpdate",
"(",
"final",
"float",
"angleNew",
",",
"final",
"boolean",
"animate",
")",
"{",
"if",
"(",
"animate",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"angle0",
"-",
"angleNew",
")",
">",
"ANGLE_DELTA_THRESHOLD",
")",
"{... | Use this to set new "magnetic field" angle at which image should rotate
@param angleNew new magnetic field angle, deg., relative to vertical axis.
@param animate true, if image shoud rotate using animation, false to set new rotation instantly | [
"Use",
"this",
"to",
"set",
"new",
"magnetic",
"field",
"angle",
"at",
"which",
"image",
"should",
"rotate"
] | train | https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/views/image/CompassImageView.java#L118-L133 |
javagl/ND | nd-arrays/src/main/java/de/javagl/nd/arrays/d/DoubleArraysND.java | DoubleArraysND.wrap | public static DoubleArrayND wrap(DoubleTuple t, IntTuple size)
{
Objects.requireNonNull(t, "The tuple is null");
Objects.requireNonNull(size, "The size is null");
int totalSize = IntTupleFunctions.reduce(size, 1, (a, b) -> a * b);
if (t.getSize() != totalSize)
{
throw new IllegalArgumentException(
"The tuple has a size of " + t.getSize() + ", the expected " +
"array size is " + size + " (total: " + totalSize + ")");
}
return new TupleDoubleArrayND(t, size);
} | java | public static DoubleArrayND wrap(DoubleTuple t, IntTuple size)
{
Objects.requireNonNull(t, "The tuple is null");
Objects.requireNonNull(size, "The size is null");
int totalSize = IntTupleFunctions.reduce(size, 1, (a, b) -> a * b);
if (t.getSize() != totalSize)
{
throw new IllegalArgumentException(
"The tuple has a size of " + t.getSize() + ", the expected " +
"array size is " + size + " (total: " + totalSize + ")");
}
return new TupleDoubleArrayND(t, size);
} | [
"public",
"static",
"DoubleArrayND",
"wrap",
"(",
"DoubleTuple",
"t",
",",
"IntTuple",
"size",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"t",
",",
"\"The tuple is null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"size",
",",
"\"The size is null\"... | Creates a <i>view</i> on the given tuple as a {@link DoubleArrayND}.
Changes in the given tuple will be visible in the returned array.
@param t The tuple
@param size The size of the array
@return The view on the tuple
@throws NullPointerException If any argument is <code>null</code>
@throws IllegalArgumentException If the
{@link DoubleTuple#getSize() size} of the tuple does not match the
given array size (that is, the product of all elements of the given
tuple). | [
"Creates",
"a",
"<i",
">",
"view<",
"/",
"i",
">",
"on",
"the",
"given",
"tuple",
"as",
"a",
"{",
"@link",
"DoubleArrayND",
"}",
".",
"Changes",
"in",
"the",
"given",
"tuple",
"will",
"be",
"visible",
"in",
"the",
"returned",
"array",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-arrays/src/main/java/de/javagl/nd/arrays/d/DoubleArraysND.java#L112-L124 |
pressgang-ccms/PressGangCCMSCommonUtilities | src/main/java/org/jboss/pressgang/ccms/utils/common/DateUtils.java | DateUtils.parseDate | public static Date parseDate(String str, String... parsePatterns) throws ParseException {
return parseDate(str, null, parsePatterns);
} | java | public static Date parseDate(String str, String... parsePatterns) throws ParseException {
return parseDate(str, null, parsePatterns);
} | [
"public",
"static",
"Date",
"parseDate",
"(",
"String",
"str",
",",
"String",
"...",
"parsePatterns",
")",
"throws",
"ParseException",
"{",
"return",
"parseDate",
"(",
"str",
",",
"null",
",",
"parsePatterns",
")",
";",
"}"
] | <p>Parses a string representing a date by trying a variety of different parsers.</p>
<p/>
<p>The parse will try each parse pattern in turn.
A parse is only deemed successful if it parses the whole of the input string.
If no parse patterns match, a ParseException is thrown.</p>
The parser will be lenient toward the parsed date.
@param str the date to parse, not null
@param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
@return the parsed date
@throws IllegalArgumentException if the date string or pattern array is null
@throws ParseException if none of the date patterns were suitable (or there were none) | [
"<p",
">",
"Parses",
"a",
"string",
"representing",
"a",
"date",
"by",
"trying",
"a",
"variety",
"of",
"different",
"parsers",
".",
"<",
"/",
"p",
">",
"<p",
"/",
">",
"<p",
">",
"The",
"parse",
"will",
"try",
"each",
"parse",
"pattern",
"in",
"turn"... | train | https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/DateUtils.java#L49-L51 |
sarl/sarl | contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java | PyExpressionGenerator._generate | protected XExpression _generate(XAssignment assignment, IAppendable it, IExtraLanguageGeneratorContext context) {
appendReturnIfExpectedReturnedExpression(it, context);
it.append("("); //$NON-NLS-1$
newFeatureCallGenerator(context, it).generate(assignment);
it.append(" = "); //$NON-NLS-1$
generate(assignment.getValue(), it, context);
it.append(")"); //$NON-NLS-1$
return assignment;
} | java | protected XExpression _generate(XAssignment assignment, IAppendable it, IExtraLanguageGeneratorContext context) {
appendReturnIfExpectedReturnedExpression(it, context);
it.append("("); //$NON-NLS-1$
newFeatureCallGenerator(context, it).generate(assignment);
it.append(" = "); //$NON-NLS-1$
generate(assignment.getValue(), it, context);
it.append(")"); //$NON-NLS-1$
return assignment;
} | [
"protected",
"XExpression",
"_generate",
"(",
"XAssignment",
"assignment",
",",
"IAppendable",
"it",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"appendReturnIfExpectedReturnedExpression",
"(",
"it",
",",
"context",
")",
";",
"it",
".",
"append",
"(",
... | Generate the given object.
@param assignment the assignment operator.
@param it the target for the generated content.
@param context the context.
@return the assignment. | [
"Generate",
"the",
"given",
"object",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java#L424-L432 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/NodeSetDTM.java | NodeSetDTM.removeNode | public void removeNode(int n)
{
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
this.removeElement(n);
} | java | public void removeNode(int n)
{
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
this.removeElement(n);
} | [
"public",
"void",
"removeNode",
"(",
"int",
"n",
")",
"{",
"if",
"(",
"!",
"m_mutable",
")",
"throw",
"new",
"RuntimeException",
"(",
"XSLMessages",
".",
"createXPATHMessage",
"(",
"XPATHErrorResources",
".",
"ER_NODESETDTM_NOT_MUTABLE",
",",
"null",
")",
")",
... | Remove a node.
@param n Node to be added
@throws RuntimeException thrown if this NodeSetDTM is not of
a mutable type. | [
"Remove",
"a",
"node",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/NodeSetDTM.java#L569-L576 |
ldapchai/ldapchai | src/main/java/com/novell/ldapchai/impl/edir/NmasCrFactory.java | NmasCrFactory.readAssignedChallengeSet | public static ChallengeSet readAssignedChallengeSet(
final ChaiProvider provider,
final ChaiPasswordPolicy passwordPolicy,
final Locale locale
)
throws ChaiUnavailableException, ChaiOperationException, ChaiValidationException
{
final String challengeSetDN;
try
{
challengeSetDN = ( ( NspmPasswordPolicy ) passwordPolicy ).getChallengeSetDN();
}
catch ( ClassCastException e )
{
LOGGER.trace( "password policy is not an nmas password policy, unable to read challenge set policy" );
return null;
}
if ( challengeSetDN == null )
{
LOGGER.trace( "password policy does not have a challengeSetDN, return null for readAssignedChallengeSet()" );
return null;
}
final String identifier = ( ( NspmPasswordPolicy ) passwordPolicy ).readStringAttribute( "nsimChallengeSetGUID" );
return readNmasAssignedChallengeSetPolicy( provider, challengeSetDN, locale, identifier );
} | java | public static ChallengeSet readAssignedChallengeSet(
final ChaiProvider provider,
final ChaiPasswordPolicy passwordPolicy,
final Locale locale
)
throws ChaiUnavailableException, ChaiOperationException, ChaiValidationException
{
final String challengeSetDN;
try
{
challengeSetDN = ( ( NspmPasswordPolicy ) passwordPolicy ).getChallengeSetDN();
}
catch ( ClassCastException e )
{
LOGGER.trace( "password policy is not an nmas password policy, unable to read challenge set policy" );
return null;
}
if ( challengeSetDN == null )
{
LOGGER.trace( "password policy does not have a challengeSetDN, return null for readAssignedChallengeSet()" );
return null;
}
final String identifier = ( ( NspmPasswordPolicy ) passwordPolicy ).readStringAttribute( "nsimChallengeSetGUID" );
return readNmasAssignedChallengeSetPolicy( provider, challengeSetDN, locale, identifier );
} | [
"public",
"static",
"ChallengeSet",
"readAssignedChallengeSet",
"(",
"final",
"ChaiProvider",
"provider",
",",
"final",
"ChaiPasswordPolicy",
"passwordPolicy",
",",
"final",
"Locale",
"locale",
")",
"throws",
"ChaiUnavailableException",
",",
"ChaiOperationException",
",",
... | <p>Read the theUser's configured ChallengeSet from the directory. Operations are performed according
to the ChaiConfiguration found by looking at the ChaiProvider underlying the ChaiEntry. For example,
the setting {@link com.novell.ldapchai.provider.ChaiSetting#EDIRECTORY_ENABLE_NMAS} determines if NMAS calls
are used to discover a universal password c/r policy.</p>
<p>This method is preferred over {@link #readAssignedChallengeSet(com.novell.ldapchai.ChaiUser)}, as it does not
require a (possibly unnecessary) call to read the user's assigned password policy.</p>
@param provider provider used for ldap communication
@param passwordPolicy the policy to examine to find a challenge set.
@param locale desired retreival locale. If the stored ChallengeSet is internationalized,
the appropriate localized strings will be returned.
@return A valid ChallengeSet if found, otherwise null.
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable
@throws ChaiValidationException when there is a logical problem with the challenge set data, such as more randoms required then exist | [
"<p",
">",
"Read",
"the",
"theUser",
"s",
"configured",
"ChallengeSet",
"from",
"the",
"directory",
".",
"Operations",
"are",
"performed",
"according",
"to",
"the",
"ChaiConfiguration",
"found",
"by",
"looking",
"at",
"the",
"ChaiProvider",
"underlying",
"the",
... | train | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/impl/edir/NmasCrFactory.java#L125-L152 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/HanLP.java | HanLP.extractWords | public static List<WordInfo> extractWords(BufferedReader reader, int size, boolean newWordsOnly) throws IOException
{
NewWordDiscover discover = new NewWordDiscover(4, 0.0f, .5f, 100f, newWordsOnly);
return discover.discover(reader, size);
} | java | public static List<WordInfo> extractWords(BufferedReader reader, int size, boolean newWordsOnly) throws IOException
{
NewWordDiscover discover = new NewWordDiscover(4, 0.0f, .5f, 100f, newWordsOnly);
return discover.discover(reader, size);
} | [
"public",
"static",
"List",
"<",
"WordInfo",
">",
"extractWords",
"(",
"BufferedReader",
"reader",
",",
"int",
"size",
",",
"boolean",
"newWordsOnly",
")",
"throws",
"IOException",
"{",
"NewWordDiscover",
"discover",
"=",
"new",
"NewWordDiscover",
"(",
"4",
",",... | 提取词语(新词发现)
@param reader 从reader获取文本
@param size 需要提取词语的数量
@param newWordsOnly 是否只提取词典中没有的词语
@return 一个词语列表 | [
"提取词语(新词发现)"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/HanLP.java#L771-L775 |
jboss/jboss-jsf-api_spec | src/main/java/javax/faces/component/UIComponent.java | UIComponent.restoreTransientState | public void restoreTransientState(FacesContext context, Object state)
{
boolean forceCreate = (state != null);
TransientStateHelper helper = getTransientStateHelper(forceCreate);
if (helper != null) {
helper.restoreTransientState(context, state);
}
} | java | public void restoreTransientState(FacesContext context, Object state)
{
boolean forceCreate = (state != null);
TransientStateHelper helper = getTransientStateHelper(forceCreate);
if (helper != null) {
helper.restoreTransientState(context, state);
}
} | [
"public",
"void",
"restoreTransientState",
"(",
"FacesContext",
"context",
",",
"Object",
"state",
")",
"{",
"boolean",
"forceCreate",
"=",
"(",
"state",
"!=",
"null",
")",
";",
"TransientStateHelper",
"helper",
"=",
"getTransientStateHelper",
"(",
"forceCreate",
... | <p class="changed_added_2_1">For components that need to support
the concept of transient state, this method will restore any
state saved on a prior call to {@link #saveTransientState}.</p>
@since 2.1 | [
"<p",
"class",
"=",
"changed_added_2_1",
">",
"For",
"components",
"that",
"need",
"to",
"support",
"the",
"concept",
"of",
"transient",
"state",
"this",
"method",
"will",
"restore",
"any",
"state",
"saved",
"on",
"a",
"prior",
"call",
"to",
"{",
"@link",
... | train | https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIComponent.java#L652-L660 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineScaleSetsInner.java | VirtualMachineScaleSetsInner.getOSUpgradeHistoryWithServiceResponseAsync | public Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>> getOSUpgradeHistoryWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
return getOSUpgradeHistorySinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>, Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>> call(ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getOSUpgradeHistoryNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>> getOSUpgradeHistoryWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
return getOSUpgradeHistorySinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>, Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>>> call(ServiceResponse<Page<UpgradeOperationHistoricalStatusInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getOSUpgradeHistoryNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"UpgradeOperationHistoricalStatusInfoInner",
">",
">",
">",
"getOSUpgradeHistoryWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"vmScaleSetName",
")",
"{",
"r... | Gets list of OS upgrades on a VM scale set instance.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<UpgradeOperationHistoricalStatusInfoInner> object | [
"Gets",
"list",
"of",
"OS",
"upgrades",
"on",
"a",
"VM",
"scale",
"set",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineScaleSetsInner.java#L1811-L1823 |
zaproxy/zaproxy | src/org/zaproxy/zap/spider/URLResolver.java | URLResolver.resolveUrl | public static String resolveUrl(final String baseUrl, final String relativeUrl) {
// Parameter check
if (baseUrl == null) {
throw new IllegalArgumentException("Base URL must not be null");
}
if (relativeUrl == null) {
throw new IllegalArgumentException("Relative URL must not be null");
}
final Url url = resolveUrl(parseUrl(baseUrl.trim()), relativeUrl.trim());
return url.toString();
} | java | public static String resolveUrl(final String baseUrl, final String relativeUrl) {
// Parameter check
if (baseUrl == null) {
throw new IllegalArgumentException("Base URL must not be null");
}
if (relativeUrl == null) {
throw new IllegalArgumentException("Relative URL must not be null");
}
final Url url = resolveUrl(parseUrl(baseUrl.trim()), relativeUrl.trim());
return url.toString();
} | [
"public",
"static",
"String",
"resolveUrl",
"(",
"final",
"String",
"baseUrl",
",",
"final",
"String",
"relativeUrl",
")",
"{",
"// Parameter check",
"if",
"(",
"baseUrl",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Base URL must no... | Resolves a given relative URL against a base URL. See <a
href="http://www.faqs.org/rfcs/rfc1808.html">RFC1808</a> Section 4 for more details.
@param baseUrl The base URL in which to resolve the specification.
@param relativeUrl The relative URL to resolve against the base URL.
@return the resolved specification. | [
"Resolves",
"a",
"given",
"relative",
"URL",
"against",
"a",
"base",
"URL",
".",
"See",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"faqs",
".",
"org",
"/",
"rfcs",
"/",
"rfc1808",
".",
"html",
">",
"RFC1808<",
"/",
"a",
">",
"Section",
"4",
... | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/spider/URLResolver.java#L40-L51 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/CollectionUtils.java | CollectionUtils.sampleWithoutReplacement | public static <E> Collection<E> sampleWithoutReplacement(Collection<E> c, int n) {
return sampleWithoutReplacement(c, n, new Random());
} | java | public static <E> Collection<E> sampleWithoutReplacement(Collection<E> c, int n) {
return sampleWithoutReplacement(c, n, new Random());
} | [
"public",
"static",
"<",
"E",
">",
"Collection",
"<",
"E",
">",
"sampleWithoutReplacement",
"(",
"Collection",
"<",
"E",
">",
"c",
",",
"int",
"n",
")",
"{",
"return",
"sampleWithoutReplacement",
"(",
"c",
",",
"n",
",",
"new",
"Random",
"(",
")",
")",... | Samples without replacement from a collection.
@param c
The collection to be sampled from
@param n
The number of samples to take
@return a new collection with the sample | [
"Samples",
"without",
"replacement",
"from",
"a",
"collection",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/CollectionUtils.java#L331-L333 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.NewLineComment | public JBBPDslBuilder NewLineComment(final String text) {
this.addItem(new ItemComment(text == null ? "" : text, true));
return this;
} | java | public JBBPDslBuilder NewLineComment(final String text) {
this.addItem(new ItemComment(text == null ? "" : text, true));
return this;
} | [
"public",
"JBBPDslBuilder",
"NewLineComment",
"(",
"final",
"String",
"text",
")",
"{",
"this",
".",
"addItem",
"(",
"new",
"ItemComment",
"(",
"text",
"==",
"null",
"?",
"\"\"",
":",
"text",
",",
"true",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add comment which will be placed on new line.
@param text text of comment, can be null
@return the builder instance, must not be null
@since 1.4.1 | [
"Add",
"comment",
"which",
"will",
"be",
"placed",
"on",
"new",
"line",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L1313-L1316 |
Azure/azure-sdk-for-java | notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java | NotificationHubsInner.createOrUpdate | public NotificationHubResourceInner createOrUpdate(String resourceGroupName, String namespaceName, String notificationHubName, NotificationHubCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName, parameters).toBlocking().single().body();
} | java | public NotificationHubResourceInner createOrUpdate(String resourceGroupName, String namespaceName, String notificationHubName, NotificationHubCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName, parameters).toBlocking().single().body();
} | [
"public",
"NotificationHubResourceInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"namespaceName",
",",
"String",
"notificationHubName",
",",
"NotificationHubCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceRespon... | Creates/Update a NotificationHub in a namespace.
@param resourceGroupName The name of the resource group.
@param namespaceName The namespace name.
@param notificationHubName The notification hub name.
@param parameters Parameters supplied to the create/update a NotificationHub Resource.
@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 NotificationHubResourceInner object if successful. | [
"Creates",
"/",
"Update",
"a",
"NotificationHub",
"in",
"a",
"namespace",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java#L244-L246 |
borball/weixin-sdk | weixin-mp/src/main/java/com/riversoft/weixin/mp/template/Templates.java | Templates.send | public long send(String toUser, String templateId, String url, MiniProgram miniProgram, Map<String, Data> messages) {
String sendUrl = WxEndpoint.get("url.template.send");
MessageWrapper messageWrapper = new MessageWrapper();
messageWrapper.setToUser(toUser);
messageWrapper.setTemplateId(templateId);
if(url != null) {
messageWrapper.setUrl(url);
}
if(miniProgram != null) {
messageWrapper.setMiniProgram(miniProgram);
}
messageWrapper.setData(messages);
String json = JsonMapper.defaultMapper().toJson(messageWrapper);
logger.debug("template message, send message: {}", json);
String response = wxClient.post(sendUrl, json);
Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
if(result.containsKey("msgid")) {
return ((Number)result.get("msgid")).longValue();
} else {
throw new WxRuntimeException(999, "send template message failed.");
}
} | java | public long send(String toUser, String templateId, String url, MiniProgram miniProgram, Map<String, Data> messages) {
String sendUrl = WxEndpoint.get("url.template.send");
MessageWrapper messageWrapper = new MessageWrapper();
messageWrapper.setToUser(toUser);
messageWrapper.setTemplateId(templateId);
if(url != null) {
messageWrapper.setUrl(url);
}
if(miniProgram != null) {
messageWrapper.setMiniProgram(miniProgram);
}
messageWrapper.setData(messages);
String json = JsonMapper.defaultMapper().toJson(messageWrapper);
logger.debug("template message, send message: {}", json);
String response = wxClient.post(sendUrl, json);
Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
if(result.containsKey("msgid")) {
return ((Number)result.get("msgid")).longValue();
} else {
throw new WxRuntimeException(999, "send template message failed.");
}
} | [
"public",
"long",
"send",
"(",
"String",
"toUser",
",",
"String",
"templateId",
",",
"String",
"url",
",",
"MiniProgram",
"miniProgram",
",",
"Map",
"<",
"String",
",",
"Data",
">",
"messages",
")",
"{",
"String",
"sendUrl",
"=",
"WxEndpoint",
".",
"get",
... | 发送模板消息
url和miniprogram都是非必填字段,若都不传则模板无跳转;
若都传,会优先跳转至小程序。
开发者可根据实际需要选择其中一种跳转方式即可。
当用户的微信客户端版本不支持跳小程序时,将会跳转至url
@param toUser
@param templateId
@param url
@param miniProgram
@param messages
@return 消息ID | [
"发送模板消息"
] | train | https://github.com/borball/weixin-sdk/blob/32bf5e45cdd8d0d28074e83954e1ec62dcf25cb7/weixin-mp/src/main/java/com/riversoft/weixin/mp/template/Templates.java#L150-L175 |
fnklabs/draenei | src/main/java/com/fnklabs/draenei/orm/DataProvider.java | DataProvider.removeAsync | public ListenableFuture<Boolean> removeAsync(@NotNull V entity) {
Timer removeAsyncTimer = METRICS.getTimer(MetricsType.DATA_PROVIDER_REMOVE.name());
Delete from = QueryBuilder.delete()
.from(getEntityMetadata().getTableName());
int primaryKeysSize = getEntityMetadata().getPrimaryKeysSize();
Delete.Where where = null;
for (int i = 0; i < primaryKeysSize; i++) {
Optional<PrimaryKeyMetadata> primaryKey = getEntityMetadata().getPrimaryKey(i);
if (!primaryKey.isPresent()) {
throw new QueryException(String.format("Invalid primary key index: %d", i));
}
PrimaryKeyMetadata primaryKeyMetadata = primaryKey.get();
if (i == 0) {
where = from.where(QueryBuilder.eq(primaryKeyMetadata.getName(), QueryBuilder.bindMarker()));
} else {
where = where.and(QueryBuilder.eq(primaryKeyMetadata.getName(), QueryBuilder.bindMarker()));
}
}
assert where != null;
PreparedStatement prepare = getCassandraClient().prepare(getEntityMetadata().getKeyspace(), where.getQueryString());
prepare.setConsistencyLevel(getWriteConsistencyLevel());
BoundStatement boundStatement = new BoundStatement(prepare);
for (int i = 0; i < primaryKeysSize; i++) {
Optional<PrimaryKeyMetadata> primaryKey = getEntityMetadata().getPrimaryKey(i);
if (!primaryKey.isPresent()) {
throw new QueryException(String.format("Invalid primary key index: %d", i));
}
PrimaryKeyMetadata primaryKeyMetadata = primaryKey.get();
Object value = primaryKeyMetadata.readValue(entity);
boundStatement.setBytesUnsafe(i, primaryKeyMetadata.serialize(value));
}
ResultSetFuture resultSetFuture = getCassandraClient().executeAsync(boundStatement);
ListenableFuture<Boolean> transform = Futures.transform(resultSetFuture, ResultSet::wasApplied, getExecutorService());
monitorFuture(removeAsyncTimer, transform);
return transform;
} | java | public ListenableFuture<Boolean> removeAsync(@NotNull V entity) {
Timer removeAsyncTimer = METRICS.getTimer(MetricsType.DATA_PROVIDER_REMOVE.name());
Delete from = QueryBuilder.delete()
.from(getEntityMetadata().getTableName());
int primaryKeysSize = getEntityMetadata().getPrimaryKeysSize();
Delete.Where where = null;
for (int i = 0; i < primaryKeysSize; i++) {
Optional<PrimaryKeyMetadata> primaryKey = getEntityMetadata().getPrimaryKey(i);
if (!primaryKey.isPresent()) {
throw new QueryException(String.format("Invalid primary key index: %d", i));
}
PrimaryKeyMetadata primaryKeyMetadata = primaryKey.get();
if (i == 0) {
where = from.where(QueryBuilder.eq(primaryKeyMetadata.getName(), QueryBuilder.bindMarker()));
} else {
where = where.and(QueryBuilder.eq(primaryKeyMetadata.getName(), QueryBuilder.bindMarker()));
}
}
assert where != null;
PreparedStatement prepare = getCassandraClient().prepare(getEntityMetadata().getKeyspace(), where.getQueryString());
prepare.setConsistencyLevel(getWriteConsistencyLevel());
BoundStatement boundStatement = new BoundStatement(prepare);
for (int i = 0; i < primaryKeysSize; i++) {
Optional<PrimaryKeyMetadata> primaryKey = getEntityMetadata().getPrimaryKey(i);
if (!primaryKey.isPresent()) {
throw new QueryException(String.format("Invalid primary key index: %d", i));
}
PrimaryKeyMetadata primaryKeyMetadata = primaryKey.get();
Object value = primaryKeyMetadata.readValue(entity);
boundStatement.setBytesUnsafe(i, primaryKeyMetadata.serialize(value));
}
ResultSetFuture resultSetFuture = getCassandraClient().executeAsync(boundStatement);
ListenableFuture<Boolean> transform = Futures.transform(resultSetFuture, ResultSet::wasApplied, getExecutorService());
monitorFuture(removeAsyncTimer, transform);
return transform;
} | [
"public",
"ListenableFuture",
"<",
"Boolean",
">",
"removeAsync",
"(",
"@",
"NotNull",
"V",
"entity",
")",
"{",
"Timer",
"removeAsyncTimer",
"=",
"METRICS",
".",
"getTimer",
"(",
"MetricsType",
".",
"DATA_PROVIDER_REMOVE",
".",
"name",
"(",
")",
")",
";",
"D... | Remove entity asynchronously
@param entity Target entity
@return Operation status result | [
"Remove",
"entity",
"asynchronously"
] | train | https://github.com/fnklabs/draenei/blob/0a8cac54f1f635be3e2950375a23291d38453ae8/src/main/java/com/fnklabs/draenei/orm/DataProvider.java#L155-L210 |
SonarSource/sonarqube | server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java | ComponentDao.scrollForIndexing | public void scrollForIndexing(DbSession session, @Nullable String projectUuid, ResultHandler<ComponentDto> handler) {
mapper(session).scrollForIndexing(projectUuid, handler);
} | java | public void scrollForIndexing(DbSession session, @Nullable String projectUuid, ResultHandler<ComponentDto> handler) {
mapper(session).scrollForIndexing(projectUuid, handler);
} | [
"public",
"void",
"scrollForIndexing",
"(",
"DbSession",
"session",
",",
"@",
"Nullable",
"String",
"projectUuid",
",",
"ResultHandler",
"<",
"ComponentDto",
">",
"handler",
")",
"{",
"mapper",
"(",
"session",
")",
".",
"scrollForIndexing",
"(",
"projectUuid",
"... | Selects all components that are relevant for indexing. The result is not returned (since it is usually too big), but handed over to the <code>handler</code>
@param session the database session
@param projectUuid the project uuid, which is selected with all of its children
@param handler the action to be applied to every result | [
"Selects",
"all",
"components",
"that",
"are",
"relevant",
"for",
"indexing",
".",
"The",
"result",
"is",
"not",
"returned",
"(",
"since",
"it",
"is",
"usually",
"too",
"big",
")",
"but",
"handed",
"over",
"to",
"the",
"<code",
">",
"handler<",
"/",
"cod... | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java#L335-L337 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/AnnotationUtility.java | AnnotationUtility.extractAsEnumerationValue | public static String extractAsEnumerationValue(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attribute) {
final Elements elementUtils=BindDataSourceSubProcessor.elementUtils;
final One<String> result = new One<String>();
extractAttributeValue(elementUtils, item, annotationClass.getName(), attribute, new OnAttributeFoundListener() {
@Override
public void onFound(String value) {
if (value.indexOf(".") >= 0)
result.value0 = value.substring(value.lastIndexOf(".") + 1);
}
});
return result.value0;
} | java | public static String extractAsEnumerationValue(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attribute) {
final Elements elementUtils=BindDataSourceSubProcessor.elementUtils;
final One<String> result = new One<String>();
extractAttributeValue(elementUtils, item, annotationClass.getName(), attribute, new OnAttributeFoundListener() {
@Override
public void onFound(String value) {
if (value.indexOf(".") >= 0)
result.value0 = value.substring(value.lastIndexOf(".") + 1);
}
});
return result.value0;
} | [
"public",
"static",
"String",
"extractAsEnumerationValue",
"(",
"Element",
"item",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"AnnotationAttributeType",
"attribute",
")",
"{",
"final",
"Elements",
"elementUtils",
"=",
"BindDataSource... | Estract from an annotation of a property the attribute value specified.
@param item the item
@param annotationClass annotation to analyze
@param attribute the attribute
@return attribute value as list of string | [
"Estract",
"from",
"an",
"annotation",
"of",
"a",
"property",
"the",
"attribute",
"value",
"specified",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/reflect/AnnotationUtility.java#L294-L308 |
aws/aws-sdk-java | aws-java-sdk-codedeploy/src/main/java/com/amazonaws/services/codedeploy/model/ListDeploymentTargetsRequest.java | ListDeploymentTargetsRequest.withTargetFilters | public ListDeploymentTargetsRequest withTargetFilters(java.util.Map<String, java.util.List<String>> targetFilters) {
setTargetFilters(targetFilters);
return this;
} | java | public ListDeploymentTargetsRequest withTargetFilters(java.util.Map<String, java.util.List<String>> targetFilters) {
setTargetFilters(targetFilters);
return this;
} | [
"public",
"ListDeploymentTargetsRequest",
"withTargetFilters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
">",
"targetFilters",
")",
"{",
"setTargetFilters",
"(",
"targetFilters",
")",
";",
... | <p>
A key used to filter the returned targets.
</p>
@param targetFilters
A key used to filter the returned targets.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"key",
"used",
"to",
"filter",
"the",
"returned",
"targets",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-codedeploy/src/main/java/com/amazonaws/services/codedeploy/model/ListDeploymentTargetsRequest.java#L169-L172 |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java | OracleDdlParser.parseCreateProcedureStatement | protected AstNode parseCreateProcedureStatement( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
markStartOfStatement(tokens);
/* ----------------------------------------------------------------------
CREATE [ OR REPLACE ] PROCEDURE [ schema. ] procedure_name
[ ( parameter_declaration [, parameter_declaration ] ) ]
[ AUTHID { CURRENT_USER | DEFINER ]
{ IS | AS }
{ [ declare_section ] body | call_spec | EXTERNAL} ;
call_spec = LANGUAGE { Java_declaration | C_declaration }
Java_declaration = JAVA NAME string
C_declaration =
C [ NAME name ]
LIBRARY lib_name
[ AGENT IN (argument[, argument ]...) ]
[ WITH CONTEXT ]
[ PARAMETERS (parameter[, parameter ]...) ]
parameter_declaration = parameter_name [ IN | { { OUT | { IN OUT }} [ NOCOPY ] } ] datatype [ { := | DEFAULT } expression ]
---------------------------------------------------------------------- */
boolean isReplace = tokens.canConsume(STMT_CREATE_OR_REPLACE_PROCEDURE);
tokens.canConsume(STMT_CREATE_PROCEDURE);
String name = parseName(tokens);
AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_PROCEDURE_STATEMENT);
if (isReplace) {
// TODO: SET isReplace = TRUE to node (possibly a cnd mixin of "replaceable"
}
boolean ok = parseParameters(tokens, node);
if (ok) {
if (tokens.canConsume("AUTHID")) {
if (tokens.canConsume("CURRENT_USER")) {
node.setProperty(AUTHID_VALUE, "AUTHID CURRENT_USER");
} else {
tokens.consume("DEFINER");
node.setProperty(AUTHID_VALUE, "DEFINER");
}
}
}
parseUntilFwdSlash(tokens, false);
tokens.canConsume("/");
markEndOfStatement(tokens, node);
return node;
} | java | protected AstNode parseCreateProcedureStatement( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
markStartOfStatement(tokens);
/* ----------------------------------------------------------------------
CREATE [ OR REPLACE ] PROCEDURE [ schema. ] procedure_name
[ ( parameter_declaration [, parameter_declaration ] ) ]
[ AUTHID { CURRENT_USER | DEFINER ]
{ IS | AS }
{ [ declare_section ] body | call_spec | EXTERNAL} ;
call_spec = LANGUAGE { Java_declaration | C_declaration }
Java_declaration = JAVA NAME string
C_declaration =
C [ NAME name ]
LIBRARY lib_name
[ AGENT IN (argument[, argument ]...) ]
[ WITH CONTEXT ]
[ PARAMETERS (parameter[, parameter ]...) ]
parameter_declaration = parameter_name [ IN | { { OUT | { IN OUT }} [ NOCOPY ] } ] datatype [ { := | DEFAULT } expression ]
---------------------------------------------------------------------- */
boolean isReplace = tokens.canConsume(STMT_CREATE_OR_REPLACE_PROCEDURE);
tokens.canConsume(STMT_CREATE_PROCEDURE);
String name = parseName(tokens);
AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_PROCEDURE_STATEMENT);
if (isReplace) {
// TODO: SET isReplace = TRUE to node (possibly a cnd mixin of "replaceable"
}
boolean ok = parseParameters(tokens, node);
if (ok) {
if (tokens.canConsume("AUTHID")) {
if (tokens.canConsume("CURRENT_USER")) {
node.setProperty(AUTHID_VALUE, "AUTHID CURRENT_USER");
} else {
tokens.consume("DEFINER");
node.setProperty(AUTHID_VALUE, "DEFINER");
}
}
}
parseUntilFwdSlash(tokens, false);
tokens.canConsume("/");
markEndOfStatement(tokens, node);
return node;
} | [
"protected",
"AstNode",
"parseCreateProcedureStatement",
"(",
"DdlTokenStream",
"tokens",
",",
"AstNode",
"parentNode",
")",
"throws",
"ParsingException",
"{",
"assert",
"tokens",
"!=",
"null",
";",
"assert",
"parentNode",
"!=",
"null",
";",
"markStartOfStatement",
"(... | Parses DDL CREATE PROCEDURE statement
@param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null
@param parentNode the parent {@link AstNode} node; may not be null
@return the parsed CREATE PROCEDURE statement node
@throws ParsingException | [
"Parses",
"DDL",
"CREATE",
"PROCEDURE",
"statement"
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java#L669-L728 |
finmath/finmath-lib | src/main/java/net/finmath/montecarlo/interestrate/products/SwaptionSingleCurve.java | SwaptionSingleCurve.getValue | @Override
public RandomVariable getValue(double evaluationTime, LIBORModelMonteCarloSimulationModel model) throws CalculationException {
/*
* Calculate value of the swap at exercise date on each path (beware of perfect foresight - all rates are simulationTime=exerciseDate)
*/
RandomVariable valueOfSwapAtExerciseDate = model.getRandomVariableForConstant(/*fixingDates[fixingDates.length-1],*/0.0);
// Calculate the value of the swap by working backward through all periods
for(int period=fixingDates.length-1; period>=0; period--)
{
double fixingDate = fixingDates[period];
double paymentDate = paymentDates[period];
double swaprate = swaprates[period];
double periodLength = periodLengths != null ? periodLengths[period] : paymentDate - fixingDate;
// Get random variables - note that this is the rate at simulation time = exerciseDate
RandomVariable libor = model.getLIBOR(exerciseDate, fixingDate, paymentDate);
// Add payment received at end of period
RandomVariable payoff = libor.sub(swaprate).mult(periodLength);
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.add(payoff);
// Discount back to beginning of period
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.discount(libor, paymentDate - fixingDate);
}
// If the exercise date is not the first periods start date, then discount back to the exercise date (calculate the forward starting swap)
if(fixingDates[0] != exerciseDate) {
RandomVariable libor = model.getLIBOR(exerciseDate, exerciseDate, fixingDates[0]);
double periodLength = fixingDates[0] - exerciseDate;
// Discount back to beginning of period
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.discount(libor, periodLength);
}
/*
* Calculate swaption value
*/
RandomVariable values = valueOfSwapAtExerciseDate.floor(0.0);
RandomVariable numeraire = model.getNumeraire(exerciseDate);
RandomVariable monteCarloProbabilities = model.getMonteCarloWeights(model.getTimeIndex(exerciseDate));
values = values.div(numeraire).mult(monteCarloProbabilities);
RandomVariable numeraireAtZero = model.getNumeraire(evaluationTime);
RandomVariable monteCarloProbabilitiesAtZero = model.getMonteCarloWeights(evaluationTime);
values = values.mult(numeraireAtZero).div(monteCarloProbabilitiesAtZero);
return values;
} | java | @Override
public RandomVariable getValue(double evaluationTime, LIBORModelMonteCarloSimulationModel model) throws CalculationException {
/*
* Calculate value of the swap at exercise date on each path (beware of perfect foresight - all rates are simulationTime=exerciseDate)
*/
RandomVariable valueOfSwapAtExerciseDate = model.getRandomVariableForConstant(/*fixingDates[fixingDates.length-1],*/0.0);
// Calculate the value of the swap by working backward through all periods
for(int period=fixingDates.length-1; period>=0; period--)
{
double fixingDate = fixingDates[period];
double paymentDate = paymentDates[period];
double swaprate = swaprates[period];
double periodLength = periodLengths != null ? periodLengths[period] : paymentDate - fixingDate;
// Get random variables - note that this is the rate at simulation time = exerciseDate
RandomVariable libor = model.getLIBOR(exerciseDate, fixingDate, paymentDate);
// Add payment received at end of period
RandomVariable payoff = libor.sub(swaprate).mult(periodLength);
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.add(payoff);
// Discount back to beginning of period
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.discount(libor, paymentDate - fixingDate);
}
// If the exercise date is not the first periods start date, then discount back to the exercise date (calculate the forward starting swap)
if(fixingDates[0] != exerciseDate) {
RandomVariable libor = model.getLIBOR(exerciseDate, exerciseDate, fixingDates[0]);
double periodLength = fixingDates[0] - exerciseDate;
// Discount back to beginning of period
valueOfSwapAtExerciseDate = valueOfSwapAtExerciseDate.discount(libor, periodLength);
}
/*
* Calculate swaption value
*/
RandomVariable values = valueOfSwapAtExerciseDate.floor(0.0);
RandomVariable numeraire = model.getNumeraire(exerciseDate);
RandomVariable monteCarloProbabilities = model.getMonteCarloWeights(model.getTimeIndex(exerciseDate));
values = values.div(numeraire).mult(monteCarloProbabilities);
RandomVariable numeraireAtZero = model.getNumeraire(evaluationTime);
RandomVariable monteCarloProbabilitiesAtZero = model.getMonteCarloWeights(evaluationTime);
values = values.mult(numeraireAtZero).div(monteCarloProbabilitiesAtZero);
return values;
} | [
"@",
"Override",
"public",
"RandomVariable",
"getValue",
"(",
"double",
"evaluationTime",
",",
"LIBORModelMonteCarloSimulationModel",
"model",
")",
"throws",
"CalculationException",
"{",
"/*\n\t\t * Calculate value of the swap at exercise date on each path (beware of perfect foresight ... | This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
Cashflows prior evaluationTime are not considered.
@param evaluationTime The time on which this products value should be observed.
@param model The model used to price the product.
@return The random variable representing the value of the product discounted to evaluation time
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method. | [
"This",
"method",
"returns",
"the",
"value",
"random",
"variable",
"of",
"the",
"product",
"within",
"the",
"specified",
"model",
"evaluated",
"at",
"a",
"given",
"evalutationTime",
".",
"Note",
":",
"For",
"a",
"lattice",
"this",
"is",
"often",
"the",
"valu... | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/montecarlo/interestrate/products/SwaptionSingleCurve.java#L115-L165 |
before/quality-check | modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java | Check.greaterOrEqualThan | @ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalNotGreaterOrEqualThanException.class })
public static <T extends Comparable<T>> T greaterOrEqualThan(@Nonnull final T expected, @Nonnull final T check,
@Nonnull final String message) {
Check.notNull(expected, "expected");
Check.notNull(check, "check");
if (expected.compareTo(check) > 0) {
throw new IllegalNotGreaterOrEqualThanException(message, check);
}
return check;
} | java | @ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalNotGreaterOrEqualThanException.class })
public static <T extends Comparable<T>> T greaterOrEqualThan(@Nonnull final T expected, @Nonnull final T check,
@Nonnull final String message) {
Check.notNull(expected, "expected");
Check.notNull(check, "check");
if (expected.compareTo(check) > 0) {
throw new IllegalNotGreaterOrEqualThanException(message, check);
}
return check;
} | [
"@",
"ArgumentsChecked",
"@",
"Throws",
"(",
"{",
"IllegalNullArgumentException",
".",
"class",
",",
"IllegalNotGreaterOrEqualThanException",
".",
"class",
"}",
")",
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"T",
">",
">",
"T",
"greaterOrEqualTha... | Ensures that a passed {@code Comparable} is greater or equal compared to another {@code Comparable}. The
comparison is made using {@code expected.compareTo(check) > 0}.
@param expected
Expected value
@param check
Comparable to be checked
@param message
an error message describing why the comparable must be greater than a value (will be passed to
{@code IllegalNotGreaterOrEqualThanException})
@return the passed {@code Comparable} argument {@code check}
@throws IllegalNotGreaterOrEqualThanException
if the argument value {@code check} is not greater or equal than the value {@code expected} when
using method {@code compareTo} | [
"Ensures",
"that",
"a",
"passed",
"{",
"@code",
"Comparable",
"}",
"is",
"greater",
"or",
"equal",
"compared",
"to",
"another",
"{",
"@code",
"Comparable",
"}",
".",
"The",
"comparison",
"is",
"made",
"using",
"{",
"@code",
"expected",
".",
"compareTo",
"(... | train | https://github.com/before/quality-check/blob/a75c32c39434ddb1f89bece57acae0536724c15a/modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java#L705-L717 |
jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java | AbstractJaxRsResourceProvider.searchWithPost | @POST
@Path("/_search")
public Response searchWithPost()
throws IOException {
return execute(getResourceRequest(RequestTypeEnum.POST, RestOperationTypeEnum.SEARCH_TYPE));
} | java | @POST
@Path("/_search")
public Response searchWithPost()
throws IOException {
return execute(getResourceRequest(RequestTypeEnum.POST, RestOperationTypeEnum.SEARCH_TYPE));
} | [
"@",
"POST",
"@",
"Path",
"(",
"\"/_search\"",
")",
"public",
"Response",
"searchWithPost",
"(",
")",
"throws",
"IOException",
"{",
"return",
"execute",
"(",
"getResourceRequest",
"(",
"RequestTypeEnum",
".",
"POST",
",",
"RestOperationTypeEnum",
".",
"SEARCH_TYPE... | Search the resource type based on some filter criteria
@return the response
@see <a href="https://www.hl7.org/fhir/http.html#search">https://www.hl7.org/fhir/http.html#search</a> | [
"Search",
"the",
"resource",
"type",
"based",
"on",
"some",
"filter",
"criteria"
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java#L143-L148 |
hibernate/hibernate-ogm | neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/predicate/impl/Neo4jPredicateFactory.java | Neo4jPredicateFactory.getPropertyIdentifier | private PropertyIdentifier getPropertyIdentifier(String entityType, List<String> propertyPath) {
return propertyHelper.getPropertyIdentifier( entityType, propertyPath, propertyPath.size() );
} | java | private PropertyIdentifier getPropertyIdentifier(String entityType, List<String> propertyPath) {
return propertyHelper.getPropertyIdentifier( entityType, propertyPath, propertyPath.size() );
} | [
"private",
"PropertyIdentifier",
"getPropertyIdentifier",
"(",
"String",
"entityType",
",",
"List",
"<",
"String",
">",
"propertyPath",
")",
"{",
"return",
"propertyHelper",
".",
"getPropertyIdentifier",
"(",
"entityType",
",",
"propertyPath",
",",
"propertyPath",
"."... | Returns the {@link PropertyIdentifier} corresponding to this property based on information provided by the {@link Neo4jAliasResolver}.
Note that all the path is required as in the current implementation, the WHERE clause is appended before the OPTIONAL MATCH clauses
so we need all the aliases referenced in the predicates in the MATCH clause. While it's definitely a limitation of the current implementation
it's not really easy to do differently because the OPTIONAL MATCH clauses have to be executed on the filtered nodes and relationships
and we don't have an easy way to know which predicates we should include in the MATCH clause.
@param entityType the type of the entity
@param propertyPath the path to the property without aliases
@return the corresponding {@link PropertyIdentifier} | [
"Returns",
"the",
"{",
"@link",
"PropertyIdentifier",
"}",
"corresponding",
"to",
"this",
"property",
"based",
"on",
"information",
"provided",
"by",
"the",
"{",
"@link",
"Neo4jAliasResolver",
"}",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/predicate/impl/Neo4jPredicateFactory.java#L113-L115 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java | AmazonDynamoDBClient.listTables | public ListTablesResult listTables(ListTablesRequest listTablesRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listTablesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<ListTablesRequest> request = marshall(listTablesRequest,
new ListTablesRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<ListTablesResult, JsonUnmarshallerContext> unmarshaller = new ListTablesResultJsonUnmarshaller();
JsonResponseHandler<ListTablesResult> responseHandler = new JsonResponseHandler<ListTablesResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | java | public ListTablesResult listTables(ListTablesRequest listTablesRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listTablesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<ListTablesRequest> request = marshall(listTablesRequest,
new ListTablesRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<ListTablesResult, JsonUnmarshallerContext> unmarshaller = new ListTablesResultJsonUnmarshaller();
JsonResponseHandler<ListTablesResult> responseHandler = new JsonResponseHandler<ListTablesResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | [
"public",
"ListTablesResult",
"listTables",
"(",
"ListTablesRequest",
"listTablesRequest",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
"{",
"ExecutionContext",
"executionContext",
"=",
"createExecutionContext",
"(",
"listTablesRequest",
")",
";",
"A... | <p>
Retrieves a paginated list of table names created by the AWS Account
of the caller in the AWS Region (e.g. <code>us-east-1</code> ).
</p>
@param listTablesRequest Container for the necessary parameters to
execute the ListTables service method on AmazonDynamoDB.
@return The response from the ListTables service method, as returned
by AmazonDynamoDB.
@throws InternalServerErrorException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue. | [
"<p",
">",
"Retrieves",
"a",
"paginated",
"list",
"of",
"table",
"names",
"created",
"by",
"the",
"AWS",
"Account",
"of",
"the",
"caller",
"in",
"the",
"AWS",
"Region",
"(",
"e",
".",
"g",
".",
"<code",
">",
"us",
"-",
"east",
"-",
"1<",
"/",
"code... | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java#L370-L382 |
sporniket/core | sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/JFrameUtils.java | JFrameUtils.getMaximisedFrameOuterBounds | public static Rectangle getMaximisedFrameOuterBounds()
{
Toolkit _toolkit = Toolkit.getDefaultToolkit();
GraphicsEnvironment _ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice _gd = _ge.getDefaultScreenDevice();
GraphicsConfiguration _gc = _gd.getDefaultConfiguration();
Insets _screenInsets = _toolkit.getScreenInsets(_gc);
Rectangle _rectangle = _gc.getBounds();
int _width = _rectangle.width - _screenInsets.left - _screenInsets.right;
int _height = _rectangle.height - _screenInsets.top - _screenInsets.bottom;
Rectangle _result = new Rectangle(_screenInsets.left, _screenInsets.top, _width, _height);
return _result;
} | java | public static Rectangle getMaximisedFrameOuterBounds()
{
Toolkit _toolkit = Toolkit.getDefaultToolkit();
GraphicsEnvironment _ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice _gd = _ge.getDefaultScreenDevice();
GraphicsConfiguration _gc = _gd.getDefaultConfiguration();
Insets _screenInsets = _toolkit.getScreenInsets(_gc);
Rectangle _rectangle = _gc.getBounds();
int _width = _rectangle.width - _screenInsets.left - _screenInsets.right;
int _height = _rectangle.height - _screenInsets.top - _screenInsets.bottom;
Rectangle _result = new Rectangle(_screenInsets.left, _screenInsets.top, _width, _height);
return _result;
} | [
"public",
"static",
"Rectangle",
"getMaximisedFrameOuterBounds",
"(",
")",
"{",
"Toolkit",
"_toolkit",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
";",
"GraphicsEnvironment",
"_ge",
"=",
"GraphicsEnvironment",
".",
"getLocalGraphicsEnvironment",
"(",
")",
";",... | Query {@link Toolkit#getScreenInsets(GraphicsConfiguration)} and {@link GraphicsConfiguration#getBounds()} to compute the
bounds of a maximized JFrame.
@return a rectangle describing the outer bounds of a maximised frame, for determining the screen size (this is not the
full-screen size). | [
"Query",
"{",
"@link",
"Toolkit#getScreenInsets",
"(",
"GraphicsConfiguration",
")",
"}",
"and",
"{",
"@link",
"GraphicsConfiguration#getBounds",
"()",
"}",
"to",
"compute",
"the",
"bounds",
"of",
"a",
"maximized",
"JFrame",
"."
] | train | https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/JFrameUtils.java#L56-L69 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ConnectionTypesInner.java | ConnectionTypesInner.createOrUpdateAsync | public Observable<ConnectionTypeInner> createOrUpdateAsync(String resourceGroupName, String automationAccountName, String connectionTypeName, ConnectionTypeCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionTypeName, parameters).map(new Func1<ServiceResponse<ConnectionTypeInner>, ConnectionTypeInner>() {
@Override
public ConnectionTypeInner call(ServiceResponse<ConnectionTypeInner> response) {
return response.body();
}
});
} | java | public Observable<ConnectionTypeInner> createOrUpdateAsync(String resourceGroupName, String automationAccountName, String connectionTypeName, ConnectionTypeCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionTypeName, parameters).map(new Func1<ServiceResponse<ConnectionTypeInner>, ConnectionTypeInner>() {
@Override
public ConnectionTypeInner call(ServiceResponse<ConnectionTypeInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ConnectionTypeInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"connectionTypeName",
",",
"ConnectionTypeCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
... | Create a connectiontype.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param connectionTypeName The parameters supplied to the create or update connectiontype operation.
@param parameters The parameters supplied to the create or update connectiontype operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ConnectionTypeInner object | [
"Create",
"a",
"connectiontype",
"."
] | 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/ConnectionTypesInner.java#L310-L317 |
grails/grails-core | grails-core/src/main/groovy/grails/util/GrailsClassUtils.java | GrailsClassUtils.getPropertyForGetter | public static String getPropertyForGetter(String getterName, Class returnType) {
return GrailsNameUtils.getPropertyForGetter(getterName, returnType);
} | java | public static String getPropertyForGetter(String getterName, Class returnType) {
return GrailsNameUtils.getPropertyForGetter(getterName, returnType);
} | [
"public",
"static",
"String",
"getPropertyForGetter",
"(",
"String",
"getterName",
",",
"Class",
"returnType",
")",
"{",
"return",
"GrailsNameUtils",
".",
"getPropertyForGetter",
"(",
"getterName",
",",
"returnType",
")",
";",
"}"
] | Returns a property name equivalent for the given getter name and return type or null if it is not a valid getter. If not null
or empty the getter name is assumed to be a valid identifier.
@param getterName The getter name
@param returnType The type the method returns
@return The property name equivalent | [
"Returns",
"a",
"property",
"name",
"equivalent",
"for",
"the",
"given",
"getter",
"name",
"and",
"return",
"type",
"or",
"null",
"if",
"it",
"is",
"not",
"a",
"valid",
"getter",
".",
"If",
"not",
"null",
"or",
"empty",
"the",
"getter",
"name",
"is",
"... | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L917-L919 |
apache/flink | flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java | HadoopOutputFormatBase.close | @Override
public void close() throws IOException {
// enforce sequential close() calls
synchronized (CLOSE_MUTEX) {
try {
this.recordWriter.close(this.context);
} catch (InterruptedException e) {
throw new IOException("Could not close RecordReader.", e);
}
if (this.outputCommitter.needsTaskCommit(this.context)) {
this.outputCommitter.commitTask(this.context);
}
Path outputPath = new Path(this.configuration.get("mapred.output.dir"));
// rename tmp-file to final name
FileSystem fs = FileSystem.get(outputPath.toUri(), this.configuration);
String taskNumberStr = Integer.toString(this.taskNumber);
String tmpFileTemplate = "tmp-r-00000";
String tmpFile = tmpFileTemplate.substring(0, 11 - taskNumberStr.length()) + taskNumberStr;
if (fs.exists(new Path(outputPath.toString() + "/" + tmpFile))) {
fs.rename(new Path(outputPath.toString() + "/" + tmpFile), new Path(outputPath.toString() + "/" + taskNumberStr));
}
}
} | java | @Override
public void close() throws IOException {
// enforce sequential close() calls
synchronized (CLOSE_MUTEX) {
try {
this.recordWriter.close(this.context);
} catch (InterruptedException e) {
throw new IOException("Could not close RecordReader.", e);
}
if (this.outputCommitter.needsTaskCommit(this.context)) {
this.outputCommitter.commitTask(this.context);
}
Path outputPath = new Path(this.configuration.get("mapred.output.dir"));
// rename tmp-file to final name
FileSystem fs = FileSystem.get(outputPath.toUri(), this.configuration);
String taskNumberStr = Integer.toString(this.taskNumber);
String tmpFileTemplate = "tmp-r-00000";
String tmpFile = tmpFileTemplate.substring(0, 11 - taskNumberStr.length()) + taskNumberStr;
if (fs.exists(new Path(outputPath.toString() + "/" + tmpFile))) {
fs.rename(new Path(outputPath.toString() + "/" + tmpFile), new Path(outputPath.toString() + "/" + taskNumberStr));
}
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"// enforce sequential close() calls",
"synchronized",
"(",
"CLOSE_MUTEX",
")",
"{",
"try",
"{",
"this",
".",
"recordWriter",
".",
"close",
"(",
"this",
".",
"context",
")",
";... | commit the task by moving the output file out from the temporary directory.
@throws java.io.IOException | [
"commit",
"the",
"task",
"by",
"moving",
"the",
"output",
"file",
"out",
"from",
"the",
"temporary",
"directory",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java#L160-L188 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDMath.java | SDMath.mergeAdd | public SDVariable mergeAdd(String name, SDVariable... inputs) {
validateSameType("mergeAdd", true, inputs);
SDVariable ret = f().mergeAdd(inputs);
return updateVariableNameAndReference(ret, name);
} | java | public SDVariable mergeAdd(String name, SDVariable... inputs) {
validateSameType("mergeAdd", true, inputs);
SDVariable ret = f().mergeAdd(inputs);
return updateVariableNameAndReference(ret, name);
} | [
"public",
"SDVariable",
"mergeAdd",
"(",
"String",
"name",
",",
"SDVariable",
"...",
"inputs",
")",
"{",
"validateSameType",
"(",
"\"mergeAdd\"",
",",
"true",
",",
"inputs",
")",
";",
"SDVariable",
"ret",
"=",
"f",
"(",
")",
".",
"mergeAdd",
"(",
"inputs",... | Merge add function: merges an arbitrary number of equal shaped arrays using element-wise addition:
out = sum_i in[i]
@param name Name of the output variable
@param inputs Input variables
@return Output variable | [
"Merge",
"add",
"function",
":",
"merges",
"an",
"arbitrary",
"number",
"of",
"equal",
"shaped",
"arrays",
"using",
"element",
"-",
"wise",
"addition",
":",
"out",
"=",
"sum_i",
"in",
"[",
"i",
"]"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDMath.java#L1727-L1731 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getRight | public Tile getRight() {
int x = tileX + 1;
if (x > getMaxTileNumber(this.zoomLevel)) {
x = 0;
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | java | public Tile getRight() {
int x = tileX + 1;
if (x > getMaxTileNumber(this.zoomLevel)) {
x = 0;
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getRight",
"(",
")",
"{",
"int",
"x",
"=",
"tileX",
"+",
"1",
";",
"if",
"(",
"x",
">",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
")",
"{",
"x",
"=",
"0",
";",
"}",
"return",
"new",
"Tile",
"(",
"x",
",",
"this"... | Returns the tile to the right of this tile.
@return tile to the right | [
"Returns",
"the",
"tile",
"to",
"the",
"right",
"of",
"this",
"tile",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L254-L260 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/util/IntHashTable.java | IntHashTable.lookup | public int lookup(Object key, int hash) {
Object node;
int hash1 = hash ^ (hash >>> 15);
int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness
int deleted = -1;
for (int i = hash1 & mask;; i = (i + hash2) & mask) {
node = objs[i];
if (node == key)
return i;
if (node == null)
return deleted >= 0 ? deleted : i;
if (node == DELETED && deleted < 0)
deleted = i;
}
} | java | public int lookup(Object key, int hash) {
Object node;
int hash1 = hash ^ (hash >>> 15);
int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness
int deleted = -1;
for (int i = hash1 & mask;; i = (i + hash2) & mask) {
node = objs[i];
if (node == key)
return i;
if (node == null)
return deleted >= 0 ? deleted : i;
if (node == DELETED && deleted < 0)
deleted = i;
}
} | [
"public",
"int",
"lookup",
"(",
"Object",
"key",
",",
"int",
"hash",
")",
"{",
"Object",
"node",
";",
"int",
"hash1",
"=",
"hash",
"^",
"(",
"hash",
">>>",
"15",
")",
";",
"int",
"hash2",
"=",
"(",
"hash",
"^",
"(",
"hash",
"<<",
"6",
")",
")",... | Find either the index of a key's value, or the index of an available space.
@param key The key to whose value you want to find.
@param hash The hash code of this key.
@return Either the index of the key's value, or an index pointing to
unoccupied space. | [
"Find",
"either",
"the",
"index",
"of",
"a",
"key",
"s",
"value",
"or",
"the",
"index",
"of",
"an",
"available",
"space",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/util/IntHashTable.java#L89-L103 |
js-lib-com/commons | src/main/java/js/util/Classes.java | Classes.invokeSetter | public static void invokeSetter(Object object, String name, String value) throws NoSuchMethodException, Exception
{
String setterName = Strings.getMethodAccessor("set", name);
Class<?> clazz = object.getClass();
Method method = findMethod(clazz, setterName);
Class<?>[] parameterTypes = method.getParameterTypes();
if(parameterTypes.length != 1) {
throw new NoSuchMethodException(String.format("%s#%s", clazz.getName(), setterName));
}
invoke(object, method, ConverterRegistry.getConverter().asObject((String)value, parameterTypes[0]));
} | java | public static void invokeSetter(Object object, String name, String value) throws NoSuchMethodException, Exception
{
String setterName = Strings.getMethodAccessor("set", name);
Class<?> clazz = object.getClass();
Method method = findMethod(clazz, setterName);
Class<?>[] parameterTypes = method.getParameterTypes();
if(parameterTypes.length != 1) {
throw new NoSuchMethodException(String.format("%s#%s", clazz.getName(), setterName));
}
invoke(object, method, ConverterRegistry.getConverter().asObject((String)value, parameterTypes[0]));
} | [
"public",
"static",
"void",
"invokeSetter",
"(",
"Object",
"object",
",",
"String",
"name",
",",
"String",
"value",
")",
"throws",
"NoSuchMethodException",
",",
"Exception",
"{",
"String",
"setterName",
"=",
"Strings",
".",
"getMethodAccessor",
"(",
"\"set\"",
"... | Invoke setter method on given object instance. Setter name has format as accepted by
{@link Strings#getMethodAccessor(String, String)} and value string is converted to method parameter type using
{@link Converter} facility. For this reason set parameter type should have a converter registered.
<p>
This method has no means to determine method using {@link Class#getMethod(String, Class...)} because parameter
value is always string and setter parameter type is unknown. For this reason this method uses
{@link #findMethod(Class, String)}. Note that find method searches for named method on object super hierarchy too.
@param object object instance,
@param name setter name, method name only without <code>set</code> prefix, dashed case accepted,
@param value value to set, string value that is converted to setter method parameter type.
@throws NoSuchMethodException if setter not found.
@throws Exception if invocation fail for whatever reason including method logic. | [
"Invoke",
"setter",
"method",
"on",
"given",
"object",
"instance",
".",
"Setter",
"name",
"has",
"format",
"as",
"accepted",
"by",
"{",
"@link",
"Strings#getMethodAccessor",
"(",
"String",
"String",
")",
"}",
"and",
"value",
"string",
"is",
"converted",
"to",
... | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Classes.java#L425-L437 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java | JsonArray.set | public JsonArray set(int index, JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.set(index, value);
return this;
} | java | public JsonArray set(int index, JsonValue value) {
if (value == null) {
throw new NullPointerException("value is null");
}
values.set(index, value);
return this;
} | [
"public",
"JsonArray",
"set",
"(",
"int",
"index",
",",
"JsonValue",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"value is null\"",
")",
";",
"}",
"values",
".",
"set",
"(",
"index",
",",
... | Replaces the element at the specified position in this array with the specified JSON value.
@param index
the index of the array element to replace
@param value
the value to be stored at the specified array position, must not be <code>null</code>
@return the array itself, to enable method chaining
@throws IndexOutOfBoundsException
if the index is out of range, i.e. <code>index < 0</code> or
<code>index >= size</code> | [
"Replaces",
"the",
"element",
"at",
"the",
"specified",
"position",
"in",
"this",
"array",
"with",
"the",
"specified",
"JSON",
"value",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/json/JsonArray.java#L366-L372 |
kiswanij/jk-util | src/main/java/com/jk/util/JKNumbersUtil.java | JKNumbersUtil.subAmounts | public static double subAmounts(final double n1, final double n2) {
final BigDecimal b1 = new BigDecimal(n1);
final BigDecimal b2 = new BigDecimal(n2);
BigDecimal b3 = b1.subtract(b2);
b3 = b3.setScale(3, BigDecimal.ROUND_HALF_UP);
final double result = b3.doubleValue();
return result;
} | java | public static double subAmounts(final double n1, final double n2) {
final BigDecimal b1 = new BigDecimal(n1);
final BigDecimal b2 = new BigDecimal(n2);
BigDecimal b3 = b1.subtract(b2);
b3 = b3.setScale(3, BigDecimal.ROUND_HALF_UP);
final double result = b3.doubleValue();
return result;
} | [
"public",
"static",
"double",
"subAmounts",
"(",
"final",
"double",
"n1",
",",
"final",
"double",
"n2",
")",
"{",
"final",
"BigDecimal",
"b1",
"=",
"new",
"BigDecimal",
"(",
"n1",
")",
";",
"final",
"BigDecimal",
"b2",
"=",
"new",
"BigDecimal",
"(",
"n2"... | Sub amounts.
@param n1 the n 1
@param n2 the n 2
@return the double | [
"Sub",
"amounts",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKNumbersUtil.java#L105-L112 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java | ConnectionPoolDescriptor.addAttribute | public void addAttribute(String attributeName, String attributeValue)
{
if (attributeName != null && attributeName.startsWith(JDBC_PROPERTY_NAME_PREFIX))
{
final String jdbcPropertyName = attributeName.substring(JDBC_PROPERTY_NAME_LENGTH);
jdbcProperties.setProperty(jdbcPropertyName, attributeValue);
}
else if (attributeName != null && attributeName.startsWith(DBCP_PROPERTY_NAME_PREFIX))
{
final String dbcpPropertyName = attributeName.substring(DBCP_PROPERTY_NAME_LENGTH);
dbcpProperties.setProperty(dbcpPropertyName, attributeValue);
}
else
{
super.addAttribute(attributeName, attributeValue);
}
} | java | public void addAttribute(String attributeName, String attributeValue)
{
if (attributeName != null && attributeName.startsWith(JDBC_PROPERTY_NAME_PREFIX))
{
final String jdbcPropertyName = attributeName.substring(JDBC_PROPERTY_NAME_LENGTH);
jdbcProperties.setProperty(jdbcPropertyName, attributeValue);
}
else if (attributeName != null && attributeName.startsWith(DBCP_PROPERTY_NAME_PREFIX))
{
final String dbcpPropertyName = attributeName.substring(DBCP_PROPERTY_NAME_LENGTH);
dbcpProperties.setProperty(dbcpPropertyName, attributeValue);
}
else
{
super.addAttribute(attributeName, attributeValue);
}
} | [
"public",
"void",
"addAttribute",
"(",
"String",
"attributeName",
",",
"String",
"attributeValue",
")",
"{",
"if",
"(",
"attributeName",
"!=",
"null",
"&&",
"attributeName",
".",
"startsWith",
"(",
"JDBC_PROPERTY_NAME_PREFIX",
")",
")",
"{",
"final",
"String",
"... | Sets a custom configuration attribute.
@param attributeName the attribute name. Names starting with
{@link #JDBC_PROPERTY_NAME_PREFIX} will be used (without the prefix) by the
ConnectionFactory when creating connections from DriverManager
(not used for external DataSource connections). Names starting with
{@link #DBCP_PROPERTY_NAME_PREFIX} to Commons DBCP (if used, also without prefix).
@param attributeValue the attribute value | [
"Sets",
"a",
"custom",
"configuration",
"attribute",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java#L143-L159 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/LabeledFormComponentPanel.java | LabeledFormComponentPanel.newLabel | protected Component newLabel(final String id, final String forId, final IModel<String> model)
{
return ComponentFactory.newLabel(id, forId, model);
} | java | protected Component newLabel(final String id, final String forId, final IModel<String> model)
{
return ComponentFactory.newLabel(id, forId, model);
} | [
"protected",
"Component",
"newLabel",
"(",
"final",
"String",
"id",
",",
"final",
"String",
"forId",
",",
"final",
"IModel",
"<",
"String",
">",
"model",
")",
"{",
"return",
"ComponentFactory",
".",
"newLabel",
"(",
"id",
",",
"forId",
",",
"model",
")",
... | Factory method for creating the new {@link Label}. This method is invoked in the constructor
from the derived classes and can be overridden so users can provide their own version of a
new {@link Label}.
@param id
the id
@param forId
the for id
@param model
the model
@return the new {@link Label} | [
"Factory",
"method",
"for",
"creating",
"the",
"new",
"{",
"@link",
"Label",
"}",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"t... | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/LabeledFormComponentPanel.java#L136-L139 |
tminglei/form-binder-java | src/main/java/com/github/tminglei/bind/Mappings.java | Mappings.text | public static Mapping<String> text(Constraint... constraints) {
return new FieldMapping(
InputMode.SINGLE,
mkSimpleConverter(Function.identity()),
new MappingMeta(MAPPING_STRING, String.class)
).constraint(constraints);
} | java | public static Mapping<String> text(Constraint... constraints) {
return new FieldMapping(
InputMode.SINGLE,
mkSimpleConverter(Function.identity()),
new MappingMeta(MAPPING_STRING, String.class)
).constraint(constraints);
} | [
"public",
"static",
"Mapping",
"<",
"String",
">",
"text",
"(",
"Constraint",
"...",
"constraints",
")",
"{",
"return",
"new",
"FieldMapping",
"(",
"InputMode",
".",
"SINGLE",
",",
"mkSimpleConverter",
"(",
"Function",
".",
"identity",
"(",
")",
")",
",",
... | (convert to String) mapping
@param constraints constraints
@return new created mapping | [
"(",
"convert",
"to",
"String",
")",
"mapping"
] | train | https://github.com/tminglei/form-binder-java/blob/4c0bd1e8f81ae56b21142bb525ee6b4deb7f92ab/src/main/java/com/github/tminglei/bind/Mappings.java#L34-L40 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/SIBMBeanResultFactory.java | SIBMBeanResultFactory.createSIBQueuedMessage | public static QueuedMessage createSIBQueuedMessage(SIMPQueuedMessageControllable qmc) {
String id = null;
int jsApproximateLength = 0;
String name = null;
String state = null;
String transactionId = null;
String type = null;
String busSystemMessageId = null;
id = qmc.getId();
name = qmc.getName();
state = null;
transactionId = null;
try {
if (qmc.getState() != null) {
state = qmc.getState().toString();
}
transactionId = qmc.getTransactionId();
} catch (SIMPException e) {
// No FFDC code needed
}
try {
JsMessage jsMessage = qmc.getJsMessage();
jsApproximateLength = jsMessage.getApproximateLength();
busSystemMessageId = jsMessage.getSystemMessageId();
type = jsMessage.getJsMessageType().toString();
} catch (SIMPControllableNotFoundException e) {
// No FFDC code needed
} catch (SIMPException e) {
// No FFDC code needed
}
return new QueuedMessage(id, name, jsApproximateLength, state, transactionId, type, busSystemMessageId);
} | java | public static QueuedMessage createSIBQueuedMessage(SIMPQueuedMessageControllable qmc) {
String id = null;
int jsApproximateLength = 0;
String name = null;
String state = null;
String transactionId = null;
String type = null;
String busSystemMessageId = null;
id = qmc.getId();
name = qmc.getName();
state = null;
transactionId = null;
try {
if (qmc.getState() != null) {
state = qmc.getState().toString();
}
transactionId = qmc.getTransactionId();
} catch (SIMPException e) {
// No FFDC code needed
}
try {
JsMessage jsMessage = qmc.getJsMessage();
jsApproximateLength = jsMessage.getApproximateLength();
busSystemMessageId = jsMessage.getSystemMessageId();
type = jsMessage.getJsMessageType().toString();
} catch (SIMPControllableNotFoundException e) {
// No FFDC code needed
} catch (SIMPException e) {
// No FFDC code needed
}
return new QueuedMessage(id, name, jsApproximateLength, state, transactionId, type, busSystemMessageId);
} | [
"public",
"static",
"QueuedMessage",
"createSIBQueuedMessage",
"(",
"SIMPQueuedMessageControllable",
"qmc",
")",
"{",
"String",
"id",
"=",
"null",
";",
"int",
"jsApproximateLength",
"=",
"0",
";",
"String",
"name",
"=",
"null",
";",
"String",
"state",
"=",
"null... | Create a SIBQueuedMessageImpl instance from the supplied
SIMPQueuedMessageControllable.
@param qmc
@return | [
"Create",
"a",
"SIBQueuedMessageImpl",
"instance",
"from",
"the",
"supplied",
"SIMPQueuedMessageControllable",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/SIBMBeanResultFactory.java#L43-L79 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3d.java | Capsule3d.setProperties | public void setProperties(Point3d a, Point3d b, DoubleProperty radius1) {
this.medial1.setProperties(a.xProperty, a.yProperty, a.zProperty);
this.medial2.setProperties(b.xProperty, b.yProperty, b.zProperty);
this.radiusProperty = radius1;
ensureAIsLowerPoint();
} | java | public void setProperties(Point3d a, Point3d b, DoubleProperty radius1) {
this.medial1.setProperties(a.xProperty, a.yProperty, a.zProperty);
this.medial2.setProperties(b.xProperty, b.yProperty, b.zProperty);
this.radiusProperty = radius1;
ensureAIsLowerPoint();
} | [
"public",
"void",
"setProperties",
"(",
"Point3d",
"a",
",",
"Point3d",
"b",
",",
"DoubleProperty",
"radius1",
")",
"{",
"this",
".",
"medial1",
".",
"setProperties",
"(",
"a",
".",
"xProperty",
",",
"a",
".",
"yProperty",
",",
"a",
".",
"zProperty",
")"... | Set the capsule.
@param a the first point of the capsule's segment.
@param b the second point of the capsule's segment.
@param radius1 the radius of the capsule. | [
"Set",
"the",
"capsule",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3d.java#L337-L342 |
integration-technology/amazon-mws-orders | src/main/java/com/amazonservices/mws/client/MwsConnection.java | MwsConnection.newCall | public MwsCall newCall(String servicePath, String operationName) {
if (!frozen) {
freeze();
}
ServiceEndpoint sep = getServiceEndpoint(servicePath);
// in future use sep+config to determine MwsCall implementation.
return new MwsAQCall(this, sep, operationName);
} | java | public MwsCall newCall(String servicePath, String operationName) {
if (!frozen) {
freeze();
}
ServiceEndpoint sep = getServiceEndpoint(servicePath);
// in future use sep+config to determine MwsCall implementation.
return new MwsAQCall(this, sep, operationName);
} | [
"public",
"MwsCall",
"newCall",
"(",
"String",
"servicePath",
",",
"String",
"operationName",
")",
"{",
"if",
"(",
"!",
"frozen",
")",
"{",
"freeze",
"(",
")",
";",
"}",
"ServiceEndpoint",
"sep",
"=",
"getServiceEndpoint",
"(",
"servicePath",
")",
";",
"//... | Create a new request.
<p>
After first call to this method connection parameters can no longer be
updated.
@param servicePath
@param operationName
@return A new request. | [
"Create",
"a",
"new",
"request",
".",
"<p",
">",
"After",
"first",
"call",
"to",
"this",
"method",
"connection",
"parameters",
"can",
"no",
"longer",
"be",
"updated",
"."
] | train | https://github.com/integration-technology/amazon-mws-orders/blob/042e8cd5b10588a30150222bf9c91faf4f130b3c/src/main/java/com/amazonservices/mws/client/MwsConnection.java#L683-L690 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyUtil.java | PropertyUtil.findMethod | private static Method findMethod(String methodName, Object instance, Class<?> valueClass, boolean setter)
throws NoSuchMethodException {
if (methodName == null) {
return null;
}
int paramCount = setter ? 1 : 0;
for (Method method : instance.getClass().getMethods()) {
if (method.getName().equals(methodName) && method.getParameterTypes().length == paramCount) {
Class<?> targetClass = setter ? method.getParameterTypes()[0] : method.getReturnType();
if (valueClass == null || TypeUtils.isAssignable(targetClass, valueClass)) {
return method;
}
}
}
throw new NoSuchMethodException("Compatible method not found: " + methodName);
} | java | private static Method findMethod(String methodName, Object instance, Class<?> valueClass, boolean setter)
throws NoSuchMethodException {
if (methodName == null) {
return null;
}
int paramCount = setter ? 1 : 0;
for (Method method : instance.getClass().getMethods()) {
if (method.getName().equals(methodName) && method.getParameterTypes().length == paramCount) {
Class<?> targetClass = setter ? method.getParameterTypes()[0] : method.getReturnType();
if (valueClass == null || TypeUtils.isAssignable(targetClass, valueClass)) {
return method;
}
}
}
throw new NoSuchMethodException("Compatible method not found: " + methodName);
} | [
"private",
"static",
"Method",
"findMethod",
"(",
"String",
"methodName",
",",
"Object",
"instance",
",",
"Class",
"<",
"?",
">",
"valueClass",
",",
"boolean",
"setter",
")",
"throws",
"NoSuchMethodException",
"{",
"if",
"(",
"methodName",
"==",
"null",
")",
... | Returns the requested method from an object instance.
@param methodName Name of the setter method.
@param instance Object instance to search.
@param valueClass The desired property return type (null if don't care).
@param setter If true, search for setter method signature. If false, getter method signature.
@return The requested method.
@throws NoSuchMethodException If method was not found. | [
"Returns",
"the",
"requested",
"method",
"from",
"an",
"object",
"instance",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyUtil.java#L73-L93 |
undertow-io/undertow | core/src/main/java/io/undertow/server/HttpServerExchange.java | HttpServerExchange.isRequestComplete | public boolean isRequestComplete() {
PooledByteBuffer[] data = getAttachment(BUFFERED_REQUEST_DATA);
if(data != null) {
return false;
}
return allAreSet(state, FLAG_REQUEST_TERMINATED);
} | java | public boolean isRequestComplete() {
PooledByteBuffer[] data = getAttachment(BUFFERED_REQUEST_DATA);
if(data != null) {
return false;
}
return allAreSet(state, FLAG_REQUEST_TERMINATED);
} | [
"public",
"boolean",
"isRequestComplete",
"(",
")",
"{",
"PooledByteBuffer",
"[",
"]",
"data",
"=",
"getAttachment",
"(",
"BUFFERED_REQUEST_DATA",
")",
";",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"allAreSet",
"(",
... | Returns true if all data has been read from the request, or if there
was not data.
@return true if the request is complete | [
"Returns",
"true",
"if",
"all",
"data",
"has",
"been",
"read",
"from",
"the",
"request",
"or",
"if",
"there",
"was",
"not",
"data",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/HttpServerExchange.java#L1237-L1243 |
igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java | OutgoingFileTransfer.sendStream | public synchronized void sendStream(final InputStream in, final String fileName, final long fileSize, final String description) {
checkTransferThread();
setFileInfo(fileName, fileSize);
transferThread = new Thread(new Runnable() {
@Override
public void run() {
// Create packet filter.
try {
outputStream = negotiateStream(fileName, fileSize, description);
} catch (XMPPErrorException e) {
handleXMPPException(e);
return;
}
catch (Exception e) {
setException(e);
}
if (outputStream == null) {
return;
}
if (!updateStatus(Status.negotiated, Status.in_progress)) {
return;
}
try {
writeToStream(in, outputStream);
} catch (IOException e) {
setStatus(FileTransfer.Status.error);
setException(e);
} finally {
CloseableUtil.maybeClose(in, LOGGER);
CloseableUtil.maybeClose(outputStream, LOGGER);
}
updateStatus(Status.in_progress, FileTransfer.Status.complete);
}
}, "File Transfer " + streamID);
transferThread.start();
} | java | public synchronized void sendStream(final InputStream in, final String fileName, final long fileSize, final String description) {
checkTransferThread();
setFileInfo(fileName, fileSize);
transferThread = new Thread(new Runnable() {
@Override
public void run() {
// Create packet filter.
try {
outputStream = negotiateStream(fileName, fileSize, description);
} catch (XMPPErrorException e) {
handleXMPPException(e);
return;
}
catch (Exception e) {
setException(e);
}
if (outputStream == null) {
return;
}
if (!updateStatus(Status.negotiated, Status.in_progress)) {
return;
}
try {
writeToStream(in, outputStream);
} catch (IOException e) {
setStatus(FileTransfer.Status.error);
setException(e);
} finally {
CloseableUtil.maybeClose(in, LOGGER);
CloseableUtil.maybeClose(outputStream, LOGGER);
}
updateStatus(Status.in_progress, FileTransfer.Status.complete);
}
}, "File Transfer " + streamID);
transferThread.start();
} | [
"public",
"synchronized",
"void",
"sendStream",
"(",
"final",
"InputStream",
"in",
",",
"final",
"String",
"fileName",
",",
"final",
"long",
"fileSize",
",",
"final",
"String",
"description",
")",
"{",
"checkTransferThread",
"(",
")",
";",
"setFileInfo",
"(",
... | This method handles the stream negotiation process and transmits the file
to the remote user. It returns immediately and the progress of the file
transfer can be monitored through several methods:
<UL>
<LI>{@link FileTransfer#getStatus()}
<LI>{@link FileTransfer#getProgress()}
<LI>{@link FileTransfer#isDone()}
</UL>
@param in the stream to transfer to the remote entity.
@param fileName the name of the file that is transferred
@param fileSize the size of the file that is transferred
@param description a description for the file to transfer. | [
"This",
"method",
"handles",
"the",
"stream",
"negotiation",
"process",
"and",
"transmits",
"the",
"file",
"to",
"the",
"remote",
"user",
".",
"It",
"returns",
"immediately",
"and",
"the",
"progress",
"of",
"the",
"file",
"transfer",
"can",
"be",
"monitored",
... | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java#L287-L325 |
elki-project/elki | elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/Itemset.java | Itemset.compareLexicographical | protected static int compareLexicographical(Itemset a, Itemset o) {
int i1 = a.iter(), i2 = o.iter();
while(a.iterValid(i1) && o.iterValid(i2)) {
int v1 = a.iterDim(i1), v2 = o.iterDim(i2);
if(v1 < v2) {
return -1;
}
if(v2 < v1) {
return +1;
}
i1 = a.iterAdvance(i1);
i2 = o.iterAdvance(i2);
}
return a.iterValid(i1) ? 1 : o.iterValid(i2) ? -1 : 0;
} | java | protected static int compareLexicographical(Itemset a, Itemset o) {
int i1 = a.iter(), i2 = o.iter();
while(a.iterValid(i1) && o.iterValid(i2)) {
int v1 = a.iterDim(i1), v2 = o.iterDim(i2);
if(v1 < v2) {
return -1;
}
if(v2 < v1) {
return +1;
}
i1 = a.iterAdvance(i1);
i2 = o.iterAdvance(i2);
}
return a.iterValid(i1) ? 1 : o.iterValid(i2) ? -1 : 0;
} | [
"protected",
"static",
"int",
"compareLexicographical",
"(",
"Itemset",
"a",
",",
"Itemset",
"o",
")",
"{",
"int",
"i1",
"=",
"a",
".",
"iter",
"(",
")",
",",
"i2",
"=",
"o",
".",
"iter",
"(",
")",
";",
"while",
"(",
"a",
".",
"iterValid",
"(",
"... | Robust compare using the iterators, lexicographical only!
Note: This does NOT take length into account.
@param o Other itemset.
@return Comparison result. | [
"Robust",
"compare",
"using",
"the",
"iterators",
"lexicographical",
"only!"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/Itemset.java#L195-L209 |
allengeorge/libraft | libraft-agent/src/main/java/io/libraft/agent/RaftAgent.java | RaftAgent.fromConfigurationObject | public static RaftAgent fromConfigurationObject(RaftConfiguration configuration, RaftListener raftListener) {
RaftConfigurationLoader.validate(configuration);
return new RaftAgent(configuration, raftListener);
} | java | public static RaftAgent fromConfigurationObject(RaftConfiguration configuration, RaftListener raftListener) {
RaftConfigurationLoader.validate(configuration);
return new RaftAgent(configuration, raftListener);
} | [
"public",
"static",
"RaftAgent",
"fromConfigurationObject",
"(",
"RaftConfiguration",
"configuration",
",",
"RaftListener",
"raftListener",
")",
"{",
"RaftConfigurationLoader",
".",
"validate",
"(",
"configuration",
")",
";",
"return",
"new",
"RaftAgent",
"(",
"configur... | Create an instance of {@code RaftAgent} from a {@code RaftConfiguration} object.
This method can be used when the {@code RaftAgent} configuration is part of a larger configuration.
@param configuration instance of {@code RaftConfiguration} with the configuration to be used.
This object will be validated
@param raftListener instance of {@code RaftListener} that will be notified of events from the Raft cluster
@return valid {@code RaftAgent} that can be used to connect to, and (if leader),
replicate {@link Command} instances to the Raft cluster | [
"Create",
"an",
"instance",
"of",
"{",
"@code",
"RaftAgent",
"}",
"from",
"a",
"{",
"@code",
"RaftConfiguration",
"}",
"object",
".",
"This",
"method",
"can",
"be",
"used",
"when",
"the",
"{",
"@code",
"RaftAgent",
"}",
"configuration",
"is",
"part",
"of",... | train | https://github.com/allengeorge/libraft/blob/00d68bb5e68d4020af59df3c8a9a14380108ac89/libraft-agent/src/main/java/io/libraft/agent/RaftAgent.java#L156-L159 |
legsem/legstar-core2 | legstar-jaxb-generator/src/main/java/com/legstar/jaxb/generator/EachHelper.java | EachHelper.iterableContext | private CharSequence iterableContext(final Iterable<Object> context, final Options options)
throws IOException {
StringBuilder buffer = new StringBuilder();
if (options.isFalsy(context)) {
buffer.append(options.inverse());
} else {
Iterator<Object> iterator = context.iterator();
int index = -1;
Context parent = options.context;
while (iterator.hasNext()) {
index += 1;
Object element = iterator.next();
boolean first = index == 0;
boolean even = index % 2 == 0;
boolean last = !iterator.hasNext();
Context current = Context.newBuilder(parent, element)
.combine("@index", index)
.combine("@first", first ? "first" : "")
.combine("@last", last ? "last" : "")
.combine("@odd", even ? "" : "odd")
.combine("@even", even ? "even" : "")
.build();
buffer.append(options.fn(current));
current.destroy();
}
}
return buffer.toString();
} | java | private CharSequence iterableContext(final Iterable<Object> context, final Options options)
throws IOException {
StringBuilder buffer = new StringBuilder();
if (options.isFalsy(context)) {
buffer.append(options.inverse());
} else {
Iterator<Object> iterator = context.iterator();
int index = -1;
Context parent = options.context;
while (iterator.hasNext()) {
index += 1;
Object element = iterator.next();
boolean first = index == 0;
boolean even = index % 2 == 0;
boolean last = !iterator.hasNext();
Context current = Context.newBuilder(parent, element)
.combine("@index", index)
.combine("@first", first ? "first" : "")
.combine("@last", last ? "last" : "")
.combine("@odd", even ? "" : "odd")
.combine("@even", even ? "even" : "")
.build();
buffer.append(options.fn(current));
current.destroy();
}
}
return buffer.toString();
} | [
"private",
"CharSequence",
"iterableContext",
"(",
"final",
"Iterable",
"<",
"Object",
">",
"context",
",",
"final",
"Options",
"options",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"opt... | Iterate over an iterable object.
@param context The context object.
@param options The helper options.
@return The string output.
@throws IOException If something goes wrong. | [
"Iterate",
"over",
"an",
"iterable",
"object",
"."
] | train | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-jaxb-generator/src/main/java/com/legstar/jaxb/generator/EachHelper.java#L80-L107 |
js-lib-com/dom | src/main/java/js/dom/w3c/DocumentImpl.java | DocumentImpl.evaluateXPathNodeListNS | EList evaluateXPathNodeListNS(Node contextNode, NamespaceContext namespaceContext, String expression, Object... args) {
if (args.length > 0) {
expression = Strings.format(expression, args);
}
NodeList nodeList = null;
try {
XPath xpath = XPathFactory.newInstance().newXPath();
if (namespaceContext != null) {
xpath.setNamespaceContext(namespaceContext);
}
Object result = xpath.evaluate(expression, contextNode, XPathConstants.NODESET);
if (result != null) {
nodeList = (NodeList) result;
}
} catch (XPathExpressionException e) {
throw new DomException(e);
}
if (nodeList == null) {
nodeList = EMPTY_NODE_LIST;
}
return createEList(nodeList);
} | java | EList evaluateXPathNodeListNS(Node contextNode, NamespaceContext namespaceContext, String expression, Object... args) {
if (args.length > 0) {
expression = Strings.format(expression, args);
}
NodeList nodeList = null;
try {
XPath xpath = XPathFactory.newInstance().newXPath();
if (namespaceContext != null) {
xpath.setNamespaceContext(namespaceContext);
}
Object result = xpath.evaluate(expression, contextNode, XPathConstants.NODESET);
if (result != null) {
nodeList = (NodeList) result;
}
} catch (XPathExpressionException e) {
throw new DomException(e);
}
if (nodeList == null) {
nodeList = EMPTY_NODE_LIST;
}
return createEList(nodeList);
} | [
"EList",
"evaluateXPathNodeListNS",
"(",
"Node",
"contextNode",
",",
"NamespaceContext",
"namespaceContext",
",",
"String",
"expression",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
">",
"0",
")",
"{",
"expression",
"=",
"Strings"... | Name space aware variant of {@link #evaluateXPathNodeList(Node, String, Object...)}.
@param contextNode evaluation context node,
@param namespaceContext name space context maps prefixes to name space URIs,
@param expression XPath expression with optional formatting tags,
@param args optional formatting arguments.
@return list of result elements, possible empty. | [
"Name",
"space",
"aware",
"variant",
"of",
"{",
"@link",
"#evaluateXPathNodeList",
"(",
"Node",
"String",
"Object",
"...",
")",
"}",
"."
] | train | https://github.com/js-lib-com/dom/blob/8c7cd7c802977f210674dec7c2a8f61e8de05b63/src/main/java/js/dom/w3c/DocumentImpl.java#L350-L373 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java | ApiOvhDbaaslogs.serviceName_input_inputId_configuration_flowgger_GET | public OvhFlowggerConfiguration serviceName_input_inputId_configuration_flowgger_GET(String serviceName, String inputId) throws IOException {
String qPath = "/dbaas/logs/{serviceName}/input/{inputId}/configuration/flowgger";
StringBuilder sb = path(qPath, serviceName, inputId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFlowggerConfiguration.class);
} | java | public OvhFlowggerConfiguration serviceName_input_inputId_configuration_flowgger_GET(String serviceName, String inputId) throws IOException {
String qPath = "/dbaas/logs/{serviceName}/input/{inputId}/configuration/flowgger";
StringBuilder sb = path(qPath, serviceName, inputId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFlowggerConfiguration.class);
} | [
"public",
"OvhFlowggerConfiguration",
"serviceName_input_inputId_configuration_flowgger_GET",
"(",
"String",
"serviceName",
",",
"String",
"inputId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dbaas/logs/{serviceName}/input/{inputId}/configuration/flowgger\"",
"... | Returns the flowgger configuration
REST: GET /dbaas/logs/{serviceName}/input/{inputId}/configuration/flowgger
@param serviceName [required] Service name
@param inputId [required] Input ID | [
"Returns",
"the",
"flowgger",
"configuration"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java#L293-L298 |
apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/DateWatermark.java | DateWatermark.getInterval | private static int getInterval(long diffInMilliSecs, long hourInterval, int maxIntervals) {
long dayInterval = TimeUnit.HOURS.toDays(hourInterval);
int totalHours = DoubleMath.roundToInt((double) diffInMilliSecs / (60 * 60 * 1000), RoundingMode.CEILING);
int totalIntervals = DoubleMath.roundToInt((double) totalHours / (dayInterval * 24), RoundingMode.CEILING);
if (totalIntervals > maxIntervals) {
hourInterval = DoubleMath.roundToInt((double) totalHours / maxIntervals, RoundingMode.CEILING);
dayInterval = DoubleMath.roundToInt((double) hourInterval / 24, RoundingMode.CEILING);
}
return Ints.checkedCast(dayInterval);
} | java | private static int getInterval(long diffInMilliSecs, long hourInterval, int maxIntervals) {
long dayInterval = TimeUnit.HOURS.toDays(hourInterval);
int totalHours = DoubleMath.roundToInt((double) diffInMilliSecs / (60 * 60 * 1000), RoundingMode.CEILING);
int totalIntervals = DoubleMath.roundToInt((double) totalHours / (dayInterval * 24), RoundingMode.CEILING);
if (totalIntervals > maxIntervals) {
hourInterval = DoubleMath.roundToInt((double) totalHours / maxIntervals, RoundingMode.CEILING);
dayInterval = DoubleMath.roundToInt((double) hourInterval / 24, RoundingMode.CEILING);
}
return Ints.checkedCast(dayInterval);
} | [
"private",
"static",
"int",
"getInterval",
"(",
"long",
"diffInMilliSecs",
",",
"long",
"hourInterval",
",",
"int",
"maxIntervals",
")",
"{",
"long",
"dayInterval",
"=",
"TimeUnit",
".",
"HOURS",
".",
"toDays",
"(",
"hourInterval",
")",
";",
"int",
"totalHours... | recalculate interval(in hours) if total number of partitions greater than maximum number of allowed partitions
@param diffInMilliSecs difference in range
@param hourInterval hour interval (ex: 24 hours)
@param maxIntervals max number of allowed partitions
@return calculated interval in days | [
"recalculate",
"interval",
"(",
"in",
"hours",
")",
"if",
"total",
"number",
"of",
"partitions",
"greater",
"than",
"maximum",
"number",
"of",
"allowed",
"partitions"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/DateWatermark.java#L124-L133 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/BasePrepareStatement.java | BasePrepareStatement.setTimestamp | public void setTimestamp(final int parameterIndex, final Timestamp timestamp, final Calendar cal)
throws SQLException {
if (timestamp == null) {
setNull(parameterIndex, ColumnType.DATETIME);
return;
}
TimeZone tz = cal != null ? cal.getTimeZone() : protocol.getTimeZone();
setParameter(parameterIndex, new TimestampParameter(timestamp, tz, useFractionalSeconds));
} | java | public void setTimestamp(final int parameterIndex, final Timestamp timestamp, final Calendar cal)
throws SQLException {
if (timestamp == null) {
setNull(parameterIndex, ColumnType.DATETIME);
return;
}
TimeZone tz = cal != null ? cal.getTimeZone() : protocol.getTimeZone();
setParameter(parameterIndex, new TimestampParameter(timestamp, tz, useFractionalSeconds));
} | [
"public",
"void",
"setTimestamp",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"Timestamp",
"timestamp",
",",
"final",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"timestamp",
"==",
"null",
")",
"{",
"setNull",
"(",
"parameterInde... | Sets the designated parameter to the given <code>java.sql.Timestamp</code> value, using the
given
<code>Calendar</code> object. The driver uses the <code>Calendar</code> object to construct
an SQL
<code>TIMESTAMP</code> value, which the driver then sends to the database. With a
<code>Calendar</code> object,
the driver can calculate the timestamp taking into account a custom timezone. If no
<code>Calendar</code> object is specified, the driver uses the default timezone, which is that
of the virtual machine running the application.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param timestamp the parameter value
@param cal the <code>Calendar</code> object the driver will use to construct the
timestamp
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code> | [
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"<code",
">",
"java",
".",
"sql",
".",
"Timestamp<",
"/",
"code",
">",
"value",
"using",
"the",
"given",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
".",
"The",
"driver",
"uses",
... | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/BasePrepareStatement.java#L593-L601 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/ClassPathUtils.java | ClassPathUtils.toFullyQualifiedName | @GwtIncompatible("incompatible method")
public static String toFullyQualifiedName(final Class<?> context, final String resourceName) {
Validate.notNull(context, "Parameter '%s' must not be null!", "context" );
Validate.notNull(resourceName, "Parameter '%s' must not be null!", "resourceName");
return toFullyQualifiedName(context.getPackage(), resourceName);
} | java | @GwtIncompatible("incompatible method")
public static String toFullyQualifiedName(final Class<?> context, final String resourceName) {
Validate.notNull(context, "Parameter '%s' must not be null!", "context" );
Validate.notNull(resourceName, "Parameter '%s' must not be null!", "resourceName");
return toFullyQualifiedName(context.getPackage(), resourceName);
} | [
"@",
"GwtIncompatible",
"(",
"\"incompatible method\"",
")",
"public",
"static",
"String",
"toFullyQualifiedName",
"(",
"final",
"Class",
"<",
"?",
">",
"context",
",",
"final",
"String",
"resourceName",
")",
"{",
"Validate",
".",
"notNull",
"(",
"context",
",",... | Returns the fully qualified name for the resource with name {@code resourceName} relative to the given context.
<p>Note that this method does not check whether the resource actually exists.
It only constructs the name.
Null inputs are not allowed.</p>
<pre>
ClassPathUtils.toFullyQualifiedName(StringUtils.class, "StringUtils.properties") = "org.apache.commons.lang3.StringUtils.properties"
</pre>
@param context The context for constructing the name.
@param resourceName the resource name to construct the fully qualified name for.
@return the fully qualified name of the resource with name {@code resourceName}.
@throws java.lang.NullPointerException if either {@code context} or {@code resourceName} is null. | [
"Returns",
"the",
"fully",
"qualified",
"name",
"for",
"the",
"resource",
"with",
"name",
"{",
"@code",
"resourceName",
"}",
"relative",
"to",
"the",
"given",
"context",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/ClassPathUtils.java#L59-L64 |
javagl/CommonUI | src/main/java/de/javagl/common/ui/text/JTextComponents.java | JTextComponents.findNext | static Point findNext(
String text, String query, int startIndex, boolean ignoreCase)
{
int offset = StringUtils.indexOf(
text, query, startIndex, ignoreCase);
int length = query.length();
while (offset != -1)
{
return new Point(offset, offset + length);
}
return null;
} | java | static Point findNext(
String text, String query, int startIndex, boolean ignoreCase)
{
int offset = StringUtils.indexOf(
text, query, startIndex, ignoreCase);
int length = query.length();
while (offset != -1)
{
return new Point(offset, offset + length);
}
return null;
} | [
"static",
"Point",
"findNext",
"(",
"String",
"text",
",",
"String",
"query",
",",
"int",
"startIndex",
",",
"boolean",
"ignoreCase",
")",
"{",
"int",
"offset",
"=",
"StringUtils",
".",
"indexOf",
"(",
"text",
",",
"query",
",",
"startIndex",
",",
"ignoreC... | Find the next appearance of the given query in the given text,
starting at the given index. The result will be a point
<code>(startIndex, endIndex)</code> indicating the appearance,
or <code>null</code> if none is found.
@param text The text
@param query The query
@param startIndex The start index
@param ignoreCase Whether the case should be ignored
@return The next appearance | [
"Find",
"the",
"next",
"appearance",
"of",
"the",
"given",
"query",
"in",
"the",
"given",
"text",
"starting",
"at",
"the",
"given",
"index",
".",
"The",
"result",
"will",
"be",
"a",
"point",
"<code",
">",
"(",
"startIndex",
"endIndex",
")",
"<",
"/",
"... | train | https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/text/JTextComponents.java#L65-L76 |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java | DefaultParser.handleUnknownToken | private void handleUnknownToken(String token) throws ParseException
{
if (token.startsWith("-") && token.length() > 1 && !stopAtNonOption)
{
throw new UnrecognizedOptionException("Unrecognized option: " + token, token);
}
cmd.addArg(token);
if (stopAtNonOption)
{
skipParsing = true;
}
} | java | private void handleUnknownToken(String token) throws ParseException
{
if (token.startsWith("-") && token.length() > 1 && !stopAtNonOption)
{
throw new UnrecognizedOptionException("Unrecognized option: " + token, token);
}
cmd.addArg(token);
if (stopAtNonOption)
{
skipParsing = true;
}
} | [
"private",
"void",
"handleUnknownToken",
"(",
"String",
"token",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"token",
".",
"startsWith",
"(",
"\"-\"",
")",
"&&",
"token",
".",
"length",
"(",
")",
">",
"1",
"&&",
"!",
"stopAtNonOption",
")",
"{",
"th... | Handles an unknown token. If the token starts with a dash an
UnrecognizedOptionException is thrown. Otherwise the token is added
to the arguments of the command line. If the stopAtNonOption flag
is set, this stops the parsing and the remaining tokens are added
as-is in the arguments of the command line.
@param token the command line token to handle | [
"Handles",
"an",
"unknown",
"token",
".",
"If",
"the",
"token",
"starts",
"with",
"a",
"dash",
"an",
"UnrecognizedOptionException",
"is",
"thrown",
".",
"Otherwise",
"the",
"token",
"is",
"added",
"to",
"the",
"arguments",
"of",
"the",
"command",
"line",
"."... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/DefaultParser.java#L343-L355 |
rundeck/rundeck | core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java | ResourceXMLGenerator.genNode | private void genNode(final Element ent, final ResourceXMLParser.Entity entity) {
for (final String nodeProp : nodeProps) {
ent.addAttribute(nodeProp, notNull(entity.getProperty(nodeProp)));
}
genAttributes(ent, entity);
} | java | private void genNode(final Element ent, final ResourceXMLParser.Entity entity) {
for (final String nodeProp : nodeProps) {
ent.addAttribute(nodeProp, notNull(entity.getProperty(nodeProp)));
}
genAttributes(ent, entity);
} | [
"private",
"void",
"genNode",
"(",
"final",
"Element",
"ent",
",",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
")",
"{",
"for",
"(",
"final",
"String",
"nodeProp",
":",
"nodeProps",
")",
"{",
"ent",
".",
"addAttribute",
"(",
"nodeProp",
",",
"no... | Gen "node" tag contents
@param ent element
@param entity entity | [
"Gen",
"node",
"tag",
"contents"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L253-L258 |
Azure/azure-sdk-for-java | compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java | DisksInner.createOrUpdateAsync | public Observable<DiskInner> createOrUpdateAsync(String resourceGroupName, String diskName, DiskInner disk) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).map(new Func1<ServiceResponse<DiskInner>, DiskInner>() {
@Override
public DiskInner call(ServiceResponse<DiskInner> response) {
return response.body();
}
});
} | java | public Observable<DiskInner> createOrUpdateAsync(String resourceGroupName, String diskName, DiskInner disk) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).map(new Func1<ServiceResponse<DiskInner>, DiskInner>() {
@Override
public DiskInner call(ServiceResponse<DiskInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DiskInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"diskName",
",",
"DiskInner",
"disk",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"diskName",
",",
... | Creates or updates a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param disk Disk object supplied in the body of the Put disk operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"disk",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java#L171-L178 |
dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java | Smaz.outputVerb | private static void outputVerb(final ByteArrayOutputStream baos, final String str) {
if (str.length() == 1) {
baos.write(254);
baos.write(str.toCharArray()[0]);
} else {
final byte[] bytes = str.getBytes(Charsets.UTF_8);
baos.write(255);
baos.write(str.length());
baos.write(bytes, 0, bytes.length);
}
} | java | private static void outputVerb(final ByteArrayOutputStream baos, final String str) {
if (str.length() == 1) {
baos.write(254);
baos.write(str.toCharArray()[0]);
} else {
final byte[] bytes = str.getBytes(Charsets.UTF_8);
baos.write(255);
baos.write(str.length());
baos.write(bytes, 0, bytes.length);
}
} | [
"private",
"static",
"void",
"outputVerb",
"(",
"final",
"ByteArrayOutputStream",
"baos",
",",
"final",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"baos",
".",
"write",
"(",
"254",
")",
";",
"baos",
"."... | Outputs the verbatim string to the output stream
@param baos
@param str | [
"Outputs",
"the",
"verbatim",
"string",
"to",
"the",
"output",
"stream"
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java#L262-L272 |
mockito/mockito | src/main/java/org/mockito/internal/stubbing/defaultanswers/RetrieveGenericsForDefaultAnswers.java | RetrieveGenericsForDefaultAnswers.findTypeFromGeneric | private static Class<?> findTypeFromGeneric(final InvocationOnMock invocation, final TypeVariable returnType) {
// Class level
final MockCreationSettings mockSettings = MockUtil.getMockHandler(invocation.getMock()).getMockSettings();
final GenericMetadataSupport returnTypeSupport = GenericMetadataSupport
.inferFrom(mockSettings.getTypeToMock())
.resolveGenericReturnType(invocation.getMethod());
final Class<?> rawType = returnTypeSupport.rawType();
// Method level
if (rawType == Object.class) {
return findTypeFromGenericInArguments(invocation, returnType);
}
return rawType;
} | java | private static Class<?> findTypeFromGeneric(final InvocationOnMock invocation, final TypeVariable returnType) {
// Class level
final MockCreationSettings mockSettings = MockUtil.getMockHandler(invocation.getMock()).getMockSettings();
final GenericMetadataSupport returnTypeSupport = GenericMetadataSupport
.inferFrom(mockSettings.getTypeToMock())
.resolveGenericReturnType(invocation.getMethod());
final Class<?> rawType = returnTypeSupport.rawType();
// Method level
if (rawType == Object.class) {
return findTypeFromGenericInArguments(invocation, returnType);
}
return rawType;
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"findTypeFromGeneric",
"(",
"final",
"InvocationOnMock",
"invocation",
",",
"final",
"TypeVariable",
"returnType",
")",
"{",
"// Class level",
"final",
"MockCreationSettings",
"mockSettings",
"=",
"MockUtil",
".",
"getMockH... | Retrieve the expected type when it came from a primitive. If the type cannot be retrieve, return null.
@param invocation the current invocation
@param returnType the expected return type
@return the type or null if not found | [
"Retrieve",
"the",
"expected",
"type",
"when",
"it",
"came",
"from",
"a",
"primitive",
".",
"If",
"the",
"type",
"cannot",
"be",
"retrieve",
"return",
"null",
"."
] | train | https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/stubbing/defaultanswers/RetrieveGenericsForDefaultAnswers.java#L90-L103 |
ManfredTremmel/gwt-bean-validators | gwtp-spring-integration/src/main/super/de/knightsoftnet/gwtp/spring/supersource/org/springframework/util/StringUtils.java | StringUtils.uriDecode | public static String uriDecode(final String source, final Charset charset) {
final int length = source.length();
if (length == 0) {
return source;
}
Assert.notNull(charset, "Charset must not be null");
final ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
boolean changed = false;
for (int i = 0; i < length; i++) {
final int ch = source.charAt(i);
if (ch == '%') {
if (i + 2 < length) {
final char hex1 = source.charAt(i + 1);
final char hex2 = source.charAt(i + 2);
final int u = Character.digit(hex1, 16);
final int l = Character.digit(hex2, 16);
if (u == -1 || l == -1) {
throw new IllegalArgumentException(
"Invalid encoded sequence \"" + source.substring(i) + "\"");
}
bos.write((char) ((u << 4) + l));
i += 2;
changed = true;
} else {
throw new IllegalArgumentException(
"Invalid encoded sequence \"" + source.substring(i) + "\"");
}
} else {
bos.write(ch);
}
}
return changed ? new String(bos.toByteArray(), charset) : source;
} | java | public static String uriDecode(final String source, final Charset charset) {
final int length = source.length();
if (length == 0) {
return source;
}
Assert.notNull(charset, "Charset must not be null");
final ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
boolean changed = false;
for (int i = 0; i < length; i++) {
final int ch = source.charAt(i);
if (ch == '%') {
if (i + 2 < length) {
final char hex1 = source.charAt(i + 1);
final char hex2 = source.charAt(i + 2);
final int u = Character.digit(hex1, 16);
final int l = Character.digit(hex2, 16);
if (u == -1 || l == -1) {
throw new IllegalArgumentException(
"Invalid encoded sequence \"" + source.substring(i) + "\"");
}
bos.write((char) ((u << 4) + l));
i += 2;
changed = true;
} else {
throw new IllegalArgumentException(
"Invalid encoded sequence \"" + source.substring(i) + "\"");
}
} else {
bos.write(ch);
}
}
return changed ? new String(bos.toByteArray(), charset) : source;
} | [
"public",
"static",
"String",
"uriDecode",
"(",
"final",
"String",
"source",
",",
"final",
"Charset",
"charset",
")",
"{",
"final",
"int",
"length",
"=",
"source",
".",
"length",
"(",
")",
";",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
"sourc... | Decode the given encoded URI component value. Based on the following rules:
<ul>
<li>Alphanumeric characters {@code "a"} through {@code "z"}, {@code "A"} through {@code "Z"},
and {@code "0"} through {@code "9"} stay the same.</li>
<li>Special characters {@code "-"}, {@code "_"}, {@code "."}, and {@code "*"} stay the
same.</li>
<li>A sequence "{@code %<i>xy</i>}" is interpreted as a hexadecimal representation of the
character.</li>
</ul>
@param source the encoded String
@param charset the character set
@return the decoded value
@throws IllegalArgumentException when the given source contains invalid encoded sequences
@since 5.0
@see java.net.URLDecoder#decode(String, String) | [
"Decode",
"the",
"given",
"encoded",
"URI",
"component",
"value",
".",
"Based",
"on",
"the",
"following",
"rules",
":",
"<ul",
">",
"<li",
">",
"Alphanumeric",
"characters",
"{",
"@code",
"a",
"}",
"through",
"{",
"@code",
"z",
"}",
"{",
"@code",
"A",
... | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/gwtp-spring-integration/src/main/super/de/knightsoftnet/gwtp/spring/supersource/org/springframework/util/StringUtils.java#L758-L791 |
RestComm/jss7 | isup/isup-impl/src/main/java/org/restcomm/protocols/ss7/isup/impl/message/parameter/CircuitAssigmentMapImpl.java | CircuitAssigmentMapImpl.enableCircuit | public void enableCircuit(int circuitNumber) throws IllegalArgumentException {
if (circuitNumber < 1 || circuitNumber > 31) {
throw new IllegalArgumentException("Cicruit number is out of range[" + circuitNumber + "] <1,31>");
}
this.mapFormat |= _CIRCUIT_ENABLED << (circuitNumber - 1);
} | java | public void enableCircuit(int circuitNumber) throws IllegalArgumentException {
if (circuitNumber < 1 || circuitNumber > 31) {
throw new IllegalArgumentException("Cicruit number is out of range[" + circuitNumber + "] <1,31>");
}
this.mapFormat |= _CIRCUIT_ENABLED << (circuitNumber - 1);
} | [
"public",
"void",
"enableCircuit",
"(",
"int",
"circuitNumber",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"circuitNumber",
"<",
"1",
"||",
"circuitNumber",
">",
"31",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cicruit number is ou... | Enables circuit
@param circuitNumber - index of circuit - must be number <1,31>
@throws IllegalArgumentException - when number is not in range | [
"Enables",
"circuit"
] | train | https://github.com/RestComm/jss7/blob/402b4b3984e581c581e309cb5f6a858fde6dbc33/isup/isup-impl/src/main/java/org/restcomm/protocols/ss7/isup/impl/message/parameter/CircuitAssigmentMapImpl.java#L113-L119 |
burberius/eve-esi | src/main/java/net/troja/eve/esi/api/UniverseApi.java | UniverseApi.getUniverseStargatesStargateId | public StargateResponse getUniverseStargatesStargateId(Integer stargateId, String datasource, String ifNoneMatch)
throws ApiException {
ApiResponse<StargateResponse> resp = getUniverseStargatesStargateIdWithHttpInfo(stargateId, datasource,
ifNoneMatch);
return resp.getData();
} | java | public StargateResponse getUniverseStargatesStargateId(Integer stargateId, String datasource, String ifNoneMatch)
throws ApiException {
ApiResponse<StargateResponse> resp = getUniverseStargatesStargateIdWithHttpInfo(stargateId, datasource,
ifNoneMatch);
return resp.getData();
} | [
"public",
"StargateResponse",
"getUniverseStargatesStargateId",
"(",
"Integer",
"stargateId",
",",
"String",
"datasource",
",",
"String",
"ifNoneMatch",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"StargateResponse",
">",
"resp",
"=",
"getUniverseStargatesStar... | Get stargate information Get information on a stargate --- This route
expires daily at 11:05
@param stargateId
stargate_id integer (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@return StargateResponse
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body | [
"Get",
"stargate",
"information",
"Get",
"information",
"on",
"a",
"stargate",
"---",
"This",
"route",
"expires",
"daily",
"at",
"11",
":",
"05"
] | train | https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/UniverseApi.java#L2787-L2792 |
james-hu/jabb-core | src/main/java/net/sf/jabb/util/web/WebApplicationConfiguration.java | WebApplicationConfiguration.getMenuItem | public WebMenuItem getMenuItem(String menuName, String path){
try{
return menuItemPaths.get(menuName).get(path);
}catch(Exception e){
log.error("Error when getting menu item for: menuName='" + menuName + "', path='" + path + "'", e);
return null;
}
} | java | public WebMenuItem getMenuItem(String menuName, String path){
try{
return menuItemPaths.get(menuName).get(path);
}catch(Exception e){
log.error("Error when getting menu item for: menuName='" + menuName + "', path='" + path + "'", e);
return null;
}
} | [
"public",
"WebMenuItem",
"getMenuItem",
"(",
"String",
"menuName",
",",
"String",
"path",
")",
"{",
"try",
"{",
"return",
"menuItemPaths",
".",
"get",
"(",
"menuName",
")",
".",
"get",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{... | Get the menu item by menu and path
@param menuName
@param path
@return the menu item within the specified menu tree with the matching path/name | [
"Get",
"the",
"menu",
"item",
"by",
"menu",
"and",
"path"
] | train | https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/web/WebApplicationConfiguration.java#L211-L218 |
wcm-io/wcm-io-handler | media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java | DefaultRenditionHandler.getVirtualRendition | private RenditionMetadata getVirtualRendition(RenditionMetadata rendition, long widthValue, long heightValue, double ratioValue) {
long width = widthValue;
long height = heightValue;
double ratio = ratioValue;
// if ratio is missing: calculate from given rendition
if (ratio < MediaFormatHandler.RATIO_TOLERANCE) {
ratio = (double)rendition.getWidth() / (double)rendition.getHeight();
}
// if height is missing - calculate from width
if (height == 0 && width > 0) {
height = (int)Math.round(width / ratio);
}
// if width is missing - calculate from height
if (width == 0 && height > 0) {
width = (int)Math.round(height * ratio);
}
// return virtual rendition
if (width > 0 && height > 0) {
if (rendition instanceof VirtualTransformedRenditionMetadata) {
VirtualTransformedRenditionMetadata cropRendition = (VirtualTransformedRenditionMetadata)rendition;
return new VirtualTransformedRenditionMetadata(cropRendition.getRendition(), width, height,
cropRendition.getCropDimension(), cropRendition.getRotation());
}
else {
return new VirtualRenditionMetadata(rendition.getRendition(), width, height);
}
}
else {
return null;
}
} | java | private RenditionMetadata getVirtualRendition(RenditionMetadata rendition, long widthValue, long heightValue, double ratioValue) {
long width = widthValue;
long height = heightValue;
double ratio = ratioValue;
// if ratio is missing: calculate from given rendition
if (ratio < MediaFormatHandler.RATIO_TOLERANCE) {
ratio = (double)rendition.getWidth() / (double)rendition.getHeight();
}
// if height is missing - calculate from width
if (height == 0 && width > 0) {
height = (int)Math.round(width / ratio);
}
// if width is missing - calculate from height
if (width == 0 && height > 0) {
width = (int)Math.round(height * ratio);
}
// return virtual rendition
if (width > 0 && height > 0) {
if (rendition instanceof VirtualTransformedRenditionMetadata) {
VirtualTransformedRenditionMetadata cropRendition = (VirtualTransformedRenditionMetadata)rendition;
return new VirtualTransformedRenditionMetadata(cropRendition.getRendition(), width, height,
cropRendition.getCropDimension(), cropRendition.getRotation());
}
else {
return new VirtualRenditionMetadata(rendition.getRendition(), width, height);
}
}
else {
return null;
}
} | [
"private",
"RenditionMetadata",
"getVirtualRendition",
"(",
"RenditionMetadata",
"rendition",
",",
"long",
"widthValue",
",",
"long",
"heightValue",
",",
"double",
"ratioValue",
")",
"{",
"long",
"width",
"=",
"widthValue",
";",
"long",
"height",
"=",
"heightValue",... | Get virtual rendition for given width/height/ratio.
@param rendition Rendition
@param widthValue Width
@param heightValue Height
@param ratioValue Ratio
@return Rendition or null | [
"Get",
"virtual",
"rendition",
"for",
"given",
"width",
"/",
"height",
"/",
"ratio",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java#L419-L454 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.columnStringToObject | public static <T> T columnStringToObject(Class objClass, String str, String delimiterRegex, String[] fieldNames)
throws InstantiationException, IllegalAccessException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException
{
Pattern delimiterPattern = Pattern.compile(delimiterRegex);
return StringUtils.<T>columnStringToObject(objClass, str, delimiterPattern, fieldNames);
} | java | public static <T> T columnStringToObject(Class objClass, String str, String delimiterRegex, String[] fieldNames)
throws InstantiationException, IllegalAccessException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException
{
Pattern delimiterPattern = Pattern.compile(delimiterRegex);
return StringUtils.<T>columnStringToObject(objClass, str, delimiterPattern, fieldNames);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"columnStringToObject",
"(",
"Class",
"objClass",
",",
"String",
"str",
",",
"String",
"delimiterRegex",
",",
"String",
"[",
"]",
"fieldNames",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
",",
"... | Converts a tab delimited string into an object with given fields
Requires the object has setXxx functions for the specified fields
@param objClass Class of object to be created
@param str string to convert
@param delimiterRegex delimiter regular expression
@param fieldNames fieldnames
@param <T> type to return
@return Object created from string | [
"Converts",
"a",
"tab",
"delimited",
"string",
"into",
"an",
"object",
"with",
"given",
"fields",
"Requires",
"the",
"object",
"has",
"setXxx",
"functions",
"for",
"the",
"specified",
"fields"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L1345-L1350 |
roboconf/roboconf-platform | core/roboconf-core/src/main/java/net/roboconf/core/errors/ErrorDetails.java | ErrorDetails.applicationTpl | public static ErrorDetails applicationTpl( String tplName, String tplVersion ) {
return new ErrorDetails( tplName + " (" + tplVersion + ")", ErrorDetailsKind.APPLICATION_TEMPLATE );
} | java | public static ErrorDetails applicationTpl( String tplName, String tplVersion ) {
return new ErrorDetails( tplName + " (" + tplVersion + ")", ErrorDetailsKind.APPLICATION_TEMPLATE );
} | [
"public",
"static",
"ErrorDetails",
"applicationTpl",
"(",
"String",
"tplName",
",",
"String",
"tplVersion",
")",
"{",
"return",
"new",
"ErrorDetails",
"(",
"tplName",
"+",
"\" (\"",
"+",
"tplVersion",
"+",
"\")\"",
",",
"ErrorDetailsKind",
".",
"APPLICATION_TEMPL... | Details for an application.
@param tplName the template's name
@param tplVersion the template's version
@return an object with error details | [
"Details",
"for",
"an",
"application",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/errors/ErrorDetails.java#L243-L245 |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/model/Entry.java | Entry.intersects | public final boolean intersects(ZonedDateTime startTime, ZonedDateTime endTime) {
return Util.intersect(startTime, endTime, getStartAsZonedDateTime(), getEndAsZonedDateTime());
} | java | public final boolean intersects(ZonedDateTime startTime, ZonedDateTime endTime) {
return Util.intersect(startTime, endTime, getStartAsZonedDateTime(), getEndAsZonedDateTime());
} | [
"public",
"final",
"boolean",
"intersects",
"(",
"ZonedDateTime",
"startTime",
",",
"ZonedDateTime",
"endTime",
")",
"{",
"return",
"Util",
".",
"intersect",
"(",
"startTime",
",",
"endTime",
",",
"getStartAsZonedDateTime",
"(",
")",
",",
"getEndAsZonedDateTime",
... | Utility method to determine if this entry and the given time interval
intersect each other (time bounds overlap each other).
@param startTime time interval start
@param endTime time interval end
@return true if the entry and the given time interval overlap | [
"Utility",
"method",
"to",
"determine",
"if",
"this",
"entry",
"and",
"the",
"given",
"time",
"interval",
"intersect",
"each",
"other",
"(",
"time",
"bounds",
"overlap",
"each",
"other",
")",
"."
] | train | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/model/Entry.java#L1461-L1463 |
belaban/JGroups | src/org/jgroups/stack/Configurator.java | Configurator.removeProvidedUpServices | protected static void removeProvidedUpServices(Protocol protocol, List<Integer> events) {
if(protocol == null || events == null)
return;
for(Protocol prot=protocol.getDownProtocol(); prot != null && !events.isEmpty(); prot=prot.getDownProtocol()) {
List<Integer> provided_up_services=prot.providedUpServices();
if(provided_up_services != null && !provided_up_services.isEmpty())
events.removeAll(provided_up_services);
}
} | java | protected static void removeProvidedUpServices(Protocol protocol, List<Integer> events) {
if(protocol == null || events == null)
return;
for(Protocol prot=protocol.getDownProtocol(); prot != null && !events.isEmpty(); prot=prot.getDownProtocol()) {
List<Integer> provided_up_services=prot.providedUpServices();
if(provided_up_services != null && !provided_up_services.isEmpty())
events.removeAll(provided_up_services);
}
} | [
"protected",
"static",
"void",
"removeProvidedUpServices",
"(",
"Protocol",
"protocol",
",",
"List",
"<",
"Integer",
">",
"events",
")",
"{",
"if",
"(",
"protocol",
"==",
"null",
"||",
"events",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Protocol",
"pr... | Removes all events provided by the protocol below protocol from events
@param protocol
@param events | [
"Removes",
"all",
"events",
"provided",
"by",
"the",
"protocol",
"below",
"protocol",
"from",
"events"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/stack/Configurator.java#L343-L351 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_flavor_flavorId_GET | public OvhFlavor project_serviceName_flavor_flavorId_GET(String serviceName, String flavorId) throws IOException {
String qPath = "/cloud/project/{serviceName}/flavor/{flavorId}";
StringBuilder sb = path(qPath, serviceName, flavorId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFlavor.class);
} | java | public OvhFlavor project_serviceName_flavor_flavorId_GET(String serviceName, String flavorId) throws IOException {
String qPath = "/cloud/project/{serviceName}/flavor/{flavorId}";
StringBuilder sb = path(qPath, serviceName, flavorId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFlavor.class);
} | [
"public",
"OvhFlavor",
"project_serviceName_flavor_flavorId_GET",
"(",
"String",
"serviceName",
",",
"String",
"flavorId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/flavor/{flavorId}\"",
";",
"StringBuilder",
"sb",
"=",
"path... | Get flavor
REST: GET /cloud/project/{serviceName}/flavor/{flavorId}
@param flavorId [required] Flavor id
@param serviceName [required] Service name | [
"Get",
"flavor"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L2312-L2317 |
apache/groovy | src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java | StaticTypeCheckingSupport.evaluateExpression | public static Object evaluateExpression(Expression expr, CompilerConfiguration config) {
String className = "Expression$" + UUID.randomUUID().toString().replace('-', '$');
ClassNode node = new ClassNode(className, Opcodes.ACC_PUBLIC, OBJECT_TYPE);
ReturnStatement code = new ReturnStatement(expr);
addGeneratedMethod(node, "eval", Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, code);
CompilerConfiguration copyConf = new CompilerConfiguration(config);
CompilationUnit cu = new CompilationUnit(copyConf);
cu.addClassNode(node);
cu.compile(Phases.CLASS_GENERATION);
@SuppressWarnings("unchecked")
List<GroovyClass> classes = (List<GroovyClass>) cu.getClasses();
Class aClass = cu.getClassLoader().defineClass(className, classes.get(0).getBytes());
try {
return aClass.getMethod("eval").invoke(null);
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new GroovyBugError(e);
}
} | java | public static Object evaluateExpression(Expression expr, CompilerConfiguration config) {
String className = "Expression$" + UUID.randomUUID().toString().replace('-', '$');
ClassNode node = new ClassNode(className, Opcodes.ACC_PUBLIC, OBJECT_TYPE);
ReturnStatement code = new ReturnStatement(expr);
addGeneratedMethod(node, "eval", Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, code);
CompilerConfiguration copyConf = new CompilerConfiguration(config);
CompilationUnit cu = new CompilationUnit(copyConf);
cu.addClassNode(node);
cu.compile(Phases.CLASS_GENERATION);
@SuppressWarnings("unchecked")
List<GroovyClass> classes = (List<GroovyClass>) cu.getClasses();
Class aClass = cu.getClassLoader().defineClass(className, classes.get(0).getBytes());
try {
return aClass.getMethod("eval").invoke(null);
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new GroovyBugError(e);
}
} | [
"public",
"static",
"Object",
"evaluateExpression",
"(",
"Expression",
"expr",
",",
"CompilerConfiguration",
"config",
")",
"{",
"String",
"className",
"=",
"\"Expression$\"",
"+",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
".",
"replace",
... | A helper method that can be used to evaluate expressions as found in annotation
parameters. For example, it will evaluate a constant, be it referenced directly as
an integer or as a reference to a field.
<p>
If this method throws an exception, then the expression cannot be evaluated on its own.
@param expr the expression to be evaluated
@param config the compiler configuration
@return the result of the expression | [
"A",
"helper",
"method",
"that",
"can",
"be",
"used",
"to",
"evaluate",
"expressions",
"as",
"found",
"in",
"annotation",
"parameters",
".",
"For",
"example",
"it",
"will",
"evaluate",
"a",
"constant",
"be",
"it",
"referenced",
"directly",
"as",
"an",
"integ... | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java#L2470-L2487 |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.scale | public static void scale(double scalar, DMatrixSparseCSC A, DMatrixSparseCSC B) {
if( A != B ) {
B.copyStructure(A);
for(int i = 0; i < A.nz_length; i++ ) {
B.nz_values[i] = A.nz_values[i]*scalar;
}
} else {
for(int i = 0; i < A.nz_length; i++ ) {
B.nz_values[i] *= scalar;
}
}
} | java | public static void scale(double scalar, DMatrixSparseCSC A, DMatrixSparseCSC B) {
if( A != B ) {
B.copyStructure(A);
for(int i = 0; i < A.nz_length; i++ ) {
B.nz_values[i] = A.nz_values[i]*scalar;
}
} else {
for(int i = 0; i < A.nz_length; i++ ) {
B.nz_values[i] *= scalar;
}
}
} | [
"public",
"static",
"void",
"scale",
"(",
"double",
"scalar",
",",
"DMatrixSparseCSC",
"A",
",",
"DMatrixSparseCSC",
"B",
")",
"{",
"if",
"(",
"A",
"!=",
"B",
")",
"{",
"B",
".",
"copyStructure",
"(",
"A",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0"... | B = scalar*A. A and B can be the same instance.
@param scalar (Input) Scalar value
@param A (Input) Matrix. Not modified.
@param B (Output) Matrix. Modified. | [
"B",
"=",
"scalar",
"*",
"A",
".",
"A",
"and",
"B",
"can",
"be",
"the",
"same",
"instance",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L384-L396 |
james-hu/jabb-core | src/main/java/net/sf/jabb/util/db/ResultSetUtility.java | ResultSetUtility.convertAllToMaps | public List<Map<String, Object>> convertAllToMaps(ResultSet rs) throws SQLException{
return convertAllToMaps(rs, null);
} | java | public List<Map<String, Object>> convertAllToMaps(ResultSet rs) throws SQLException{
return convertAllToMaps(rs, null);
} | [
"public",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"convertAllToMaps",
"(",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"return",
"convertAllToMaps",
"(",
"rs",
",",
"null",
")",
";",
"}"
] | Convert all rows of the ResultSet to a Map. The keys of the Map are property names transformed from column names.
@param rs the result set
@return A list of Map representations of all the rows in the result set
@throws SQLException | [
"Convert",
"all",
"rows",
"of",
"the",
"ResultSet",
"to",
"a",
"Map",
".",
"The",
"keys",
"of",
"the",
"Map",
"are",
"property",
"names",
"transformed",
"from",
"column",
"names",
"."
] | train | https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/ResultSetUtility.java#L92-L94 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ActivitysInner.java | ActivitysInner.listByModuleAsync | public Observable<Page<ActivityInner>> listByModuleAsync(final String resourceGroupName, final String automationAccountName, final String moduleName) {
return listByModuleWithServiceResponseAsync(resourceGroupName, automationAccountName, moduleName)
.map(new Func1<ServiceResponse<Page<ActivityInner>>, Page<ActivityInner>>() {
@Override
public Page<ActivityInner> call(ServiceResponse<Page<ActivityInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ActivityInner>> listByModuleAsync(final String resourceGroupName, final String automationAccountName, final String moduleName) {
return listByModuleWithServiceResponseAsync(resourceGroupName, automationAccountName, moduleName)
.map(new Func1<ServiceResponse<Page<ActivityInner>>, Page<ActivityInner>>() {
@Override
public Page<ActivityInner> call(ServiceResponse<Page<ActivityInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ActivityInner",
">",
">",
"listByModuleAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"automationAccountName",
",",
"final",
"String",
"moduleName",
")",
"{",
"return",
"listByModuleWithServiceRe... | Retrieve a list of activities in the module identified by module name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param moduleName The name of module.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ActivityInner> object | [
"Retrieve",
"a",
"list",
"of",
"activities",
"in",
"the",
"module",
"identified",
"by",
"module",
"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/ActivitysInner.java#L224-L232 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/CommonG.java | CommonG.retrieveServiceStatus | public String retrieveServiceStatus(String service, String cluster) throws Exception {
String status = "";
String endPoint = "/service/deploy-api/deploy/status/service?service=" + service;
String element = "$.status";
Future response;
this.setRestProtocol("https://");
this.setRestHost(cluster);
this.setRestPort(":443");
response = this.generateRequest("GET", true, null, null, endPoint, null, "json");
this.setResponse("GET", (Response) response.get());
assertThat(this.getResponse().getStatusCode()).as("It hasn't been possible to obtain status for service: " + service).isEqualTo(200);
String json = this.getResponse().getResponse();
String value = this.getJSONPathString(json, element, null);
switch (value) {
case "0":
status = "deploying";
break;
case "1":
status = "suspended";
break;
case "2":
status = "running";
break;
case "3":
status = "delayed";
break;
default:
throw new Exception("Unknown service status code");
}
return status;
} | java | public String retrieveServiceStatus(String service, String cluster) throws Exception {
String status = "";
String endPoint = "/service/deploy-api/deploy/status/service?service=" + service;
String element = "$.status";
Future response;
this.setRestProtocol("https://");
this.setRestHost(cluster);
this.setRestPort(":443");
response = this.generateRequest("GET", true, null, null, endPoint, null, "json");
this.setResponse("GET", (Response) response.get());
assertThat(this.getResponse().getStatusCode()).as("It hasn't been possible to obtain status for service: " + service).isEqualTo(200);
String json = this.getResponse().getResponse();
String value = this.getJSONPathString(json, element, null);
switch (value) {
case "0":
status = "deploying";
break;
case "1":
status = "suspended";
break;
case "2":
status = "running";
break;
case "3":
status = "delayed";
break;
default:
throw new Exception("Unknown service status code");
}
return status;
} | [
"public",
"String",
"retrieveServiceStatus",
"(",
"String",
"service",
",",
"String",
"cluster",
")",
"throws",
"Exception",
"{",
"String",
"status",
"=",
"\"\"",
";",
"String",
"endPoint",
"=",
"\"/service/deploy-api/deploy/status/service?service=\"",
"+",
"service",
... | Get service status
@param service name of the service to be checked
@param cluster URI of the cluster
@return String normalized service status
@throws Exception exception * | [
"Get",
"service",
"status"
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/CommonG.java#L2261-L2297 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java | InternalService.removeParticipants | public Observable<ComapiResult<Void>> removeParticipants(@NonNull final String conversationId, @NonNull final List<String> ids) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueRemoveParticipants(conversationId, ids);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doRemoveParticipants(token, conversationId, ids);
}
} | java | public Observable<ComapiResult<Void>> removeParticipants(@NonNull final String conversationId, @NonNull final List<String> ids) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueRemoveParticipants(conversationId, ids);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doRemoveParticipants(token, conversationId, ids);
}
} | [
"public",
"Observable",
"<",
"ComapiResult",
"<",
"Void",
">",
">",
"removeParticipants",
"(",
"@",
"NonNull",
"final",
"String",
"conversationId",
",",
"@",
"NonNull",
"final",
"List",
"<",
"String",
">",
"ids",
")",
"{",
"final",
"String",
"token",
"=",
... | Returns observable to remove list of participants from a conversation.
@param conversationId ID of a conversation to delete.
@param ids List of participant ids to be removed.
@return Observable to remove list of participants from a conversation. | [
"Returns",
"observable",
"to",
"remove",
"list",
"of",
"participants",
"from",
"a",
"conversation",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java#L606-L617 |
alb-i986/selenium-tinafw | src/main/java/me/alb_i986/selenium/tinafw/config/TinafwGuiceModule.java | TinafwGuiceModule.webDriverFactoryProvider | @Provides
@Singleton
WebDriverFactory webDriverFactoryProvider() {
WebDriverFactory tmpFactoryFromConfig;
URL hubURL = Config.getGridHubUrl();
if(hubURL == null) {
tmpFactoryFromConfig = new WebDriverFactoryLocal();
} else {
DesiredCapabilities extraDesiredCapabilities = new DesiredCapabilities();
extraDesiredCapabilities.setVersion(Config.getGridBrowserVersion());
extraDesiredCapabilities.setPlatform(Config.getGridPlatform());
tmpFactoryFromConfig = new WebDriverFactoryRemote(hubURL, extraDesiredCapabilities);
}
Long implicitWait = Config.getImplicitWait();
if(implicitWait != null)
tmpFactoryFromConfig = new WebDriverFactoryDecoratorImplicitWait(implicitWait, tmpFactoryFromConfig);
return tmpFactoryFromConfig;
} | java | @Provides
@Singleton
WebDriverFactory webDriverFactoryProvider() {
WebDriverFactory tmpFactoryFromConfig;
URL hubURL = Config.getGridHubUrl();
if(hubURL == null) {
tmpFactoryFromConfig = new WebDriverFactoryLocal();
} else {
DesiredCapabilities extraDesiredCapabilities = new DesiredCapabilities();
extraDesiredCapabilities.setVersion(Config.getGridBrowserVersion());
extraDesiredCapabilities.setPlatform(Config.getGridPlatform());
tmpFactoryFromConfig = new WebDriverFactoryRemote(hubURL, extraDesiredCapabilities);
}
Long implicitWait = Config.getImplicitWait();
if(implicitWait != null)
tmpFactoryFromConfig = new WebDriverFactoryDecoratorImplicitWait(implicitWait, tmpFactoryFromConfig);
return tmpFactoryFromConfig;
} | [
"@",
"Provides",
"@",
"Singleton",
"WebDriverFactory",
"webDriverFactoryProvider",
"(",
")",
"{",
"WebDriverFactory",
"tmpFactoryFromConfig",
";",
"URL",
"hubURL",
"=",
"Config",
".",
"getGridHubUrl",
"(",
")",
";",
"if",
"(",
"hubURL",
"==",
"null",
")",
"{",
... | A {@link WebDriverFactory} according to the settings:
<ul>
<li>a {@link WebDriverFactoryLocal} if {@link Config#PROP_GRID_HUB_URL} is
not defined;
<li>else, a {@link WebDriverFactoryRemote}
<li>finally, decorate it with {@link WebDriverFactoryDecoratorImplicitWait}, if
{@link Config#PROP_TIMEOUT_IMPLICIT_WAIT} is defined
</ul> | [
"A",
"{"
] | train | https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/config/TinafwGuiceModule.java#L31-L48 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/value/support/EqualsValueChangeDetector.java | EqualsValueChangeDetector.hasValueChanged | public boolean hasValueChanged(Object oldValue, Object newValue) {
return !(oldValue == newValue || (oldValue != null && oldValue.equals( newValue )));
} | java | public boolean hasValueChanged(Object oldValue, Object newValue) {
return !(oldValue == newValue || (oldValue != null && oldValue.equals( newValue )));
} | [
"public",
"boolean",
"hasValueChanged",
"(",
"Object",
"oldValue",
",",
"Object",
"newValue",
")",
"{",
"return",
"!",
"(",
"oldValue",
"==",
"newValue",
"||",
"(",
"oldValue",
"!=",
"null",
"&&",
"oldValue",
".",
"equals",
"(",
"newValue",
")",
")",
")",
... | Determines if there has been a change in value between the provided arguments. The
objects are compared using the <code>equals</code> method.
@param oldValue Original object value
@param newValue New object value
@return true if the objects are different enough to indicate a change in the value
model | [
"Determines",
"if",
"there",
"has",
"been",
"a",
"change",
"in",
"value",
"between",
"the",
"provided",
"arguments",
".",
"The",
"objects",
"are",
"compared",
"using",
"the",
"<code",
">",
"equals<",
"/",
"code",
">",
"method",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/value/support/EqualsValueChangeDetector.java#L40-L42 |
Azure/azure-sdk-for-java | marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java | MarketplaceAgreementsInner.getAsync | public Observable<AgreementTermsInner> getAsync(String publisherId, String offerId, String planId) {
return getWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
} | java | public Observable<AgreementTermsInner> getAsync(String publisherId, String offerId, String planId) {
return getWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AgreementTermsInner",
">",
"getAsync",
"(",
"String",
"publisherId",
",",
"String",
"offerId",
",",
"String",
"planId",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"publisherId",
",",
"offerId",
",",
"planId",
")",
".",
... | Get marketplace terms.
@param publisherId Publisher identifier string of image being deployed.
@param offerId Offer identifier string of image being deployed.
@param planId Plan identifier string of image being deployed.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AgreementTermsInner object | [
"Get",
"marketplace",
"terms",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java#L126-L133 |
knowitall/common-java | src/main/java/edu/washington/cs/knowitall/commonlib/FileUtils.java | FileUtils.pipe | public static void pipe(InputStream is, OutputStream os, int buffersize) throws IOException {
byte[] buffer = new byte[buffersize];
while (is.read(buffer) != -1) {
os.write(buffer);
}
} | java | public static void pipe(InputStream is, OutputStream os, int buffersize) throws IOException {
byte[] buffer = new byte[buffersize];
while (is.read(buffer) != -1) {
os.write(buffer);
}
} | [
"public",
"static",
"void",
"pipe",
"(",
"InputStream",
"is",
",",
"OutputStream",
"os",
",",
"int",
"buffersize",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"buffersize",
"]",
";",
"while",
"(",
"is",
".",
... | *
Writes all lines read from the reader.
@param is The input stream
@param os The output stream
@param buffersize size of the buffer to use
@throws IOException | [
"*",
"Writes",
"all",
"lines",
"read",
"from",
"the",
"reader",
"."
] | train | https://github.com/knowitall/common-java/blob/6c3e7b2f13da5afb1306e87a6c322c55b65fddfc/src/main/java/edu/washington/cs/knowitall/commonlib/FileUtils.java#L66-L71 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/RDN.java | RDN.toRFC1779String | public String toRFC1779String(Map<String, String> oidMap) {
if (assertion.length == 1) {
return assertion[0].toRFC1779String(oidMap);
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < assertion.length; i++) {
if (i != 0) {
sb.append(" + ");
}
sb.append(assertion[i].toRFC1779String(oidMap));
}
return sb.toString();
} | java | public String toRFC1779String(Map<String, String> oidMap) {
if (assertion.length == 1) {
return assertion[0].toRFC1779String(oidMap);
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < assertion.length; i++) {
if (i != 0) {
sb.append(" + ");
}
sb.append(assertion[i].toRFC1779String(oidMap));
}
return sb.toString();
} | [
"public",
"String",
"toRFC1779String",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"oidMap",
")",
"{",
"if",
"(",
"assertion",
".",
"length",
"==",
"1",
")",
"{",
"return",
"assertion",
"[",
"0",
"]",
".",
"toRFC1779String",
"(",
"oidMap",
")",
";",... | /*
Returns a printable form of this RDN using the algorithm defined in
RFC 1779. RFC 1779 attribute type keywords are emitted, as well
as keywords contained in the OID/keyword map. | [
"/",
"*",
"Returns",
"a",
"printable",
"form",
"of",
"this",
"RDN",
"using",
"the",
"algorithm",
"defined",
"in",
"RFC",
"1779",
".",
"RFC",
"1779",
"attribute",
"type",
"keywords",
"are",
"emitted",
"as",
"well",
"as",
"keywords",
"contained",
"in",
"the"... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/RDN.java#L375-L388 |
sarl/sarl | contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyGenerator.java | PyGenerator._generate | protected void _generate(SarlField field, PyAppendable it, IExtraLanguageGeneratorContext context) {
if (field.isStatic()) {
// Static field
generatePythonField(field, it, context);
} else {
final String key = this.qualifiedNameProvider.getFullyQualifiedName(field.getDeclaringType()).toString();
final List<SarlField> fields = context.getMultimapValues(INSTANCE_VARIABLES_MEMENTO, key);
fields.add(field);
}
} | java | protected void _generate(SarlField field, PyAppendable it, IExtraLanguageGeneratorContext context) {
if (field.isStatic()) {
// Static field
generatePythonField(field, it, context);
} else {
final String key = this.qualifiedNameProvider.getFullyQualifiedName(field.getDeclaringType()).toString();
final List<SarlField> fields = context.getMultimapValues(INSTANCE_VARIABLES_MEMENTO, key);
fields.add(field);
}
} | [
"protected",
"void",
"_generate",
"(",
"SarlField",
"field",
",",
"PyAppendable",
"it",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"if",
"(",
"field",
".",
"isStatic",
"(",
")",
")",
"{",
"// Static field",
"generatePythonField",
"(",
"field",
"... | Generate the given object.
@param field the fields.
@param it the target for the generated content.
@param context the context. | [
"Generate",
"the",
"given",
"object",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyGenerator.java#L938-L947 |
aws/aws-sdk-java | aws-java-sdk-kms/src/main/java/com/amazonaws/services/kms/model/EncryptRequest.java | EncryptRequest.getEncryptionContext | public java.util.Map<String, String> getEncryptionContext() {
if (encryptionContext == null) {
encryptionContext = new com.amazonaws.internal.SdkInternalMap<String, String>();
}
return encryptionContext;
} | java | public java.util.Map<String, String> getEncryptionContext() {
if (encryptionContext == null) {
encryptionContext = new com.amazonaws.internal.SdkInternalMap<String, String>();
}
return encryptionContext;
} | [
"public",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"getEncryptionContext",
"(",
")",
"{",
"if",
"(",
"encryptionContext",
"==",
"null",
")",
"{",
"encryptionContext",
"=",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"... | <p>
Name-value pair that specifies the encryption context to be used for authenticated encryption. If used here, the
same value must be supplied to the <code>Decrypt</code> API or decryption will fail. For more information, see <a
href="http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html">Encryption Context</a>.
</p>
@return Name-value pair that specifies the encryption context to be used for authenticated encryption. If used
here, the same value must be supplied to the <code>Decrypt</code> API or decryption will fail. For more
information, see <a
href="http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html">Encryption
Context</a>. | [
"<p",
">",
"Name",
"-",
"value",
"pair",
"that",
"specifies",
"the",
"encryption",
"context",
"to",
"be",
"used",
"for",
"authenticated",
"encryption",
".",
"If",
"used",
"here",
"the",
"same",
"value",
"must",
"be",
"supplied",
"to",
"the",
"<code",
">",
... | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-kms/src/main/java/com/amazonaws/services/kms/model/EncryptRequest.java#L411-L416 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTextAreaRenderer.java | WTextAreaRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTextArea textArea = (WTextArea) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = textArea.isReadOnly();
xml.appendTagOpen("ui:textarea");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", textArea.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = textArea.getColumns();
int rows = textArea.getRows();
int minLength = textArea.getMinLength();
int maxLength = textArea.getMaxLength();
WComponent submitControl = textArea.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("disabled", textArea.isDisabled(), "true");
xml.appendOptionalAttribute("required", textArea.isMandatory(), "true");
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("toolTip", textArea.getToolTip());
xml.appendOptionalAttribute("accessibleText", textArea.getAccessibleText());
xml.appendOptionalAttribute("rows", rows > 0, rows);
xml.appendOptionalAttribute("cols", cols > 0, cols);
xml.appendOptionalAttribute("buttonId", submitControlId);
String placeholder = textArea.getPlaceholder();
xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder);
String autocomplete = textArea.getAutocomplete();
xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete);
}
xml.appendClose();
if (textArea.isRichTextArea()) {
/*
* This is a nested element instead of an attribute to cater for future enhancements
* such as turning rich text features on or off, or specifying JSON config either as
* a URL attribute or a nested CDATA section.
*/
xml.append("<ui:rtf />");
}
String textString = textArea.getText();
if (textString != null) {
if (textArea.isReadOnly() && textArea.isRichTextArea()) {
// read only we want to output unescaped, but it must still be XML valid.
xml.write(HtmlToXMLUtil.unescapeToXML(textString));
} else {
xml.appendEscaped(textString);
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(textArea, renderContext);
}
xml.appendEndTag("ui:textarea");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTextArea textArea = (WTextArea) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = textArea.isReadOnly();
xml.appendTagOpen("ui:textarea");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", textArea.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = textArea.getColumns();
int rows = textArea.getRows();
int minLength = textArea.getMinLength();
int maxLength = textArea.getMaxLength();
WComponent submitControl = textArea.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("disabled", textArea.isDisabled(), "true");
xml.appendOptionalAttribute("required", textArea.isMandatory(), "true");
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("toolTip", textArea.getToolTip());
xml.appendOptionalAttribute("accessibleText", textArea.getAccessibleText());
xml.appendOptionalAttribute("rows", rows > 0, rows);
xml.appendOptionalAttribute("cols", cols > 0, cols);
xml.appendOptionalAttribute("buttonId", submitControlId);
String placeholder = textArea.getPlaceholder();
xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder);
String autocomplete = textArea.getAutocomplete();
xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete);
}
xml.appendClose();
if (textArea.isRichTextArea()) {
/*
* This is a nested element instead of an attribute to cater for future enhancements
* such as turning rich text features on or off, or specifying JSON config either as
* a URL attribute or a nested CDATA section.
*/
xml.append("<ui:rtf />");
}
String textString = textArea.getText();
if (textString != null) {
if (textArea.isReadOnly() && textArea.isRichTextArea()) {
// read only we want to output unescaped, but it must still be XML valid.
xml.write(HtmlToXMLUtil.unescapeToXML(textString));
} else {
xml.appendEscaped(textString);
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(textArea, renderContext);
}
xml.appendEndTag("ui:textarea");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WTextArea",
"textArea",
"=",
"(",
"WTextArea",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderCo... | Paints the given WTextArea.
@param component the WTextArea to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WTextArea",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTextAreaRenderer.java#L25-L86 |
bazaarvoice/emodb | table/src/main/java/com/bazaarvoice/emodb/table/db/astyanax/CQLStashTableDAO.java | CQLStashTableDAO.fromSameShard | private boolean fromSameShard(ByteBuffer fromInclusive, ByteBuffer toExclusive) {
return fromInclusive.remaining() >= 9 &&
toExclusive.remaining() >= 9 &&
RowKeyUtils.getShardId(fromInclusive) == RowKeyUtils.getShardId(toExclusive) &&
RowKeyUtils.getTableUuid(fromInclusive) == RowKeyUtils.getTableUuid(toExclusive);
} | java | private boolean fromSameShard(ByteBuffer fromInclusive, ByteBuffer toExclusive) {
return fromInclusive.remaining() >= 9 &&
toExclusive.remaining() >= 9 &&
RowKeyUtils.getShardId(fromInclusive) == RowKeyUtils.getShardId(toExclusive) &&
RowKeyUtils.getTableUuid(fromInclusive) == RowKeyUtils.getTableUuid(toExclusive);
} | [
"private",
"boolean",
"fromSameShard",
"(",
"ByteBuffer",
"fromInclusive",
",",
"ByteBuffer",
"toExclusive",
")",
"{",
"return",
"fromInclusive",
".",
"remaining",
"(",
")",
">=",
"9",
"&&",
"toExclusive",
".",
"remaining",
"(",
")",
">=",
"9",
"&&",
"RowKeyUt... | Two tokens are from the same shard if the following are both true:
<ol>
<li>Both tokens are at least 9 bytes long (1 shard + 8 table uuid bytes)</li>
<li>The shard and table uuid for both tokens are identical</li>
</ol> | [
"Two",
"tokens",
"are",
"from",
"the",
"same",
"shard",
"if",
"the",
"following",
"are",
"both",
"true",
":",
"<ol",
">",
"<li",
">",
"Both",
"tokens",
"are",
"at",
"least",
"9",
"bytes",
"long",
"(",
"1",
"shard",
"+",
"8",
"table",
"uuid",
"bytes",... | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/table/src/main/java/com/bazaarvoice/emodb/table/db/astyanax/CQLStashTableDAO.java#L128-L133 |
vincentk/joptimizer | src/main/java/com/joptimizer/optimizers/LPPrimalDualMethod.java | LPPrimalDualMethod.GradLSum | protected DoubleMatrix2D GradLSum(DoubleMatrix1D L, DoubleMatrix1D fiX) {
//DoubleMatrix2D GradLSum = F2.make(1, getDim());
SparseDoubleMatrix2D GradLSum = new SparseDoubleMatrix2D(getDim(), getDim(), getDim(), 0.001, 0.01);
for(int i=0; i<getDim(); i++){
double d = 0;
d -= L.getQuick(i) / fiX.getQuick(i);
d -= L.getQuick(getDim() + i) / fiX.getQuick(getDim() + i);
//GradLSum.setQuick(0, i, d);
GradLSum.setQuick(i, i, d);
}
return GradLSum;
} | java | protected DoubleMatrix2D GradLSum(DoubleMatrix1D L, DoubleMatrix1D fiX) {
//DoubleMatrix2D GradLSum = F2.make(1, getDim());
SparseDoubleMatrix2D GradLSum = new SparseDoubleMatrix2D(getDim(), getDim(), getDim(), 0.001, 0.01);
for(int i=0; i<getDim(); i++){
double d = 0;
d -= L.getQuick(i) / fiX.getQuick(i);
d -= L.getQuick(getDim() + i) / fiX.getQuick(getDim() + i);
//GradLSum.setQuick(0, i, d);
GradLSum.setQuick(i, i, d);
}
return GradLSum;
} | [
"protected",
"DoubleMatrix2D",
"GradLSum",
"(",
"DoubleMatrix1D",
"L",
",",
"DoubleMatrix1D",
"fiX",
")",
"{",
"//DoubleMatrix2D GradLSum = F2.make(1, getDim());\r",
"SparseDoubleMatrix2D",
"GradLSum",
"=",
"new",
"SparseDoubleMatrix2D",
"(",
"getDim",
"(",
")",
",",
"get... | Return the H matrix (that is diagonal).
This is the third addendum of (11.56) of "Convex Optimization".
@see "Convex Optimization, 11.56" | [
"Return",
"the",
"H",
"matrix",
"(",
"that",
"is",
"diagonal",
")",
".",
"This",
"is",
"the",
"third",
"addendum",
"of",
"(",
"11",
".",
"56",
")",
"of",
"Convex",
"Optimization",
"."
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/optimizers/LPPrimalDualMethod.java#L745-L757 |
jtablesaw/tablesaw | core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java | DataFrameJoiner.rightOuter | public Table rightOuter(Table table2, String col2Name) {
return rightOuter(table2, false, col2Name);
} | java | public Table rightOuter(Table table2, String col2Name) {
return rightOuter(table2, false, col2Name);
} | [
"public",
"Table",
"rightOuter",
"(",
"Table",
"table2",
",",
"String",
"col2Name",
")",
"{",
"return",
"rightOuter",
"(",
"table2",
",",
"false",
",",
"col2Name",
")",
";",
"}"
] | Joins the joiner to the table2, using the given column for the second table and returns the resulting table
@param table2 The table to join with
@param col2Name The column to join on. If col2Name refers to a double column, the join is performed after
rounding to integers.
@return The resulting table | [
"Joins",
"the",
"joiner",
"to",
"the",
"table2",
"using",
"the",
"given",
"column",
"for",
"the",
"second",
"table",
"and",
"returns",
"the",
"resulting",
"table"
] | train | https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L578-L580 |
samskivert/pythagoras | src/main/java/pythagoras/d/RectangularShape.java | RectangularShape.setFrameFromCenter | public void setFrameFromCenter (XY center, XY corner) {
setFrameFromCenter(center.x(), center.y(), corner.x(), corner.y());
} | java | public void setFrameFromCenter (XY center, XY corner) {
setFrameFromCenter(center.x(), center.y(), corner.x(), corner.y());
} | [
"public",
"void",
"setFrameFromCenter",
"(",
"XY",
"center",
",",
"XY",
"corner",
")",
"{",
"setFrameFromCenter",
"(",
"center",
".",
"x",
"(",
")",
",",
"center",
".",
"y",
"(",
")",
",",
"corner",
".",
"x",
"(",
")",
",",
"corner",
".",
"y",
"(",... | Sets the location and size of the framing rectangle of this shape based on the supplied
center and corner points. | [
"Sets",
"the",
"location",
"and",
"size",
"of",
"the",
"framing",
"rectangle",
"of",
"this",
"shape",
"based",
"on",
"the",
"supplied",
"center",
"and",
"corner",
"points",
"."
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/RectangularShape.java#L79-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.