repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 192 | func_name stringlengths 5 108 | whole_func_string stringlengths 75 3.91k | language stringclasses 1
value | func_code_string stringlengths 75 3.91k | func_code_tokens listlengths 21 629 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 647 | split_name stringclasses 1
value | func_code_url stringlengths 111 306 |
|---|---|---|---|---|---|---|---|---|---|---|
google/closure-compiler | src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java | JsDocInfoParser.parseAndRecordTypeNode | Node parseAndRecordTypeNode(JsDocToken token) {
return parseAndRecordTypeNode(token, stream.getLineno(), stream.getCharno(),
token == JsDocToken.LEFT_CURLY, false);
} | java | Node parseAndRecordTypeNode(JsDocToken token) {
return parseAndRecordTypeNode(token, stream.getLineno(), stream.getCharno(),
token == JsDocToken.LEFT_CURLY, false);
} | [
"Node",
"parseAndRecordTypeNode",
"(",
"JsDocToken",
"token",
")",
"{",
"return",
"parseAndRecordTypeNode",
"(",
"token",
",",
"stream",
".",
"getLineno",
"(",
")",
",",
"stream",
".",
"getCharno",
"(",
")",
",",
"token",
"==",
"JsDocToken",
".",
"LEFT_CURLY",... | Looks for a type expression at the current token and if found,
returns it. Note that this method consumes input.
@param token The current token.
@return The type expression found or null if none. | [
"Looks",
"for",
"a",
"type",
"expression",
"at",
"the",
"current",
"token",
"and",
"if",
"found",
"returns",
"it",
".",
"Note",
"that",
"this",
"method",
"consumes",
"input",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1496-L1499 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/watched/WatchedDoubleStepQREigen_DDRM.java | WatchedDoubleStepQREigen_DDRM.performImplicitDoubleStep | public void performImplicitDoubleStep(int x1, int x2 , double real , double img ) {
double a11 = A.get(x1,x1);
double a21 = A.get(x1+1,x1);
double a12 = A.get(x1,x1+1);
double a22 = A.get(x1+1,x1+1);
double a32 = A.get(x1+2,x1+1);
double p_plus_t = 2.0*real;
double p_times_t = real*real + img*img;
double b11,b21,b31;
if( useStandardEq ) {
b11 = (a11*a11 - p_plus_t*a11+p_times_t)/a21 + a12;
b21 = a11+a22-p_plus_t;
b31 = a32;
} else {
// this is different from the version in the book and seems in my testing to be more resilient to
// over flow issues
b11 = (a11*a11 - p_plus_t*a11+p_times_t) + a12*a21;
b21 = (a11+a22-p_plus_t)*a21;
b31 = a32*a21;
}
performImplicitDoubleStep(x1, x2, b11, b21, b31);
} | java | public void performImplicitDoubleStep(int x1, int x2 , double real , double img ) {
double a11 = A.get(x1,x1);
double a21 = A.get(x1+1,x1);
double a12 = A.get(x1,x1+1);
double a22 = A.get(x1+1,x1+1);
double a32 = A.get(x1+2,x1+1);
double p_plus_t = 2.0*real;
double p_times_t = real*real + img*img;
double b11,b21,b31;
if( useStandardEq ) {
b11 = (a11*a11 - p_plus_t*a11+p_times_t)/a21 + a12;
b21 = a11+a22-p_plus_t;
b31 = a32;
} else {
// this is different from the version in the book and seems in my testing to be more resilient to
// over flow issues
b11 = (a11*a11 - p_plus_t*a11+p_times_t) + a12*a21;
b21 = (a11+a22-p_plus_t)*a21;
b31 = a32*a21;
}
performImplicitDoubleStep(x1, x2, b11, b21, b31);
} | [
"public",
"void",
"performImplicitDoubleStep",
"(",
"int",
"x1",
",",
"int",
"x2",
",",
"double",
"real",
",",
"double",
"img",
")",
"{",
"double",
"a11",
"=",
"A",
".",
"get",
"(",
"x1",
",",
"x1",
")",
";",
"double",
"a21",
"=",
"A",
".",
"get",
... | Performs an implicit double step given the set of two imaginary eigenvalues provided.
Since one eigenvalue is the complex conjugate of the other only one set of real and imaginary
numbers is needed.
@param x1 upper index of submatrix.
@param x2 lower index of submatrix.
@param real Real component of each of the eigenvalues.
@param img Imaginary component of one of the eigenvalues. | [
"Performs",
"an",
"implicit",
"double",
"step",
"given",
"the",
"set",
"of",
"two",
"imaginary",
"eigenvalues",
"provided",
".",
"Since",
"one",
"eigenvalue",
"is",
"the",
"complex",
"conjugate",
"of",
"the",
"other",
"only",
"one",
"set",
"of",
"real",
"and... | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/watched/WatchedDoubleStepQREigen_DDRM.java#L252-L276 |
OpenBEL/openbel-framework | org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/cache/CacheUtil.java | CacheUtil.createLocalHash | public static File createLocalHash(File resource, String remoteLocation)
throws ResourceDownloadError {
File localHashFile;
try {
String contents = readFileToString(resource);
String hashValue = hasher.hashValue(contents);
String absPath = resource.getAbsolutePath();
String localHashPath = absPath + SHA256_EXTENSION;
localHashFile = new File(localHashPath);
write(localHashFile, hashValue, UTF_8);
return localHashFile;
} catch (IOException e) {
throw new ResourceDownloadError(remoteLocation, e.getMessage());
}
} | java | public static File createLocalHash(File resource, String remoteLocation)
throws ResourceDownloadError {
File localHashFile;
try {
String contents = readFileToString(resource);
String hashValue = hasher.hashValue(contents);
String absPath = resource.getAbsolutePath();
String localHashPath = absPath + SHA256_EXTENSION;
localHashFile = new File(localHashPath);
write(localHashFile, hashValue, UTF_8);
return localHashFile;
} catch (IOException e) {
throw new ResourceDownloadError(remoteLocation, e.getMessage());
}
} | [
"public",
"static",
"File",
"createLocalHash",
"(",
"File",
"resource",
",",
"String",
"remoteLocation",
")",
"throws",
"ResourceDownloadError",
"{",
"File",
"localHashFile",
";",
"try",
"{",
"String",
"contents",
"=",
"readFileToString",
"(",
"resource",
")",
";"... | Creates a hash of the contents of the {@link File} <tt>resource</tt> and
writes it to a file alongside the real resource file. The hash file
can be found by appending {@link ResourceType#SHA256_EXTENSION} to the
resource path.
@param resource {@link File}, the local resource file
@param remoteLocation {@link String}, the remote resource location
@return {@link File}, the local hash file that was created
@throws IOException Thrown if there was an IO error reading the local
resource file, or writing the local hash file
@throws ResourceDownloadError | [
"Creates",
"a",
"hash",
"of",
"the",
"contents",
"of",
"the",
"{",
"@link",
"File",
"}",
"<tt",
">",
"resource<",
"/",
"tt",
">",
"and",
"writes",
"it",
"to",
"a",
"file",
"alongside",
"the",
"real",
"resource",
"file",
".",
"The",
"hash",
"file",
"c... | train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/cache/CacheUtil.java#L237-L253 |
AlmogBaku/IntlPhoneInput | intlphoneinput/src/main/java/net/rimoto/intlphoneinput/CountrySpinnerAdapter.java | CountrySpinnerAdapter.getView | @Override
public View getView(int position, View convertView, ViewGroup parent) {
Country country = getItem(position);
if (convertView == null) {
convertView = new ImageView(getContext());
}
((ImageView) convertView).setImageResource(getFlagResource(country));
return convertView;
} | java | @Override
public View getView(int position, View convertView, ViewGroup parent) {
Country country = getItem(position);
if (convertView == null) {
convertView = new ImageView(getContext());
}
((ImageView) convertView).setImageResource(getFlagResource(country));
return convertView;
} | [
"@",
"Override",
"public",
"View",
"getView",
"(",
"int",
"position",
",",
"View",
"convertView",
",",
"ViewGroup",
"parent",
")",
"{",
"Country",
"country",
"=",
"getItem",
"(",
"position",
")",
";",
"if",
"(",
"convertView",
"==",
"null",
")",
"{",
"co... | Drop down selected view
@param position position of selected item
@param convertView View of selected item
@param parent parent of selected view
@return convertView | [
"Drop",
"down",
"selected",
"view"
] | train | https://github.com/AlmogBaku/IntlPhoneInput/blob/ac7313a2d1683feb4d535d5dbee6676b53879059/intlphoneinput/src/main/java/net/rimoto/intlphoneinput/CountrySpinnerAdapter.java#L61-L72 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geodesy/SphereUtil.java | SphereUtil.crossTrackDistanceRad | public static double crossTrackDistanceRad(double lat1, double lon1, double lat2, double lon2, double latQ, double lonQ, double dist1Q) {
final double dlon12 = lon2 - lon1;
final double dlon1Q = lonQ - lon1;
// Compute trigonometric functions only once.
final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
final double slat1 = sinAndCos(lat1, tmp), clat1 = tmp.value;
final double slatQ = sinAndCos(latQ, tmp), clatQ = tmp.value;
final double slat2 = sinAndCos(lat2, tmp), clat2 = tmp.value;
// / Compute the course
// y = sin(dlon) * cos(lat2)
final double sdlon12 = sinAndCos(dlon12, tmp), cdlon12 = tmp.value;
final double sdlon1Q = sinAndCos(dlon1Q, tmp), cdlon1Q = tmp.value;
final double yE = sdlon12 * clat2;
final double yQ = sdlon1Q * clatQ;
// x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dlon)
final double xE = clat1 * slat2 - slat1 * clat2 * cdlon12;
final double xQ = clat1 * slatQ - slat1 * clatQ * cdlon1Q;
final double crs12 = atan2(yE, xE);
final double crs1Q = atan2(yQ, xQ);
// / Calculate cross-track distance
return asin(sin(dist1Q) * sin(crs1Q - crs12));
} | java | public static double crossTrackDistanceRad(double lat1, double lon1, double lat2, double lon2, double latQ, double lonQ, double dist1Q) {
final double dlon12 = lon2 - lon1;
final double dlon1Q = lonQ - lon1;
// Compute trigonometric functions only once.
final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
final double slat1 = sinAndCos(lat1, tmp), clat1 = tmp.value;
final double slatQ = sinAndCos(latQ, tmp), clatQ = tmp.value;
final double slat2 = sinAndCos(lat2, tmp), clat2 = tmp.value;
// / Compute the course
// y = sin(dlon) * cos(lat2)
final double sdlon12 = sinAndCos(dlon12, tmp), cdlon12 = tmp.value;
final double sdlon1Q = sinAndCos(dlon1Q, tmp), cdlon1Q = tmp.value;
final double yE = sdlon12 * clat2;
final double yQ = sdlon1Q * clatQ;
// x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dlon)
final double xE = clat1 * slat2 - slat1 * clat2 * cdlon12;
final double xQ = clat1 * slatQ - slat1 * clatQ * cdlon1Q;
final double crs12 = atan2(yE, xE);
final double crs1Q = atan2(yQ, xQ);
// / Calculate cross-track distance
return asin(sin(dist1Q) * sin(crs1Q - crs12));
} | [
"public",
"static",
"double",
"crossTrackDistanceRad",
"(",
"double",
"lat1",
",",
"double",
"lon1",
",",
"double",
"lat2",
",",
"double",
"lon2",
",",
"double",
"latQ",
",",
"double",
"lonQ",
",",
"double",
"dist1Q",
")",
"{",
"final",
"double",
"dlon12",
... | Compute the cross-track distance.
@param lat1 Latitude of starting point.
@param lon1 Longitude of starting point.
@param lat2 Latitude of destination point.
@param lon2 Longitude of destination point.
@param latQ Latitude of query point.
@param lonQ Longitude of query point.
@param dist1Q Distance from starting point to query point on unit sphere
@return Cross-track distance on unit sphere. May be negative - this gives
the side. | [
"Compute",
"the",
"cross",
"-",
"track",
"distance",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geodesy/SphereUtil.java#L436-L462 |
bbottema/outlook-message-parser | src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java | OutlookMessageParser.checkRecipientDocumentEntry | private void checkRecipientDocumentEntry(final DocumentEntry de, final OutlookRecipient recipient)
throws IOException {
if (de.getName().startsWith(PROPS_KEY)) {
//TODO: parse properties stream
final List<DocumentEntry> deList = getDocumentEntriesFromPropertiesStream(de);
for (final DocumentEntry deFromProps : deList) {
final OutlookMessageProperty msgProp = getMessagePropertyFromDocumentEntry(deFromProps);
recipient.setProperty(msgProp);
}
} else {
recipient.setProperty(getMessagePropertyFromDocumentEntry(de));
}
} | java | private void checkRecipientDocumentEntry(final DocumentEntry de, final OutlookRecipient recipient)
throws IOException {
if (de.getName().startsWith(PROPS_KEY)) {
//TODO: parse properties stream
final List<DocumentEntry> deList = getDocumentEntriesFromPropertiesStream(de);
for (final DocumentEntry deFromProps : deList) {
final OutlookMessageProperty msgProp = getMessagePropertyFromDocumentEntry(deFromProps);
recipient.setProperty(msgProp);
}
} else {
recipient.setProperty(getMessagePropertyFromDocumentEntry(de));
}
} | [
"private",
"void",
"checkRecipientDocumentEntry",
"(",
"final",
"DocumentEntry",
"de",
",",
"final",
"OutlookRecipient",
"recipient",
")",
"throws",
"IOException",
"{",
"if",
"(",
"de",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"PROPS_KEY",
")",
")",
"... | Parses a recipient document entry which can either be a simple entry or
a stream that has to be split up into multiple document entries again.
The parsed information is put into the {@link OutlookRecipient} object.
@param de The current node in the .msg file.
@param recipient The resulting {@link OutlookRecipient} object.
@throws IOException Thrown if the .msg file could not be parsed. | [
"Parses",
"a",
"recipient",
"document",
"entry",
"which",
"can",
"either",
"be",
"a",
"simple",
"entry",
"or",
"a",
"stream",
"that",
"has",
"to",
"be",
"split",
"up",
"into",
"multiple",
"document",
"entries",
"again",
".",
"The",
"parsed",
"information",
... | train | https://github.com/bbottema/outlook-message-parser/blob/ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java#L233-L245 |
TestFX/Monocle | src/main/java/com/sun/glass/ui/monocle/TouchState.java | TouchState.getWindow | MonocleWindow getWindow(boolean recalculateCache, MonocleWindow fallback) {
if (window == null) {
window = fallback;
}
if (recalculateCache) {
window = fallback;
if (primaryID >= 0) {
Point p = getPointForID(primaryID);
if (p != null) {
window = (MonocleWindow)
MonocleWindowManager.getInstance()
.getWindowForLocation(p.x, p.y);
}
}
}
return window;
} | java | MonocleWindow getWindow(boolean recalculateCache, MonocleWindow fallback) {
if (window == null) {
window = fallback;
}
if (recalculateCache) {
window = fallback;
if (primaryID >= 0) {
Point p = getPointForID(primaryID);
if (p != null) {
window = (MonocleWindow)
MonocleWindowManager.getInstance()
.getWindowForLocation(p.x, p.y);
}
}
}
return window;
} | [
"MonocleWindow",
"getWindow",
"(",
"boolean",
"recalculateCache",
",",
"MonocleWindow",
"fallback",
")",
"{",
"if",
"(",
"window",
"==",
"null",
")",
"{",
"window",
"=",
"fallback",
";",
"}",
"if",
"(",
"recalculateCache",
")",
"{",
"window",
"=",
"fallback"... | Returns the Glass window on which this event state is located.
assignPrimaryID() should be called before this method.
@param recalculateCache true if the cached value should be discarded and
recomputed
@param fallback the window to use if no primary ID is available | [
"Returns",
"the",
"Glass",
"window",
"on",
"which",
"this",
"event",
"state",
"is",
"located",
".",
"assignPrimaryID",
"()",
"should",
"be",
"called",
"before",
"this",
"method",
"."
] | train | https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/TouchState.java#L80-L96 |
UrielCh/ovh-java-sdk | ovh-java-sdk-sslGateway/src/main/java/net/minidev/ovh/api/ApiOvhSslGateway.java | ApiOvhSslGateway.serviceName_server_id_PUT | public void serviceName_server_id_PUT(String serviceName, Long id, OvhServer body) throws IOException {
String qPath = "/sslGateway/{serviceName}/server/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_server_id_PUT(String serviceName, Long id, OvhServer body) throws IOException {
String qPath = "/sslGateway/{serviceName}/server/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_server_id_PUT",
"(",
"String",
"serviceName",
",",
"Long",
"id",
",",
"OvhServer",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/sslGateway/{serviceName}/server/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
... | Alter this object properties
REST: PUT /sslGateway/{serviceName}/server/{id}
@param body [required] New object properties
@param serviceName [required] The internal name of your SSL Gateway
@param id [required] Id of your server
API beta | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-sslGateway/src/main/java/net/minidev/ovh/api/ApiOvhSslGateway.java#L315-L319 |
podio/podio-java | src/main/java/com/podio/calendar/CalendarAPI.java | CalendarAPI.getGlobal | public List<Event> getGlobal(LocalDate dateFrom, LocalDate dateTo,
List<Integer> spaceIds, ReferenceType... types) {
return getCalendar("", dateFrom, dateTo, spaceIds, types);
} | java | public List<Event> getGlobal(LocalDate dateFrom, LocalDate dateTo,
List<Integer> spaceIds, ReferenceType... types) {
return getCalendar("", dateFrom, dateTo, spaceIds, types);
} | [
"public",
"List",
"<",
"Event",
">",
"getGlobal",
"(",
"LocalDate",
"dateFrom",
",",
"LocalDate",
"dateTo",
",",
"List",
"<",
"Integer",
">",
"spaceIds",
",",
"ReferenceType",
"...",
"types",
")",
"{",
"return",
"getCalendar",
"(",
"\"\"",
",",
"dateFrom",
... | Returns all items that the user have access to and all tasks that are
assigned to the user. The items and tasks can be filtered by a list of
space ids, but tasks without a reference will always be returned.
@param dateFrom
The from date
@param dateTo
The to date
@param types
The types of events that should be returned. Leave out to get
all types of events.
@return The events in the calendar | [
"Returns",
"all",
"items",
"that",
"the",
"user",
"have",
"access",
"to",
"and",
"all",
"tasks",
"that",
"are",
"assigned",
"to",
"the",
"user",
".",
"The",
"items",
"and",
"tasks",
"can",
"be",
"filtered",
"by",
"a",
"list",
"of",
"space",
"ids",
"but... | train | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/calendar/CalendarAPI.java#L103-L106 |
cdk/cdk | legacy/src/main/java/org/openscience/cdk/geometry/GeometryTools.java | GeometryTools.scaleMolecule | public static void scaleMolecule(IAtomContainer atomCon, Dimension areaDim, double fillFactor) {
Dimension molDim = get2DDimension(atomCon);
double widthFactor = (double) areaDim.width / (double) molDim.width;
double heightFactor = (double) areaDim.height / (double) molDim.height;
double scaleFactor = Math.min(widthFactor, heightFactor) * fillFactor;
scaleMolecule(atomCon, scaleFactor);
} | java | public static void scaleMolecule(IAtomContainer atomCon, Dimension areaDim, double fillFactor) {
Dimension molDim = get2DDimension(atomCon);
double widthFactor = (double) areaDim.width / (double) molDim.width;
double heightFactor = (double) areaDim.height / (double) molDim.height;
double scaleFactor = Math.min(widthFactor, heightFactor) * fillFactor;
scaleMolecule(atomCon, scaleFactor);
} | [
"public",
"static",
"void",
"scaleMolecule",
"(",
"IAtomContainer",
"atomCon",
",",
"Dimension",
"areaDim",
",",
"double",
"fillFactor",
")",
"{",
"Dimension",
"molDim",
"=",
"get2DDimension",
"(",
"atomCon",
")",
";",
"double",
"widthFactor",
"=",
"(",
"double"... | Scales a molecule such that it fills a given percentage of a given
dimension.
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
@param atomCon The molecule to be scaled
@param areaDim The dimension to be filled
@param fillFactor The percentage of the dimension to be filled | [
"Scales",
"a",
"molecule",
"such",
"that",
"it",
"fills",
"a",
"given",
"percentage",
"of",
"a",
"given",
"dimension",
".",
"See",
"comment",
"for",
"center",
"(",
"IAtomContainer",
"atomCon",
"Dimension",
"areaDim",
"HashMap",
"renderingCoordinates",
")",
"for"... | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/legacy/src/main/java/org/openscience/cdk/geometry/GeometryTools.java#L151-L157 |
codescape/bitvunit | bitvunit-core/src/main/java/de/codescape/bitvunit/util/html/HtmlPageUtil.java | HtmlPageUtil.toHtmlPage | public static HtmlPage toHtmlPage(Reader reader) {
try {
return toHtmlPage(IOUtils.toString(reader));
} catch (IOException e) {
throw new RuntimeException("Error creating HtmlPage from Reader.", e);
}
} | java | public static HtmlPage toHtmlPage(Reader reader) {
try {
return toHtmlPage(IOUtils.toString(reader));
} catch (IOException e) {
throw new RuntimeException("Error creating HtmlPage from Reader.", e);
}
} | [
"public",
"static",
"HtmlPage",
"toHtmlPage",
"(",
"Reader",
"reader",
")",
"{",
"try",
"{",
"return",
"toHtmlPage",
"(",
"IOUtils",
".",
"toString",
"(",
"reader",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeE... | Creates a {@link HtmlPage} from a given {@link Reader} that reads the HTML code for that page.
@param reader {@link Reader} that reads the HTML code
@return {@link HtmlPage} for this {@link Reader} | [
"Creates",
"a",
"{",
"@link",
"HtmlPage",
"}",
"from",
"a",
"given",
"{",
"@link",
"Reader",
"}",
"that",
"reads",
"the",
"HTML",
"code",
"for",
"that",
"page",
"."
] | train | https://github.com/codescape/bitvunit/blob/cef6d9af60d684e41294981c10b6d92c8f063a4e/bitvunit-core/src/main/java/de/codescape/bitvunit/util/html/HtmlPageUtil.java#L61-L67 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Retryer.java | Retryer.timeout | public Retryer<R> timeout(long duration, TimeUnit timeUnit) {
return timeout(duration, timeUnit, null);
} | java | public Retryer<R> timeout(long duration, TimeUnit timeUnit) {
return timeout(duration, timeUnit, null);
} | [
"public",
"Retryer",
"<",
"R",
">",
"timeout",
"(",
"long",
"duration",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"timeout",
"(",
"duration",
",",
"timeUnit",
",",
"null",
")",
";",
"}"
] | Timing out after the specified time limit
@param duration
@param timeUnit
@return | [
"Timing",
"out",
"after",
"the",
"specified",
"time",
"limit"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Retryer.java#L76-L78 |
RestComm/sip-servlets | sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java | FacebookRestClient.feed_publishStoryToUser | public boolean feed_publishStoryToUser(CharSequence title, CharSequence body, Integer priority)
throws FacebookException, IOException {
return feed_publishStoryToUser(title, body, null, priority);
} | java | public boolean feed_publishStoryToUser(CharSequence title, CharSequence body, Integer priority)
throws FacebookException, IOException {
return feed_publishStoryToUser(title, body, null, priority);
} | [
"public",
"boolean",
"feed_publishStoryToUser",
"(",
"CharSequence",
"title",
",",
"CharSequence",
"body",
",",
"Integer",
"priority",
")",
"throws",
"FacebookException",
",",
"IOException",
"{",
"return",
"feed_publishStoryToUser",
"(",
"title",
",",
"body",
",",
"... | Publish a story to the logged-in user's newsfeed.
@param title the title of the feed story
@param body the body of the feed story
@param priority
@return whether the story was successfully published; false in case of permission error
@see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishStoryToUser">
Developers Wiki: Feed.publishStoryToUser</a> | [
"Publish",
"a",
"story",
"to",
"the",
"logged",
"-",
"in",
"user",
"s",
"newsfeed",
"."
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L350-L353 |
Jasig/uPortal | uPortal-persondir/src/main/java/org/apereo/portal/persondir/PortalRootPersonAttributeDao.java | PortalRootPersonAttributeDao.getPerson | @Override
public IPersonAttributes getPerson(String uid) {
final IPersonAttributes rslt = delegatePersonAttributeDao.getPerson(uid);
if (rslt == null) {
// Nothing we can do with that
return null;
}
return postProcessPerson(rslt, uid);
} | java | @Override
public IPersonAttributes getPerson(String uid) {
final IPersonAttributes rslt = delegatePersonAttributeDao.getPerson(uid);
if (rslt == null) {
// Nothing we can do with that
return null;
}
return postProcessPerson(rslt, uid);
} | [
"@",
"Override",
"public",
"IPersonAttributes",
"getPerson",
"(",
"String",
"uid",
")",
"{",
"final",
"IPersonAttributes",
"rslt",
"=",
"delegatePersonAttributeDao",
".",
"getPerson",
"(",
"uid",
")",
";",
"if",
"(",
"rslt",
"==",
"null",
")",
"{",
"// Nothing... | This method is for "filling" a specific individual.
@param uid The username (identity) of a known individual
@return A completely "filled" person, including overrides, or <code>null</code> if the person
is unknown | [
"This",
"method",
"is",
"for",
"filling",
"a",
"specific",
"individual",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-persondir/src/main/java/org/apereo/portal/persondir/PortalRootPersonAttributeDao.java#L110-L120 |
azkaban/azkaban | az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java | HadoopConfigurationInjector.getPath | public static String getPath(Props props, String workingDir) {
return new File(workingDir, getDirName(props)).toString();
} | java | public static String getPath(Props props, String workingDir) {
return new File(workingDir, getDirName(props)).toString();
} | [
"public",
"static",
"String",
"getPath",
"(",
"Props",
"props",
",",
"String",
"workingDir",
")",
"{",
"return",
"new",
"File",
"(",
"workingDir",
",",
"getDirName",
"(",
"props",
")",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Gets the path to the directory in which the generated links and Hadoop
conf properties files are written.
@param props The Azkaban properties
@param workingDir The Azkaban job working directory | [
"Gets",
"the",
"path",
"to",
"the",
"directory",
"in",
"which",
"the",
"generated",
"links",
"and",
"Hadoop",
"conf",
"properties",
"files",
"are",
"written",
"."
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java#L188-L190 |
JamesIry/jADT | jADT-core/src/main/java/com/pogofish/jadt/JADT.java | JADT.standardConfigDriver | public static JADT standardConfigDriver() {
logger.fine("Using standard configuration.");
final SourceFactory sourceFactory = new FileSourceFactory();
final ClassBodyEmitter classBodyEmitter = new StandardClassBodyEmitter();
final ConstructorEmitter constructorEmitter = new StandardConstructorEmitter(classBodyEmitter);
final DataTypeEmitter dataTypeEmitter = new StandardDataTypeEmitter(classBodyEmitter, constructorEmitter);
final DocEmitter docEmitter = new StandardDocEmitter(dataTypeEmitter);
final Parser parser = new StandardParser(new JavaCCParserImplFactory());
final Checker checker = new StandardChecker();
final SinkFactoryFactory factoryFactory = new FileSinkFactoryFactory();
return new JADT(sourceFactory, parser, checker, docEmitter, factoryFactory);
} | java | public static JADT standardConfigDriver() {
logger.fine("Using standard configuration.");
final SourceFactory sourceFactory = new FileSourceFactory();
final ClassBodyEmitter classBodyEmitter = new StandardClassBodyEmitter();
final ConstructorEmitter constructorEmitter = new StandardConstructorEmitter(classBodyEmitter);
final DataTypeEmitter dataTypeEmitter = new StandardDataTypeEmitter(classBodyEmitter, constructorEmitter);
final DocEmitter docEmitter = new StandardDocEmitter(dataTypeEmitter);
final Parser parser = new StandardParser(new JavaCCParserImplFactory());
final Checker checker = new StandardChecker();
final SinkFactoryFactory factoryFactory = new FileSinkFactoryFactory();
return new JADT(sourceFactory, parser, checker, docEmitter, factoryFactory);
} | [
"public",
"static",
"JADT",
"standardConfigDriver",
"(",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Using standard configuration.\"",
")",
";",
"final",
"SourceFactory",
"sourceFactory",
"=",
"new",
"FileSourceFactory",
"(",
")",
";",
"final",
"ClassBodyEmitter",
"cla... | Convenient factory method to create a complete standard configuration
@return Driver configured with all the Standard bits | [
"Convenient",
"factory",
"method",
"to",
"create",
"a",
"complete",
"standard",
"configuration"
] | train | https://github.com/JamesIry/jADT/blob/92ee94b6624cd673851497d78c218837dcf02b8a/jADT-core/src/main/java/com/pogofish/jadt/JADT.java#L91-L103 |
Blazebit/blaze-utils | blaze-common-utils/src/main/java/com/blazebit/security/BCrypt.java | BCrypt.ekskey | private void ekskey(final byte data[], final byte key[]) {
int i;
final int koffp[] = {0}, doffp[] = {0};
final int lr[] = {0, 0};
final int plen = P.length, slen = S.length;
for (i = 0; i < plen; i++) {
P[i] = P[i] ^ streamtoword(key, koffp);
}
for (i = 0; i < plen; i += 2) {
lr[0] ^= streamtoword(data, doffp);
lr[1] ^= streamtoword(data, doffp);
encipher(lr, 0);
P[i] = lr[0];
P[i + 1] = lr[1];
}
for (i = 0; i < slen; i += 2) {
lr[0] ^= streamtoword(data, doffp);
lr[1] ^= streamtoword(data, doffp);
encipher(lr, 0);
S[i] = lr[0];
S[i + 1] = lr[1];
}
} | java | private void ekskey(final byte data[], final byte key[]) {
int i;
final int koffp[] = {0}, doffp[] = {0};
final int lr[] = {0, 0};
final int plen = P.length, slen = S.length;
for (i = 0; i < plen; i++) {
P[i] = P[i] ^ streamtoword(key, koffp);
}
for (i = 0; i < plen; i += 2) {
lr[0] ^= streamtoword(data, doffp);
lr[1] ^= streamtoword(data, doffp);
encipher(lr, 0);
P[i] = lr[0];
P[i + 1] = lr[1];
}
for (i = 0; i < slen; i += 2) {
lr[0] ^= streamtoword(data, doffp);
lr[1] ^= streamtoword(data, doffp);
encipher(lr, 0);
S[i] = lr[0];
S[i + 1] = lr[1];
}
} | [
"private",
"void",
"ekskey",
"(",
"final",
"byte",
"data",
"[",
"]",
",",
"final",
"byte",
"key",
"[",
"]",
")",
"{",
"int",
"i",
";",
"final",
"int",
"koffp",
"[",
"]",
"=",
"{",
"0",
"}",
",",
"doffp",
"[",
"]",
"=",
"{",
"0",
"}",
";",
"... | Perform the "enhanced key schedule" step described by Provos and Mazieres
in "A Future-Adaptable Password Scheme"
http://www.openbsd.org/papers/bcrypt-paper.ps
@param data salt information
@param key password information | [
"Perform",
"the",
"enhanced",
"key",
"schedule",
"step",
"described",
"by",
"Provos",
"and",
"Mazieres",
"in",
"A",
"Future",
"-",
"Adaptable",
"Password",
"Scheme",
"http",
":",
"//",
"www",
".",
"openbsd",
".",
"org",
"/",
"papers",
"/",
"bcrypt",
"-",
... | train | https://github.com/Blazebit/blaze-utils/blob/3e35a694a8f71d515aad066196acd523994d6aaa/blaze-common-utils/src/main/java/com/blazebit/security/BCrypt.java#L522-L547 |
lucee/Lucee | core/src/main/java/lucee/runtime/type/scope/client/ClientFile.java | ClientFile.getInstance | public static Client getInstance(String name, PageContext pc, Log log) {
Resource res = _loadResource(pc.getConfig(), SCOPE_CLIENT, name, pc.getCFID());
Struct data = _loadData(pc, res, log);
return new ClientFile(pc, res, data);
} | java | public static Client getInstance(String name, PageContext pc, Log log) {
Resource res = _loadResource(pc.getConfig(), SCOPE_CLIENT, name, pc.getCFID());
Struct data = _loadData(pc, res, log);
return new ClientFile(pc, res, data);
} | [
"public",
"static",
"Client",
"getInstance",
"(",
"String",
"name",
",",
"PageContext",
"pc",
",",
"Log",
"log",
")",
"{",
"Resource",
"res",
"=",
"_loadResource",
"(",
"pc",
".",
"getConfig",
"(",
")",
",",
"SCOPE_CLIENT",
",",
"name",
",",
"pc",
".",
... | load new instance of the class
@param name
@param pc
@param log
@return | [
"load",
"new",
"instance",
"of",
"the",
"class"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/type/scope/client/ClientFile.java#L59-L64 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java | IoUtil.writeObjects | public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws IORuntimeException {
ObjectOutputStream osw = null;
try {
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
for (Object content : contents) {
if (content != null) {
osw.writeObject(content);
osw.flush();
}
}
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
if (isCloseOut) {
close(osw);
}
}
} | java | public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws IORuntimeException {
ObjectOutputStream osw = null;
try {
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
for (Object content : contents) {
if (content != null) {
osw.writeObject(content);
osw.flush();
}
}
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
if (isCloseOut) {
close(osw);
}
}
} | [
"public",
"static",
"void",
"writeObjects",
"(",
"OutputStream",
"out",
",",
"boolean",
"isCloseOut",
",",
"Serializable",
"...",
"contents",
")",
"throws",
"IORuntimeException",
"{",
"ObjectOutputStream",
"osw",
"=",
"null",
";",
"try",
"{",
"osw",
"=",
"out",
... | 将多部分内容写到流中
@param out 输出流
@param isCloseOut 写入完毕是否关闭输出流
@param contents 写入的内容
@throws IORuntimeException IO异常 | [
"将多部分内容写到流中"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java#L932-L949 |
alkacon/opencms-core | src/org/opencms/cmis/CmsCmisRelationHelper.java | CmsCmisRelationHelper.collectAllowableActions | protected AllowableActions collectAllowableActions(CmsObject cms, CmsResource file, CmsRelation relation) {
try {
Set<Action> aas = new LinkedHashSet<Action>();
AllowableActionsImpl result = new AllowableActionsImpl();
CmsLock lock = cms.getLock(file);
CmsUser user = cms.getRequestContext().getCurrentUser();
boolean canWrite = !cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (lock.isOwnedBy(user) || lock.isLockableBy(user))
&& cms.hasPermissions(file, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT);
addAction(aas, Action.CAN_GET_PROPERTIES, true);
addAction(aas, Action.CAN_DELETE_OBJECT, canWrite && !relation.getType().isDefinedInContent());
result.setAllowableActions(aas);
return result;
} catch (CmsException e) {
handleCmsException(e);
return null;
}
} | java | protected AllowableActions collectAllowableActions(CmsObject cms, CmsResource file, CmsRelation relation) {
try {
Set<Action> aas = new LinkedHashSet<Action>();
AllowableActionsImpl result = new AllowableActionsImpl();
CmsLock lock = cms.getLock(file);
CmsUser user = cms.getRequestContext().getCurrentUser();
boolean canWrite = !cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (lock.isOwnedBy(user) || lock.isLockableBy(user))
&& cms.hasPermissions(file, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT);
addAction(aas, Action.CAN_GET_PROPERTIES, true);
addAction(aas, Action.CAN_DELETE_OBJECT, canWrite && !relation.getType().isDefinedInContent());
result.setAllowableActions(aas);
return result;
} catch (CmsException e) {
handleCmsException(e);
return null;
}
} | [
"protected",
"AllowableActions",
"collectAllowableActions",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"file",
",",
"CmsRelation",
"relation",
")",
"{",
"try",
"{",
"Set",
"<",
"Action",
">",
"aas",
"=",
"new",
"LinkedHashSet",
"<",
"Action",
">",
"(",
")",
... | Collects the allowable actions for a relation.<p>
@param cms the current CMS context
@param file the source of the relation
@param relation the relation object
@return the allowable actions for the given resource | [
"Collects",
"the",
"allowable",
"actions",
"for",
"a",
"relation",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/cmis/CmsCmisRelationHelper.java#L384-L403 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java | ImageMiscOps.fillBorder | public static void fillBorder(GrayF64 input, double value, int radius ) {
// top and bottom
for (int y = 0; y < radius; y++) {
int indexTop = input.startIndex + y * input.stride;
int indexBottom = input.startIndex + (input.height-y-1) * input.stride;
for (int x = 0; x < input.width; x++) {
input.data[indexTop++] = value;
input.data[indexBottom++] = value;
}
}
// left and right
int h = input.height-radius;
int indexStart = input.startIndex + radius*input.stride;
for (int x = 0; x < radius; x++) {
int indexLeft = indexStart + x;
int indexRight = indexStart + input.width-1-x;
for (int y = radius; y < h; y++) {
input.data[indexLeft] = value;
input.data[indexRight] = value;
indexLeft += input.stride;
indexRight += input.stride;
}
}
} | java | public static void fillBorder(GrayF64 input, double value, int radius ) {
// top and bottom
for (int y = 0; y < radius; y++) {
int indexTop = input.startIndex + y * input.stride;
int indexBottom = input.startIndex + (input.height-y-1) * input.stride;
for (int x = 0; x < input.width; x++) {
input.data[indexTop++] = value;
input.data[indexBottom++] = value;
}
}
// left and right
int h = input.height-radius;
int indexStart = input.startIndex + radius*input.stride;
for (int x = 0; x < radius; x++) {
int indexLeft = indexStart + x;
int indexRight = indexStart + input.width-1-x;
for (int y = radius; y < h; y++) {
input.data[indexLeft] = value;
input.data[indexRight] = value;
indexLeft += input.stride;
indexRight += input.stride;
}
}
} | [
"public",
"static",
"void",
"fillBorder",
"(",
"GrayF64",
"input",
",",
"double",
"value",
",",
"int",
"radius",
")",
"{",
"// top and bottom",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"radius",
";",
"y",
"++",
")",
"{",
"int",
"indexTop",
"=... | Fills the outside border with the specified value
@param input An image.
@param value The value that the image is being filled with.
@param radius Border width. | [
"Fills",
"the",
"outside",
"border",
"with",
"the",
"specified",
"value"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageMiscOps.java#L2906-L2932 |
SvenEwald/xmlbeam | src/main/java/org/xmlbeam/XBProjector.java | XBProjector.autoMapEmptyDocument | public <T> XBAutoMap<T> autoMapEmptyDocument(final Class<T> valueType) {
Document document = xMLFactoriesConfig.createDocumentBuilder().newDocument();
return createAutoMapForDocument(valueType, document);
} | java | public <T> XBAutoMap<T> autoMapEmptyDocument(final Class<T> valueType) {
Document document = xMLFactoriesConfig.createDocumentBuilder().newDocument();
return createAutoMapForDocument(valueType, document);
} | [
"public",
"<",
"T",
">",
"XBAutoMap",
"<",
"T",
">",
"autoMapEmptyDocument",
"(",
"final",
"Class",
"<",
"T",
">",
"valueType",
")",
"{",
"Document",
"document",
"=",
"xMLFactoriesConfig",
".",
"createDocumentBuilder",
"(",
")",
".",
"newDocument",
"(",
")",... | Create an empty document and bind an XBAutoMap to it.
@param valueType
component type of map
@return an empty Map view to the document | [
"Create",
"an",
"empty",
"document",
"and",
"bind",
"an",
"XBAutoMap",
"to",
"it",
"."
] | train | https://github.com/SvenEwald/xmlbeam/blob/acaac1b8fa28d246f17187f5e3c6696458a0b447/src/main/java/org/xmlbeam/XBProjector.java#L825-L828 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optInt | public static int optInt(@Nullable Bundle bundle, @Nullable String key) {
return optInt(bundle, key, 0);
} | java | public static int optInt(@Nullable Bundle bundle, @Nullable String key) {
return optInt(bundle, key, 0);
} | [
"public",
"static",
"int",
"optInt",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
")",
"{",
"return",
"optInt",
"(",
"bundle",
",",
"key",
",",
"0",
")",
";",
"}"
] | Returns a optional int value. In other words, returns the value mapped by key if it exists and is a int.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns 0.
@param bundle a bundle. If the bundle is null, this method will return 0.
@param key a key for the value.
@return a int value if exists, 0 otherwise.
@see android.os.Bundle#getInt(String) | [
"Returns",
"a",
"optional",
"int",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"int",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
"{"
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L541-L543 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/preview/util/CmsRectangle.java | CmsRectangle.fromLeftTopWidthHeight | public static CmsRectangle fromLeftTopWidthHeight(double left, double top, double width, double height) {
CmsRectangle result = new CmsRectangle();
result.m_left = left;
result.m_top = top;
result.m_width = width;
result.m_height = height;
return result;
} | java | public static CmsRectangle fromLeftTopWidthHeight(double left, double top, double width, double height) {
CmsRectangle result = new CmsRectangle();
result.m_left = left;
result.m_top = top;
result.m_width = width;
result.m_height = height;
return result;
} | [
"public",
"static",
"CmsRectangle",
"fromLeftTopWidthHeight",
"(",
"double",
"left",
",",
"double",
"top",
",",
"double",
"width",
",",
"double",
"height",
")",
"{",
"CmsRectangle",
"result",
"=",
"new",
"CmsRectangle",
"(",
")",
";",
"result",
".",
"m_left",
... | Creates a new rectangle given its left, top coordinates and its width and height.<p>
@param left the left side
@param top the top side
@param width the width
@param height the height
@return the new rectangel | [
"Creates",
"a",
"new",
"rectangle",
"given",
"its",
"left",
"top",
"coordinates",
"and",
"its",
"width",
"and",
"height",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/preview/util/CmsRectangle.java#L66-L74 |
foundation-runtime/service-directory | 1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java | DirectoryLookupService.removeNotificationHandler | public void removeNotificationHandler(String serviceName, NotificationHandler handler) {
ServiceInstanceUtils.validateServiceName(serviceName);
if (handler == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"NotificationHandler");
}
List<InstanceChangeListener<ModelServiceInstance>> list = changeListenerMap.get(serviceName);
if (list != null) {
boolean found = false;
for (InstanceChangeListener<ModelServiceInstance> listener : list) {
if (listener instanceof NotificationHandlerAdapter
&& ((NotificationHandlerAdapter) listener).getAdapter() == handler) {
list.remove(listener);
found = true;
break;
}
}
if (!found) {
LOGGER.error(ErrorCode.NOTIFICATION_HANDLER_DOES_NOT_EXIST.getMessageTemplate());
}
} else {
LOGGER.error(String.format(ErrorCode.SERVICE_DOES_NOT_EXIST.getMessageTemplate(), serviceName));
}
} | java | public void removeNotificationHandler(String serviceName, NotificationHandler handler) {
ServiceInstanceUtils.validateServiceName(serviceName);
if (handler == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"NotificationHandler");
}
List<InstanceChangeListener<ModelServiceInstance>> list = changeListenerMap.get(serviceName);
if (list != null) {
boolean found = false;
for (InstanceChangeListener<ModelServiceInstance> listener : list) {
if (listener instanceof NotificationHandlerAdapter
&& ((NotificationHandlerAdapter) listener).getAdapter() == handler) {
list.remove(listener);
found = true;
break;
}
}
if (!found) {
LOGGER.error(ErrorCode.NOTIFICATION_HANDLER_DOES_NOT_EXIST.getMessageTemplate());
}
} else {
LOGGER.error(String.format(ErrorCode.SERVICE_DOES_NOT_EXIST.getMessageTemplate(), serviceName));
}
} | [
"public",
"void",
"removeNotificationHandler",
"(",
"String",
"serviceName",
",",
"NotificationHandler",
"handler",
")",
"{",
"ServiceInstanceUtils",
".",
"validateServiceName",
"(",
"serviceName",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"throw",
"... | Remove the NotificationHandler from the Service.
@param serviceName the service name.
@param handler the NotificationHandler for the service. | [
"Remove",
"the",
"NotificationHandler",
"from",
"the",
"Service",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java#L497-L523 |
jpaoletti/java-presentation-manager | modules/jpm-core/src/main/java/jpaoletti/jpm/core/monitor/FileMonitorSource.java | FileMonitorSource.getLinesFrom | @Override
public List<MonitorLine> getLinesFrom(Object actual) throws Exception {
//TODO Enhance line retrieve to get last lines directly
String line;
Integer currentLineNo = 0;
final List<MonitorLine> result = new ArrayList<MonitorLine>();
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(getFilename()));
Integer startLine = (actual == null) ? 0 : (Integer) actual;
//read to startLine
while (currentLineNo < startLine + 1) {
if (in.readLine() == null) {
throw new IOException("File too small");
}
currentLineNo++;
}
//read until endLine
line = in.readLine();
while (line != null) {
result.add(new MonitorLine(currentLineNo, line));
currentLineNo++;
line = in.readLine();
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ignore) {
}
}
return result;
} | java | @Override
public List<MonitorLine> getLinesFrom(Object actual) throws Exception {
//TODO Enhance line retrieve to get last lines directly
String line;
Integer currentLineNo = 0;
final List<MonitorLine> result = new ArrayList<MonitorLine>();
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(getFilename()));
Integer startLine = (actual == null) ? 0 : (Integer) actual;
//read to startLine
while (currentLineNo < startLine + 1) {
if (in.readLine() == null) {
throw new IOException("File too small");
}
currentLineNo++;
}
//read until endLine
line = in.readLine();
while (line != null) {
result.add(new MonitorLine(currentLineNo, line));
currentLineNo++;
line = in.readLine();
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ignore) {
}
}
return result;
} | [
"@",
"Override",
"public",
"List",
"<",
"MonitorLine",
">",
"getLinesFrom",
"(",
"Object",
"actual",
")",
"throws",
"Exception",
"{",
"//TODO Enhance line retrieve to get last lines directly",
"String",
"line",
";",
"Integer",
"currentLineNo",
"=",
"0",
";",
"final",
... | Get the file lines since the actual until the last.
@param actual Actual line identification
@return The list of lines
@throws Exception | [
"Get",
"the",
"file",
"lines",
"since",
"the",
"actual",
"until",
"the",
"last",
"."
] | train | https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/monitor/FileMonitorSource.java#L26-L60 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/MPXReader.java | MPXReader.populateResourceAssignment | private void populateResourceAssignment(Record record, ResourceAssignment assignment) throws MPXJException
{
//
// Handle malformed MPX files - ensure that we can locate the resource
// using either the Unique ID attribute or the ID attribute.
//
Resource resource = m_projectFile.getResourceByUniqueID(record.getInteger(12));
if (resource == null)
{
resource = m_projectFile.getResourceByID(record.getInteger(0));
}
assignment.setUnits(record.getUnits(1));
assignment.setWork(record.getDuration(2));
assignment.setBaselineWork(record.getDuration(3));
assignment.setActualWork(record.getDuration(4));
assignment.setOvertimeWork(record.getDuration(5));
assignment.setCost(record.getCurrency(6));
assignment.setBaselineCost(record.getCurrency(7));
assignment.setActualCost(record.getCurrency(8));
assignment.setStart(record.getDateTime(9));
assignment.setFinish(record.getDateTime(10));
assignment.setDelay(record.getDuration(11));
//
// Calculate the remaining work
//
Duration work = assignment.getWork();
Duration actualWork = assignment.getActualWork();
if (work != null && actualWork != null)
{
if (work.getUnits() != actualWork.getUnits())
{
actualWork = actualWork.convertUnits(work.getUnits(), m_projectFile.getProjectProperties());
}
assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
if (resource != null)
{
assignment.setResourceUniqueID(resource.getUniqueID());
resource.addResourceAssignment(assignment);
}
m_eventManager.fireAssignmentReadEvent(assignment);
} | java | private void populateResourceAssignment(Record record, ResourceAssignment assignment) throws MPXJException
{
//
// Handle malformed MPX files - ensure that we can locate the resource
// using either the Unique ID attribute or the ID attribute.
//
Resource resource = m_projectFile.getResourceByUniqueID(record.getInteger(12));
if (resource == null)
{
resource = m_projectFile.getResourceByID(record.getInteger(0));
}
assignment.setUnits(record.getUnits(1));
assignment.setWork(record.getDuration(2));
assignment.setBaselineWork(record.getDuration(3));
assignment.setActualWork(record.getDuration(4));
assignment.setOvertimeWork(record.getDuration(5));
assignment.setCost(record.getCurrency(6));
assignment.setBaselineCost(record.getCurrency(7));
assignment.setActualCost(record.getCurrency(8));
assignment.setStart(record.getDateTime(9));
assignment.setFinish(record.getDateTime(10));
assignment.setDelay(record.getDuration(11));
//
// Calculate the remaining work
//
Duration work = assignment.getWork();
Duration actualWork = assignment.getActualWork();
if (work != null && actualWork != null)
{
if (work.getUnits() != actualWork.getUnits())
{
actualWork = actualWork.convertUnits(work.getUnits(), m_projectFile.getProjectProperties());
}
assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
if (resource != null)
{
assignment.setResourceUniqueID(resource.getUniqueID());
resource.addResourceAssignment(assignment);
}
m_eventManager.fireAssignmentReadEvent(assignment);
} | [
"private",
"void",
"populateResourceAssignment",
"(",
"Record",
"record",
",",
"ResourceAssignment",
"assignment",
")",
"throws",
"MPXJException",
"{",
"//",
"// Handle malformed MPX files - ensure that we can locate the resource",
"// using either the Unique ID attribute or the ID att... | Populate a resource assignment.
@param record MPX record
@param assignment resource assignment
@throws MPXJException | [
"Populate",
"a",
"resource",
"assignment",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXReader.java#L1403-L1449 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java | NormalDistribution.logpdf | public static double logpdf(double x, double mu, double sigma) {
x = (x - mu) / sigma;
return MathUtil.LOG_ONE_BY_SQRTTWOPI - FastMath.log(sigma) - .5 * x * x;
} | java | public static double logpdf(double x, double mu, double sigma) {
x = (x - mu) / sigma;
return MathUtil.LOG_ONE_BY_SQRTTWOPI - FastMath.log(sigma) - .5 * x * x;
} | [
"public",
"static",
"double",
"logpdf",
"(",
"double",
"x",
",",
"double",
"mu",
",",
"double",
"sigma",
")",
"{",
"x",
"=",
"(",
"x",
"-",
"mu",
")",
"/",
"sigma",
";",
"return",
"MathUtil",
".",
"LOG_ONE_BY_SQRTTWOPI",
"-",
"FastMath",
".",
"log",
... | Log probability density function of the normal distribution.
<p>
\[\log\frac{1}{\sqrt{2\pi}} - \log\sigma - \tfrac{(x-\mu)^2}{2\sigma^2}\]
@param x The value.
@param mu The mean.
@param sigma The standard deviation.
@return PDF of the given normal distribution at x. | [
"Log",
"probability",
"density",
"function",
"of",
"the",
"normal",
"distribution",
".",
"<p",
">",
"\\",
"[",
"\\",
"log",
"\\",
"frac",
"{",
"1",
"}",
"{",
"\\",
"sqrt",
"{",
"2",
"\\",
"pi",
"}}",
"-",
"\\",
"log",
"\\",
"sigma",
"-",
"\\",
"t... | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java#L412-L415 |
javagl/ND | nd-arrays/src/main/java/de/javagl/nd/arrays/j/LongArraysND.java | LongArraysND.toFormattedString | public static String toFormattedString(LongArrayND array, String format)
{
if (array == null)
{
return "null";
}
StringBuilder sb = new StringBuilder();
Iterable<MutableIntTuple> iterable =
IntTupleIterables.lexicographicalIterable(array.getSize());
IntTuple previous = null;
for (IntTuple coordinates : iterable)
{
if (previous != null)
{
int c = Utils.countDifferences(previous, coordinates);
for (int i=0; i<c-1; i++)
{
sb.append("\n");
}
}
long value = array.get(coordinates);
sb.append(String.format(format+", ", value));
previous = coordinates;
}
return sb.toString();
} | java | public static String toFormattedString(LongArrayND array, String format)
{
if (array == null)
{
return "null";
}
StringBuilder sb = new StringBuilder();
Iterable<MutableIntTuple> iterable =
IntTupleIterables.lexicographicalIterable(array.getSize());
IntTuple previous = null;
for (IntTuple coordinates : iterable)
{
if (previous != null)
{
int c = Utils.countDifferences(previous, coordinates);
for (int i=0; i<c-1; i++)
{
sb.append("\n");
}
}
long value = array.get(coordinates);
sb.append(String.format(format+", ", value));
previous = coordinates;
}
return sb.toString();
} | [
"public",
"static",
"String",
"toFormattedString",
"(",
"LongArrayND",
"array",
",",
"String",
"format",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"return",
"\"null\"",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";"... | Creates a formatted representation of the given array. After each
dimension, a newline character will be inserted.
@param array The array
@param format The format for the array entries
@return The hash code | [
"Creates",
"a",
"formatted",
"representation",
"of",
"the",
"given",
"array",
".",
"After",
"each",
"dimension",
"a",
"newline",
"character",
"will",
"be",
"inserted",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-arrays/src/main/java/de/javagl/nd/arrays/j/LongArraysND.java#L361-L386 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.trStyleHtmlContent | public static String trStyleHtmlContent(String style, String... content) {
return tagStyleHtmlContent(Html.Tag.TR, style, content);
} | java | public static String trStyleHtmlContent(String style, String... content) {
return tagStyleHtmlContent(Html.Tag.TR, style, content);
} | [
"public",
"static",
"String",
"trStyleHtmlContent",
"(",
"String",
"style",
",",
"String",
"...",
"content",
")",
"{",
"return",
"tagStyleHtmlContent",
"(",
"Html",
".",
"Tag",
".",
"TR",
",",
"style",
",",
"content",
")",
";",
"}"
] | Build a HTML TableRow with given CSS style attributes for a string.
Use this method if given content contains HTML snippets, prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param style style for tr element
@param content content string
@return HTML tr element as string | [
"Build",
"a",
"HTML",
"TableRow",
"with",
"given",
"CSS",
"style",
"attributes",
"for",
"a",
"string",
".",
"Use",
"this",
"method",
"if",
"given",
"content",
"contains",
"HTML",
"snippets",
"prepared",
"with",
"{",
"@link",
"HtmlBuilder#htmlEncode",
"(",
"Str... | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L127-L129 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java | SDBaseOps.gte | public SDVariable gte(SDVariable x, SDVariable y) {
return gte(null, x, y);
} | java | public SDVariable gte(SDVariable x, SDVariable y) {
return gte(null, x, y);
} | [
"public",
"SDVariable",
"gte",
"(",
"SDVariable",
"x",
",",
"SDVariable",
"y",
")",
"{",
"return",
"gte",
"(",
"null",
",",
"x",
",",
"y",
")",
";",
"}"
] | Greater than or equal to operation: elementwise x >= y<br>
If x and y arrays have equal shape, the output shape is the same as these inputs.<br>
Note: supports broadcasting if x and y have different shapes and are broadcastable.<br>
Returns an array with values 1 where condition is satisfied, or value 0 otherwise.
@param x Input 1
@param y Input 2
@return Output SDVariable with values 0 and 1 based on where the condition is satisfied | [
"Greater",
"than",
"or",
"equal",
"to",
"operation",
":",
"elementwise",
"x",
">",
"=",
"y<br",
">",
"If",
"x",
"and",
"y",
"arrays",
"have",
"equal",
"shape",
"the",
"output",
"shape",
"is",
"the",
"same",
"as",
"these",
"inputs",
".",
"<br",
">",
"... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L710-L712 |
google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclaration.java | Es6RewriteBlockScopedFunctionDeclaration.visitBlockScopedFunctionDeclaration | private void visitBlockScopedFunctionDeclaration(NodeTraversal t, Node n, Node parent) {
// Prepare a spot for the function.
Node oldNameNode = n.getFirstChild();
Node fnNameNode = oldNameNode.cloneNode();
Node let = IR.declaration(fnNameNode, Token.LET).srcref(n);
NodeUtil.addFeatureToScript(t.getCurrentScript(), Feature.LET_DECLARATIONS);
// Prepare the function.
oldNameNode.setString("");
compiler.reportChangeToEnclosingScope(oldNameNode);
// Move the function to the front of the parent.
parent.removeChild(n);
parent.addChildToFront(let);
compiler.reportChangeToEnclosingScope(let);
fnNameNode.addChildToFront(n);
} | java | private void visitBlockScopedFunctionDeclaration(NodeTraversal t, Node n, Node parent) {
// Prepare a spot for the function.
Node oldNameNode = n.getFirstChild();
Node fnNameNode = oldNameNode.cloneNode();
Node let = IR.declaration(fnNameNode, Token.LET).srcref(n);
NodeUtil.addFeatureToScript(t.getCurrentScript(), Feature.LET_DECLARATIONS);
// Prepare the function.
oldNameNode.setString("");
compiler.reportChangeToEnclosingScope(oldNameNode);
// Move the function to the front of the parent.
parent.removeChild(n);
parent.addChildToFront(let);
compiler.reportChangeToEnclosingScope(let);
fnNameNode.addChildToFront(n);
} | [
"private",
"void",
"visitBlockScopedFunctionDeclaration",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
",",
"Node",
"parent",
")",
"{",
"// Prepare a spot for the function.",
"Node",
"oldNameNode",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"fnNameNode",... | Rewrite the function declaration from:
<pre>
function f() {}
FUNCTION
NAME x
PARAM_LIST
BLOCK
</pre>
to
<pre>
let f = function() {};
LET
NAME f
FUNCTION
NAME (w/ empty string)
PARAM_LIST
BLOCK
</pre>
This is similar to {@link Normalize.NormalizeStatements#rewriteFunctionDeclaration} but
rewrites to "let" instead of "var". | [
"Rewrite",
"the",
"function",
"declaration",
"from",
":"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclaration.java#L92-L108 |
andkulikov/Transitions-Everywhere | library(1.x)/src/main/java/com/transitionseverywhere/Transition.java | Transition.excludeChildren | @NonNull
public Transition excludeChildren(int targetId, boolean exclude) {
if (targetId >= 0) {
mTargetIdChildExcludes = excludeObject(mTargetIdChildExcludes, targetId, exclude);
}
return this;
} | java | @NonNull
public Transition excludeChildren(int targetId, boolean exclude) {
if (targetId >= 0) {
mTargetIdChildExcludes = excludeObject(mTargetIdChildExcludes, targetId, exclude);
}
return this;
} | [
"@",
"NonNull",
"public",
"Transition",
"excludeChildren",
"(",
"int",
"targetId",
",",
"boolean",
"exclude",
")",
"{",
"if",
"(",
"targetId",
">=",
"0",
")",
"{",
"mTargetIdChildExcludes",
"=",
"excludeObject",
"(",
"mTargetIdChildExcludes",
",",
"targetId",
",... | Whether to add the children of the given id to the list of targets to exclude
from this transition. The <code>exclude</code> parameter specifies whether
the children of the target should be added to or removed from the excluded list.
Excluding children in this way provides a simple mechanism for excluding all
children of specific targets, rather than individually excluding each
child individually.
<p/>
<p>Excluding targets is a general mechanism for allowing transitions to run on
a view hierarchy while skipping target views that should not be part of
the transition. For example, you may want to avoid animating children
of a specific ListView or Spinner. Views can be excluded either by their
id, or by their instance reference, or by the Class of that view
(eg, {@link Spinner}).</p>
@param targetId The id of a target whose children should be ignored when running
this transition.
@param exclude Whether to add the target to or remove the target from the
current list of excluded-child targets.
@return This transition object.
@see #excludeTarget(int, boolean)
@see #excludeChildren(View, boolean)
@see #excludeChildren(Class, boolean) | [
"Whether",
"to",
"add",
"the",
"children",
"of",
"the",
"given",
"id",
"to",
"the",
"list",
"of",
"targets",
"to",
"exclude",
"from",
"this",
"transition",
".",
"The",
"<code",
">",
"exclude<",
"/",
"code",
">",
"parameter",
"specifies",
"whether",
"the",
... | train | https://github.com/andkulikov/Transitions-Everywhere/blob/828efe5f152a2f05e2bfeee6254b74ad2269d4f1/library(1.x)/src/main/java/com/transitionseverywhere/Transition.java#L1197-L1203 |
OpenLiberty/open-liberty | dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/ws/JoblogUtil.java | JoblogUtil.logRawMsgToJobLogAndTraceOnly | @Trivial
public static void logRawMsgToJobLogAndTraceOnly(Level level, String msg, Logger traceLogger){
if(level.intValue() > Level.FINE.intValue()){
traceLogger.log(Level.FINE, msg);
logToJoblogIfNotTraceLoggable(Level.FINE, msg, traceLogger);
}
else{
traceLogger.log(level, msg);
logToJoblogIfNotTraceLoggable(level, msg, traceLogger);
}
} | java | @Trivial
public static void logRawMsgToJobLogAndTraceOnly(Level level, String msg, Logger traceLogger){
if(level.intValue() > Level.FINE.intValue()){
traceLogger.log(Level.FINE, msg);
logToJoblogIfNotTraceLoggable(Level.FINE, msg, traceLogger);
}
else{
traceLogger.log(level, msg);
logToJoblogIfNotTraceLoggable(level, msg, traceLogger);
}
} | [
"@",
"Trivial",
"public",
"static",
"void",
"logRawMsgToJobLogAndTraceOnly",
"(",
"Level",
"level",
",",
"String",
"msg",
",",
"Logger",
"traceLogger",
")",
"{",
"if",
"(",
"level",
".",
"intValue",
"(",
")",
">",
"Level",
".",
"FINE",
".",
"intValue",
"("... | logs the message to joblog and trace.
If Level > FINE, this method will reduce the level to FINE while logging to trace.log
to prevent the message to be logged in console.log and messages.log file
Joblog messages will be logged as per supplied logging level
Use this method when you don't want a very verbose stack in messages.log and console.log
@param level Original logging level the message was logged at by the code writing the log msg.
@param rawMsg Message is complete, it has already been translated with parameters a filled in,
or it is a raw, non-translated message like an exception or similar trace.
@param traceLogger Logger to use to attempt to log message to trace.log (whether it will or not
depends on config) | [
"logs",
"the",
"message",
"to",
"joblog",
"and",
"trace",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/ws/JoblogUtil.java#L72-L83 |
facebookarchive/swift | swift-codec/src/main/java/com/facebook/swift/codec/internal/compiler/ThriftCodecByteCodeGenerator.java | ThriftCodecByteCodeGenerator.defineWriteBridgeMethod | private void defineWriteBridgeMethod()
{
classDefinition.addMethod(
new MethodDefinition(a(PUBLIC, BRIDGE, SYNTHETIC), "write", null, arg("struct", Object.class), arg("protocol", TProtocol.class))
.addException(Exception.class)
.loadThis()
.loadVariable("struct", structType)
.loadVariable("protocol")
.invokeVirtual(
codecType,
"write",
type(void.class),
structType,
type(TProtocol.class)
)
.ret()
);
} | java | private void defineWriteBridgeMethod()
{
classDefinition.addMethod(
new MethodDefinition(a(PUBLIC, BRIDGE, SYNTHETIC), "write", null, arg("struct", Object.class), arg("protocol", TProtocol.class))
.addException(Exception.class)
.loadThis()
.loadVariable("struct", structType)
.loadVariable("protocol")
.invokeVirtual(
codecType,
"write",
type(void.class),
structType,
type(TProtocol.class)
)
.ret()
);
} | [
"private",
"void",
"defineWriteBridgeMethod",
"(",
")",
"{",
"classDefinition",
".",
"addMethod",
"(",
"new",
"MethodDefinition",
"(",
"a",
"(",
"PUBLIC",
",",
"BRIDGE",
",",
"SYNTHETIC",
")",
",",
"\"write\"",
",",
"null",
",",
"arg",
"(",
"\"struct\"",
","... | Defines the generics bridge method with untyped args to the type specific write method. | [
"Defines",
"the",
"generics",
"bridge",
"method",
"with",
"untyped",
"args",
"to",
"the",
"type",
"specific",
"write",
"method",
"."
] | train | https://github.com/facebookarchive/swift/blob/3f1f098a50d6106f50cd6fe1c361dd373ede0197/swift-codec/src/main/java/com/facebook/swift/codec/internal/compiler/ThriftCodecByteCodeGenerator.java#L1020-L1037 |
alkacon/opencms-core | src/org/opencms/jsp/parse/A_CmsConfiguredHtmlParser.java | A_CmsConfiguredHtmlParser.doParse | public String doParse(String html, String encoding, List<String> noAutoCloseTags)
throws ParserException, CmsException {
m_visitor = createVisitorInstance();
m_visitor.setNoAutoCloseTags(noAutoCloseTags);
String result = "";
m_visitor.process(html, encoding);
result = m_visitor.getResult();
return result;
} | java | public String doParse(String html, String encoding, List<String> noAutoCloseTags)
throws ParserException, CmsException {
m_visitor = createVisitorInstance();
m_visitor.setNoAutoCloseTags(noAutoCloseTags);
String result = "";
m_visitor.process(html, encoding);
result = m_visitor.getResult();
return result;
} | [
"public",
"String",
"doParse",
"(",
"String",
"html",
",",
"String",
"encoding",
",",
"List",
"<",
"String",
">",
"noAutoCloseTags",
")",
"throws",
"ParserException",
",",
"CmsException",
"{",
"m_visitor",
"=",
"createVisitorInstance",
"(",
")",
";",
"m_visitor"... | Returns the result of subsequent parsing to the <cms:parse< tag implementation.<p>
@param encoding the encoding to use for parsing
@param html the html content to parse
@param noAutoCloseTags a list of upper case tag names for which parsing / visiting should not correct missing closing tags.
@return the result of subsequent parsing to the <cms:parse< tag implementation
@throws ParserException if something goes wrong at parsing
@throws CmsException if something goes wrong at accessing OpenCms core functionality | [
"Returns",
"the",
"result",
"of",
"subsequent",
"parsing",
"to",
"the",
"<",
";",
"cms",
":",
"parse<",
";",
"tag",
"implementation",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/parse/A_CmsConfiguredHtmlParser.java#L99-L108 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/nonparametrics/independentsamples/KolmogorovSmirnovIndependentSamples.java | KolmogorovSmirnovIndependentSamples.calculateCriticalValue | protected static double calculateCriticalValue(boolean is_twoTailed, int n1, int n2, double aLevel) {
double a=aLevel;
if(is_twoTailed) {
a=aLevel/2.0;
}
double one_minus_a=1.0-a;
double Ka=1.36;//start by this value and go either up or down until you pass the desired level of significance
int direction=1;//go up
if(ContinuousDistributions.kolmogorov(Ka)>one_minus_a) {
direction=-1;//go down
}
for(int i=0;i<110;++i) { //Why maximum 110 steps? Because the minimum value before kolmogorov goes to 0 is 0.27 and the maximum (empirically) is about 2.5. Both of them are about 110 steps of 0.01 distance away
Ka+=(direction*0.01);
double sign=(one_minus_a-ContinuousDistributions.kolmogorov(Ka))*direction;
//this changes sign ONLY when we just passed the value
if(sign<=0) {
break;
}
}
double criticalValue=Ka*Math.sqrt(((double)n1+n2)/(n1*n2));
return criticalValue;
} | java | protected static double calculateCriticalValue(boolean is_twoTailed, int n1, int n2, double aLevel) {
double a=aLevel;
if(is_twoTailed) {
a=aLevel/2.0;
}
double one_minus_a=1.0-a;
double Ka=1.36;//start by this value and go either up or down until you pass the desired level of significance
int direction=1;//go up
if(ContinuousDistributions.kolmogorov(Ka)>one_minus_a) {
direction=-1;//go down
}
for(int i=0;i<110;++i) { //Why maximum 110 steps? Because the minimum value before kolmogorov goes to 0 is 0.27 and the maximum (empirically) is about 2.5. Both of them are about 110 steps of 0.01 distance away
Ka+=(direction*0.01);
double sign=(one_minus_a-ContinuousDistributions.kolmogorov(Ka))*direction;
//this changes sign ONLY when we just passed the value
if(sign<=0) {
break;
}
}
double criticalValue=Ka*Math.sqrt(((double)n1+n2)/(n1*n2));
return criticalValue;
} | [
"protected",
"static",
"double",
"calculateCriticalValue",
"(",
"boolean",
"is_twoTailed",
",",
"int",
"n1",
",",
"int",
"n2",
",",
"double",
"aLevel",
")",
"{",
"double",
"a",
"=",
"aLevel",
";",
"if",
"(",
"is_twoTailed",
")",
"{",
"a",
"=",
"aLevel",
... | Calculate Critical Value for a particular $n and $aLevel combination
@param is_twoTailed
@param n1
@param n2
@param aLevel
@return | [
"Calculate",
"Critical",
"Value",
"for",
"a",
"particular",
"$n",
"and",
"$aLevel",
"combination"
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/nonparametrics/independentsamples/KolmogorovSmirnovIndependentSamples.java#L138-L164 |
hawkular/hawkular-agent | hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/util/Util.java | Util.getContextUrlString | public static StringBuilder getContextUrlString(String baseUrl, String context) throws MalformedURLException {
StringBuilder urlStr = new StringBuilder(baseUrl);
ensureEndsWithSlash(urlStr);
if (context != null && context.length() > 0) {
if (context.startsWith("/")) {
urlStr.append(context.substring(1));
} else {
urlStr.append(context);
}
ensureEndsWithSlash(urlStr);
}
return urlStr;
} | java | public static StringBuilder getContextUrlString(String baseUrl, String context) throws MalformedURLException {
StringBuilder urlStr = new StringBuilder(baseUrl);
ensureEndsWithSlash(urlStr);
if (context != null && context.length() > 0) {
if (context.startsWith("/")) {
urlStr.append(context.substring(1));
} else {
urlStr.append(context);
}
ensureEndsWithSlash(urlStr);
}
return urlStr;
} | [
"public",
"static",
"StringBuilder",
"getContextUrlString",
"(",
"String",
"baseUrl",
",",
"String",
"context",
")",
"throws",
"MalformedURLException",
"{",
"StringBuilder",
"urlStr",
"=",
"new",
"StringBuilder",
"(",
"baseUrl",
")",
";",
"ensureEndsWithSlash",
"(",
... | Given a base URL (like 'http://localhost:8080') this will append the given context string to it and will return
the URL with a forward-slash as its last character.
This returns a StringBuilder so the caller can continue building its desired URL by appending to it additional
context paths, query strings, and the like.
@param baseUrl base URL to append the given context to
@param context the context to add to the given base URL
@return the base URL with the context appended to it
@throws MalformedURLException if URL cannot be built | [
"Given",
"a",
"base",
"URL",
"(",
"like",
"http",
":",
"//",
"localhost",
":",
"8080",
")",
"this",
"will",
"append",
"the",
"given",
"context",
"string",
"to",
"it",
"and",
"will",
"return",
"the",
"URL",
"with",
"a",
"forward",
"-",
"slash",
"as",
... | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/util/Util.java#L155-L167 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/QuantilesHelper.java | QuantilesHelper.chunkContainingPos | public static int chunkContainingPos(final long[] arr, final long pos) {
final int nominalLength = arr.length - 1; /* remember, arr contains an "extra" position */
assert nominalLength > 0;
final long n = arr[nominalLength];
assert 0 <= pos;
assert pos < n;
final int l = 0;
final int r = nominalLength;
// the following three asserts should probably be retained since they ensure
// that the necessary invariants hold at the beginning of the search
assert l < r;
assert arr[l] <= pos;
assert pos < arr[r];
return searchForChunkContainingPos(arr, pos, l, r);
} | java | public static int chunkContainingPos(final long[] arr, final long pos) {
final int nominalLength = arr.length - 1; /* remember, arr contains an "extra" position */
assert nominalLength > 0;
final long n = arr[nominalLength];
assert 0 <= pos;
assert pos < n;
final int l = 0;
final int r = nominalLength;
// the following three asserts should probably be retained since they ensure
// that the necessary invariants hold at the beginning of the search
assert l < r;
assert arr[l] <= pos;
assert pos < arr[r];
return searchForChunkContainingPos(arr, pos, l, r);
} | [
"public",
"static",
"int",
"chunkContainingPos",
"(",
"final",
"long",
"[",
"]",
"arr",
",",
"final",
"long",
"pos",
")",
"{",
"final",
"int",
"nominalLength",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"/* remember, arr contains an \"extra\" position */",
"asser... | This is written in terms of a plain array to facilitate testing.
@param arr the chunk containing the position
@param pos the position
@return the index of the chunk containing the position | [
"This",
"is",
"written",
"in",
"terms",
"of",
"a",
"plain",
"array",
"to",
"facilitate",
"testing",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/QuantilesHelper.java#L46-L60 |
mlhartme/sushi | src/main/java/net/oneandone/sushi/fs/Node.java | Node.copyDirectory | public List<Node> copyDirectory(Node destdir, Filter filter) throws DirectoryNotFoundException, CopyException {
return new Copy(this, filter).directory(destdir);
} | java | public List<Node> copyDirectory(Node destdir, Filter filter) throws DirectoryNotFoundException, CopyException {
return new Copy(this, filter).directory(destdir);
} | [
"public",
"List",
"<",
"Node",
">",
"copyDirectory",
"(",
"Node",
"destdir",
",",
"Filter",
"filter",
")",
"throws",
"DirectoryNotFoundException",
",",
"CopyException",
"{",
"return",
"new",
"Copy",
"(",
"this",
",",
"filter",
")",
".",
"directory",
"(",
"de... | Throws an exception is this or dest is not a directory. Overwrites existing files in dest.
@return list of files and directories created | [
"Throws",
"an",
"exception",
"is",
"this",
"or",
"dest",
"is",
"not",
"a",
"directory",
".",
"Overwrites",
"existing",
"files",
"in",
"dest",
"."
] | train | https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/fs/Node.java#L776-L778 |
lite2073/email-validator | src/com/dominicsayers/isemail/IsEMail.java | IsEMail.replaceCharAt | private static String replaceCharAt(String s, int pos, char c) {
return s.substring(0, pos) + c + s.substring(pos + 1);
} | java | private static String replaceCharAt(String s, int pos, char c) {
return s.substring(0, pos) + c + s.substring(pos + 1);
} | [
"private",
"static",
"String",
"replaceCharAt",
"(",
"String",
"s",
",",
"int",
"pos",
",",
"char",
"c",
")",
"{",
"return",
"s",
".",
"substring",
"(",
"0",
",",
"pos",
")",
"+",
"c",
"+",
"s",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
";",
... | Replaces a char in a String
@param s
The input string
@param pos
The position of the char to be replaced
@param c
The new char
@return The new String
@see Source: http://www.rgagnon.com/javadetails/java-0030.html | [
"Replaces",
"a",
"char",
"in",
"a",
"String"
] | train | https://github.com/lite2073/email-validator/blob/cfdda77ed630854b44d62def0d5b7228d5c4e712/src/com/dominicsayers/isemail/IsEMail.java#L745-L747 |
minio/minio-java | api/src/main/java/io/minio/MinioClient.java | MinioClient.traceOn | public void traceOn(OutputStream traceStream) {
if (traceStream == null) {
throw new NullPointerException();
} else {
this.traceStream = new PrintWriter(new OutputStreamWriter(traceStream, StandardCharsets.UTF_8), true);
}
} | java | public void traceOn(OutputStream traceStream) {
if (traceStream == null) {
throw new NullPointerException();
} else {
this.traceStream = new PrintWriter(new OutputStreamWriter(traceStream, StandardCharsets.UTF_8), true);
}
} | [
"public",
"void",
"traceOn",
"(",
"OutputStream",
"traceStream",
")",
"{",
"if",
"(",
"traceStream",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"traceStream",
"=",
"new",
"PrintWriter",
"("... | Enables HTTP call tracing and written to traceStream.
@param traceStream {@link OutputStream} for writing HTTP call tracing.
@see #traceOff | [
"Enables",
"HTTP",
"call",
"tracing",
"and",
"written",
"to",
"traceStream",
"."
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L5112-L5118 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/ScrollBarButtonPainter.java | ScrollBarButtonPainter.getScrollBarButtonBackgroundColors | private TwoColors getScrollBarButtonBackgroundColors(boolean buttonsTogether, boolean isIncrease) {
if (state == Which.FOREGROUND_CAP) {
return scrollBarCapColors;
} else if (isPressed) {
return isIncrease ? scrollBarButtonIncreasePressed : scrollBarButtonDecreasePressed;
} else {
if (buttonsTogether) {
return isIncrease ? scrollBarButtonIncreaseTogether : scrollBarButtonDecreaseTogether;
} else {
return isIncrease ? scrollBarButtonIncreaseApart : scrollBarButtonDecreaseApart;
}
}
} | java | private TwoColors getScrollBarButtonBackgroundColors(boolean buttonsTogether, boolean isIncrease) {
if (state == Which.FOREGROUND_CAP) {
return scrollBarCapColors;
} else if (isPressed) {
return isIncrease ? scrollBarButtonIncreasePressed : scrollBarButtonDecreasePressed;
} else {
if (buttonsTogether) {
return isIncrease ? scrollBarButtonIncreaseTogether : scrollBarButtonDecreaseTogether;
} else {
return isIncrease ? scrollBarButtonIncreaseApart : scrollBarButtonDecreaseApart;
}
}
} | [
"private",
"TwoColors",
"getScrollBarButtonBackgroundColors",
"(",
"boolean",
"buttonsTogether",
",",
"boolean",
"isIncrease",
")",
"{",
"if",
"(",
"state",
"==",
"Which",
".",
"FOREGROUND_CAP",
")",
"{",
"return",
"scrollBarCapColors",
";",
"}",
"else",
"if",
"("... | DOCUMENT ME!
@param buttonsTogether DOCUMENT ME!
@param isIncrease DOCUMENT ME!
@return DOCUMENT ME! | [
"DOCUMENT",
"ME!"
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/ScrollBarButtonPainter.java#L425-L438 |
samskivert/pythagoras | src/main/java/pythagoras/d/Matrix3.java | Matrix3.setToTransform | public Matrix3 setToTransform (IVector translation, double rotation, IVector scale) {
double sx = scale.x(), sy = scale.y();
return setToRotation(rotation).set(m00 * sx, m10 * sy, translation.x(),
m01 * sx, m11 * sy, translation.y(),
0f, 0f, 1f);
} | java | public Matrix3 setToTransform (IVector translation, double rotation, IVector scale) {
double sx = scale.x(), sy = scale.y();
return setToRotation(rotation).set(m00 * sx, m10 * sy, translation.x(),
m01 * sx, m11 * sy, translation.y(),
0f, 0f, 1f);
} | [
"public",
"Matrix3",
"setToTransform",
"(",
"IVector",
"translation",
",",
"double",
"rotation",
",",
"IVector",
"scale",
")",
"{",
"double",
"sx",
"=",
"scale",
".",
"x",
"(",
")",
",",
"sy",
"=",
"scale",
".",
"y",
"(",
")",
";",
"return",
"setToRota... | Sets this to a matrix that first scales, then rotates, then translates.
@return a reference to this matrix, for chaining. | [
"Sets",
"this",
"to",
"a",
"matrix",
"that",
"first",
"scales",
"then",
"rotates",
"then",
"translates",
"."
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/Matrix3.java#L276-L281 |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/UtilOptimize.java | UtilOptimize.process | public static boolean process( IterativeOptimization search , int maxSteps ) {
for( int i = 0; i < maxSteps; i++ ) {
boolean converged = step(search);
if( converged ) {
return search.isConverged();
}
}
return true;
} | java | public static boolean process( IterativeOptimization search , int maxSteps ) {
for( int i = 0; i < maxSteps; i++ ) {
boolean converged = step(search);
if( converged ) {
return search.isConverged();
}
}
return true;
} | [
"public",
"static",
"boolean",
"process",
"(",
"IterativeOptimization",
"search",
",",
"int",
"maxSteps",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxSteps",
";",
"i",
"++",
")",
"{",
"boolean",
"converged",
"=",
"step",
"(",
"search... | Iterate until the line search converges or the maximum number of iterations has been exceeded.
The maximum number of steps is specified. A step is defined as the number of times the
optimization parameters are changed.
@param search Search algorithm
@param maxSteps Maximum number of steps.
@return Value returned by {@link IterativeOptimization#iterate} | [
"Iterate",
"until",
"the",
"line",
"search",
"converges",
"or",
"the",
"maximum",
"number",
"of",
"iterations",
"has",
"been",
"exceeded",
"."
] | train | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/UtilOptimize.java#L38-L47 |
netty/netty | common/src/main/java/io/netty/util/internal/StringUtil.java | StringUtil.toHexStringPadded | public static <T extends Appendable> T toHexStringPadded(T dst, byte[] src) {
return toHexStringPadded(dst, src, 0, src.length);
} | java | public static <T extends Appendable> T toHexStringPadded(T dst, byte[] src) {
return toHexStringPadded(dst, src, 0, src.length);
} | [
"public",
"static",
"<",
"T",
"extends",
"Appendable",
">",
"T",
"toHexStringPadded",
"(",
"T",
"dst",
",",
"byte",
"[",
"]",
"src",
")",
"{",
"return",
"toHexStringPadded",
"(",
"dst",
",",
"src",
",",
"0",
",",
"src",
".",
"length",
")",
";",
"}"
] | Converts the specified byte array into a hexadecimal value and appends it to the specified buffer. | [
"Converts",
"the",
"specified",
"byte",
"array",
"into",
"a",
"hexadecimal",
"value",
"and",
"appends",
"it",
"to",
"the",
"specified",
"buffer",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/StringUtil.java#L123-L125 |
sarl/sarl | contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java | PyExpressionGenerator._generate | protected XExpression _generate(XTryCatchFinallyExpression tryStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
it.append("try:"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(tryStatement.getExpression(), context.getExpectedExpressionType(), it, context);
it.decreaseIndentation().newLine();
for (final XCatchClause clause : tryStatement.getCatchClauses()) {
it.append("except "); //$NON-NLS-1$
it.append(clause.getDeclaredParam().getParameterType().getType());
it.append(", "); //$NON-NLS-1$
it.append(it.declareUniqueNameVariable(clause.getDeclaredParam(), clause.getDeclaredParam().getSimpleName()));
it.append(":"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(clause.getExpression(), context.getExpectedExpressionType(), it, context);
it.decreaseIndentation().newLine();
}
if (tryStatement.getFinallyExpression() != null) {
it.append("finally:"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(tryStatement.getFinallyExpression(), it, context);
it.decreaseIndentation();
}
return tryStatement;
} | java | protected XExpression _generate(XTryCatchFinallyExpression tryStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
it.append("try:"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(tryStatement.getExpression(), context.getExpectedExpressionType(), it, context);
it.decreaseIndentation().newLine();
for (final XCatchClause clause : tryStatement.getCatchClauses()) {
it.append("except "); //$NON-NLS-1$
it.append(clause.getDeclaredParam().getParameterType().getType());
it.append(", "); //$NON-NLS-1$
it.append(it.declareUniqueNameVariable(clause.getDeclaredParam(), clause.getDeclaredParam().getSimpleName()));
it.append(":"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(clause.getExpression(), context.getExpectedExpressionType(), it, context);
it.decreaseIndentation().newLine();
}
if (tryStatement.getFinallyExpression() != null) {
it.append("finally:"); //$NON-NLS-1$
it.increaseIndentation().newLine();
generate(tryStatement.getFinallyExpression(), it, context);
it.decreaseIndentation();
}
return tryStatement;
} | [
"protected",
"XExpression",
"_generate",
"(",
"XTryCatchFinallyExpression",
"tryStatement",
",",
"IAppendable",
"it",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"it",
".",
"append",
"(",
"\"try:\"",
")",
";",
"//$NON-NLS-1$",
"it",
".",
"increaseInden... | Generate the given object.
@param tryStatement the try-catch-finally statement.
@param it the target for the generated content.
@param context the context.
@return the statement. | [
"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#L929-L951 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/AiMaterial.java | AiMaterial.getTextureOp | public AiTextureOp getTextureOp(AiTextureType type, int index) {
checkTexRange(type, index);
Property p = getProperty(PropertyKey.TEX_OP.m_key);
if (null == p || null == p.getData()) {
return (AiTextureOp) m_defaults.get(PropertyKey.TEX_OP);
}
return AiTextureOp.fromRawValue((Integer) p.getData());
} | java | public AiTextureOp getTextureOp(AiTextureType type, int index) {
checkTexRange(type, index);
Property p = getProperty(PropertyKey.TEX_OP.m_key);
if (null == p || null == p.getData()) {
return (AiTextureOp) m_defaults.get(PropertyKey.TEX_OP);
}
return AiTextureOp.fromRawValue((Integer) p.getData());
} | [
"public",
"AiTextureOp",
"getTextureOp",
"(",
"AiTextureType",
"type",
",",
"int",
"index",
")",
"{",
"checkTexRange",
"(",
"type",
",",
"index",
")",
";",
"Property",
"p",
"=",
"getProperty",
"(",
"PropertyKey",
".",
"TEX_OP",
".",
"m_key",
")",
";",
"if"... | Returns the texture operation.<p>
If missing, defaults to {@link AiTextureOp#ADD}
@param type the texture type
@param index the index in the texture stack
@return the texture operation | [
"Returns",
"the",
"texture",
"operation",
".",
"<p",
">"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/AiMaterial.java#L955-L965 |
Netflix/ribbon | ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/reactive/ExecutionContextListenerInvoker.java | ExecutionContextListenerInvoker.onExceptionWithServer | public void onExceptionWithServer(ExecutionContext<I> context, Throwable exception, ExecutionInfo info) {
for (ExecutionListener<I, O> listener: listeners) {
try {
if (!isListenerDisabled(listener)) {
listener.onExceptionWithServer(context.getChildContext(listener), exception, info);
}
} catch (Throwable e) {
logger.error("Error invoking listener " + listener, e);
}
}
} | java | public void onExceptionWithServer(ExecutionContext<I> context, Throwable exception, ExecutionInfo info) {
for (ExecutionListener<I, O> listener: listeners) {
try {
if (!isListenerDisabled(listener)) {
listener.onExceptionWithServer(context.getChildContext(listener), exception, info);
}
} catch (Throwable e) {
logger.error("Error invoking listener " + listener, e);
}
}
} | [
"public",
"void",
"onExceptionWithServer",
"(",
"ExecutionContext",
"<",
"I",
">",
"context",
",",
"Throwable",
"exception",
",",
"ExecutionInfo",
"info",
")",
"{",
"for",
"(",
"ExecutionListener",
"<",
"I",
",",
"O",
">",
"listener",
":",
"listeners",
")",
... | Called when an exception is received from executing the request on a server.
@param exception Exception received | [
"Called",
"when",
"an",
"exception",
"is",
"received",
"from",
"executing",
"the",
"request",
"on",
"a",
"server",
"."
] | train | https://github.com/Netflix/ribbon/blob/d15cd7715b0bf2f64ae6ca98c5e4d184f178e261/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/reactive/ExecutionContextListenerInvoker.java#L118-L128 |
jcuda/jnvgraph | JNvgraphJava/src/main/java/jcuda/jnvgraph/JNvgraph.java | JNvgraph.nvgraphGetEdgeData | public static int nvgraphGetEdgeData(
nvgraphHandle handle,
nvgraphGraphDescr descrG,
Pointer edgeData,
long setnum)
{
return checkResult(nvgraphGetEdgeDataNative(handle, descrG, edgeData, setnum));
} | java | public static int nvgraphGetEdgeData(
nvgraphHandle handle,
nvgraphGraphDescr descrG,
Pointer edgeData,
long setnum)
{
return checkResult(nvgraphGetEdgeDataNative(handle, descrG, edgeData, setnum));
} | [
"public",
"static",
"int",
"nvgraphGetEdgeData",
"(",
"nvgraphHandle",
"handle",
",",
"nvgraphGraphDescr",
"descrG",
",",
"Pointer",
"edgeData",
",",
"long",
"setnum",
")",
"{",
"return",
"checkResult",
"(",
"nvgraphGetEdgeDataNative",
"(",
"handle",
",",
"descrG",
... | Copy the edge set #setnum in *edgeData, sets have 0-based index | [
"Copy",
"the",
"edge",
"set",
"#setnum",
"in",
"*",
"edgeData",
"sets",
"have",
"0",
"-",
"based",
"index"
] | train | https://github.com/jcuda/jnvgraph/blob/2c6bd7c58edac181753bacf30af2cceeb1989a78/JNvgraphJava/src/main/java/jcuda/jnvgraph/JNvgraph.java#L366-L373 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java | MimeTypeUtil.getMimeType | public static String getMimeType(Resource resource, String defaultValue) {
MimeType mimeType = getMimeType(resource);
return mimeType != null ? mimeType.toString() : defaultValue;
} | java | public static String getMimeType(Resource resource, String defaultValue) {
MimeType mimeType = getMimeType(resource);
return mimeType != null ? mimeType.toString() : defaultValue;
} | [
"public",
"static",
"String",
"getMimeType",
"(",
"Resource",
"resource",
",",
"String",
"defaultValue",
")",
"{",
"MimeType",
"mimeType",
"=",
"getMimeType",
"(",
"resource",
")",
";",
"return",
"mimeType",
"!=",
"null",
"?",
"mimeType",
".",
"toString",
"(",... | Detects the mime type of a binary resource (nt:file, nt:resource or another asset type).
@param resource the binary resource
@param defaultValue the default value if the detection has no useful result
@return he detected mime type or the default value given | [
"Detects",
"the",
"mime",
"type",
"of",
"a",
"binary",
"resource",
"(",
"nt",
":",
"file",
"nt",
":",
"resource",
"or",
"another",
"asset",
"type",
")",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/MimeTypeUtil.java#L59-L62 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/plugins/JarPluginProviderLoader.java | JarPluginProviderLoader.extractJarContents | private void extractJarContents(final String[] entries, final File destdir) throws IOException {
if (!destdir.exists()) {
if (!destdir.mkdir()) {
log.warn("Unable to create cache dir for plugin: " + destdir.getAbsolutePath());
}
}
debug("extracting lib files from jar: " + pluginJar);
for (final String path : entries) {
debug("Expand zip " + pluginJar.getAbsolutePath() + " to dir: " + destdir + ", file: " + path);
ZipUtil.extractZipFile(pluginJar.getAbsolutePath(), destdir, path);
}
} | java | private void extractJarContents(final String[] entries, final File destdir) throws IOException {
if (!destdir.exists()) {
if (!destdir.mkdir()) {
log.warn("Unable to create cache dir for plugin: " + destdir.getAbsolutePath());
}
}
debug("extracting lib files from jar: " + pluginJar);
for (final String path : entries) {
debug("Expand zip " + pluginJar.getAbsolutePath() + " to dir: " + destdir + ", file: " + path);
ZipUtil.extractZipFile(pluginJar.getAbsolutePath(), destdir, path);
}
} | [
"private",
"void",
"extractJarContents",
"(",
"final",
"String",
"[",
"]",
"entries",
",",
"final",
"File",
"destdir",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"destdir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"destdir",
".",
"mkd... | Extract specific entries from the jar to a destination directory. Creates the
destination directory if it does not exist
@param entries
the entries to extract
@param destdir
destination directory | [
"Extract",
"specific",
"entries",
"from",
"the",
"jar",
"to",
"a",
"destination",
"directory",
".",
"Creates",
"the",
"destination",
"directory",
"if",
"it",
"does",
"not",
"exist"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/JarPluginProviderLoader.java#L530-L543 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsLinkManager.java | CmsLinkManager.getAbsoluteUri | public static String getAbsoluteUri(String relativeUri, String baseUri) {
if (isAbsoluteUri(relativeUri)) {
// URI is null or already absolute
return relativeUri;
}
try {
URL url = new URL(new URL(m_baseUrl, baseUri), relativeUri);
StringBuffer result = new StringBuffer(100);
result.append(url.getPath());
if (url.getQuery() != null) {
result.append('?');
result.append(url.getQuery());
}
if (url.getRef() != null) {
result.append('#');
result.append(url.getRef());
}
return result.toString();
} catch (MalformedURLException e) {
LOG.debug(e.getLocalizedMessage(), e);
return relativeUri;
}
} | java | public static String getAbsoluteUri(String relativeUri, String baseUri) {
if (isAbsoluteUri(relativeUri)) {
// URI is null or already absolute
return relativeUri;
}
try {
URL url = new URL(new URL(m_baseUrl, baseUri), relativeUri);
StringBuffer result = new StringBuffer(100);
result.append(url.getPath());
if (url.getQuery() != null) {
result.append('?');
result.append(url.getQuery());
}
if (url.getRef() != null) {
result.append('#');
result.append(url.getRef());
}
return result.toString();
} catch (MalformedURLException e) {
LOG.debug(e.getLocalizedMessage(), e);
return relativeUri;
}
} | [
"public",
"static",
"String",
"getAbsoluteUri",
"(",
"String",
"relativeUri",
",",
"String",
"baseUri",
")",
"{",
"if",
"(",
"isAbsoluteUri",
"(",
"relativeUri",
")",
")",
"{",
"// URI is null or already absolute",
"return",
"relativeUri",
";",
"}",
"try",
"{",
... | Calculates the absolute URI for the "relativeUri" with the given absolute "baseUri" as start. <p>
If "relativeUri" is already absolute, it is returned unchanged.
This method also returns "relativeUri" unchanged if it is not well-formed.<p>
@param relativeUri the relative URI to calculate an absolute URI for
@param baseUri the base URI, this must be an absolute URI
@return an absolute URI calculated from "relativeUri" and "baseUri" | [
"Calculates",
"the",
"absolute",
"URI",
"for",
"the",
"relativeUri",
"with",
"the",
"given",
"absolute",
"baseUri",
"as",
"start",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L115-L138 |
thorntail/thorntail | fractions/topology-webapp/src/main/java/org/wildfly/swarm/topology/webapp/TopologyWebAppFraction.java | TopologyWebAppFraction.proxyService | public void proxyService(String serviceName, String contextPath) {
if (proxiedServiceMappings().containsValue(contextPath)) {
throw new IllegalArgumentException("Cannot proxy multiple services under the same context path");
}
proxiedServiceMappings.put(serviceName, contextPath);
} | java | public void proxyService(String serviceName, String contextPath) {
if (proxiedServiceMappings().containsValue(contextPath)) {
throw new IllegalArgumentException("Cannot proxy multiple services under the same context path");
}
proxiedServiceMappings.put(serviceName, contextPath);
} | [
"public",
"void",
"proxyService",
"(",
"String",
"serviceName",
",",
"String",
"contextPath",
")",
"{",
"if",
"(",
"proxiedServiceMappings",
"(",
")",
".",
"containsValue",
"(",
"contextPath",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Ca... | Set up a load-balancing reverse proxy for the given service at the
given context path. Requests to this proxy will be load-balanced
among all instances of the service, as provided by our Topology.
@param serviceName the name of the service to proxy
@param contextPath the context path expose the proxy under | [
"Set",
"up",
"a",
"load",
"-",
"balancing",
"reverse",
"proxy",
"for",
"the",
"given",
"service",
"at",
"the",
"given",
"context",
"path",
".",
"Requests",
"to",
"this",
"proxy",
"will",
"be",
"load",
"-",
"balanced",
"among",
"all",
"instances",
"of",
"... | train | https://github.com/thorntail/thorntail/blob/4a391b68ffae98c6e66d30a3bfb99dadc9509f14/fractions/topology-webapp/src/main/java/org/wildfly/swarm/topology/webapp/TopologyWebAppFraction.java#L55-L60 |
classgraph/classgraph | src/main/java/io/github/classgraph/ClassInfoList.java | ClassInfoList.loadClasses | public <T> List<Class<T>> loadClasses(final Class<T> superclassOrInterfaceType) {
return loadClasses(superclassOrInterfaceType, /* ignoreExceptions = */ false);
} | java | public <T> List<Class<T>> loadClasses(final Class<T> superclassOrInterfaceType) {
return loadClasses(superclassOrInterfaceType, /* ignoreExceptions = */ false);
} | [
"public",
"<",
"T",
">",
"List",
"<",
"Class",
"<",
"T",
">",
">",
"loadClasses",
"(",
"final",
"Class",
"<",
"T",
">",
"superclassOrInterfaceType",
")",
"{",
"return",
"loadClasses",
"(",
"superclassOrInterfaceType",
",",
"/* ignoreExceptions = */",
"false",
... | Convert this list of {@link ClassInfo} objects to a list of {@code Class<?>} objects, casting each item in
the list to the requested superclass or interface type. Causes the classloader to load the class named by
each {@link ClassInfo} object, if it is not already loaded.
<p>
<b>Important note:</b> since {@code superclassOrInterfaceType} is a class reference for an already-loaded
class, it is critical that {@code superclassOrInterfaceType} is loaded by the same classloader as the class
referred to by this {@code ClassInfo} object, otherwise the class cast will fail.
@param <T>
The superclass or interface.
@param superclassOrInterfaceType
The superclass or interface class reference to cast each loaded class to.
@return The loaded {@code Class<?>} objects corresponding to each {@link ClassInfo} object in this list.
@throws IllegalArgumentException
if an exception or error was thrown while trying to load or cast any of the classes. | [
"Convert",
"this",
"list",
"of",
"{",
"@link",
"ClassInfo",
"}",
"objects",
"to",
"a",
"list",
"of",
"{",
"@code",
"Class<?",
">",
"}",
"objects",
"casting",
"each",
"item",
"in",
"the",
"list",
"to",
"the",
"requested",
"superclass",
"or",
"interface",
... | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfoList.java#L240-L242 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.order_orderId_details_orderDetailId_GET | public OvhOrderDetail order_orderId_details_orderDetailId_GET(Long orderId, Long orderDetailId) throws IOException {
String qPath = "/me/order/{orderId}/details/{orderDetailId}";
StringBuilder sb = path(qPath, orderId, orderDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrderDetail.class);
} | java | public OvhOrderDetail order_orderId_details_orderDetailId_GET(Long orderId, Long orderDetailId) throws IOException {
String qPath = "/me/order/{orderId}/details/{orderDetailId}";
StringBuilder sb = path(qPath, orderId, orderDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrderDetail.class);
} | [
"public",
"OvhOrderDetail",
"order_orderId_details_orderDetailId_GET",
"(",
"Long",
"orderId",
",",
"Long",
"orderDetailId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/order/{orderId}/details/{orderDetailId}\"",
";",
"StringBuilder",
"sb",
"=",
"path"... | Get this object properties
REST: GET /me/order/{orderId}/details/{orderDetailId}
@param orderId [required]
@param orderDetailId [required] | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L1957-L1962 |
radkovo/CSSBox | src/main/java/org/fit/cssbox/layout/BoxFactory.java | BoxFactory.computeInheritedStyle | private void computeInheritedStyle(ElementBox dest, ElementBox parent)
{
NodeData newstyle = dest.getStyle().inheritFrom(parent.getStyle());
dest.setStyle(newstyle);
} | java | private void computeInheritedStyle(ElementBox dest, ElementBox parent)
{
NodeData newstyle = dest.getStyle().inheritFrom(parent.getStyle());
dest.setStyle(newstyle);
} | [
"private",
"void",
"computeInheritedStyle",
"(",
"ElementBox",
"dest",
",",
"ElementBox",
"parent",
")",
"{",
"NodeData",
"newstyle",
"=",
"dest",
".",
"getStyle",
"(",
")",
".",
"inheritFrom",
"(",
"parent",
".",
"getStyle",
"(",
")",
")",
";",
"dest",
".... | Computes the style of a node based on its parent using the CSS inheritance.
@param dest the box whose style should be computed
@param parent the parent box | [
"Computes",
"the",
"style",
"of",
"a",
"node",
"based",
"on",
"its",
"parent",
"using",
"the",
"CSS",
"inheritance",
"."
] | train | https://github.com/radkovo/CSSBox/blob/38aaf8f22d233d7b4dbc12a56cdbc72b447bc559/src/main/java/org/fit/cssbox/layout/BoxFactory.java#L989-L993 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.createImageTags | public ImageTagCreateSummary createImageTags(UUID projectId, CreateImageTagsOptionalParameter createImageTagsOptionalParameter) {
return createImageTagsWithServiceResponseAsync(projectId, createImageTagsOptionalParameter).toBlocking().single().body();
} | java | public ImageTagCreateSummary createImageTags(UUID projectId, CreateImageTagsOptionalParameter createImageTagsOptionalParameter) {
return createImageTagsWithServiceResponseAsync(projectId, createImageTagsOptionalParameter).toBlocking().single().body();
} | [
"public",
"ImageTagCreateSummary",
"createImageTags",
"(",
"UUID",
"projectId",
",",
"CreateImageTagsOptionalParameter",
"createImageTagsOptionalParameter",
")",
"{",
"return",
"createImageTagsWithServiceResponseAsync",
"(",
"projectId",
",",
"createImageTagsOptionalParameter",
")"... | Associate a set of images with a set of tags.
@param projectId The project id
@param createImageTagsOptionalParameter the object representing the optional parameters to be set before calling this API
@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 ImageTagCreateSummary object if successful. | [
"Associate",
"a",
"set",
"of",
"images",
"with",
"a",
"set",
"of",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L3599-L3601 |
Impetus/Kundera | src/kundera-hbase/kundera-hbase-v2/src/main/java/com/impetus/client/hbase/schemamanager/HBaseSchemaManager.java | HBaseSchemaManager.addColumnFamilyAndSetProperties | private void addColumnFamilyAndSetProperties(HTableDescriptor tableDescriptor, String colFamilyName)
{
if (!tableDescriptor.hasFamily(colFamilyName.getBytes()))
{
HColumnDescriptor hColumnDescriptor = getColumnDescriptor(colFamilyName);
tableDescriptor.addFamily(hColumnDescriptor);
setExternalProperties(tableDescriptor.getNameAsString(), hColumnDescriptor);
}
} | java | private void addColumnFamilyAndSetProperties(HTableDescriptor tableDescriptor, String colFamilyName)
{
if (!tableDescriptor.hasFamily(colFamilyName.getBytes()))
{
HColumnDescriptor hColumnDescriptor = getColumnDescriptor(colFamilyName);
tableDescriptor.addFamily(hColumnDescriptor);
setExternalProperties(tableDescriptor.getNameAsString(), hColumnDescriptor);
}
} | [
"private",
"void",
"addColumnFamilyAndSetProperties",
"(",
"HTableDescriptor",
"tableDescriptor",
",",
"String",
"colFamilyName",
")",
"{",
"if",
"(",
"!",
"tableDescriptor",
".",
"hasFamily",
"(",
"colFamilyName",
".",
"getBytes",
"(",
")",
")",
")",
"{",
"HColum... | Adds the column family and set properties.
@param tableDescriptor
the table descriptor
@param colFamilyName
the sec table | [
"Adds",
"the",
"column",
"family",
"and",
"set",
"properties",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-hbase/kundera-hbase-v2/src/main/java/com/impetus/client/hbase/schemamanager/HBaseSchemaManager.java#L362-L370 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java | DateUtil.isIn | public static boolean isIn(Date date, Date beginDate, Date endDate) {
if (date instanceof DateTime) {
return ((DateTime) date).isIn(beginDate, endDate);
} else {
return new DateTime(date).isIn(beginDate, endDate);
}
} | java | public static boolean isIn(Date date, Date beginDate, Date endDate) {
if (date instanceof DateTime) {
return ((DateTime) date).isIn(beginDate, endDate);
} else {
return new DateTime(date).isIn(beginDate, endDate);
}
} | [
"public",
"static",
"boolean",
"isIn",
"(",
"Date",
"date",
",",
"Date",
"beginDate",
",",
"Date",
"endDate",
")",
"{",
"if",
"(",
"date",
"instanceof",
"DateTime",
")",
"{",
"return",
"(",
"(",
"DateTime",
")",
"date",
")",
".",
"isIn",
"(",
"beginDat... | 当前日期是否在日期指定范围内<br>
起始日期和结束日期可以互换
@param date 被检查的日期
@param beginDate 起始日期
@param endDate 结束日期
@return 是否在范围内
@since 3.0.8 | [
"当前日期是否在日期指定范围内<br",
">",
"起始日期和结束日期可以互换"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L1366-L1372 |
99soft/guartz | src/main/java/org/nnsoft/guice/guartz/QuartzModule.java | QuartzModule.doBind | protected final <T> void doBind( Multibinder<T> binder, Class<? extends T> type )
{
checkNotNull( type );
binder.addBinding().to( type );
} | java | protected final <T> void doBind( Multibinder<T> binder, Class<? extends T> type )
{
checkNotNull( type );
binder.addBinding().to( type );
} | [
"protected",
"final",
"<",
"T",
">",
"void",
"doBind",
"(",
"Multibinder",
"<",
"T",
">",
"binder",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"type",
")",
"{",
"checkNotNull",
"(",
"type",
")",
";",
"binder",
".",
"addBinding",
"(",
")",
".",
"t... | Utility method to respect the DRY principle.
@param <T>
@param binder
@param type | [
"Utility",
"method",
"to",
"respect",
"the",
"DRY",
"principle",
"."
] | train | https://github.com/99soft/guartz/blob/3f59096d8dff52475d1677bd5fdff61d12e5fa14/src/main/java/org/nnsoft/guice/guartz/QuartzModule.java#L206-L210 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/util/concurrent/ConcurrentWeakHashMap.java | ConcurrentWeakHashMap.putIfAbsent | public V putIfAbsent( K key, V value )
{
if( value == null )
{
throw new NullPointerException();
}
int hash = hash( key.hashCode() );
return segmentFor( hash ).put( key, hash, value, true );
} | java | public V putIfAbsent( K key, V value )
{
if( value == null )
{
throw new NullPointerException();
}
int hash = hash( key.hashCode() );
return segmentFor( hash ).put( key, hash, value, true );
} | [
"public",
"V",
"putIfAbsent",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"int",
"hash",
"=",
"hash",
"(",
"key",
".",
"hashCode",
"(",
")",
... | {@inheritDoc}
@return the previous value associated with the specified key,
or <tt>null</tt> if there was no mapping for the key
@throws NullPointerException if the specified key or value is null | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/concurrent/ConcurrentWeakHashMap.java#L1153-L1161 |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/FilesystemPath.java | FilesystemPath.schemeWalk | @Override
public PathImpl schemeWalk(String userPath,
Map<String,Object> attributes,
String filePath,
int offset)
{
String canonicalPath;
if (offset < filePath.length()
&& (filePath.charAt(offset) == '/'
|| filePath.charAt(offset) == _separatorChar))
canonicalPath = normalizePath("/", filePath, offset, _separatorChar);
else
canonicalPath = normalizePath(_pathname, filePath, offset,
_separatorChar);
return fsWalk(userPath, attributes, canonicalPath);
} | java | @Override
public PathImpl schemeWalk(String userPath,
Map<String,Object> attributes,
String filePath,
int offset)
{
String canonicalPath;
if (offset < filePath.length()
&& (filePath.charAt(offset) == '/'
|| filePath.charAt(offset) == _separatorChar))
canonicalPath = normalizePath("/", filePath, offset, _separatorChar);
else
canonicalPath = normalizePath(_pathname, filePath, offset,
_separatorChar);
return fsWalk(userPath, attributes, canonicalPath);
} | [
"@",
"Override",
"public",
"PathImpl",
"schemeWalk",
"(",
"String",
"userPath",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
",",
"String",
"filePath",
",",
"int",
"offset",
")",
"{",
"String",
"canonicalPath",
";",
"if",
"(",
"offset",
"<"... | schemeWalk is called by Path for a scheme lookup like file:/tmp/foo
@param userPath the user's lookup() path
@param attributes the user's attributes
@param filePath the actual lookup() path
@param offset offset into filePath | [
"schemeWalk",
"is",
"called",
"by",
"Path",
"for",
"a",
"scheme",
"lookup",
"like",
"file",
":",
"/",
"tmp",
"/",
"foo"
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/FilesystemPath.java#L111-L128 |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreakerFactory.java | CircuitBreakerFactory.getIntegerPropertyOverrideValue | private Integer getIntegerPropertyOverrideValue(String name, String key) {
if (properties != null) {
String propertyName = getPropertyName(name, key);
String propertyOverrideValue = properties.getProperty(propertyName);
if (propertyOverrideValue != null) {
try {
return Integer.parseInt(propertyOverrideValue);
}
catch (NumberFormatException e) {
logger.error("Could not parse property override key={}, value={}",
key, propertyOverrideValue);
}
}
}
return null;
} | java | private Integer getIntegerPropertyOverrideValue(String name, String key) {
if (properties != null) {
String propertyName = getPropertyName(name, key);
String propertyOverrideValue = properties.getProperty(propertyName);
if (propertyOverrideValue != null) {
try {
return Integer.parseInt(propertyOverrideValue);
}
catch (NumberFormatException e) {
logger.error("Could not parse property override key={}, value={}",
key, propertyOverrideValue);
}
}
}
return null;
} | [
"private",
"Integer",
"getIntegerPropertyOverrideValue",
"(",
"String",
"name",
",",
"String",
"key",
")",
"{",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"String",
"propertyName",
"=",
"getPropertyName",
"(",
"name",
",",
"key",
")",
";",
"String",
"p... | Get an integer property override value.
@param name the {@link CircuitBreaker} name.
@param key the property override key.
@return the property override value, or null if it is not found. | [
"Get",
"an",
"integer",
"property",
"override",
"value",
"."
] | train | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreakerFactory.java#L174-L191 |
apache/incubator-shardingsphere | sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/common/dml/PredicateUtils.java | PredicateUtils.createInCondition | public static Optional<Condition> createInCondition(final PredicateInRightValue inRightValue, final Column column) {
List<SQLExpression> sqlExpressions = new LinkedList<>();
for (ExpressionSegment each : inRightValue.getSqlExpressions()) {
if (!(each instanceof SimpleExpressionSegment)) {
sqlExpressions.clear();
break;
} else {
sqlExpressions.add(((SimpleExpressionSegment) each).getSQLExpression());
}
}
return sqlExpressions.isEmpty() ? Optional.<Condition>absent() : Optional.of(new Condition(column, sqlExpressions));
} | java | public static Optional<Condition> createInCondition(final PredicateInRightValue inRightValue, final Column column) {
List<SQLExpression> sqlExpressions = new LinkedList<>();
for (ExpressionSegment each : inRightValue.getSqlExpressions()) {
if (!(each instanceof SimpleExpressionSegment)) {
sqlExpressions.clear();
break;
} else {
sqlExpressions.add(((SimpleExpressionSegment) each).getSQLExpression());
}
}
return sqlExpressions.isEmpty() ? Optional.<Condition>absent() : Optional.of(new Condition(column, sqlExpressions));
} | [
"public",
"static",
"Optional",
"<",
"Condition",
">",
"createInCondition",
"(",
"final",
"PredicateInRightValue",
"inRightValue",
",",
"final",
"Column",
"column",
")",
"{",
"List",
"<",
"SQLExpression",
">",
"sqlExpressions",
"=",
"new",
"LinkedList",
"<>",
"(",... | Create condition of IN operator.
@param inRightValue right value of IN operator
@param column column
@return condition | [
"Create",
"condition",
"of",
"IN",
"operator",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/common/dml/PredicateUtils.java#L112-L123 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Collections.java | Collections.binarySearch | @SuppressWarnings("unchecked")
public static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c) {
if (c==null)
return binarySearch((List<? extends Comparable<? super T>>) list, key);
if (list instanceof RandomAccess || list.size()<BINARYSEARCH_THRESHOLD)
return Collections.indexedBinarySearch(list, key, c);
else
return Collections.iteratorBinarySearch(list, key, c);
} | java | @SuppressWarnings("unchecked")
public static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c) {
if (c==null)
return binarySearch((List<? extends Comparable<? super T>>) list, key);
if (list instanceof RandomAccess || list.size()<BINARYSEARCH_THRESHOLD)
return Collections.indexedBinarySearch(list, key, c);
else
return Collections.iteratorBinarySearch(list, key, c);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"int",
"binarySearch",
"(",
"List",
"<",
"?",
"extends",
"T",
">",
"list",
",",
"T",
"key",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"c",
")",
"{",
"if",
... | Searches the specified list for the specified object using the binary
search algorithm. The list must be sorted into ascending order
according to the specified comparator (as by the
{@link #sort(List, Comparator) sort(List, Comparator)}
method), prior to making this call. If it is
not sorted, the results are undefined. If the list contains multiple
elements equal to the specified object, there is no guarantee which one
will be found.
<p>This method runs in log(n) time for a "random access" list (which
provides near-constant-time positional access). If the specified list
does not implement the {@link RandomAccess} interface and is large,
this method will do an iterator-based binary search that performs
O(n) link traversals and O(log n) element comparisons.
@param <T> the class of the objects in the list
@param list the list to be searched.
@param key the key to be searched for.
@param c the comparator by which the list is ordered.
A <tt>null</tt> value indicates that the elements'
{@linkplain Comparable natural ordering} should be used.
@return the index of the search key, if it is contained in the list;
otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The
<i>insertion point</i> is defined as the point at which the
key would be inserted into the list: the index of the first
element greater than the key, or <tt>list.size()</tt> if all
elements in the list are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.
@throws ClassCastException if the list contains elements that are not
<i>mutually comparable</i> using the specified comparator,
or the search key is not mutually comparable with the
elements of the list using this comparator. | [
"Searches",
"the",
"specified",
"list",
"for",
"the",
"specified",
"object",
"using",
"the",
"binary",
"search",
"algorithm",
".",
"The",
"list",
"must",
"be",
"sorted",
"into",
"ascending",
"order",
"according",
"to",
"the",
"specified",
"comparator",
"(",
"a... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Collections.java#L346-L355 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/watch/WatchMonitor.java | WatchMonitor.createAll | public static WatchMonitor createAll(URL url, Watcher watcher){
try {
return createAll(Paths.get(url.toURI()), watcher);
} catch (URISyntaxException e) {
throw new WatchException(e);
}
} | java | public static WatchMonitor createAll(URL url, Watcher watcher){
try {
return createAll(Paths.get(url.toURI()), watcher);
} catch (URISyntaxException e) {
throw new WatchException(e);
}
} | [
"public",
"static",
"WatchMonitor",
"createAll",
"(",
"URL",
"url",
",",
"Watcher",
"watcher",
")",
"{",
"try",
"{",
"return",
"createAll",
"(",
"Paths",
".",
"get",
"(",
"url",
".",
"toURI",
"(",
")",
")",
",",
"watcher",
")",
";",
"}",
"catch",
"("... | 创建并初始化监听,监听所有事件
@param url URL
@param watcher {@link Watcher}
@return {@link WatchMonitor} | [
"创建并初始化监听,监听所有事件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/watch/WatchMonitor.java#L204-L210 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/Environment.java | Environment.doHttpPost | public void doHttpPost(String url, String templateName, Object model, HttpResponse result, Map<String, Object> headers, String contentType) {
String request = processTemplate(templateName, model);
result.setRequest(request);
doHttpPost(url, result, headers, contentType);
} | java | public void doHttpPost(String url, String templateName, Object model, HttpResponse result, Map<String, Object> headers, String contentType) {
String request = processTemplate(templateName, model);
result.setRequest(request);
doHttpPost(url, result, headers, contentType);
} | [
"public",
"void",
"doHttpPost",
"(",
"String",
"url",
",",
"String",
"templateName",
",",
"Object",
"model",
",",
"HttpResponse",
"result",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"headers",
",",
"String",
"contentType",
")",
"{",
"String",
"request",... | Performs POST to supplied url of result of applying template with model.
@param url url to post to.
@param templateName name of template to use.
@param model model for template.
@param result result to populate with response.
@param headers headers to add.
@param contentType contentType for request. | [
"Performs",
"POST",
"to",
"supplied",
"url",
"of",
"result",
"of",
"applying",
"template",
"with",
"model",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/Environment.java#L272-L276 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/MatrixFeatures_DDRM.java | MatrixFeatures_DDRM.isOrthogonal | public static boolean isOrthogonal(DMatrixRMaj Q , double tol )
{
if( Q.numRows < Q.numCols ) {
throw new IllegalArgumentException("The number of rows must be more than or equal to the number of columns");
}
DMatrixRMaj u[] = CommonOps_DDRM.columnsToVector(Q, null);
for( int i = 0; i < u.length; i++ ) {
DMatrixRMaj a = u[i];
for( int j = i+1; j < u.length; j++ ) {
double val = VectorVectorMult_DDRM.innerProd(a,u[j]);
if( !(Math.abs(val) <= tol))
return false;
}
}
return true;
} | java | public static boolean isOrthogonal(DMatrixRMaj Q , double tol )
{
if( Q.numRows < Q.numCols ) {
throw new IllegalArgumentException("The number of rows must be more than or equal to the number of columns");
}
DMatrixRMaj u[] = CommonOps_DDRM.columnsToVector(Q, null);
for( int i = 0; i < u.length; i++ ) {
DMatrixRMaj a = u[i];
for( int j = i+1; j < u.length; j++ ) {
double val = VectorVectorMult_DDRM.innerProd(a,u[j]);
if( !(Math.abs(val) <= tol))
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isOrthogonal",
"(",
"DMatrixRMaj",
"Q",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"Q",
".",
"numRows",
"<",
"Q",
".",
"numCols",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The number of rows must be more than o... | <p>
Checks to see if a matrix is orthogonal or isometric.
</p>
@param Q The matrix being tested. Not modified.
@param tol Tolerance.
@return True if it passes the test. | [
"<p",
">",
"Checks",
"to",
"see",
"if",
"a",
"matrix",
"is",
"orthogonal",
"or",
"isometric",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/MatrixFeatures_DDRM.java#L476-L496 |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.invokeAsync | public Observable<Indexable> invokeAsync(final InvocationContext context) {
return Observable.defer(new Func0<Observable<Indexable>>() {
@Override
public Observable<Indexable> call() {
if (proxyTaskGroupWrapper.isActive()) {
return proxyTaskGroupWrapper.taskGroup()
.invokeInternAsync(context, true, null);
} else {
Set<String> processedKeys = runBeforeGroupInvoke(null);
if (proxyTaskGroupWrapper.isActive()) {
// If proxy got activated after 'runBeforeGroupInvoke()' stage due to the addition of direct
// 'postRunDependent's then delegate group invocation to proxy group.
//
return proxyTaskGroupWrapper.taskGroup()
.invokeInternAsync(context, true, processedKeys);
} else {
return invokeInternAsync(context, false, null);
}
}
}
});
} | java | public Observable<Indexable> invokeAsync(final InvocationContext context) {
return Observable.defer(new Func0<Observable<Indexable>>() {
@Override
public Observable<Indexable> call() {
if (proxyTaskGroupWrapper.isActive()) {
return proxyTaskGroupWrapper.taskGroup()
.invokeInternAsync(context, true, null);
} else {
Set<String> processedKeys = runBeforeGroupInvoke(null);
if (proxyTaskGroupWrapper.isActive()) {
// If proxy got activated after 'runBeforeGroupInvoke()' stage due to the addition of direct
// 'postRunDependent's then delegate group invocation to proxy group.
//
return proxyTaskGroupWrapper.taskGroup()
.invokeInternAsync(context, true, processedKeys);
} else {
return invokeInternAsync(context, false, null);
}
}
}
});
} | [
"public",
"Observable",
"<",
"Indexable",
">",
"invokeAsync",
"(",
"final",
"InvocationContext",
"context",
")",
"{",
"return",
"Observable",
".",
"defer",
"(",
"new",
"Func0",
"<",
"Observable",
"<",
"Indexable",
">",
">",
"(",
")",
"{",
"@",
"Override",
... | Invokes tasks in the group.
@param context group level shared context that need be passed to invokeAsync(cxt)
method of each task item in the group when it is selected for invocation.
@return an observable that emits the result of tasks in the order they finishes. | [
"Invokes",
"tasks",
"in",
"the",
"group",
"."
] | train | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L239-L260 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/ns/ns_detail_vlan.java | ns_detail_vlan.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
ns_detail_vlan_responses result = (ns_detail_vlan_responses) service.get_payload_formatter().string_to_resource(ns_detail_vlan_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.ns_detail_vlan_response_array);
}
ns_detail_vlan[] result_ns_detail_vlan = new ns_detail_vlan[result.ns_detail_vlan_response_array.length];
for(int i = 0; i < result.ns_detail_vlan_response_array.length; i++)
{
result_ns_detail_vlan[i] = result.ns_detail_vlan_response_array[i].ns_detail_vlan[0];
}
return result_ns_detail_vlan;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
ns_detail_vlan_responses result = (ns_detail_vlan_responses) service.get_payload_formatter().string_to_resource(ns_detail_vlan_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.ns_detail_vlan_response_array);
}
ns_detail_vlan[] result_ns_detail_vlan = new ns_detail_vlan[result.ns_detail_vlan_response_array.length];
for(int i = 0; i < result.ns_detail_vlan_response_array.length; i++)
{
result_ns_detail_vlan[i] = result.ns_detail_vlan_response_array[i].ns_detail_vlan[0];
}
return result_ns_detail_vlan;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"ns_detail_vlan_responses",
"result",
"=",
"(",
"ns_detail_vlan_responses",
")",
"service",
".",
"get_payload_... | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/ns/ns_detail_vlan.java#L268-L285 |
j256/ormlite-core | src/main/java/com/j256/ormlite/stmt/QueryBuilder.java | QueryBuilder.orderBy | public QueryBuilder<T, ID> orderBy(String columnName, boolean ascending) {
FieldType fieldType = verifyColumnName(columnName);
if (fieldType.isForeignCollection()) {
throw new IllegalArgumentException("Can't orderBy foreign collection field: " + columnName);
}
addOrderBy(new OrderBy(columnName, ascending));
return this;
} | java | public QueryBuilder<T, ID> orderBy(String columnName, boolean ascending) {
FieldType fieldType = verifyColumnName(columnName);
if (fieldType.isForeignCollection()) {
throw new IllegalArgumentException("Can't orderBy foreign collection field: " + columnName);
}
addOrderBy(new OrderBy(columnName, ascending));
return this;
} | [
"public",
"QueryBuilder",
"<",
"T",
",",
"ID",
">",
"orderBy",
"(",
"String",
"columnName",
",",
"boolean",
"ascending",
")",
"{",
"FieldType",
"fieldType",
"=",
"verifyColumnName",
"(",
"columnName",
")",
";",
"if",
"(",
"fieldType",
".",
"isForeignCollection... | Add "ORDER BY" clause to the SQL query statement. This can be called multiple times to add additional "ORDER BY"
clauses. Ones earlier are applied first. | [
"Add",
"ORDER",
"BY",
"clause",
"to",
"the",
"SQL",
"query",
"statement",
".",
"This",
"can",
"be",
"called",
"multiple",
"times",
"to",
"add",
"additional",
"ORDER",
"BY",
"clauses",
".",
"Ones",
"earlier",
"are",
"applied",
"first",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/QueryBuilder.java#L175-L182 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SarlCompiler.java | SarlCompiler._toJavaExpression | protected void _toJavaExpression(SarlAssertExpression assertExpression, ITreeAppendable appendable) {
if (!assertExpression.isIsStatic() && isAtLeastJava8(assertExpression)) {
appendable.append("/* error - couldn't compile nested assert */"); //$NON-NLS-1$
}
} | java | protected void _toJavaExpression(SarlAssertExpression assertExpression, ITreeAppendable appendable) {
if (!assertExpression.isIsStatic() && isAtLeastJava8(assertExpression)) {
appendable.append("/* error - couldn't compile nested assert */"); //$NON-NLS-1$
}
} | [
"protected",
"void",
"_toJavaExpression",
"(",
"SarlAssertExpression",
"assertExpression",
",",
"ITreeAppendable",
"appendable",
")",
"{",
"if",
"(",
"!",
"assertExpression",
".",
"isIsStatic",
"(",
")",
"&&",
"isAtLeastJava8",
"(",
"assertExpression",
")",
")",
"{"... | Generate the Java code related to the expression for the assert keyword.
@param assertExpression the expression.
@param appendable the output. | [
"Generate",
"the",
"Java",
"code",
"related",
"to",
"the",
"expression",
"for",
"the",
"assert",
"keyword",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SarlCompiler.java#L705-L709 |
NordicSemiconductor/Android-DFU-Library | dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java | DfuBaseService.openInputStream | private InputStream openInputStream(@NonNull final Uri stream, final String mimeType, final int mbrSize, final int types)
throws IOException {
final InputStream is = getContentResolver().openInputStream(stream);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
final String[] projection = {MediaStore.Images.Media.DISPLAY_NAME};
final Cursor cursor = getContentResolver().query(stream, projection, null, null, null);
try {
if (cursor.moveToNext()) {
final String fileName = cursor.getString(0 /* DISPLAY_NAME*/);
if (fileName.toLowerCase(Locale.US).endsWith("hex"))
return new HexInputStream(is, mbrSize);
}
} finally {
cursor.close();
}
return is;
} | java | private InputStream openInputStream(@NonNull final Uri stream, final String mimeType, final int mbrSize, final int types)
throws IOException {
final InputStream is = getContentResolver().openInputStream(stream);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
final String[] projection = {MediaStore.Images.Media.DISPLAY_NAME};
final Cursor cursor = getContentResolver().query(stream, projection, null, null, null);
try {
if (cursor.moveToNext()) {
final String fileName = cursor.getString(0 /* DISPLAY_NAME*/);
if (fileName.toLowerCase(Locale.US).endsWith("hex"))
return new HexInputStream(is, mbrSize);
}
} finally {
cursor.close();
}
return is;
} | [
"private",
"InputStream",
"openInputStream",
"(",
"@",
"NonNull",
"final",
"Uri",
"stream",
",",
"final",
"String",
"mimeType",
",",
"final",
"int",
"mbrSize",
",",
"final",
"int",
"types",
")",
"throws",
"IOException",
"{",
"final",
"InputStream",
"is",
"=",
... | Opens the binary input stream. A Uri to the stream is given.
@param stream the Uri to the stream.
@param mimeType the file type.
@param mbrSize the size of MBR, by default 0x1000.
@param types the content files types in ZIP.
@return The input stream with binary image content. | [
"Opens",
"the",
"binary",
"input",
"stream",
".",
"A",
"Uri",
"to",
"the",
"stream",
"is",
"given",
"."
] | train | https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ec14c8c522bebe801a9a4c3dfbbeb1f53262c03f/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java#L1435-L1454 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java | Task.triggerCheckpointBarrier | public void triggerCheckpointBarrier(
final long checkpointID,
final long checkpointTimestamp,
final CheckpointOptions checkpointOptions,
final boolean advanceToEndOfEventTime) {
final AbstractInvokable invokable = this.invokable;
final CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointID, checkpointTimestamp);
if (executionState == ExecutionState.RUNNING && invokable != null) {
// build a local closure
final String taskName = taskNameWithSubtask;
final SafetyNetCloseableRegistry safetyNetCloseableRegistry =
FileSystemSafetyNet.getSafetyNetCloseableRegistryForThread();
Runnable runnable = new Runnable() {
@Override
public void run() {
// set safety net from the task's context for checkpointing thread
LOG.debug("Creating FileSystem stream leak safety net for {}", Thread.currentThread().getName());
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(safetyNetCloseableRegistry);
try {
boolean success = invokable.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
if (!success) {
checkpointResponder.declineCheckpoint(
getJobID(), getExecutionId(), checkpointID,
new CheckpointDeclineTaskNotReadyException(taskName));
}
}
catch (Throwable t) {
if (getExecutionState() == ExecutionState.RUNNING) {
failExternally(new Exception(
"Error while triggering checkpoint " + checkpointID + " for " +
taskNameWithSubtask, t));
} else {
LOG.debug("Encountered error while triggering checkpoint {} for " +
"{} ({}) while being not in state running.", checkpointID,
taskNameWithSubtask, executionId, t);
}
} finally {
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(null);
}
}
};
executeAsyncCallRunnable(
runnable,
String.format("Checkpoint Trigger for %s (%s).", taskNameWithSubtask, executionId),
checkpointOptions.getCheckpointType().isSynchronous());
}
else {
LOG.debug("Declining checkpoint request for non-running task {} ({}).", taskNameWithSubtask, executionId);
// send back a message that we did not do the checkpoint
checkpointResponder.declineCheckpoint(jobId, executionId, checkpointID,
new CheckpointDeclineTaskNotReadyException(taskNameWithSubtask));
}
} | java | public void triggerCheckpointBarrier(
final long checkpointID,
final long checkpointTimestamp,
final CheckpointOptions checkpointOptions,
final boolean advanceToEndOfEventTime) {
final AbstractInvokable invokable = this.invokable;
final CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointID, checkpointTimestamp);
if (executionState == ExecutionState.RUNNING && invokable != null) {
// build a local closure
final String taskName = taskNameWithSubtask;
final SafetyNetCloseableRegistry safetyNetCloseableRegistry =
FileSystemSafetyNet.getSafetyNetCloseableRegistryForThread();
Runnable runnable = new Runnable() {
@Override
public void run() {
// set safety net from the task's context for checkpointing thread
LOG.debug("Creating FileSystem stream leak safety net for {}", Thread.currentThread().getName());
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(safetyNetCloseableRegistry);
try {
boolean success = invokable.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
if (!success) {
checkpointResponder.declineCheckpoint(
getJobID(), getExecutionId(), checkpointID,
new CheckpointDeclineTaskNotReadyException(taskName));
}
}
catch (Throwable t) {
if (getExecutionState() == ExecutionState.RUNNING) {
failExternally(new Exception(
"Error while triggering checkpoint " + checkpointID + " for " +
taskNameWithSubtask, t));
} else {
LOG.debug("Encountered error while triggering checkpoint {} for " +
"{} ({}) while being not in state running.", checkpointID,
taskNameWithSubtask, executionId, t);
}
} finally {
FileSystemSafetyNet.setSafetyNetCloseableRegistryForThread(null);
}
}
};
executeAsyncCallRunnable(
runnable,
String.format("Checkpoint Trigger for %s (%s).", taskNameWithSubtask, executionId),
checkpointOptions.getCheckpointType().isSynchronous());
}
else {
LOG.debug("Declining checkpoint request for non-running task {} ({}).", taskNameWithSubtask, executionId);
// send back a message that we did not do the checkpoint
checkpointResponder.declineCheckpoint(jobId, executionId, checkpointID,
new CheckpointDeclineTaskNotReadyException(taskNameWithSubtask));
}
} | [
"public",
"void",
"triggerCheckpointBarrier",
"(",
"final",
"long",
"checkpointID",
",",
"final",
"long",
"checkpointTimestamp",
",",
"final",
"CheckpointOptions",
"checkpointOptions",
",",
"final",
"boolean",
"advanceToEndOfEventTime",
")",
"{",
"final",
"AbstractInvokab... | Calls the invokable to trigger a checkpoint.
@param checkpointID The ID identifying the checkpoint.
@param checkpointTimestamp The timestamp associated with the checkpoint.
@param checkpointOptions Options for performing this checkpoint.
@param advanceToEndOfEventTime Flag indicating if the source should inject a {@code MAX_WATERMARK} in the pipeline
to fire any registered event-time timers. | [
"Calls",
"the",
"invokable",
"to",
"trigger",
"a",
"checkpoint",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java#L1161-L1219 |
maxirosson/jdroid-android | jdroid-android-core/src/main/java/com/jdroid/android/utils/TooltipHelper.java | TooltipHelper.setup | public static void setup(View view, final CharSequence text) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
return showCheatSheet(view, text);
}
});
} | java | public static void setup(View view, final CharSequence text) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
return showCheatSheet(view, text);
}
});
} | [
"public",
"static",
"void",
"setup",
"(",
"View",
"view",
",",
"final",
"CharSequence",
"text",
")",
"{",
"view",
".",
"setOnLongClickListener",
"(",
"new",
"View",
".",
"OnLongClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onLongClick",... | Sets up a cheat sheet (tooltip) for the given view by setting its {@link android.view.View.OnLongClickListener}.
When the view is long-pressed, a {@link Toast} with the given text will be shown either above (default) or below
the view (if there isn't room above it).
@param view The view to add a cheat sheet for.
@param text The text to show on long-press. | [
"Sets",
"up",
"a",
"cheat",
"sheet",
"(",
"tooltip",
")",
"for",
"the",
"given",
"view",
"by",
"setting",
"its",
"{",
"@link",
"android",
".",
"view",
".",
"View",
".",
"OnLongClickListener",
"}",
".",
"When",
"the",
"view",
"is",
"long",
"-",
"pressed... | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/utils/TooltipHelper.java#L71-L79 |
keyboardsurfer/Crouton | library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java | Crouton.showText | public static void showText(Activity activity, CharSequence text, Style style) {
makeText(activity, text, style).show();
} | java | public static void showText(Activity activity, CharSequence text, Style style) {
makeText(activity, text, style).show();
} | [
"public",
"static",
"void",
"showText",
"(",
"Activity",
"activity",
",",
"CharSequence",
"text",
",",
"Style",
"style",
")",
"{",
"makeText",
"(",
"activity",
",",
"text",
",",
"style",
")",
".",
"show",
"(",
")",
";",
"}"
] | Creates a {@link Crouton} with provided text and style for a given activity
and displays it directly.
@param activity
The {@link android.app.Activity} that the {@link Crouton} should
be attached to.
@param text
The text you want to display.
@param style
The style that this {@link Crouton} should be created with. | [
"Creates",
"a",
"{",
"@link",
"Crouton",
"}",
"with",
"provided",
"text",
"and",
"style",
"for",
"a",
"given",
"activity",
"and",
"displays",
"it",
"directly",
"."
] | train | https://github.com/keyboardsurfer/Crouton/blob/7806b15e4d52793e1f5aeaa4a55b1e220289e619/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java#L377-L379 |
hageldave/ImagingKit | ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ArrayUtils.java | ArrayUtils.scaleArray | public static void scaleArray(final double[] array, final double factor){
for(int i = 0; i < array.length; i++){
array[i] *= factor;
}
} | java | public static void scaleArray(final double[] array, final double factor){
for(int i = 0; i < array.length; i++){
array[i] *= factor;
}
} | [
"public",
"static",
"void",
"scaleArray",
"(",
"final",
"double",
"[",
"]",
"array",
",",
"final",
"double",
"factor",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"array",
"[",
"i",... | Multiplies elements of array by specified factor
@param array of elements to scale
@param factor to scale by | [
"Multiplies",
"elements",
"of",
"array",
"by",
"specified",
"factor"
] | train | https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ArrayUtils.java#L119-L123 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java | LayoutParser.parseXML | public XMLNode parseXML(String root) throws DocFileIOException, SimpleDocletException {
if (!xmlElementsMap.containsKey(root)) {
try {
currentRoot = root;
isParsing = false;
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
InputStream in = configuration.getBuilderXML();
saxParser.parse(in, this);
} catch (IOException | ParserConfigurationException | SAXException e) {
String message = (configuration.builderXMLPath == null)
? configuration.getResources().getText("doclet.exception.read.resource",
Configuration.DEFAULT_BUILDER_XML, e)
: configuration.getResources().getText("doclet.exception.read.file",
configuration.builderXMLPath, e);
throw new SimpleDocletException(message, e);
}
}
return xmlElementsMap.get(root);
} | java | public XMLNode parseXML(String root) throws DocFileIOException, SimpleDocletException {
if (!xmlElementsMap.containsKey(root)) {
try {
currentRoot = root;
isParsing = false;
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
InputStream in = configuration.getBuilderXML();
saxParser.parse(in, this);
} catch (IOException | ParserConfigurationException | SAXException e) {
String message = (configuration.builderXMLPath == null)
? configuration.getResources().getText("doclet.exception.read.resource",
Configuration.DEFAULT_BUILDER_XML, e)
: configuration.getResources().getText("doclet.exception.read.file",
configuration.builderXMLPath, e);
throw new SimpleDocletException(message, e);
}
}
return xmlElementsMap.get(root);
} | [
"public",
"XMLNode",
"parseXML",
"(",
"String",
"root",
")",
"throws",
"DocFileIOException",
",",
"SimpleDocletException",
"{",
"if",
"(",
"!",
"xmlElementsMap",
".",
"containsKey",
"(",
"root",
")",
")",
"{",
"try",
"{",
"currentRoot",
"=",
"root",
";",
"is... | Parse the XML specifying the layout of the documentation.
@param root the name of the desired node
@return the list of XML elements parsed.
@throws DocFileIOException if there is a problem reading a user-supplied build file
@throws SimpleDocletException if there is a problem reading the system build file | [
"Parse",
"the",
"XML",
"specifying",
"the",
"layout",
"of",
"the",
"documentation",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java#L86-L105 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java | CacheProviderWrapper.getValue | @Override
public Object getValue(Object id, String template, boolean askPermission, boolean ignoreCounting) {
final String methodName = "getValue()";
Object value = null;
com.ibm.websphere.cache.CacheEntry ce = this.coreCache.get(id);
if (ce != null) {
value = ce.getValue();
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return value;
} | java | @Override
public Object getValue(Object id, String template, boolean askPermission, boolean ignoreCounting) {
final String methodName = "getValue()";
Object value = null;
com.ibm.websphere.cache.CacheEntry ce = this.coreCache.get(id);
if (ce != null) {
value = ce.getValue();
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return value;
} | [
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"Object",
"id",
",",
"String",
"template",
",",
"boolean",
"askPermission",
",",
"boolean",
"ignoreCounting",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"getValue()\"",
";",
"Object",
"value",
"=",
"... | Returns the value to which this map maps the specified cache id. Returns
<tt>null</tt> if the map contains no mapping for this key.
@param id cache id whose associated value is to be returned.
@param template template name associated with cache id (No effect on CoreCache)
@param askPermission True implies that execution must ask the coordinating CacheUnit for permission (No effect on CoreCache).
@param ignoreCounting True implies that no counting for PMI and cache statistics (No effect on CoreCache)
@return the value to which this map maps the specified cache id, or
<tt>null</tt> if the map contains no mapping for this cache id. | [
"Returns",
"the",
"value",
"to",
"which",
"this",
"map",
"maps",
"the",
"specified",
"cache",
"id",
".",
"Returns",
"<tt",
">",
"null<",
"/",
"tt",
">",
"if",
"the",
"map",
"contains",
"no",
"mapping",
"for",
"this",
"key",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java#L415-L427 |
real-logic/agrona | agrona/src/main/java/org/agrona/collections/ArrayListUtil.java | ArrayListUtil.fastUnorderedRemove | public static <T> boolean fastUnorderedRemove(final ArrayList<T> list, final T e)
{
for (int i = 0, size = list.size(); i < size; i++)
{
if (e == list.get(i))
{
fastUnorderedRemove(list, i, size - 1);
return true;
}
}
return false;
} | java | public static <T> boolean fastUnorderedRemove(final ArrayList<T> list, final T e)
{
for (int i = 0, size = list.size(); i < size; i++)
{
if (e == list.get(i))
{
fastUnorderedRemove(list, i, size - 1);
return true;
}
}
return false;
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"fastUnorderedRemove",
"(",
"final",
"ArrayList",
"<",
"T",
">",
"list",
",",
"final",
"T",
"e",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"size",
"=",
"list",
".",
"size",
"(",
")",
";",
"i",
... | Removes element but instead of copying all elements to the left, moves into the same slot the last element.
This avoids the copy costs, but spoils the list order. If element is the last element then it is just removed.
@param list to be modified.
@param e to be removed.
@param <T> element type.
@return true if found and removed, false otherwise. | [
"Removes",
"element",
"but",
"instead",
"of",
"copying",
"all",
"elements",
"to",
"the",
"left",
"moves",
"into",
"the",
"same",
"slot",
"the",
"last",
"element",
".",
"This",
"avoids",
"the",
"copy",
"costs",
"but",
"spoils",
"the",
"list",
"order",
".",
... | train | https://github.com/real-logic/agrona/blob/d1ea76e6e3598cd6a0d34879687652ef123f639b/agrona/src/main/java/org/agrona/collections/ArrayListUtil.java#L78-L90 |
OpenLiberty/open-liberty | dev/com.ibm.ws.classloader.context/src/com/ibm/ws/classloader/context/internal/ClassloaderContextImpl.java | ClassloaderContextImpl.setCL | private void setCL(final ClassLoader cl) {
PrivilegedAction<Object> action = new PrivilegedAction<Object>() {
@Override
@FFDCIgnore(SecurityException.class)
public Object run() {
final Thread t = Thread.currentThread();
try {
t.setContextClassLoader(cl);
} catch (SecurityException e) {
// If this work happens to run on an java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread,
// setting the ClassLoader may be rejected. If this happens, give a decent error message.
if (t instanceof ForkJoinWorkerThread && "InnocuousForkJoinWorkerThreadGroup".equals(t.getThreadGroup().getName())) {
throw new SecurityException(Tr.formatMessage(tc, "cannot.apply.classloader.context", t.getName()), e);
} else {
throw e;
}
}
return null;
}
};
AccessController.doPrivileged(action);
} | java | private void setCL(final ClassLoader cl) {
PrivilegedAction<Object> action = new PrivilegedAction<Object>() {
@Override
@FFDCIgnore(SecurityException.class)
public Object run() {
final Thread t = Thread.currentThread();
try {
t.setContextClassLoader(cl);
} catch (SecurityException e) {
// If this work happens to run on an java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread,
// setting the ClassLoader may be rejected. If this happens, give a decent error message.
if (t instanceof ForkJoinWorkerThread && "InnocuousForkJoinWorkerThreadGroup".equals(t.getThreadGroup().getName())) {
throw new SecurityException(Tr.formatMessage(tc, "cannot.apply.classloader.context", t.getName()), e);
} else {
throw e;
}
}
return null;
}
};
AccessController.doPrivileged(action);
} | [
"private",
"void",
"setCL",
"(",
"final",
"ClassLoader",
"cl",
")",
"{",
"PrivilegedAction",
"<",
"Object",
">",
"action",
"=",
"new",
"PrivilegedAction",
"<",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"@",
"FFDCIgnore",
"(",
"SecurityException",
".",
... | Sets the provided classloader on the current thread.
@param cl The clasloader to be set. | [
"Sets",
"the",
"provided",
"classloader",
"on",
"the",
"current",
"thread",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.classloader.context/src/com/ibm/ws/classloader/context/internal/ClassloaderContextImpl.java#L151-L172 |
google/j2objc | jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java | MutableBigInteger.divide3n2n | private MutableBigInteger divide3n2n(MutableBigInteger b, MutableBigInteger quotient) {
int n = b.intLen / 2; // half the length of b in ints
// step 1: view this as [a1,a2,a3] where each ai is n ints or less; let a12=[a1,a2]
MutableBigInteger a12 = new MutableBigInteger(this);
a12.safeRightShift(32*n);
// step 2: view b as [b1,b2] where each bi is n ints or less
MutableBigInteger b1 = new MutableBigInteger(b);
b1.safeRightShift(n * 32);
BigInteger b2 = b.getLower(n);
MutableBigInteger r;
MutableBigInteger d;
if (compareShifted(b, n) < 0) {
// step 3a: if a1<b1, let quotient=a12/b1 and r=a12%b1
r = a12.divide2n1n(b1, quotient);
// step 4: d=quotient*b2
d = new MutableBigInteger(quotient.toBigInteger().multiply(b2));
} else {
// step 3b: if a1>=b1, let quotient=beta^n-1 and r=a12-b1*2^n+b1
quotient.ones(n);
a12.add(b1);
b1.leftShift(32*n);
a12.subtract(b1);
r = a12;
// step 4: d=quotient*b2=(b2 << 32*n) - b2
d = new MutableBigInteger(b2);
d.leftShift(32 * n);
d.subtract(new MutableBigInteger(b2));
}
// step 5: r = r*beta^n + a3 - d (paper says a4)
// However, don't subtract d until after the while loop so r doesn't become negative
r.leftShift(32 * n);
r.addLower(this, n);
// step 6: add b until r>=d
while (r.compare(d) < 0) {
r.add(b);
quotient.subtract(MutableBigInteger.ONE);
}
r.subtract(d);
return r;
} | java | private MutableBigInteger divide3n2n(MutableBigInteger b, MutableBigInteger quotient) {
int n = b.intLen / 2; // half the length of b in ints
// step 1: view this as [a1,a2,a3] where each ai is n ints or less; let a12=[a1,a2]
MutableBigInteger a12 = new MutableBigInteger(this);
a12.safeRightShift(32*n);
// step 2: view b as [b1,b2] where each bi is n ints or less
MutableBigInteger b1 = new MutableBigInteger(b);
b1.safeRightShift(n * 32);
BigInteger b2 = b.getLower(n);
MutableBigInteger r;
MutableBigInteger d;
if (compareShifted(b, n) < 0) {
// step 3a: if a1<b1, let quotient=a12/b1 and r=a12%b1
r = a12.divide2n1n(b1, quotient);
// step 4: d=quotient*b2
d = new MutableBigInteger(quotient.toBigInteger().multiply(b2));
} else {
// step 3b: if a1>=b1, let quotient=beta^n-1 and r=a12-b1*2^n+b1
quotient.ones(n);
a12.add(b1);
b1.leftShift(32*n);
a12.subtract(b1);
r = a12;
// step 4: d=quotient*b2=(b2 << 32*n) - b2
d = new MutableBigInteger(b2);
d.leftShift(32 * n);
d.subtract(new MutableBigInteger(b2));
}
// step 5: r = r*beta^n + a3 - d (paper says a4)
// However, don't subtract d until after the while loop so r doesn't become negative
r.leftShift(32 * n);
r.addLower(this, n);
// step 6: add b until r>=d
while (r.compare(d) < 0) {
r.add(b);
quotient.subtract(MutableBigInteger.ONE);
}
r.subtract(d);
return r;
} | [
"private",
"MutableBigInteger",
"divide3n2n",
"(",
"MutableBigInteger",
"b",
",",
"MutableBigInteger",
"quotient",
")",
"{",
"int",
"n",
"=",
"b",
".",
"intLen",
"/",
"2",
";",
"// half the length of b in ints",
"// step 1: view this as [a1,a2,a3] where each ai is n ints or... | This method implements algorithm 2 from pg. 5 of the Burnikel-Ziegler paper.
It divides a 3n-digit number by a 2n-digit number.<br/>
The parameter beta is 2<sup>32</sup> so all shifts are multiples of 32 bits.<br/>
<br/>
{@code this} must be a nonnegative number such that {@code 2*this.bitLength() <= 3*b.bitLength()}
@param quotient output parameter for {@code this/b}
@return {@code this%b} | [
"This",
"method",
"implements",
"algorithm",
"2",
"from",
"pg",
".",
"5",
"of",
"the",
"Burnikel",
"-",
"Ziegler",
"paper",
".",
"It",
"divides",
"a",
"3n",
"-",
"digit",
"number",
"by",
"a",
"2n",
"-",
"digit",
"number",
".",
"<br",
"/",
">",
"The",... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java#L1345-L1392 |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/AutotuningPCA.java | AutotuningPCA.computeExplainedVariance | private double computeExplainedVariance(double[] eigenValues, int filteredEigenPairs) {
double strongsum = 0., weaksum = 0.;
for(int i = 0; i < filteredEigenPairs; i++) {
strongsum += eigenValues[i];
}
for(int i = filteredEigenPairs; i < eigenValues.length; i++) {
weaksum += eigenValues[i];
}
return strongsum / (strongsum + weaksum);
} | java | private double computeExplainedVariance(double[] eigenValues, int filteredEigenPairs) {
double strongsum = 0., weaksum = 0.;
for(int i = 0; i < filteredEigenPairs; i++) {
strongsum += eigenValues[i];
}
for(int i = filteredEigenPairs; i < eigenValues.length; i++) {
weaksum += eigenValues[i];
}
return strongsum / (strongsum + weaksum);
} | [
"private",
"double",
"computeExplainedVariance",
"(",
"double",
"[",
"]",
"eigenValues",
",",
"int",
"filteredEigenPairs",
")",
"{",
"double",
"strongsum",
"=",
"0.",
",",
"weaksum",
"=",
"0.",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"filte... | Compute the explained variance for a filtered EigenPairs.
@param eigenValues Eigen values
@param filteredEigenPairs Filtered eigenpairs
@return explained variance by the strong eigenvectors. | [
"Compute",
"the",
"explained",
"variance",
"for",
"a",
"filtered",
"EigenPairs",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/AutotuningPCA.java#L219-L228 |
QNJR-GROUP/EasyTransaction | easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/IdempotentHelper.java | IdempotentHelper.getIdempotentPo | public IdempotentPo getIdempotentPo(EasyTransFilterChain filterChain, Map<String,Object> header, EasyTransRequest<?, ?> reqest){
BusinessIdentifer businessType = ReflectUtil.getBusinessIdentifer(reqest.getClass());
Object trxIdObj = header.get(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
TransactionId transactionId = (TransactionId) trxIdObj;
Integer callSeq = Integer.parseInt(header.get(EasytransConstant.CallHeadKeys.CALL_SEQ).toString());
JdbcTemplate jdbcTemplate = getJdbcTemplate(filterChain, reqest);
List<IdempotentPo> listQuery = jdbcTemplate.query(
selectSql,
new Object[]{
stringCodecer.findId(APP_ID, transactionId.getAppId()),
stringCodecer.findId(BUSINESS_CODE,transactionId.getBusCode()),
transactionId.getTrxId(),
stringCodecer.findId(APP_ID, businessType.appId()),
stringCodecer.findId(BUSINESS_CODE,businessType.busCode()),
callSeq,
stringCodecer.findId(APP_ID,appId)},
beanPropertyRowMapper
);
if(listQuery.size() == 1){
return listQuery.get(0);
}else if (listQuery.size() == 0){
return null;
}else{
throw new RuntimeException("Unkonw Error!" + listQuery);
}
} | java | public IdempotentPo getIdempotentPo(EasyTransFilterChain filterChain, Map<String,Object> header, EasyTransRequest<?, ?> reqest){
BusinessIdentifer businessType = ReflectUtil.getBusinessIdentifer(reqest.getClass());
Object trxIdObj = header.get(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
TransactionId transactionId = (TransactionId) trxIdObj;
Integer callSeq = Integer.parseInt(header.get(EasytransConstant.CallHeadKeys.CALL_SEQ).toString());
JdbcTemplate jdbcTemplate = getJdbcTemplate(filterChain, reqest);
List<IdempotentPo> listQuery = jdbcTemplate.query(
selectSql,
new Object[]{
stringCodecer.findId(APP_ID, transactionId.getAppId()),
stringCodecer.findId(BUSINESS_CODE,transactionId.getBusCode()),
transactionId.getTrxId(),
stringCodecer.findId(APP_ID, businessType.appId()),
stringCodecer.findId(BUSINESS_CODE,businessType.busCode()),
callSeq,
stringCodecer.findId(APP_ID,appId)},
beanPropertyRowMapper
);
if(listQuery.size() == 1){
return listQuery.get(0);
}else if (listQuery.size() == 0){
return null;
}else{
throw new RuntimeException("Unkonw Error!" + listQuery);
}
} | [
"public",
"IdempotentPo",
"getIdempotentPo",
"(",
"EasyTransFilterChain",
"filterChain",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"header",
",",
"EasyTransRequest",
"<",
"?",
",",
"?",
">",
"reqest",
")",
"{",
"BusinessIdentifer",
"businessType",
"=",
"Ref... | get execute result from database
@param filterChain
@param reqest
@return | [
"get",
"execute",
"result",
"from",
"database"
] | train | https://github.com/QNJR-GROUP/EasyTransaction/blob/53b031724a3fd1145f32b9a7b5c6fb8138d6a426/easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/IdempotentHelper.java#L142-L168 |
apache/incubator-atlas | common/src/main/java/org/apache/atlas/utils/ParamChecker.java | ParamChecker.lessThan | public static void lessThan(long value, long maxValue, String name) {
if (value <= 0) {
throw new IllegalArgumentException(name + " should be > 0, current value " + value);
}
if (value > maxValue) {
throw new IllegalArgumentException(name + " should be <= " + maxValue + ", current value " + value);
}
} | java | public static void lessThan(long value, long maxValue, String name) {
if (value <= 0) {
throw new IllegalArgumentException(name + " should be > 0, current value " + value);
}
if (value > maxValue) {
throw new IllegalArgumentException(name + " should be <= " + maxValue + ", current value " + value);
}
} | [
"public",
"static",
"void",
"lessThan",
"(",
"long",
"value",
",",
"long",
"maxValue",
",",
"String",
"name",
")",
"{",
"if",
"(",
"value",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" should be > 0, current value \"",... | Checks that the given value is <= max value.
@param value
@param maxValue
@param name | [
"Checks",
"that",
"the",
"given",
"value",
"is",
"<",
"=",
"max",
"value",
"."
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java#L147-L154 |
apache/incubator-druid | sql/src/main/java/org/apache/druid/sql/calcite/schema/InformationSchema.java | InformationSchema.getView | @Nullable
private static TableMacro getView(final SchemaPlus schemaPlus, final String functionName)
{
// Look for a zero-arg function that is also a TableMacro. The returned value
// is never null so we don't need to check for that.
final Collection<org.apache.calcite.schema.Function> functions =
schemaPlus.getFunctions(functionName);
for (org.apache.calcite.schema.Function function : functions) {
if (function.getParameters().isEmpty() && function instanceof TableMacro) {
return (TableMacro) function;
}
}
return null;
} | java | @Nullable
private static TableMacro getView(final SchemaPlus schemaPlus, final String functionName)
{
// Look for a zero-arg function that is also a TableMacro. The returned value
// is never null so we don't need to check for that.
final Collection<org.apache.calcite.schema.Function> functions =
schemaPlus.getFunctions(functionName);
for (org.apache.calcite.schema.Function function : functions) {
if (function.getParameters().isEmpty() && function instanceof TableMacro) {
return (TableMacro) function;
}
}
return null;
} | [
"@",
"Nullable",
"private",
"static",
"TableMacro",
"getView",
"(",
"final",
"SchemaPlus",
"schemaPlus",
",",
"final",
"String",
"functionName",
")",
"{",
"// Look for a zero-arg function that is also a TableMacro. The returned value",
"// is never null so we don't need to check fo... | Return a view macro that may or may not be defined in a certain schema. If it's not defined, returns null.
@param schemaPlus schema
@param functionName function name
@return view, or null | [
"Return",
"a",
"view",
"macro",
"that",
"may",
"or",
"may",
"not",
"be",
"defined",
"in",
"a",
"certain",
"schema",
".",
"If",
"it",
"s",
"not",
"defined",
"returns",
"null",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/sql/src/main/java/org/apache/druid/sql/calcite/schema/InformationSchema.java#L432-L447 |
mapbox/mapbox-plugins-android | plugin-offline/src/main/java/com/mapbox/mapboxsdk/plugins/offline/offline/OfflineDownloadService.java | OfflineDownloadService.onResolveCommand | private void onResolveCommand(String intentAction, OfflineDownloadOptions offlineDownload) {
if (OfflineConstants.ACTION_START_DOWNLOAD.equals(intentAction)) {
createDownload(offlineDownload);
} else if (OfflineConstants.ACTION_CANCEL_DOWNLOAD.equals(intentAction)) {
cancelDownload(offlineDownload);
}
} | java | private void onResolveCommand(String intentAction, OfflineDownloadOptions offlineDownload) {
if (OfflineConstants.ACTION_START_DOWNLOAD.equals(intentAction)) {
createDownload(offlineDownload);
} else if (OfflineConstants.ACTION_CANCEL_DOWNLOAD.equals(intentAction)) {
cancelDownload(offlineDownload);
}
} | [
"private",
"void",
"onResolveCommand",
"(",
"String",
"intentAction",
",",
"OfflineDownloadOptions",
"offlineDownload",
")",
"{",
"if",
"(",
"OfflineConstants",
".",
"ACTION_START_DOWNLOAD",
".",
"equals",
"(",
"intentAction",
")",
")",
"{",
"createDownload",
"(",
"... | Several actions can take place inside this service including starting and canceling a specific
region download. First, it is determined what action to take by using the {@code intentAction}
parameter. This action is finally passed in to the correct map offline methods.
@param intentAction string holding the task that should be performed on the specific
{@link OfflineDownloadOptions} regional download.
@param offlineDownload the download model which defines the region and other metadata needed to
download the correct region.
@since 0.1.0 | [
"Several",
"actions",
"can",
"take",
"place",
"inside",
"this",
"service",
"including",
"starting",
"and",
"canceling",
"a",
"specific",
"region",
"download",
".",
"First",
"it",
"is",
"determined",
"what",
"action",
"to",
"take",
"by",
"using",
"the",
"{",
... | train | https://github.com/mapbox/mapbox-plugins-android/blob/c683cad4d8306945d71838d96fae73b8cbe2e6c9/plugin-offline/src/main/java/com/mapbox/mapboxsdk/plugins/offline/offline/OfflineDownloadService.java#L110-L116 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/Expression.java | Expression.asIteratorRaw | public DTMIterator asIteratorRaw(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException
{
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
XNodeSet nodeset = (XNodeSet)execute(xctxt);
return nodeset.iterRaw();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
} | java | public DTMIterator asIteratorRaw(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException
{
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
XNodeSet nodeset = (XNodeSet)execute(xctxt);
return nodeset.iterRaw();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
} | [
"public",
"DTMIterator",
"asIteratorRaw",
"(",
"XPathContext",
"xctxt",
",",
"int",
"contextNode",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"try",
"{",
"xctxt",
".",
"pushCurrentNodeAndExpression",
"(",
"contextNode",
... | Given an select expression and a context, evaluate the XPath
and return the resulting iterator, but do not clone.
@param xctxt The execution context.
@param contextNode The node that "." expresses.
@return A valid DTMIterator.
@throws TransformerException thrown if the active ProblemListener decides
the error condition is severe enough to halt processing.
@throws javax.xml.transform.TransformerException
@xsl.usage experimental | [
"Given",
"an",
"select",
"expression",
"and",
"a",
"context",
"evaluate",
"the",
"XPath",
"and",
"return",
"the",
"resulting",
"iterator",
"but",
"do",
"not",
"clone",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/Expression.java#L275-L290 |
osglworks/java-tool | src/main/java/org/osgl/util/E.java | E.NPE | public static void NPE(Object o1, Object o2, Object o3) {
if (null == o1 || null == o2 || null == o3) {
throw new NullPointerException();
}
} | java | public static void NPE(Object o1, Object o2, Object o3) {
if (null == o1 || null == o2 || null == o3) {
throw new NullPointerException();
}
} | [
"public",
"static",
"void",
"NPE",
"(",
"Object",
"o1",
",",
"Object",
"o2",
",",
"Object",
"o3",
")",
"{",
"if",
"(",
"null",
"==",
"o1",
"||",
"null",
"==",
"o2",
"||",
"null",
"==",
"o3",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")... | Throws out {@link NullPointerException} if `o1` or `o2` or `o3` is `null`.
@param o1
the first object to be evaluated
@param o2
the second object to be evaluated
@param o3
the third object to be evaluated | [
"Throws",
"out",
"{"
] | train | https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/util/E.java#L132-L136 |
sarl/sarl | contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyGenerator.java | PyGenerator._generate | protected void _generate(SarlConstructor constructor, PyAppendable it, IExtraLanguageGeneratorContext context) {
if (constructor.isStatic()) {
generateExecutable("___static_init___", constructor, false, false, null, //$NON-NLS-1$
getTypeBuilder().getDocumentation(constructor),
it, context);
it.newLine().append("___static_init___()"); //$NON-NLS-1$
} else {
generateExecutable("__init__", constructor, true, false, null, //$NON-NLS-1$
getTypeBuilder().getDocumentation(constructor),
it, context);
}
} | java | protected void _generate(SarlConstructor constructor, PyAppendable it, IExtraLanguageGeneratorContext context) {
if (constructor.isStatic()) {
generateExecutable("___static_init___", constructor, false, false, null, //$NON-NLS-1$
getTypeBuilder().getDocumentation(constructor),
it, context);
it.newLine().append("___static_init___()"); //$NON-NLS-1$
} else {
generateExecutable("__init__", constructor, true, false, null, //$NON-NLS-1$
getTypeBuilder().getDocumentation(constructor),
it, context);
}
} | [
"protected",
"void",
"_generate",
"(",
"SarlConstructor",
"constructor",
",",
"PyAppendable",
"it",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"if",
"(",
"constructor",
".",
"isStatic",
"(",
")",
")",
"{",
"generateExecutable",
"(",
"\"___static_ini... | Generate the given object.
@param constructor the constructor.
@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#L969-L980 |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeChanged | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | java | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | [
"public",
"final",
"void",
"notifyHeaderItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">=",
"headerItemCount",
")",
... | Notifies that multiple header items are changed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"changed",
"."
] | train | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L158-L163 |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/AnnotationUtils.java | AnnotationUtils.getDefaultValue | public static Object getDefaultValue(Annotation annotation, String attributeName) {
return getDefaultValue(annotation.annotationType(), attributeName);
} | java | public static Object getDefaultValue(Annotation annotation, String attributeName) {
return getDefaultValue(annotation.annotationType(), attributeName);
} | [
"public",
"static",
"Object",
"getDefaultValue",
"(",
"Annotation",
"annotation",
",",
"String",
"attributeName",
")",
"{",
"return",
"getDefaultValue",
"(",
"annotation",
".",
"annotationType",
"(",
")",
",",
"attributeName",
")",
";",
"}"
] | Retrieve the <em>default value</em> of a named Annotation attribute, given an annotation instance.
@param annotation the annotation instance from which to retrieve the default value
@param attributeName the name of the attribute value to retrieve
@return the default value of the named attribute, or <code>null</code> if not found
@see #getDefaultValue(Class, String) | [
"Retrieve",
"the",
"<em",
">",
"default",
"value<",
"/",
"em",
">",
"of",
"a",
"named",
"Annotation",
"attribute",
"given",
"an",
"annotation",
"instance",
"."
] | train | https://github.com/webdriverextensions/webdriverextensions/blob/80151a2bb4fe92b093e60b1e628b8c3d73fb1cc1/src/main/java/com/github/webdriverextensions/internal/junitrunner/AnnotationUtils.java#L157-L159 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/util/TableUtils.java | TableUtils.waitUntilExists | public static void waitUntilExists(final AmazonDynamoDB dynamo, final String tableName)
throws InterruptedException {
waitUntilExists(dynamo, tableName, DEFAULT_WAIT_TIMEOUT, DEFAULT_WAIT_INTERVAL);
} | java | public static void waitUntilExists(final AmazonDynamoDB dynamo, final String tableName)
throws InterruptedException {
waitUntilExists(dynamo, tableName, DEFAULT_WAIT_TIMEOUT, DEFAULT_WAIT_INTERVAL);
} | [
"public",
"static",
"void",
"waitUntilExists",
"(",
"final",
"AmazonDynamoDB",
"dynamo",
",",
"final",
"String",
"tableName",
")",
"throws",
"InterruptedException",
"{",
"waitUntilExists",
"(",
"dynamo",
",",
"tableName",
",",
"DEFAULT_WAIT_TIMEOUT",
",",
"DEFAULT_WAI... | Waits up to 10 minutes for a specified DynamoDB table to resolve,
indicating that it exists. If the table doesn't return a result after
this time, a SdkClientException is thrown.
@param dynamo
The DynamoDB client to use to make requests.
@param tableName
The name of the table being resolved.
@throws SdkClientException
If the specified table does not resolve before this method
times out and stops polling.
@throws InterruptedException
If the thread is interrupted while waiting for the table to
resolve. | [
"Waits",
"up",
"to",
"10",
"minutes",
"for",
"a",
"specified",
"DynamoDB",
"table",
"to",
"resolve",
"indicating",
"that",
"it",
"exists",
".",
"If",
"the",
"table",
"doesn",
"t",
"return",
"a",
"result",
"after",
"this",
"time",
"a",
"SdkClientException",
... | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/util/TableUtils.java#L83-L86 |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.remove | public void remove(List<Value> values) {
Key[] keys = makeSubKeys(values);
List<byte[]> digestList = getDigestList();
// int startIndex = digestList.IndexOf (subKey.digest);
// int count = values.Count;
// foreach (Key key in keys){
//
// client.Delete (this.policy, key);
// }
// client.Operate(this.policy, this.key, ListOperation.Remove(this.binNameString, startIndex, count));
for (Key key : keys) {
client.delete(this.policy, key);
digestList.remove(key.digest);
}
client.put(this.policy, this.key, new Bin(this.binNameString, digestList));
} | java | public void remove(List<Value> values) {
Key[] keys = makeSubKeys(values);
List<byte[]> digestList = getDigestList();
// int startIndex = digestList.IndexOf (subKey.digest);
// int count = values.Count;
// foreach (Key key in keys){
//
// client.Delete (this.policy, key);
// }
// client.Operate(this.policy, this.key, ListOperation.Remove(this.binNameString, startIndex, count));
for (Key key : keys) {
client.delete(this.policy, key);
digestList.remove(key.digest);
}
client.put(this.policy, this.key, new Bin(this.binNameString, digestList));
} | [
"public",
"void",
"remove",
"(",
"List",
"<",
"Value",
">",
"values",
")",
"{",
"Key",
"[",
"]",
"keys",
"=",
"makeSubKeys",
"(",
"values",
")",
";",
"List",
"<",
"byte",
"[",
"]",
">",
"digestList",
"=",
"getDigestList",
"(",
")",
";",
"//\t\tint st... | Delete values from list.
@param values A list of values to delete | [
"Delete",
"values",
"from",
"list",
"."
] | train | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L277-L295 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/network/rnatip_stats.java | rnatip_stats.get | public static rnatip_stats get(nitro_service service, String Rnatip) throws Exception{
rnatip_stats obj = new rnatip_stats();
obj.set_Rnatip(Rnatip);
rnatip_stats response = (rnatip_stats) obj.stat_resource(service);
return response;
} | java | public static rnatip_stats get(nitro_service service, String Rnatip) throws Exception{
rnatip_stats obj = new rnatip_stats();
obj.set_Rnatip(Rnatip);
rnatip_stats response = (rnatip_stats) obj.stat_resource(service);
return response;
} | [
"public",
"static",
"rnatip_stats",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"Rnatip",
")",
"throws",
"Exception",
"{",
"rnatip_stats",
"obj",
"=",
"new",
"rnatip_stats",
"(",
")",
";",
"obj",
".",
"set_Rnatip",
"(",
"Rnatip",
")",
";",
"rnatip... | Use this API to fetch statistics of rnatip_stats resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"statistics",
"of",
"rnatip_stats",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/network/rnatip_stats.java#L249-L254 |
gosu-lang/gosu-lang | gosu-lab/src/main/java/editor/util/ProgressFeedback.java | ProgressFeedback.runWithProgress | public static ProgressFeedback runWithProgress( final String strNotice, final IRunnableWithProgress task )
{
return runWithProgress( strNotice, task, false, false );
} | java | public static ProgressFeedback runWithProgress( final String strNotice, final IRunnableWithProgress task )
{
return runWithProgress( strNotice, task, false, false );
} | [
"public",
"static",
"ProgressFeedback",
"runWithProgress",
"(",
"final",
"String",
"strNotice",
",",
"final",
"IRunnableWithProgress",
"task",
")",
"{",
"return",
"runWithProgress",
"(",
"strNotice",
",",
"task",
",",
"false",
",",
"false",
")",
";",
"}"
] | A helper method that executes a task in a worker thread and displays feedback
in a progress windows.
@param strNotice The text notice to display in the ProgressWindow.
@param task The task to execute in a separate (worker) thread. | [
"A",
"helper",
"method",
"that",
"executes",
"a",
"task",
"in",
"a",
"worker",
"thread",
"and",
"displays",
"feedback",
"in",
"a",
"progress",
"windows",
"."
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/util/ProgressFeedback.java#L42-L45 |
kuali/ojb-1.0.4 | src/jca/org/apache/ojb/otm/connector/OTMJCAManagedConnectionFactory.java | OTMJCAManagedConnectionFactory.createManagedConnection | public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
{
Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
try
{
Kit kit = getKit();
PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
OTMConnection connection = kit.acquireConnection(key);
return new OTMJCAManagedConnection(this, connection, key);
}
catch (ResourceException e)
{
throw new OTMConnectionRuntimeException(e.getMessage());
}
} | java | public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
{
Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
try
{
Kit kit = getKit();
PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
OTMConnection connection = kit.acquireConnection(key);
return new OTMJCAManagedConnection(this, connection, key);
}
catch (ResourceException e)
{
throw new OTMConnectionRuntimeException(e.getMessage());
}
} | [
"public",
"ManagedConnection",
"createManagedConnection",
"(",
"Subject",
"subject",
",",
"ConnectionRequestInfo",
"info",
")",
"{",
"Util",
".",
"log",
"(",
"\"In OTMJCAManagedConnectionFactory.createManagedConnection\"",
")",
";",
"try",
"{",
"Kit",
"kit",
"=",
"getKi... | return a new managed connection. This connection is wrapped around the real connection and delegates to it
to get work done.
@param subject
@param info
@return | [
"return",
"a",
"new",
"managed",
"connection",
".",
"This",
"connection",
"is",
"wrapped",
"around",
"the",
"real",
"connection",
"and",
"delegates",
"to",
"it",
"to",
"get",
"work",
"done",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/jca/org/apache/ojb/otm/connector/OTMJCAManagedConnectionFactory.java#L83-L97 |
mbenson/therian | core/src/main/java/therian/operator/convert/DefaultCopyingConverter.java | DefaultCopyingConverter.perform | @Override
@SuppressWarnings({ "unchecked" })
public boolean perform(TherianContext context, final Convert<?, ?> convert) {
return new Delegate(convert).perform(context, convert);
} | java | @Override
@SuppressWarnings({ "unchecked" })
public boolean perform(TherianContext context, final Convert<?, ?> convert) {
return new Delegate(convert).perform(context, convert);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"boolean",
"perform",
"(",
"TherianContext",
"context",
",",
"final",
"Convert",
"<",
"?",
",",
"?",
">",
"convert",
")",
"{",
"return",
"new",
"Delegate",
"(",
"conve... | specifically avoid doing typed ops as we want to catch stuff that slips through the cracks | [
"specifically",
"avoid",
"doing",
"typed",
"ops",
"as",
"we",
"want",
"to",
"catch",
"stuff",
"that",
"slips",
"through",
"the",
"cracks"
] | train | https://github.com/mbenson/therian/blob/0653505f73e2a6f5b0abc394ea6d83af03408254/core/src/main/java/therian/operator/convert/DefaultCopyingConverter.java#L95-L99 |
VoltDB/voltdb | src/frontend/org/voltdb/messaging/FastDeserializer.java | FastDeserializer.readObject | public FastSerializable readObject(final FastSerializable obj, final DeserializationMonitor monitor) throws IOException {
final int startPosition = buffer.position();
obj.readExternal(this);
final int endPosition = buffer.position();
if (monitor != null) {
monitor.deserializedBytes(endPosition - startPosition);
}
return obj;
} | java | public FastSerializable readObject(final FastSerializable obj, final DeserializationMonitor monitor) throws IOException {
final int startPosition = buffer.position();
obj.readExternal(this);
final int endPosition = buffer.position();
if (monitor != null) {
monitor.deserializedBytes(endPosition - startPosition);
}
return obj;
} | [
"public",
"FastSerializable",
"readObject",
"(",
"final",
"FastSerializable",
"obj",
",",
"final",
"DeserializationMonitor",
"monitor",
")",
"throws",
"IOException",
"{",
"final",
"int",
"startPosition",
"=",
"buffer",
".",
"position",
"(",
")",
";",
"obj",
".",
... | Read an object from a a byte array stream into th provied instance. Takes in a
deserialization monitor which is notified of how many bytes were deserialized.
@param obj Instance of the class of the type to be deserialized.
@param monitor Monitor that will be notified of how many bytes are deserialized
@return A deserialized object.
@throws IOException Rethrows any IOExceptions thrown. | [
"Read",
"an",
"object",
"from",
"a",
"a",
"byte",
"array",
"stream",
"into",
"th",
"provied",
"instance",
".",
"Takes",
"in",
"a",
"deserialization",
"monitor",
"which",
"is",
"notified",
"of",
"how",
"many",
"bytes",
"were",
"deserialized",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/messaging/FastDeserializer.java#L130-L138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.