repository_name stringlengths 7 54 | func_path_in_repository stringlengths 18 218 | func_name stringlengths 5 140 | whole_func_string stringlengths 79 3.99k | language stringclasses 1
value | func_code_string stringlengths 79 3.99k | func_code_tokens listlengths 20 624 | func_documentation_string stringlengths 61 1.96k | func_documentation_tokens listlengths 1 478 | split_name stringclasses 1
value | func_code_url stringlengths 107 339 |
|---|---|---|---|---|---|---|---|---|---|---|
GerdHolz/TOVAL | src/de/invation/code/toval/misc/ListUtils.java | ListUtils.getRandomSublistMax | public static <T> List<T> getRandomSublistMax(List<T> list, int maxCount) {
int count = rand.nextInt(maxCount) + 1;
return getRandomSublist(list, count);
} | java | public static <T> List<T> getRandomSublistMax(List<T> list, int maxCount) {
int count = rand.nextInt(maxCount) + 1;
return getRandomSublist(list, count);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getRandomSublistMax",
"(",
"List",
"<",
"T",
">",
"list",
",",
"int",
"maxCount",
")",
"{",
"int",
"count",
"=",
"rand",
".",
"nextInt",
"(",
"maxCount",
")",
"+",
"1",
";",
"return",
"getR... | Generates a random sublist of <code>list</code>, that contains at most
<code>maxCount</code> elements.
@param <T>
Type of list elements
@param list
Basic list for operation
@param maxCount
Maximum number of items
@return A sublist with at most <code>maxCount</code> elements | [
"Generates",
"a",
"random",
"sublist",
"of",
"<code",
">",
"list<",
"/",
"code",
">",
"that",
"contains",
"at",
"most",
"<code",
">",
"maxCount<",
"/",
"code",
">",
"elements",
"."
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/ListUtils.java#L484-L487 |
jtmelton/appsensor | appsensor-core/src/main/java/org/owasp/appsensor/core/storage/AttackStore.java | AttackStore.isMatchingAttack | protected boolean isMatchingAttack(SearchCriteria criteria, Attack attack) {
boolean match = false;
User user = criteria.getUser();
DetectionPoint detectionPoint = criteria.getDetectionPoint();
Collection<String> detectionSystemIds = criteria.getDetectionSystemIds();
DateTime earliest = DateUtils.fromString(criteria.getEarliest());
Rule rule = criteria.getRule();
// check user match if user specified
boolean userMatch = (user != null) ? user.equals(attack.getUser()) : true;
// check detection system match if detection systems specified
boolean detectionSystemMatch = (detectionSystemIds != null && detectionSystemIds.size() > 0) ?
detectionSystemIds.contains(attack.getDetectionSystem().getDetectionSystemId()) : true;
// check detection point match if detection point specified
boolean detectionPointMatch = (detectionPoint != null) ?
detectionPoint.typeAndThresholdMatches(attack.getDetectionPoint()) : true;
//check rule match if rule specified
boolean ruleMatch = true;
if (rule != null) {
ruleMatch = (attack.getRule() != null) ?
rule.guidMatches(attack.getRule()) : false;
}
boolean earliestMatch = (earliest != null) ? earliest.isBefore(DateUtils.fromString(attack.getTimestamp())): true;
if (userMatch && detectionSystemMatch && detectionPointMatch && ruleMatch && earliestMatch) {
match = true;
}
return match;
} | java | protected boolean isMatchingAttack(SearchCriteria criteria, Attack attack) {
boolean match = false;
User user = criteria.getUser();
DetectionPoint detectionPoint = criteria.getDetectionPoint();
Collection<String> detectionSystemIds = criteria.getDetectionSystemIds();
DateTime earliest = DateUtils.fromString(criteria.getEarliest());
Rule rule = criteria.getRule();
// check user match if user specified
boolean userMatch = (user != null) ? user.equals(attack.getUser()) : true;
// check detection system match if detection systems specified
boolean detectionSystemMatch = (detectionSystemIds != null && detectionSystemIds.size() > 0) ?
detectionSystemIds.contains(attack.getDetectionSystem().getDetectionSystemId()) : true;
// check detection point match if detection point specified
boolean detectionPointMatch = (detectionPoint != null) ?
detectionPoint.typeAndThresholdMatches(attack.getDetectionPoint()) : true;
//check rule match if rule specified
boolean ruleMatch = true;
if (rule != null) {
ruleMatch = (attack.getRule() != null) ?
rule.guidMatches(attack.getRule()) : false;
}
boolean earliestMatch = (earliest != null) ? earliest.isBefore(DateUtils.fromString(attack.getTimestamp())): true;
if (userMatch && detectionSystemMatch && detectionPointMatch && ruleMatch && earliestMatch) {
match = true;
}
return match;
} | [
"protected",
"boolean",
"isMatchingAttack",
"(",
"SearchCriteria",
"criteria",
",",
"Attack",
"attack",
")",
"{",
"boolean",
"match",
"=",
"false",
";",
"User",
"user",
"=",
"criteria",
".",
"getUser",
"(",
")",
";",
"DetectionPoint",
"detectionPoint",
"=",
"c... | Finder for attacks in the AttackStore.
@param criteria the {@link org.owasp.appsensor.core.criteria.SearchCriteria} object to search by
@param attack the {@link Attack} object to match on
@return true or false depending on the matching of the search criteria to the {@link Attack} | [
"Finder",
"for",
"attacks",
"in",
"the",
"AttackStore",
"."
] | train | https://github.com/jtmelton/appsensor/blob/c3b4e9ada50fdee974e0d618ec4bdfabc2163798/appsensor-core/src/main/java/org/owasp/appsensor/core/storage/AttackStore.java#L157-L191 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java | AbstractJsonDeserializer.getTypedParam | protected <A> A getTypedParam(String paramName, String errorMessage, Class<A> clazz) throws IOException {
return getTypedParam(paramName, errorMessage, clazz, (Map<String, Object>) inputParams.get());
} | java | protected <A> A getTypedParam(String paramName, String errorMessage, Class<A> clazz) throws IOException {
return getTypedParam(paramName, errorMessage, clazz, (Map<String, Object>) inputParams.get());
} | [
"protected",
"<",
"A",
">",
"A",
"getTypedParam",
"(",
"String",
"paramName",
",",
"String",
"errorMessage",
",",
"Class",
"<",
"A",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"return",
"getTypedParam",
"(",
"paramName",
",",
"errorMessage",
",",
"claz... | Convenience method for subclasses. Uses the default parametermap for this deserializer.
@param paramName the name of the parameter
@param errorMessage the errormessage to add to the exception if the param does not exist.
@param clazz the class of the parameter that should be parsed.
@param <A> the type of the parameter
@return a stringparameter with given name. If it does not exist and the errormessage is provided,
an IOException is thrown with that message. if the errormessage is not provided, null is returned.
@throws IOException Exception if the paramname does not exist and an errormessage is provided. | [
"Convenience",
"method",
"for",
"subclasses",
".",
"Uses",
"the",
"default",
"parametermap",
"for",
"this",
"deserializer",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/AbstractJsonDeserializer.java#L299-L301 |
antopen/alipay-sdk-java | src/main/java/com/alipay/api/internal/util/XmlUtils.java | XmlUtils.getChildElement | public static Element getChildElement(Element parent, String tagName) {
List<Element> children = getChildElements(parent, tagName);
if (children.isEmpty()) {
return null;
} else {
return children.get(0);
}
} | java | public static Element getChildElement(Element parent, String tagName) {
List<Element> children = getChildElements(parent, tagName);
if (children.isEmpty()) {
return null;
} else {
return children.get(0);
}
} | [
"public",
"static",
"Element",
"getChildElement",
"(",
"Element",
"parent",
",",
"String",
"tagName",
")",
"{",
"List",
"<",
"Element",
">",
"children",
"=",
"getChildElements",
"(",
"parent",
",",
"tagName",
")",
";",
"if",
"(",
"children",
".",
"isEmpty",
... | Gets the immediately child element from the parent element.
@param parent the parent element in the element tree
@param tagName the specified tag name
@return immediately child element of parent element, NULL otherwise | [
"Gets",
"the",
"immediately",
"child",
"element",
"from",
"the",
"parent",
"element",
"."
] | train | https://github.com/antopen/alipay-sdk-java/blob/e82aeac7d0239330ee173c7e393596e51e41c1cd/src/main/java/com/alipay/api/internal/util/XmlUtils.java#L284-L292 |
rpuch/xremoting | xremoting-core/src/main/java/com/googlecode/xremoting/core/commonshttpclient/HttpClientBuilder.java | HttpClientBuilder.basicAuth | public HttpClientBuilder basicAuth(String username, String password) {
basicAuthUsername = username;
basicAuthPassword = password;
return this;
} | java | public HttpClientBuilder basicAuth(String username, String password) {
basicAuthUsername = username;
basicAuthPassword = password;
return this;
} | [
"public",
"HttpClientBuilder",
"basicAuth",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"basicAuthUsername",
"=",
"username",
";",
"basicAuthPassword",
"=",
"password",
";",
"return",
"this",
";",
"}"
] | Turns on a Basic authentication.
@param username username to send
@param password password to send
@return this
@see #basicAuthHost(String)
@see #basicAuthPort(int) | [
"Turns",
"on",
"a",
"Basic",
"authentication",
"."
] | train | https://github.com/rpuch/xremoting/blob/519b640e5225652a8c23e10e5cab71827636a8b1/xremoting-core/src/main/java/com/googlecode/xremoting/core/commonshttpclient/HttpClientBuilder.java#L101-L105 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/ZipUtil.java | ZipUtil.copyEntries | private static void copyEntries(File zip, final ZipOutputStream out) {
// this one doesn't call copyEntries with ignoredEntries, because that has poorer performance
final Set<String> names = new HashSet<String>();
iterate(zip, new ZipEntryCallback() {
public void process(InputStream in, ZipEntry zipEntry) throws IOException {
String entryName = zipEntry.getName();
if (names.add(entryName)) {
ZipEntryUtil.copyEntry(zipEntry, in, out);
}
else if (log.isDebugEnabled()) {
log.debug("Duplicate entry: {}", entryName);
}
}
});
} | java | private static void copyEntries(File zip, final ZipOutputStream out) {
// this one doesn't call copyEntries with ignoredEntries, because that has poorer performance
final Set<String> names = new HashSet<String>();
iterate(zip, new ZipEntryCallback() {
public void process(InputStream in, ZipEntry zipEntry) throws IOException {
String entryName = zipEntry.getName();
if (names.add(entryName)) {
ZipEntryUtil.copyEntry(zipEntry, in, out);
}
else if (log.isDebugEnabled()) {
log.debug("Duplicate entry: {}", entryName);
}
}
});
} | [
"private",
"static",
"void",
"copyEntries",
"(",
"File",
"zip",
",",
"final",
"ZipOutputStream",
"out",
")",
"{",
"// this one doesn't call copyEntries with ignoredEntries, because that has poorer performance",
"final",
"Set",
"<",
"String",
">",
"names",
"=",
"new",
"Has... | Copies all entries from one ZIP file to another.
@param zip
source ZIP file.
@param out
target ZIP stream. | [
"Copies",
"all",
"entries",
"from",
"one",
"ZIP",
"file",
"to",
"another",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L2373-L2387 |
zamrokk/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java | SDKUtil.generateParameterHash | public static String generateParameterHash(String path, String func, List<String> args) {
logger.debug(String.format("GenerateParameterHash : path=%s, func=%s, args=%s", path, func, args));
// Append the arguments
StringBuilder param = new StringBuilder(path);
param.append(func);
args.forEach(param::append);
// Compute the hash
String strHash = Hex.toHexString(hash(param.toString().getBytes(), new SHA3Digest()));
return strHash;
} | java | public static String generateParameterHash(String path, String func, List<String> args) {
logger.debug(String.format("GenerateParameterHash : path=%s, func=%s, args=%s", path, func, args));
// Append the arguments
StringBuilder param = new StringBuilder(path);
param.append(func);
args.forEach(param::append);
// Compute the hash
String strHash = Hex.toHexString(hash(param.toString().getBytes(), new SHA3Digest()));
return strHash;
} | [
"public",
"static",
"String",
"generateParameterHash",
"(",
"String",
"path",
",",
"String",
"func",
",",
"List",
"<",
"String",
">",
"args",
")",
"{",
"logger",
".",
"debug",
"(",
"String",
".",
"format",
"(",
"\"GenerateParameterHash : path=%s, func=%s, args=%s\... | Generate parameter hash for the given chain code path,func and args
@param path Chain code path
@param func Chain code function name
@param args List of arguments
@return hash of path, func and args | [
"Generate",
"parameter",
"hash",
"for",
"the",
"given",
"chain",
"code",
"path",
"func",
"and",
"args"
] | train | https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/helper/SDKUtil.java#L59-L71 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/customer/accounts/CustomerNoteUrl.java | CustomerNoteUrl.addAccountNoteUrl | public static MozuUrl addAccountNoteUrl(Integer accountId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/accounts/{accountId}/notes?responseFields={responseFields}");
formatter.formatUrl("accountId", accountId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl addAccountNoteUrl(Integer accountId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/accounts/{accountId}/notes?responseFields={responseFields}");
formatter.formatUrl("accountId", accountId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"addAccountNoteUrl",
"(",
"Integer",
"accountId",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/customer/accounts/{accountId}/notes?responseFields={responseFields}\"",
")"... | Get Resource Url for AddAccountNote
@param accountId Unique identifier of the customer account.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"AddAccountNote"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/customer/accounts/CustomerNoteUrl.java#L60-L66 |
rwl/CSparseJ | src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_cholsol.java | Dcs_cholsol.cs_cholsol | public static boolean cs_cholsol(int order, Dcs A, double[] b) {
double x[];
Dcss S;
Dcsn N;
int n;
boolean ok;
if (!Dcs_util.CS_CSC(A) || b == null)
return (false); /* check inputs */
n = A.n;
S = Dcs_schol.cs_schol(order, A); /* ordering and symbolic analysis */
N = Dcs_chol.cs_chol(A, S); /* numeric Cholesky factorization */
x = new double[n]; /* get workspace */
ok = (S != null && N != null);
if (ok) {
Dcs_ipvec.cs_ipvec(S.pinv, b, x, n); /* x = P*b */
Dcs_lsolve.cs_lsolve(N.L, x); /* x = L\x */
Dcs_ltsolve.cs_ltsolve(N.L, x); /* x = L'\x */
Dcs_pvec.cs_pvec(S.pinv, x, b, n); /* b = P'*x */
}
return (ok);
} | java | public static boolean cs_cholsol(int order, Dcs A, double[] b) {
double x[];
Dcss S;
Dcsn N;
int n;
boolean ok;
if (!Dcs_util.CS_CSC(A) || b == null)
return (false); /* check inputs */
n = A.n;
S = Dcs_schol.cs_schol(order, A); /* ordering and symbolic analysis */
N = Dcs_chol.cs_chol(A, S); /* numeric Cholesky factorization */
x = new double[n]; /* get workspace */
ok = (S != null && N != null);
if (ok) {
Dcs_ipvec.cs_ipvec(S.pinv, b, x, n); /* x = P*b */
Dcs_lsolve.cs_lsolve(N.L, x); /* x = L\x */
Dcs_ltsolve.cs_ltsolve(N.L, x); /* x = L'\x */
Dcs_pvec.cs_pvec(S.pinv, x, b, n); /* b = P'*x */
}
return (ok);
} | [
"public",
"static",
"boolean",
"cs_cholsol",
"(",
"int",
"order",
",",
"Dcs",
"A",
",",
"double",
"[",
"]",
"b",
")",
"{",
"double",
"x",
"[",
"]",
";",
"Dcss",
"S",
";",
"Dcsn",
"N",
";",
"int",
"n",
";",
"boolean",
"ok",
";",
"if",
"(",
"!",
... | Solves Ax=b where A is symmetric positive definite; b is overwritten with
solution.
@param order
ordering method to use (0 or 1)
@param A
column-compressed matrix, symmetric positive definite, only
upper triangular part is used
@param b
right hand side, b is overwritten with solution
@return true if successful, false on error | [
"Solves",
"Ax",
"=",
"b",
"where",
"A",
"is",
"symmetric",
"positive",
"definite",
";",
"b",
"is",
"overwritten",
"with",
"solution",
"."
] | train | https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_cholsol.java#L52-L72 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/internal/UploadCallable.java | UploadCallable.uploadPartsInParallel | private void uploadPartsInParallel(UploadPartRequestFactory requestFactory,
String uploadId) {
Map<Integer,PartSummary> partNumbers = identifyExistingPartsForResume(uploadId);
while (requestFactory.hasMoreRequests()) {
if (threadPool.isShutdown()) throw new CancellationException("TransferManager has been shutdown");
UploadPartRequest request = requestFactory.getNextUploadPartRequest();
if (partNumbers.containsKey(request.getPartNumber())) {
PartSummary summary = partNumbers.get(request.getPartNumber());
eTagsToSkip.add(new PartETag(request.getPartNumber(), summary
.getETag()));
transferProgress.updateProgress(summary.getSize());
continue;
}
futures.add(threadPool.submit(new UploadPartCallable(s3, request, shouldCalculatePartMd5())));
}
} | java | private void uploadPartsInParallel(UploadPartRequestFactory requestFactory,
String uploadId) {
Map<Integer,PartSummary> partNumbers = identifyExistingPartsForResume(uploadId);
while (requestFactory.hasMoreRequests()) {
if (threadPool.isShutdown()) throw new CancellationException("TransferManager has been shutdown");
UploadPartRequest request = requestFactory.getNextUploadPartRequest();
if (partNumbers.containsKey(request.getPartNumber())) {
PartSummary summary = partNumbers.get(request.getPartNumber());
eTagsToSkip.add(new PartETag(request.getPartNumber(), summary
.getETag()));
transferProgress.updateProgress(summary.getSize());
continue;
}
futures.add(threadPool.submit(new UploadPartCallable(s3, request, shouldCalculatePartMd5())));
}
} | [
"private",
"void",
"uploadPartsInParallel",
"(",
"UploadPartRequestFactory",
"requestFactory",
",",
"String",
"uploadId",
")",
"{",
"Map",
"<",
"Integer",
",",
"PartSummary",
">",
"partNumbers",
"=",
"identifyExistingPartsForResume",
"(",
"uploadId",
")",
";",
"while"... | Submits a callable for each part to upload to our thread pool and records its corresponding Future. | [
"Submits",
"a",
"callable",
"for",
"each",
"part",
"to",
"upload",
"to",
"our",
"thread",
"pool",
"and",
"records",
"its",
"corresponding",
"Future",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/internal/UploadCallable.java#L282-L299 |
SvenEwald/xmlbeam | src/main/java/org/xmlbeam/util/intern/ReflectionHelper.java | ReflectionHelper.throwThrowable | public static void throwThrowable(final Class<?> throwableType, final Object[] args, final Throwable optionalCause) throws Throwable {
Class<?>[] argsClasses = getClassesOfObjects(args);
Constructor<?> constructor = ReflectionHelper.getCallableConstructorForParams(throwableType, argsClasses);
Throwable throwable = null;
if (constructor != null) {
throwable = (Throwable) constructor.newInstance(args);
} else {
throwable = (Throwable) throwableType.newInstance();
}
if (optionalCause != null) {
throwable.initCause(optionalCause);
}
throw throwable;
} | java | public static void throwThrowable(final Class<?> throwableType, final Object[] args, final Throwable optionalCause) throws Throwable {
Class<?>[] argsClasses = getClassesOfObjects(args);
Constructor<?> constructor = ReflectionHelper.getCallableConstructorForParams(throwableType, argsClasses);
Throwable throwable = null;
if (constructor != null) {
throwable = (Throwable) constructor.newInstance(args);
} else {
throwable = (Throwable) throwableType.newInstance();
}
if (optionalCause != null) {
throwable.initCause(optionalCause);
}
throw throwable;
} | [
"public",
"static",
"void",
"throwThrowable",
"(",
"final",
"Class",
"<",
"?",
">",
"throwableType",
",",
"final",
"Object",
"[",
"]",
"args",
",",
"final",
"Throwable",
"optionalCause",
")",
"throws",
"Throwable",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
... | Throws a throwable of type throwableType. The throwable will be created using an args
matching constructor or the default constructor if no matching constructor can be found.
@param throwableType
type of throwable to be thrown
@param args
for the throwable construction
@param optionalCause
cause to be set, may be null
@throws Throwable | [
"Throws",
"a",
"throwable",
"of",
"type",
"throwableType",
".",
"The",
"throwable",
"will",
"be",
"created",
"using",
"an",
"args",
"matching",
"constructor",
"or",
"the",
"default",
"constructor",
"if",
"no",
"matching",
"constructor",
"can",
"be",
"found",
"... | train | https://github.com/SvenEwald/xmlbeam/blob/acaac1b8fa28d246f17187f5e3c6696458a0b447/src/main/java/org/xmlbeam/util/intern/ReflectionHelper.java#L522-L536 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.getRecording | public GetRecordingResponse getRecording(String recording) {
checkStringNotEmpty(recording, "The parameter recording should NOT be null or empty string.");
GetRecordingRequest request = new GetRecordingRequest();
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, RECORDING, recording);
return invokeHttpClient(internalRequest, GetRecordingResponse.class);
} | java | public GetRecordingResponse getRecording(String recording) {
checkStringNotEmpty(recording, "The parameter recording should NOT be null or empty string.");
GetRecordingRequest request = new GetRecordingRequest();
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, RECORDING, recording);
return invokeHttpClient(internalRequest, GetRecordingResponse.class);
} | [
"public",
"GetRecordingResponse",
"getRecording",
"(",
"String",
"recording",
")",
"{",
"checkStringNotEmpty",
"(",
"recording",
",",
"\"The parameter recording should NOT be null or empty string.\"",
")",
";",
"GetRecordingRequest",
"request",
"=",
"new",
"GetRecordingRequest"... | Get your live recording preset by live recording preset name.
@param recording Live recording preset name.
@return Your live recording preset | [
"Get",
"your",
"live",
"recording",
"preset",
"by",
"live",
"recording",
"preset",
"name",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L1125-L1130 |
census-instrumentation/opencensus-java | contrib/dropwizard5/src/main/java/io/opencensus/contrib/dropwizard5/DropWizardMetrics.java | DropWizardMetrics.collectMeter | private Metric collectMeter(MetricName dropwizardMetric, Meter meter) {
String metricName = DropWizardUtils.generateFullMetricName(dropwizardMetric.getKey(), "meter");
String metricDescription =
DropWizardUtils.generateFullMetricDescription(dropwizardMetric.getKey(), meter);
final AbstractMap.SimpleImmutableEntry<List<LabelKey>, List<LabelValue>> labels =
DropWizardUtils.generateLabels(dropwizardMetric);
MetricDescriptor metricDescriptor =
MetricDescriptor.create(
metricName, metricDescription, DEFAULT_UNIT, Type.CUMULATIVE_INT64, labels.getKey());
TimeSeries timeSeries =
TimeSeries.createWithOnePoint(
labels.getValue(),
Point.create(Value.longValue(meter.getCount()), clock.now()),
cumulativeStartTimestamp);
return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
} | java | private Metric collectMeter(MetricName dropwizardMetric, Meter meter) {
String metricName = DropWizardUtils.generateFullMetricName(dropwizardMetric.getKey(), "meter");
String metricDescription =
DropWizardUtils.generateFullMetricDescription(dropwizardMetric.getKey(), meter);
final AbstractMap.SimpleImmutableEntry<List<LabelKey>, List<LabelValue>> labels =
DropWizardUtils.generateLabels(dropwizardMetric);
MetricDescriptor metricDescriptor =
MetricDescriptor.create(
metricName, metricDescription, DEFAULT_UNIT, Type.CUMULATIVE_INT64, labels.getKey());
TimeSeries timeSeries =
TimeSeries.createWithOnePoint(
labels.getValue(),
Point.create(Value.longValue(meter.getCount()), clock.now()),
cumulativeStartTimestamp);
return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
} | [
"private",
"Metric",
"collectMeter",
"(",
"MetricName",
"dropwizardMetric",
",",
"Meter",
"meter",
")",
"{",
"String",
"metricName",
"=",
"DropWizardUtils",
".",
"generateFullMetricName",
"(",
"dropwizardMetric",
".",
"getKey",
"(",
")",
",",
"\"meter\"",
")",
";"... | Returns a {@code Metric} collected from {@link io.dropwizard.metrics5.Meter}.
@param dropwizardMetric the metric name.
@param meter the meter object to collect
@return a {@code Metric}. | [
"Returns",
"a",
"{",
"@code",
"Metric",
"}",
"collected",
"from",
"{",
"@link",
"io",
".",
"dropwizard",
".",
"metrics5",
".",
"Meter",
"}",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/contrib/dropwizard5/src/main/java/io/opencensus/contrib/dropwizard5/DropWizardMetrics.java#L171-L188 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/ParameterException.java | ParameterException.prefixParameterToMessage | public static String prefixParameterToMessage(Parameter<?> p, String message) {
return new StringBuilder(100 + message.length()) //
.append(p instanceof Flag ? "Flag '" : "Parameter '") //
.append(p.getOptionID().getName()) //
.append("' ").append(message).toString();
} | java | public static String prefixParameterToMessage(Parameter<?> p, String message) {
return new StringBuilder(100 + message.length()) //
.append(p instanceof Flag ? "Flag '" : "Parameter '") //
.append(p.getOptionID().getName()) //
.append("' ").append(message).toString();
} | [
"public",
"static",
"String",
"prefixParameterToMessage",
"(",
"Parameter",
"<",
"?",
">",
"p",
",",
"String",
"message",
")",
"{",
"return",
"new",
"StringBuilder",
"(",
"100",
"+",
"message",
".",
"length",
"(",
")",
")",
"//",
".",
"append",
"(",
"p",... | Prefix parameter information to error message.
@param p Parameter
@param message Error message
@return Combined error message | [
"Prefix",
"parameter",
"information",
"to",
"error",
"message",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/ParameterException.java#L85-L90 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java | FSDataset.detachBlock | public boolean detachBlock(int namespaceId, Block block, int numLinks) throws IOException {
DatanodeBlockInfo info = null;
lock.readLock().lock();
try {
info = volumeMap.get(namespaceId, block);
} finally {
lock.readLock().unlock();
}
return info.detachBlock(namespaceId, block, numLinks);
} | java | public boolean detachBlock(int namespaceId, Block block, int numLinks) throws IOException {
DatanodeBlockInfo info = null;
lock.readLock().lock();
try {
info = volumeMap.get(namespaceId, block);
} finally {
lock.readLock().unlock();
}
return info.detachBlock(namespaceId, block, numLinks);
} | [
"public",
"boolean",
"detachBlock",
"(",
"int",
"namespaceId",
",",
"Block",
"block",
",",
"int",
"numLinks",
")",
"throws",
"IOException",
"{",
"DatanodeBlockInfo",
"info",
"=",
"null",
";",
"lock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
... | Make a copy of the block if this block is linked to an existing
snapshot. This ensures that modifying this block does not modify
data in any existing snapshots.
@param block Block
@param numLinks Detach if the number of links exceed this value
@throws IOException
@return - true if the specified block was detached | [
"Make",
"a",
"copy",
"of",
"the",
"block",
"if",
"this",
"block",
"is",
"linked",
"to",
"an",
"existing",
"snapshot",
".",
"This",
"ensures",
"that",
"modifying",
"this",
"block",
"does",
"not",
"modify",
"data",
"in",
"any",
"existing",
"snapshots",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java#L1844-L1855 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_miniPabx_serviceName_hunting_agent_POST | public OvhEasyMiniPabxHuntingAgent billingAccount_miniPabx_serviceName_hunting_agent_POST(String billingAccount, String serviceName, String agentNumber, Boolean logged, Long noReplyTimer, Long position) throws IOException {
String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/hunting/agent";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "agentNumber", agentNumber);
addBody(o, "logged", logged);
addBody(o, "noReplyTimer", noReplyTimer);
addBody(o, "position", position);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhEasyMiniPabxHuntingAgent.class);
} | java | public OvhEasyMiniPabxHuntingAgent billingAccount_miniPabx_serviceName_hunting_agent_POST(String billingAccount, String serviceName, String agentNumber, Boolean logged, Long noReplyTimer, Long position) throws IOException {
String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/hunting/agent";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "agentNumber", agentNumber);
addBody(o, "logged", logged);
addBody(o, "noReplyTimer", noReplyTimer);
addBody(o, "position", position);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhEasyMiniPabxHuntingAgent.class);
} | [
"public",
"OvhEasyMiniPabxHuntingAgent",
"billingAccount_miniPabx_serviceName_hunting_agent_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"agentNumber",
",",
"Boolean",
"logged",
",",
"Long",
"noReplyTimer",
",",
"Long",
"position",
")... | Create a new agent
REST: POST /telephony/{billingAccount}/miniPabx/{serviceName}/hunting/agent
@param agentNumber [required] The phone number of the agent
@param noReplyTimer [required] The maxium ringing time
@param position [required] The position in the hunting
@param logged [required] True if the agent is logged
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Create",
"a",
"new",
"agent"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5219-L5229 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/allocator/context/impl/BasicContextPool.java | BasicContextPool.getDeviceBuffers | protected void getDeviceBuffers(CudaContext context, int deviceId) {
NativeOps nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); //((CudaExecutioner) Nd4j.getExecutioner()).getNativeOps();
// we hardcode sizeOf to sizeOf(double)
int sizeOf = 8;
val reductionPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (reductionPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] reduction buffer memory!");
nativeOps.memsetAsync(reductionPointer, 0, 16384 * sizeOf, 0, context.getOldStream());
context.syncOldStream();
val allocationPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (allocationPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] allocation buffer memory!");
val scalarPointer = nativeOps.mallocHost(sizeOf, 0);
if (scalarPointer == null)
throw new IllegalStateException("Can't allocate [HOST] scalar buffer memory!");
context.setBufferScalar(scalarPointer);
context.setBufferAllocation(allocationPointer);
context.setBufferReduction(reductionPointer);
val specialPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (specialPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] special buffer memory!");
nativeOps.memsetAsync(specialPointer, 0, 16384 * sizeOf, 0, context.getOldStream());
context.setBufferSpecial(specialPointer);
} | java | protected void getDeviceBuffers(CudaContext context, int deviceId) {
NativeOps nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); //((CudaExecutioner) Nd4j.getExecutioner()).getNativeOps();
// we hardcode sizeOf to sizeOf(double)
int sizeOf = 8;
val reductionPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (reductionPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] reduction buffer memory!");
nativeOps.memsetAsync(reductionPointer, 0, 16384 * sizeOf, 0, context.getOldStream());
context.syncOldStream();
val allocationPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (allocationPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] allocation buffer memory!");
val scalarPointer = nativeOps.mallocHost(sizeOf, 0);
if (scalarPointer == null)
throw new IllegalStateException("Can't allocate [HOST] scalar buffer memory!");
context.setBufferScalar(scalarPointer);
context.setBufferAllocation(allocationPointer);
context.setBufferReduction(reductionPointer);
val specialPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
if (specialPointer == null)
throw new IllegalStateException("Can't allocate [DEVICE] special buffer memory!");
nativeOps.memsetAsync(specialPointer, 0, 16384 * sizeOf, 0, context.getOldStream());
context.setBufferSpecial(specialPointer);
} | [
"protected",
"void",
"getDeviceBuffers",
"(",
"CudaContext",
"context",
",",
"int",
"deviceId",
")",
"{",
"NativeOps",
"nativeOps",
"=",
"NativeOpsHolder",
".",
"getInstance",
"(",
")",
".",
"getDeviceNativeOps",
"(",
")",
";",
"//((CudaExecutioner) Nd4j.getExecutione... | This method is used to allocate
@param context
@param deviceId | [
"This",
"method",
"is",
"used",
"to",
"allocate"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/allocator/context/impl/BasicContextPool.java#L291-L324 |
jbundle/jbundle | thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java | PaperPrint.printHeader | protected void printHeader(Graphics2D g2d, String headerText)
{
FontMetrics fm = g2d.getFontMetrics();
int textHeight = fm.getHeight();
int stringWidth = fm.stringWidth(headerText);
int textX = (pageRect.width - stringWidth) / 2 + pageRect.x;
int textY = pageRect.y + textHeight + BORDER;
g2d.drawString(headerText , textX, textY);
} | java | protected void printHeader(Graphics2D g2d, String headerText)
{
FontMetrics fm = g2d.getFontMetrics();
int textHeight = fm.getHeight();
int stringWidth = fm.stringWidth(headerText);
int textX = (pageRect.width - stringWidth) / 2 + pageRect.x;
int textY = pageRect.y + textHeight + BORDER;
g2d.drawString(headerText , textX, textY);
} | [
"protected",
"void",
"printHeader",
"(",
"Graphics2D",
"g2d",
",",
"String",
"headerText",
")",
"{",
"FontMetrics",
"fm",
"=",
"g2d",
".",
"getFontMetrics",
"(",
")",
";",
"int",
"textHeight",
"=",
"fm",
".",
"getHeight",
"(",
")",
";",
"int",
"stringWidth... | Print the page header.
@param g2d The graphics environment.
@param headerText The text to print for the header. | [
"Print",
"the",
"page",
"header",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java#L132-L140 |
iig-uni-freiburg/SEWOL | ext/org/deckfour/xes/info/XLogInfoFactory.java | XLogInfoFactory.createLogInfo | public static XLogInfo createLogInfo(XLog log, XEventClassifier classifier) {
/*
* Get the possible info cached by the log.
*/
XLogInfo info = log.getInfo(classifier);
if (info == null) {
/*
* Info not cached. Create it.
*/
info = XLogInfoImpl.create(log, classifier);
/*
* Cache it.
*/
log.setInfo(classifier, info);
}
return info;
} | java | public static XLogInfo createLogInfo(XLog log, XEventClassifier classifier) {
/*
* Get the possible info cached by the log.
*/
XLogInfo info = log.getInfo(classifier);
if (info == null) {
/*
* Info not cached. Create it.
*/
info = XLogInfoImpl.create(log, classifier);
/*
* Cache it.
*/
log.setInfo(classifier, info);
}
return info;
} | [
"public",
"static",
"XLogInfo",
"createLogInfo",
"(",
"XLog",
"log",
",",
"XEventClassifier",
"classifier",
")",
"{",
"/*\n\t\t * Get the possible info cached by the log.\n\t\t */",
"XLogInfo",
"info",
"=",
"log",
".",
"getInfo",
"(",
"classifier",
")",
";",
"if",
"("... | Creates a new log info summary with a custom event classifier.
@param log The event log to create an info summary for.
@param classifier The event classifier to be used.
@return The log info summary for this log. | [
"Creates",
"a",
"new",
"log",
"info",
"summary",
"with",
"a",
"custom",
"event",
"classifier",
"."
] | train | https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/info/XLogInfoFactory.java#L69-L85 |
cwilper/ttff | src/main/java/com/github/cwilper/ttff/Sources.java | Sources.drain | public static <T> long drain(Source<T> source,
final Collection<T> collection)
throws IOException {
return drain(source, new AbstractSink<T>() {
@Override
public void put(T item) {
collection.add(item);
}
});
} | java | public static <T> long drain(Source<T> source,
final Collection<T> collection)
throws IOException {
return drain(source, new AbstractSink<T>() {
@Override
public void put(T item) {
collection.add(item);
}
});
} | [
"public",
"static",
"<",
"T",
">",
"long",
"drain",
"(",
"Source",
"<",
"T",
">",
"source",
",",
"final",
"Collection",
"<",
"T",
">",
"collection",
")",
"throws",
"IOException",
"{",
"return",
"drain",
"(",
"source",
",",
"new",
"AbstractSink",
"<",
"... | Exhausts the given source, adding each item to the given collection.
<p>
The source will be automatically closed regardless of success.
@param source the source to exhaust.
@param collection the collection add each item to.
@param <T> the type.
@return the number of items encountered.
@throws IOException if an I/O problem occurs. | [
"Exhausts",
"the",
"given",
"source",
"adding",
"each",
"item",
"to",
"the",
"given",
"collection",
".",
"<p",
">",
"The",
"source",
"will",
"be",
"automatically",
"closed",
"regardless",
"of",
"success",
"."
] | train | https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L244-L253 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/VirtualCdj.java | VirtualCdj.sendSyncControlCommand | private void sendSyncControlCommand(DeviceUpdate target, byte command) throws IOException {
ensureRunning();
byte[] payload = new byte[SYNC_CONTROL_PAYLOAD.length];
System.arraycopy(SYNC_CONTROL_PAYLOAD, 0, payload, 0, SYNC_CONTROL_PAYLOAD.length);
payload[2] = getDeviceNumber();
payload[8] = getDeviceNumber();
payload[12] = command;
assembleAndSendPacket(Util.PacketType.SYNC_CONTROL, payload, target.getAddress(), BeatFinder.BEAT_PORT);
} | java | private void sendSyncControlCommand(DeviceUpdate target, byte command) throws IOException {
ensureRunning();
byte[] payload = new byte[SYNC_CONTROL_PAYLOAD.length];
System.arraycopy(SYNC_CONTROL_PAYLOAD, 0, payload, 0, SYNC_CONTROL_PAYLOAD.length);
payload[2] = getDeviceNumber();
payload[8] = getDeviceNumber();
payload[12] = command;
assembleAndSendPacket(Util.PacketType.SYNC_CONTROL, payload, target.getAddress(), BeatFinder.BEAT_PORT);
} | [
"private",
"void",
"sendSyncControlCommand",
"(",
"DeviceUpdate",
"target",
",",
"byte",
"command",
")",
"throws",
"IOException",
"{",
"ensureRunning",
"(",
")",
";",
"byte",
"[",
"]",
"payload",
"=",
"new",
"byte",
"[",
"SYNC_CONTROL_PAYLOAD",
".",
"length",
... | Assemble and send a packet that performs sync control, turning a device's sync mode on or off, or telling it
to become the tempo master.
@param target an update from the device whose sync state is to be set
@param command the byte identifying the specific sync command to be sent
@throws IOException if there is a problem sending the command to the device | [
"Assemble",
"and",
"send",
"a",
"packet",
"that",
"performs",
"sync",
"control",
"turning",
"a",
"device",
"s",
"sync",
"mode",
"on",
"or",
"off",
"or",
"telling",
"it",
"to",
"become",
"the",
"tempo",
"master",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/VirtualCdj.java#L1146-L1154 |
wcm-io-caravan/caravan-hal | resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java | HalResource.removeLinkWithHref | public HalResource removeLinkWithHref(String relation, String href) {
List<Link> links = getLinks(relation);
for (int i = 0; i < links.size(); i++) {
if (href.equals(links.get(i).getHref())) {
return removeLink(relation, i);
}
}
return this;
} | java | public HalResource removeLinkWithHref(String relation, String href) {
List<Link> links = getLinks(relation);
for (int i = 0; i < links.size(); i++) {
if (href.equals(links.get(i).getHref())) {
return removeLink(relation, i);
}
}
return this;
} | [
"public",
"HalResource",
"removeLinkWithHref",
"(",
"String",
"relation",
",",
"String",
"href",
")",
"{",
"List",
"<",
"Link",
">",
"links",
"=",
"getLinks",
"(",
"relation",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"links",
".",
"... | Remove the link with the given relation and href
@param relation Link relation
@param href to identify the link to remove
@return this HAL resource | [
"Remove",
"the",
"link",
"with",
"the",
"given",
"relation",
"and",
"href"
] | train | https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L451-L461 |
EasyinnovaSL/Tiff-Library-4J | src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java | BaselineProfile.CheckGrayscaleImage | private void CheckGrayscaleImage(IfdTags metadata, int n) {
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
// if (bps != 4 && bps != 8)
if (bps < 1)
validation.addError("Invalid Bits per Sample", "IFD" + n, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
} | java | private void CheckGrayscaleImage(IfdTags metadata, int n) {
// Bits per Sample
long bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getFirstNumericValue();
// if (bps != 4 && bps != 8)
if (bps < 1)
validation.addError("Invalid Bits per Sample", "IFD" + n, bps);
// Compression
long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
// if (comp != 1 && comp != 32773)
if (comp < 1)
validation.addError("Invalid Compression", "IFD" + n, comp);
} | [
"private",
"void",
"CheckGrayscaleImage",
"(",
"IfdTags",
"metadata",
",",
"int",
"n",
")",
"{",
"// Bits per Sample",
"long",
"bps",
"=",
"metadata",
".",
"get",
"(",
"TiffTags",
".",
"getTagId",
"(",
"\"BitsPerSample\"",
")",
")",
".",
"getFirstNumericValue",
... | Check Grayscale Image.
@param metadata the metadata
@param n the IFD number | [
"Check",
"Grayscale",
"Image",
"."
] | train | https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/BaselineProfile.java#L268-L280 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java | IntegralImageOps.block_zero | public static long block_zero(GrayS64 integral , int x0 , int y0 , int x1 , int y1 )
{
return ImplIntegralImageOps.block_zero(integral,x0,y0,x1,y1);
} | java | public static long block_zero(GrayS64 integral , int x0 , int y0 , int x1 , int y1 )
{
return ImplIntegralImageOps.block_zero(integral,x0,y0,x1,y1);
} | [
"public",
"static",
"long",
"block_zero",
"(",
"GrayS64",
"integral",
",",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"x1",
",",
"int",
"y1",
")",
"{",
"return",
"ImplIntegralImageOps",
".",
"block_zero",
"(",
"integral",
",",
"x0",
",",
"y0",
",",
"x1... | <p>
Computes the value of a block inside an integral image and treats pixels outside of the
image as zero. The block is defined as follows: x0 < x ≤ x1 and y0 < y ≤ y1.
</p>
@param integral Integral image.
@param x0 Lower bound of the block. Exclusive.
@param y0 Lower bound of the block. Exclusive.
@param x1 Upper bound of the block. Inclusive.
@param y1 Upper bound of the block. Inclusive.
@return Value inside the block. | [
"<p",
">",
"Computes",
"the",
"value",
"of",
"a",
"block",
"inside",
"an",
"integral",
"image",
"and",
"treats",
"pixels",
"outside",
"of",
"the",
"image",
"as",
"zero",
".",
"The",
"block",
"is",
"defined",
"as",
"follows",
":",
"x0",
"<",
";",
"x",... | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java#L498-L501 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/ValueMap.java | ValueMap.createValueMap | static <T extends ValueMap> T createValueMap(Map map, Class<T> clazz) {
try {
Constructor<T> constructor = clazz.getDeclaredConstructor(Map.class);
constructor.setAccessible(true);
return constructor.newInstance(map);
} catch (Exception e) {
throw new AssertionError(
"Could not create instance of " + clazz.getCanonicalName() + ".\n" + e);
}
} | java | static <T extends ValueMap> T createValueMap(Map map, Class<T> clazz) {
try {
Constructor<T> constructor = clazz.getDeclaredConstructor(Map.class);
constructor.setAccessible(true);
return constructor.newInstance(map);
} catch (Exception e) {
throw new AssertionError(
"Could not create instance of " + clazz.getCanonicalName() + ".\n" + e);
}
} | [
"static",
"<",
"T",
"extends",
"ValueMap",
">",
"T",
"createValueMap",
"(",
"Map",
"map",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"try",
"{",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"clazz",
".",
"getDeclaredConstructor",
"(",
"Map",
... | Uses reflection to create an instance of a subclass of {@link ValueMap}. The subclass
<b>must</b> declare a map constructor. | [
"Uses",
"reflection",
"to",
"create",
"an",
"instance",
"of",
"a",
"subclass",
"of",
"{"
] | train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/ValueMap.java#L63-L72 |
google/j2objc | jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java | MutableBigInteger.divaddLong | private int divaddLong(int dh, int dl, int[] result, int offset) {
long carry = 0;
long sum = (dl & LONG_MASK) + (result[1+offset] & LONG_MASK);
result[1+offset] = (int)sum;
sum = (dh & LONG_MASK) + (result[offset] & LONG_MASK) + carry;
result[offset] = (int)sum;
carry = sum >>> 32;
return (int)carry;
} | java | private int divaddLong(int dh, int dl, int[] result, int offset) {
long carry = 0;
long sum = (dl & LONG_MASK) + (result[1+offset] & LONG_MASK);
result[1+offset] = (int)sum;
sum = (dh & LONG_MASK) + (result[offset] & LONG_MASK) + carry;
result[offset] = (int)sum;
carry = sum >>> 32;
return (int)carry;
} | [
"private",
"int",
"divaddLong",
"(",
"int",
"dh",
",",
"int",
"dl",
",",
"int",
"[",
"]",
"result",
",",
"int",
"offset",
")",
"{",
"long",
"carry",
"=",
"0",
";",
"long",
"sum",
"=",
"(",
"dl",
"&",
"LONG_MASK",
")",
"+",
"(",
"result",
"[",
"... | A primitive used for division by long.
Specialized version of the method divadd.
dh is a high part of the divisor, dl is a low part | [
"A",
"primitive",
"used",
"for",
"division",
"by",
"long",
".",
"Specialized",
"version",
"of",
"the",
"method",
"divadd",
".",
"dh",
"is",
"a",
"high",
"part",
"of",
"the",
"divisor",
"dl",
"is",
"a",
"low",
"part"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java#L1791-L1801 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/lang/Validator.java | Validator.validateGeneral | public static <T extends CharSequence> T validateGeneral(T value, String errorMsg) throws ValidateException {
if (false == isGeneral(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | java | public static <T extends CharSequence> T validateGeneral(T value, String errorMsg) throws ValidateException {
if (false == isGeneral(value)) {
throw new ValidateException(errorMsg);
}
return value;
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validateGeneral",
"(",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"false",
"==",
"isGeneral",
"(",
"value",
")",
")",
"{",
"throw",
"new",... | 验证是否为英文字母 、数字和下划线
@param <T> 字符串类型
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常 | [
"验证是否为英文字母",
"、数字和下划线"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L358-L363 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/corpus/io/IOUtil.java | IOUtil.loadDictionary | public static void loadDictionary(BufferedReader br, TreeMap<String, CoreDictionary.Attribute> storage, boolean isCSV, Nature defaultNature) throws IOException
{
String splitter = "\\s";
if (isCSV)
{
splitter = ",";
}
String line;
boolean firstLine = true;
while ((line = br.readLine()) != null)
{
if (firstLine)
{
line = IOUtil.removeUTF8BOM(line);
firstLine = false;
}
String param[] = line.split(splitter);
int natureCount = (param.length - 1) / 2;
CoreDictionary.Attribute attribute;
if (natureCount == 0)
{
attribute = new CoreDictionary.Attribute(defaultNature);
}
else
{
attribute = new CoreDictionary.Attribute(natureCount);
for (int i = 0; i < natureCount; ++i)
{
attribute.nature[i] = LexiconUtility.convertStringToNature(param[1 + 2 * i]);
attribute.frequency[i] = Integer.parseInt(param[2 + 2 * i]);
attribute.totalFrequency += attribute.frequency[i];
}
}
storage.put(param[0], attribute);
}
br.close();
} | java | public static void loadDictionary(BufferedReader br, TreeMap<String, CoreDictionary.Attribute> storage, boolean isCSV, Nature defaultNature) throws IOException
{
String splitter = "\\s";
if (isCSV)
{
splitter = ",";
}
String line;
boolean firstLine = true;
while ((line = br.readLine()) != null)
{
if (firstLine)
{
line = IOUtil.removeUTF8BOM(line);
firstLine = false;
}
String param[] = line.split(splitter);
int natureCount = (param.length - 1) / 2;
CoreDictionary.Attribute attribute;
if (natureCount == 0)
{
attribute = new CoreDictionary.Attribute(defaultNature);
}
else
{
attribute = new CoreDictionary.Attribute(natureCount);
for (int i = 0; i < natureCount; ++i)
{
attribute.nature[i] = LexiconUtility.convertStringToNature(param[1 + 2 * i]);
attribute.frequency[i] = Integer.parseInt(param[2 + 2 * i]);
attribute.totalFrequency += attribute.frequency[i];
}
}
storage.put(param[0], attribute);
}
br.close();
} | [
"public",
"static",
"void",
"loadDictionary",
"(",
"BufferedReader",
"br",
",",
"TreeMap",
"<",
"String",
",",
"CoreDictionary",
".",
"Attribute",
">",
"storage",
",",
"boolean",
"isCSV",
",",
"Nature",
"defaultNature",
")",
"throws",
"IOException",
"{",
"String... | 将一个BufferedReader中的词条加载到词典
@param br 源
@param storage 储存位置
@throws IOException 异常表示加载失败 | [
"将一个BufferedReader中的词条加载到词典"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/corpus/io/IOUtil.java#L705-L742 |
iipc/openwayback | wayback-core/src/main/java/org/archive/wayback/replay/DecodingResource.java | DecodingResource.forEncoding | public static DecodingResource forEncoding(String contentEncoding, Resource source) throws IOException {
InputStream stream = decodingStream(contentEncoding, source);
if (stream == null) {
return null;
}
return new DecodingResource(source, stream);
} | java | public static DecodingResource forEncoding(String contentEncoding, Resource source) throws IOException {
InputStream stream = decodingStream(contentEncoding, source);
if (stream == null) {
return null;
}
return new DecodingResource(source, stream);
} | [
"public",
"static",
"DecodingResource",
"forEncoding",
"(",
"String",
"contentEncoding",
",",
"Resource",
"source",
")",
"throws",
"IOException",
"{",
"InputStream",
"stream",
"=",
"decodingStream",
"(",
"contentEncoding",
",",
"source",
")",
";",
"if",
"(",
"stre... | Returns a DecodingResource that wraps an existing resource with a decompressor for the given
Content-Encoding.
@param contentEncoding the value of the Content-Encoding header
@param source the resource to wrap
@return the new resource or null if the contentEncoding is not supported | [
"Returns",
"a",
"DecodingResource",
"that",
"wraps",
"an",
"existing",
"resource",
"with",
"a",
"decompressor",
"for",
"the",
"given",
"Content",
"-",
"Encoding",
"."
] | train | https://github.com/iipc/openwayback/blob/da74c3a59a5b5a5c365bd4702dcb45d263535794/wayback-core/src/main/java/org/archive/wayback/replay/DecodingResource.java#L87-L93 |
alkacon/opencms-core | src/org/opencms/util/CmsStringUtil.java | CmsStringUtil.getIntValue | public static int getIntValue(String value, int defaultValue, String key) {
int result;
try {
result = Integer.valueOf(value).intValue();
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.ERR_UNABLE_TO_PARSE_INT_2, value, key));
}
result = defaultValue;
}
return result;
} | java | public static int getIntValue(String value, int defaultValue, String key) {
int result;
try {
result = Integer.valueOf(value).intValue();
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.ERR_UNABLE_TO_PARSE_INT_2, value, key));
}
result = defaultValue;
}
return result;
} | [
"public",
"static",
"int",
"getIntValue",
"(",
"String",
"value",
",",
"int",
"defaultValue",
",",
"String",
"key",
")",
"{",
"int",
"result",
";",
"try",
"{",
"result",
"=",
"Integer",
".",
"valueOf",
"(",
"value",
")",
".",
"intValue",
"(",
")",
";",... | Returns the Integer (int) value for the given String value.<p>
All parse errors are caught and the given default value is returned in this case.<p>
@param value the value to parse as int
@param defaultValue the default value in case of parsing errors
@param key a key to be included in the debug output in case of parse errors
@return the int value for the given parameter value String | [
"Returns",
"the",
"Integer",
"(",
"int",
")",
"value",
"for",
"the",
"given",
"String",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsStringUtil.java#L805-L817 |
io7m/jcanephora | com.io7m.jcanephora.core/src/main/java/com/io7m/jcanephora/core/JCGLTextureUpdates.java | JCGLTextureUpdates.newUpdateReplacingArea2D | public static JCGLTexture2DUpdateType newUpdateReplacingArea2D(
final JCGLTexture2DUsableType t,
final AreaL update_area)
{
NullCheck.notNull(t, "Texture");
NullCheck.notNull(update_area, "Area");
final AreaL texture_area = AreaSizesL.area(t.size());
if (!AreasL.contains(texture_area, update_area)) {
final StringBuilder sb = new StringBuilder(128);
sb.append("Target area is not contained within the texture's area.");
sb.append(System.lineSeparator());
sb.append(" Texture area: ");
sb.append(t.size());
sb.append(System.lineSeparator());
sb.append(" Target area: ");
sb.append(update_area);
sb.append(System.lineSeparator());
throw new RangeCheckException(sb.toString());
}
final long width = update_area.width();
final long height = update_area.height();
final int bpp = t.format().getBytesPerPixel();
final long size = width * height * (long) bpp;
final ByteBuffer data = ByteBuffer.allocateDirect(Math.toIntExact(size));
data.order(ByteOrder.nativeOrder());
return new Update2D(t, update_area, data);
} | java | public static JCGLTexture2DUpdateType newUpdateReplacingArea2D(
final JCGLTexture2DUsableType t,
final AreaL update_area)
{
NullCheck.notNull(t, "Texture");
NullCheck.notNull(update_area, "Area");
final AreaL texture_area = AreaSizesL.area(t.size());
if (!AreasL.contains(texture_area, update_area)) {
final StringBuilder sb = new StringBuilder(128);
sb.append("Target area is not contained within the texture's area.");
sb.append(System.lineSeparator());
sb.append(" Texture area: ");
sb.append(t.size());
sb.append(System.lineSeparator());
sb.append(" Target area: ");
sb.append(update_area);
sb.append(System.lineSeparator());
throw new RangeCheckException(sb.toString());
}
final long width = update_area.width();
final long height = update_area.height();
final int bpp = t.format().getBytesPerPixel();
final long size = width * height * (long) bpp;
final ByteBuffer data = ByteBuffer.allocateDirect(Math.toIntExact(size));
data.order(ByteOrder.nativeOrder());
return new Update2D(t, update_area, data);
} | [
"public",
"static",
"JCGLTexture2DUpdateType",
"newUpdateReplacingArea2D",
"(",
"final",
"JCGLTexture2DUsableType",
"t",
",",
"final",
"AreaL",
"update_area",
")",
"{",
"NullCheck",
".",
"notNull",
"(",
"t",
",",
"\"Texture\"",
")",
";",
"NullCheck",
".",
"notNull",... | Create a new update that will replace the given {@code area} of {@code t}.
{@code area} must be included within the area of {@code t}.
@param t The texture
@param update_area The area that will be updated
@return A new update
@throws RangeCheckException Iff {@code area} is not included within {@code
t} | [
"Create",
"a",
"new",
"update",
"that",
"will",
"replace",
"the",
"given",
"{",
"@code",
"area",
"}",
"of",
"{",
"@code",
"t",
"}",
".",
"{",
"@code",
"area",
"}",
"must",
"be",
"included",
"within",
"the",
"area",
"of",
"{",
"@code",
"t",
"}",
"."... | train | https://github.com/io7m/jcanephora/blob/0004c1744b7f0969841d04cd4fa693f402b10980/com.io7m.jcanephora.core/src/main/java/com/io7m/jcanephora/core/JCGLTextureUpdates.java#L129-L158 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java | JobScheduleOperations.patchJobSchedule | public void patchJobSchedule(String jobScheduleId, Schedule schedule, JobSpecification jobSpecification, List<MetadataItem> metadata) throws BatchErrorException, IOException {
patchJobSchedule(jobScheduleId, schedule, jobSpecification, metadata, null);
} | java | public void patchJobSchedule(String jobScheduleId, Schedule schedule, JobSpecification jobSpecification, List<MetadataItem> metadata) throws BatchErrorException, IOException {
patchJobSchedule(jobScheduleId, schedule, jobSpecification, metadata, null);
} | [
"public",
"void",
"patchJobSchedule",
"(",
"String",
"jobScheduleId",
",",
"Schedule",
"schedule",
",",
"JobSpecification",
"jobSpecification",
",",
"List",
"<",
"MetadataItem",
">",
"metadata",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"patchJobS... | Updates the specified job schedule.
This method only replaces the properties specified with non-null values.
@param jobScheduleId The ID of the job schedule. If null, any existing schedule is left unchanged.
@param schedule The schedule according to which jobs will be created.
@param jobSpecification The details of the jobs to be created on this schedule. Updates affect only jobs that are started after the update has taken place. Any currently active job continues with the older specification. If null, the existing job specification is left unchanged.
@param metadata A list of name-value pairs associated with the job schedule as metadata. If null, the existing metadata are left unchanged.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Updates",
"the",
"specified",
"job",
"schedule",
".",
"This",
"method",
"only",
"replaces",
"the",
"properties",
"specified",
"with",
"non",
"-",
"null",
"values",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java#L193-L195 |
icode/ameba | src/main/java/ameba/message/error/DefaultExceptionMapper.java | DefaultExceptionMapper.parseDescription | protected String parseDescription(Throwable exception, int status) {
if (exception instanceof UnprocessableEntityException && StringUtils.isNotBlank(exception.getMessage())) {
return exception.getMessage();
}
return ErrorMessage.parseDescription(status);
} | java | protected String parseDescription(Throwable exception, int status) {
if (exception instanceof UnprocessableEntityException && StringUtils.isNotBlank(exception.getMessage())) {
return exception.getMessage();
}
return ErrorMessage.parseDescription(status);
} | [
"protected",
"String",
"parseDescription",
"(",
"Throwable",
"exception",
",",
"int",
"status",
")",
"{",
"if",
"(",
"exception",
"instanceof",
"UnprocessableEntityException",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"exception",
".",
"getMessage",
"(",
")",
"... | <p>parseDescription.</p>
@param exception a {@link java.lang.Throwable} object.
@param status a int.
@return a {@link java.lang.String} object. | [
"<p",
">",
"parseDescription",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/message/error/DefaultExceptionMapper.java#L76-L81 |
aws/aws-sdk-java | aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/JmesPathCodeGenVisitor.java | JmesPathCodeGenVisitor.visit | @Override
public String visit(final JmesPathFlatten flatten, final Void aVoid)
throws InvalidTypeException {
return "new JmesPathFlatten( " + flatten.getFlattenExpr()
.accept(this, aVoid) + ")";
} | java | @Override
public String visit(final JmesPathFlatten flatten, final Void aVoid)
throws InvalidTypeException {
return "new JmesPathFlatten( " + flatten.getFlattenExpr()
.accept(this, aVoid) + ")";
} | [
"@",
"Override",
"public",
"String",
"visit",
"(",
"final",
"JmesPathFlatten",
"flatten",
",",
"final",
"Void",
"aVoid",
")",
"throws",
"InvalidTypeException",
"{",
"return",
"\"new JmesPathFlatten( \"",
"+",
"flatten",
".",
"getFlattenExpr",
"(",
")",
".",
"accep... | Generates the code for a new JmesPathFlatten.
@param flatten JmesPath flatten type
@param aVoid void
@return String that represents a call to
the new flatten projection
@throws InvalidTypeException | [
"Generates",
"the",
"code",
"for",
"a",
"new",
"JmesPathFlatten",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/JmesPathCodeGenVisitor.java#L97-L102 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/i18n/dao/GeneratedDi18nDaoImpl.java | GeneratedDi18nDaoImpl.queryByBaseBundle | public Iterable<Di18n> queryByBaseBundle(java.lang.String baseBundle) {
return queryByField(null, Di18nMapper.Field.BASEBUNDLE.getFieldName(), baseBundle);
} | java | public Iterable<Di18n> queryByBaseBundle(java.lang.String baseBundle) {
return queryByField(null, Di18nMapper.Field.BASEBUNDLE.getFieldName(), baseBundle);
} | [
"public",
"Iterable",
"<",
"Di18n",
">",
"queryByBaseBundle",
"(",
"java",
".",
"lang",
".",
"String",
"baseBundle",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"Di18nMapper",
".",
"Field",
".",
"BASEBUNDLE",
".",
"getFieldName",
"(",
")",
",",
"... | query-by method for field baseBundle
@param baseBundle the specified attribute
@return an Iterable of Di18ns for the specified baseBundle | [
"query",
"-",
"by",
"method",
"for",
"field",
"baseBundle"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/i18n/dao/GeneratedDi18nDaoImpl.java#L43-L45 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckReport.java | CmsContentCheckReport.displayReport | @Override
public void displayReport() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
switch (getAction()) {
case ACTION_REPORT_END:
// set the results of the content check
m_contentCheck = (CmsContentCheck)((Map)getSettings().getDialogObject()).get(getParamClassname());
I_CmsResourceCollector collector = new CmsContentCheckCollector(null, m_contentCheck.getResults());
getSettings().setCollector(collector);
try {
getToolManager().jspForwardTool(this, "/contenttools/check/result", null);
} catch (Exception e) {
actionCloseDialog();
}
break;
case ACTION_CANCEL:
actionCloseDialog();
break;
case ACTION_REPORT_UPDATE:
setParamAction(REPORT_UPDATE);
getJsp().include(FILE_REPORT_OUTPUT);
break;
case ACTION_REPORT_BEGIN:
case ACTION_CONFIRMED:
case ACTION_DEFAULT:
default:
I_CmsReportThread m_thread = initializeThread();
m_thread.start();
setParamAction(REPORT_BEGIN);
setParamThread(m_thread.getUUID().toString());
getJsp().include(FILE_REPORT_OUTPUT);
}
} | java | @Override
public void displayReport() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
switch (getAction()) {
case ACTION_REPORT_END:
// set the results of the content check
m_contentCheck = (CmsContentCheck)((Map)getSettings().getDialogObject()).get(getParamClassname());
I_CmsResourceCollector collector = new CmsContentCheckCollector(null, m_contentCheck.getResults());
getSettings().setCollector(collector);
try {
getToolManager().jspForwardTool(this, "/contenttools/check/result", null);
} catch (Exception e) {
actionCloseDialog();
}
break;
case ACTION_CANCEL:
actionCloseDialog();
break;
case ACTION_REPORT_UPDATE:
setParamAction(REPORT_UPDATE);
getJsp().include(FILE_REPORT_OUTPUT);
break;
case ACTION_REPORT_BEGIN:
case ACTION_CONFIRMED:
case ACTION_DEFAULT:
default:
I_CmsReportThread m_thread = initializeThread();
m_thread.start();
setParamAction(REPORT_BEGIN);
setParamThread(m_thread.getUUID().toString());
getJsp().include(FILE_REPORT_OUTPUT);
}
} | [
"@",
"Override",
"public",
"void",
"displayReport",
"(",
")",
"throws",
"JspException",
"{",
"// save initialized instance of this class in request attribute for included sub-elements",
"getJsp",
"(",
")",
".",
"getRequest",
"(",
")",
".",
"setAttribute",
"(",
"SESSION_WORK... | Performs the dialog actions depending on the initialized action.<p>
@throws JspException if dialog actions fail | [
"Performs",
"the",
"dialog",
"actions",
"depending",
"on",
"the",
"initialized",
"action",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckReport.java#L86-L120 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/SARLProjectConfigurator.java | SARLProjectConfigurator.addNatures | public static IStatus addNatures(IProject project, IProgressMonitor monitor, String... natureIdentifiers) {
if (project != null && natureIdentifiers != null && natureIdentifiers.length > 0) {
try {
final SubMonitor subMonitor = SubMonitor.convert(monitor, natureIdentifiers.length + 2);
final IProjectDescription description = project.getDescription();
final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds()));
for (final String natureIdentifier : natureIdentifiers) {
if (!Strings.isNullOrEmpty(natureIdentifier) && !natures.contains(natureIdentifier)) {
natures.add(0, natureIdentifier);
}
subMonitor.worked(1);
}
final String[] newNatures = natures.toArray(new String[natures.size()]);
final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures);
subMonitor.worked(1);
// check the status and decide what to do
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, subMonitor.newChild(1));
}
subMonitor.done();
return status;
} catch (CoreException exception) {
return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, exception);
}
}
return SARLEclipsePlugin.getDefault().createOkStatus();
} | java | public static IStatus addNatures(IProject project, IProgressMonitor monitor, String... natureIdentifiers) {
if (project != null && natureIdentifiers != null && natureIdentifiers.length > 0) {
try {
final SubMonitor subMonitor = SubMonitor.convert(monitor, natureIdentifiers.length + 2);
final IProjectDescription description = project.getDescription();
final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds()));
for (final String natureIdentifier : natureIdentifiers) {
if (!Strings.isNullOrEmpty(natureIdentifier) && !natures.contains(natureIdentifier)) {
natures.add(0, natureIdentifier);
}
subMonitor.worked(1);
}
final String[] newNatures = natures.toArray(new String[natures.size()]);
final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures);
subMonitor.worked(1);
// check the status and decide what to do
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, subMonitor.newChild(1));
}
subMonitor.done();
return status;
} catch (CoreException exception) {
return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, exception);
}
}
return SARLEclipsePlugin.getDefault().createOkStatus();
} | [
"public",
"static",
"IStatus",
"addNatures",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
",",
"String",
"...",
"natureIdentifiers",
")",
"{",
"if",
"(",
"project",
"!=",
"null",
"&&",
"natureIdentifiers",
"!=",
"null",
"&&",
"natureIdentifiers"... | Add the natures to the given project.
@param project the project.
@param monitor the monitor.
@param natureIdentifiers the identifiers of the natures to add to the project.
@return the status if the operation.
@since 0.8 | [
"Add",
"the",
"natures",
"to",
"the",
"given",
"project",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/SARLProjectConfigurator.java#L714-L744 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/views/overlay/Polyline.java | Polyline.getCloseTo | public GeoPoint getCloseTo(GeoPoint point, double tolerance, MapView mapView) {
return mOutline.getCloseTo(point, tolerance, mapView.getProjection(), false);
} | java | public GeoPoint getCloseTo(GeoPoint point, double tolerance, MapView mapView) {
return mOutline.getCloseTo(point, tolerance, mapView.getProjection(), false);
} | [
"public",
"GeoPoint",
"getCloseTo",
"(",
"GeoPoint",
"point",
",",
"double",
"tolerance",
",",
"MapView",
"mapView",
")",
"{",
"return",
"mOutline",
".",
"getCloseTo",
"(",
"point",
",",
"tolerance",
",",
"mapView",
".",
"getProjection",
"(",
")",
",",
"fals... | @since 6.0.3
Detection is done is screen coordinates.
@param point
@param tolerance in pixels
@return the first GeoPoint of the Polyline close enough to the point | [
"@since",
"6",
".",
"0",
".",
"3",
"Detection",
"is",
"done",
"is",
"screen",
"coordinates",
"."
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/views/overlay/Polyline.java#L188-L190 |
sksamuel/scrimage | scrimage-filters/src/main/java/thirdparty/jhlabs/image/SplineColormap.java | SplineColormap.addKnot | public void addKnot(int x, int color) {
int[] nx = new int[numKnots+1];
int[] ny = new int[numKnots+1];
System.arraycopy(xKnots, 0, nx, 0, numKnots);
System.arraycopy(yKnots, 0, ny, 0, numKnots);
xKnots = nx;
yKnots = ny;
xKnots[numKnots] = x;
yKnots[numKnots] = color;
numKnots++;
sortKnots();
rebuildGradient();
} | java | public void addKnot(int x, int color) {
int[] nx = new int[numKnots+1];
int[] ny = new int[numKnots+1];
System.arraycopy(xKnots, 0, nx, 0, numKnots);
System.arraycopy(yKnots, 0, ny, 0, numKnots);
xKnots = nx;
yKnots = ny;
xKnots[numKnots] = x;
yKnots[numKnots] = color;
numKnots++;
sortKnots();
rebuildGradient();
} | [
"public",
"void",
"addKnot",
"(",
"int",
"x",
",",
"int",
"color",
")",
"{",
"int",
"[",
"]",
"nx",
"=",
"new",
"int",
"[",
"numKnots",
"+",
"1",
"]",
";",
"int",
"[",
"]",
"ny",
"=",
"new",
"int",
"[",
"numKnots",
"+",
"1",
"]",
";",
"System... | Add a new knot.
@param x the knot position
@param color the color
@see #removeKnot | [
"Add",
"a",
"new",
"knot",
"."
] | train | https://github.com/sksamuel/scrimage/blob/52dab448136e6657a71951b0e6b7d5e64dc979ac/scrimage-filters/src/main/java/thirdparty/jhlabs/image/SplineColormap.java#L80-L92 |
datacleaner/DataCleaner | engine/env/spark/src/main/java/org/datacleaner/spark/functions/RowProcessingFunction.java | RowProcessingFunction.createReplacementResource | private Resource createReplacementResource(final Resource resource, final int partitionNumber) {
final String formattedPartitionNumber = String.format("%05d", partitionNumber);
if (resource instanceof HdfsResource || resource instanceof HadoopResource) {
final String path = resource.getQualifiedPath() + "/part-" + formattedPartitionNumber;
final URI uri = URI.create(path);
return HdfsHelper.createHelper().getResourceToUse(uri);
}
if (resource instanceof FileResource) {
final File file = ((FileResource) resource).getFile();
if (file.exists() && file.isFile()) {
// a file already exists - we cannot just create a directory
// then
return resource;
}
if (!file.exists()) {
file.mkdirs();
}
return new FileResource(resource.getQualifiedPath() + "/part-" + formattedPartitionNumber);
}
return null;
} | java | private Resource createReplacementResource(final Resource resource, final int partitionNumber) {
final String formattedPartitionNumber = String.format("%05d", partitionNumber);
if (resource instanceof HdfsResource || resource instanceof HadoopResource) {
final String path = resource.getQualifiedPath() + "/part-" + formattedPartitionNumber;
final URI uri = URI.create(path);
return HdfsHelper.createHelper().getResourceToUse(uri);
}
if (resource instanceof FileResource) {
final File file = ((FileResource) resource).getFile();
if (file.exists() && file.isFile()) {
// a file already exists - we cannot just create a directory
// then
return resource;
}
if (!file.exists()) {
file.mkdirs();
}
return new FileResource(resource.getQualifiedPath() + "/part-" + formattedPartitionNumber);
}
return null;
} | [
"private",
"Resource",
"createReplacementResource",
"(",
"final",
"Resource",
"resource",
",",
"final",
"int",
"partitionNumber",
")",
"{",
"final",
"String",
"formattedPartitionNumber",
"=",
"String",
".",
"format",
"(",
"\"%05d\"",
",",
"partitionNumber",
")",
";"... | Creates a {@link Resource} replacement to use for configured properties.
@param resource
@param partitionNumber
@return a replacement resource, or null if it shouldn't be replaced | [
"Creates",
"a",
"{",
"@link",
"Resource",
"}",
"replacement",
"to",
"use",
"for",
"configured",
"properties",
"."
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/engine/env/spark/src/main/java/org/datacleaner/spark/functions/RowProcessingFunction.java#L186-L206 |
bushidowallet/bushido-java-service | bushido-wallet-service/src/main/java/com/bitcoin/blockchain/api/service/v2wallet/V2WalletServiceImpl.java | V2WalletServiceImpl.getTransactionsKeys | public Response getTransactionsKeys(String key, int account) {
Response operation = new Response();
if (walletDAO.hasWallet(key)) {
V2Wallet wallet = wallets.getWallet(key);
if (wallet == null) {
wallet = init(key);
}
operation.setPayload(wallet.getTransactionsKeys(account));
} else {
operation.addError(new Error(3));
}
return operation;
} | java | public Response getTransactionsKeys(String key, int account) {
Response operation = new Response();
if (walletDAO.hasWallet(key)) {
V2Wallet wallet = wallets.getWallet(key);
if (wallet == null) {
wallet = init(key);
}
operation.setPayload(wallet.getTransactionsKeys(account));
} else {
operation.addError(new Error(3));
}
return operation;
} | [
"public",
"Response",
"getTransactionsKeys",
"(",
"String",
"key",
",",
"int",
"account",
")",
"{",
"Response",
"operation",
"=",
"new",
"Response",
"(",
")",
";",
"if",
"(",
"walletDAO",
".",
"hasWallet",
"(",
"key",
")",
")",
"{",
"V2Wallet",
"wallet",
... | Gets public keys with transactions associated with them
@param key
@param account
@return | [
"Gets",
"public",
"keys",
"with",
"transactions",
"associated",
"with",
"them"
] | train | https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-wallet-service/src/main/java/com/bitcoin/blockchain/api/service/v2wallet/V2WalletServiceImpl.java#L172-L184 |
ACRA/acra | acra-mail/src/main/java/org/acra/sender/EmailIntentSender.java | EmailIntentSender.getPackageName | @Nullable
private String getPackageName(@NonNull ComponentName resolveActivity, @NonNull List<Intent> initialIntents) {
String packageName = resolveActivity.getPackageName();
if (packageName.equals("android")) {
//multiple activities support the intent and no default is set
if (initialIntents.size() > 1) {
packageName = null;
} else if (initialIntents.size() == 1) {
//only one of them supports attachments, use that one
packageName = initialIntents.get(0).getPackage();
}
}
return packageName;
} | java | @Nullable
private String getPackageName(@NonNull ComponentName resolveActivity, @NonNull List<Intent> initialIntents) {
String packageName = resolveActivity.getPackageName();
if (packageName.equals("android")) {
//multiple activities support the intent and no default is set
if (initialIntents.size() > 1) {
packageName = null;
} else if (initialIntents.size() == 1) {
//only one of them supports attachments, use that one
packageName = initialIntents.get(0).getPackage();
}
}
return packageName;
} | [
"@",
"Nullable",
"private",
"String",
"getPackageName",
"(",
"@",
"NonNull",
"ComponentName",
"resolveActivity",
",",
"@",
"NonNull",
"List",
"<",
"Intent",
">",
"initialIntents",
")",
"{",
"String",
"packageName",
"=",
"resolveActivity",
".",
"getPackageName",
"(... | Finds the package name of the default email client supporting attachments
@param resolveActivity the resolved activity
@param initialIntents a list of intents to be used when
@return package name of the default email client, or null if more than one app match | [
"Finds",
"the",
"package",
"name",
"of",
"the",
"default",
"email",
"client",
"supporting",
"attachments"
] | train | https://github.com/ACRA/acra/blob/bfa3235ab110328c5ab2f792ddf8ee87be4a32d1/acra-mail/src/main/java/org/acra/sender/EmailIntentSender.java#L119-L132 |
jenkinsci/github-plugin | src/main/java/org/jenkinsci/plugins/github/common/ExpandableMessage.java | ExpandableMessage.expandAll | public String expandAll(Run<?, ?> run, TaskListener listener) throws IOException, InterruptedException {
if (run instanceof AbstractBuild) {
try {
return TokenMacro.expandAll(
(AbstractBuild) run,
listener,
content,
false,
Collections.<TokenMacro>emptyList()
);
} catch (MacroEvaluationException e) {
LOGGER.error("Can't process token content {} in {} ({})",
content, run.getParent().getFullName(), e.getMessage());
LOGGER.trace(e.getMessage(), e);
return content;
}
} else {
// fallback to env vars only because of token-macro allow only AbstractBuild in 1.11
return run.getEnvironment(listener).expand(trimToEmpty(content));
}
} | java | public String expandAll(Run<?, ?> run, TaskListener listener) throws IOException, InterruptedException {
if (run instanceof AbstractBuild) {
try {
return TokenMacro.expandAll(
(AbstractBuild) run,
listener,
content,
false,
Collections.<TokenMacro>emptyList()
);
} catch (MacroEvaluationException e) {
LOGGER.error("Can't process token content {} in {} ({})",
content, run.getParent().getFullName(), e.getMessage());
LOGGER.trace(e.getMessage(), e);
return content;
}
} else {
// fallback to env vars only because of token-macro allow only AbstractBuild in 1.11
return run.getEnvironment(listener).expand(trimToEmpty(content));
}
} | [
"public",
"String",
"expandAll",
"(",
"Run",
"<",
"?",
",",
"?",
">",
"run",
",",
"TaskListener",
"listener",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"if",
"(",
"run",
"instanceof",
"AbstractBuild",
")",
"{",
"try",
"{",
"return",
"... | Expands all env vars. In case of AbstractBuild also expands token macro and build vars
@param run build context
@param listener usually used to log something to console while building env vars
@return string with expanded vars and tokens | [
"Expands",
"all",
"env",
"vars",
".",
"In",
"case",
"of",
"AbstractBuild",
"also",
"expands",
"token",
"macro",
"and",
"build",
"vars"
] | train | https://github.com/jenkinsci/github-plugin/blob/4e05b9aeb488af5342c78f78aa3c55114e8d462a/src/main/java/org/jenkinsci/plugins/github/common/ExpandableMessage.java#L49-L69 |
teatrove/teatrove | trove/src/main/java/org/teatrove/trove/net/HttpUtils.java | HttpUtils.readLine | public static String readLine(InputStream in, byte[] buffer)
throws IllegalArgumentException, IOException
{
return readLine(in, buffer, -1);
} | java | public static String readLine(InputStream in, byte[] buffer)
throws IllegalArgumentException, IOException
{
return readLine(in, buffer, -1);
} | [
"public",
"static",
"String",
"readLine",
"(",
"InputStream",
"in",
",",
"byte",
"[",
"]",
"buffer",
")",
"throws",
"IllegalArgumentException",
",",
"IOException",
"{",
"return",
"readLine",
"(",
"in",
",",
"buffer",
",",
"-",
"1",
")",
";",
"}"
] | Reads a line from an HTTP InputStream, using the given buffer for
temporary storage.
@param in stream to read from
@param buffer temporary buffer to use
@throws IllegalArgumentException if the given InputStream doesn't
support marking | [
"Reads",
"a",
"line",
"from",
"an",
"HTTP",
"InputStream",
"using",
"the",
"given",
"buffer",
"for",
"temporary",
"storage",
"."
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/HttpUtils.java#L35-L39 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java | FieldUtils.writeStaticField | public static void writeStaticField(final Field field, final Object value) throws IllegalAccessException {
writeStaticField(field, value, false);
} | java | public static void writeStaticField(final Field field, final Object value) throws IllegalAccessException {
writeStaticField(field, value, false);
} | [
"public",
"static",
"void",
"writeStaticField",
"(",
"final",
"Field",
"field",
",",
"final",
"Object",
"value",
")",
"throws",
"IllegalAccessException",
"{",
"writeStaticField",
"(",
"field",
",",
"value",
",",
"false",
")",
";",
"}"
] | Writes a {@code public static} {@link Field}.
@param field
to write
@param value
to set
@throws IllegalArgumentException
if the field is {@code null} or not {@code static}, or {@code value} is not assignable
@throws IllegalAccessException
if the field is not {@code public} or is {@code final} | [
"Writes",
"a",
"{",
"@code",
"public",
"static",
"}",
"{",
"@link",
"Field",
"}",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java#L530-L532 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java | InconsistentKeyNameCasing.report | @Override
public void report() {
for (Map.Entry<KeyType, Map<String, Map<String, List<SourceInfo>>>> entry : parmInfo.entrySet()) {
KeyType type = entry.getKey();
Map<String, Map<String, List<SourceInfo>>> typeMap = entry.getValue();
for (Map<String, List<SourceInfo>> parmCaseInfo : typeMap.values()) {
if (parmCaseInfo.size() > 1) {
BugInstance bi = new BugInstance(this, type.getDescription(), NORMAL_PRIORITY);
for (Map.Entry<String, List<SourceInfo>> sourceInfos : parmCaseInfo.entrySet()) {
for (SourceInfo sourceInfo : sourceInfos.getValue()) {
bi.addClass(sourceInfo.clsName);
bi.addMethod(sourceInfo.clsName, sourceInfo.methodName, sourceInfo.signature, sourceInfo.isStatic);
bi.addSourceLine(sourceInfo.srcLine);
bi.addString(sourceInfos.getKey());
}
}
bugReporter.reportBug(bi);
}
}
}
parmInfo.clear();
} | java | @Override
public void report() {
for (Map.Entry<KeyType, Map<String, Map<String, List<SourceInfo>>>> entry : parmInfo.entrySet()) {
KeyType type = entry.getKey();
Map<String, Map<String, List<SourceInfo>>> typeMap = entry.getValue();
for (Map<String, List<SourceInfo>> parmCaseInfo : typeMap.values()) {
if (parmCaseInfo.size() > 1) {
BugInstance bi = new BugInstance(this, type.getDescription(), NORMAL_PRIORITY);
for (Map.Entry<String, List<SourceInfo>> sourceInfos : parmCaseInfo.entrySet()) {
for (SourceInfo sourceInfo : sourceInfos.getValue()) {
bi.addClass(sourceInfo.clsName);
bi.addMethod(sourceInfo.clsName, sourceInfo.methodName, sourceInfo.signature, sourceInfo.isStatic);
bi.addSourceLine(sourceInfo.srcLine);
bi.addString(sourceInfos.getKey());
}
}
bugReporter.reportBug(bi);
}
}
}
parmInfo.clear();
} | [
"@",
"Override",
"public",
"void",
"report",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"KeyType",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"SourceInfo",
">",
">",
">",
">",
"entry",
":",
"parmInfo",
".",
... | implements the visitor to look for the collected parm names, and look for duplicates that are different in casing only. | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"the",
"collected",
"parm",
"names",
"and",
"look",
"for",
"duplicates",
"that",
"are",
"different",
"in",
"casing",
"only",
"."
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java#L166-L190 |
wcm-io/wcm-io-wcm | commons/src/main/java/io/wcm/wcm/commons/util/Path.java | Path.getAbsoluteLevelOffset | private static int getAbsoluteLevelOffset(@NotNull String path, @NotNull ResourceResolver resourceResolver) {
Matcher versionHistoryMatcher = VERSION_HISTORY_PATTERN.matcher(path);
if (versionHistoryMatcher.matches()) {
return 3;
}
Matcher legacyVersionHistoryMatcher = LEGACY_VERSION_HISTORY_PATTERN.matcher(path);
if (legacyVersionHistoryMatcher.matches()) {
if (isTenant(resourceResolver)) {
legacyVersionHistoryMatcher = LEGACY_VERSION_HISTORY_TENANT_PATTERN.matcher(path);
if (legacyVersionHistoryMatcher.matches()) {
return 3;
}
}
return 2;
}
Matcher launchesMatcher = LAUNCHES_PATTERN.matcher(path);
if (launchesMatcher.matches()) {
return 6;
}
return 0;
} | java | private static int getAbsoluteLevelOffset(@NotNull String path, @NotNull ResourceResolver resourceResolver) {
Matcher versionHistoryMatcher = VERSION_HISTORY_PATTERN.matcher(path);
if (versionHistoryMatcher.matches()) {
return 3;
}
Matcher legacyVersionHistoryMatcher = LEGACY_VERSION_HISTORY_PATTERN.matcher(path);
if (legacyVersionHistoryMatcher.matches()) {
if (isTenant(resourceResolver)) {
legacyVersionHistoryMatcher = LEGACY_VERSION_HISTORY_TENANT_PATTERN.matcher(path);
if (legacyVersionHistoryMatcher.matches()) {
return 3;
}
}
return 2;
}
Matcher launchesMatcher = LAUNCHES_PATTERN.matcher(path);
if (launchesMatcher.matches()) {
return 6;
}
return 0;
} | [
"private",
"static",
"int",
"getAbsoluteLevelOffset",
"(",
"@",
"NotNull",
"String",
"path",
",",
"@",
"NotNull",
"ResourceResolver",
"resourceResolver",
")",
"{",
"Matcher",
"versionHistoryMatcher",
"=",
"VERSION_HISTORY_PATTERN",
".",
"matcher",
"(",
"path",
")",
... | Calculates offset for absolute level if path is a version history or launch path.
@param path Path
@param resourceResolver Resource resolver
@return 0 or offset if a version history or launch path. | [
"Calculates",
"offset",
"for",
"absolute",
"level",
"if",
"path",
"is",
"a",
"version",
"history",
"or",
"launch",
"path",
"."
] | train | https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/commons/src/main/java/io/wcm/wcm/commons/util/Path.java#L157-L177 |
d-sauer/JCalcAPI | src/main/java/org/jdice/calc/Properties.java | Properties.getInheritedRoundingMode | public static Rounding getInheritedRoundingMode(AbstractCalculator calc, Num value) {
if (value.getRoundingMode() == null) {
if (calc != null && calc.getRoundingMode() != null)
return calc.getRoundingMode();
else
return Properties.defRoundingMode;
}
else
return value.getRoundingMode();
} | java | public static Rounding getInheritedRoundingMode(AbstractCalculator calc, Num value) {
if (value.getRoundingMode() == null) {
if (calc != null && calc.getRoundingMode() != null)
return calc.getRoundingMode();
else
return Properties.defRoundingMode;
}
else
return value.getRoundingMode();
} | [
"public",
"static",
"Rounding",
"getInheritedRoundingMode",
"(",
"AbstractCalculator",
"calc",
",",
"Num",
"value",
")",
"{",
"if",
"(",
"value",
".",
"getRoundingMode",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"calc",
"!=",
"null",
"&&",
"calc",
".",
... | If {@link Num} don't define scale then use scale from {@link AbstractCalculator} instance.
Othervise use default scale {@link Properties#DEFAULT_SCALE}
@param calc
@param value | [
"If",
"{",
"@link",
"Num",
"}",
"don",
"t",
"define",
"scale",
"then",
"use",
"scale",
"from",
"{",
"@link",
"AbstractCalculator",
"}",
"instance",
".",
"Othervise",
"use",
"default",
"scale",
"{",
"@link",
"Properties#DEFAULT_SCALE",
"}"
] | train | https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/Properties.java#L408-L417 |
googleapis/google-http-java-client | google-http-client/src/main/java/com/google/api/client/http/HttpHeaders.java | HttpHeaders.fromHttpResponse | public final void fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger)
throws IOException {
clear();
ParseHeaderState state = new ParseHeaderState(this, logger);
int headerCount = response.getHeaderCount();
for (int i = 0; i < headerCount; i++) {
parseHeader(response.getHeaderName(i), response.getHeaderValue(i), state);
}
state.finish();
} | java | public final void fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger)
throws IOException {
clear();
ParseHeaderState state = new ParseHeaderState(this, logger);
int headerCount = response.getHeaderCount();
for (int i = 0; i < headerCount; i++) {
parseHeader(response.getHeaderName(i), response.getHeaderValue(i), state);
}
state.finish();
} | [
"public",
"final",
"void",
"fromHttpResponse",
"(",
"LowLevelHttpResponse",
"response",
",",
"StringBuilder",
"logger",
")",
"throws",
"IOException",
"{",
"clear",
"(",
")",
";",
"ParseHeaderState",
"state",
"=",
"new",
"ParseHeaderState",
"(",
"this",
",",
"logge... | Puts all headers of the {@link LowLevelHttpResponse} into this {@link HttpHeaders} object.
@param response Response from which the headers are copied
@param logger {@link StringBuilder} to which logging output is added or {@code null} to disable
logging
@since 1.10 | [
"Puts",
"all",
"headers",
"of",
"the",
"{",
"@link",
"LowLevelHttpResponse",
"}",
"into",
"this",
"{",
"@link",
"HttpHeaders",
"}",
"object",
"."
] | train | https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client/src/main/java/com/google/api/client/http/HttpHeaders.java#L958-L967 |
JoeKerouac/utils | src/main/java/com/joe/utils/reflect/BeanUtils.java | BeanUtils.tryBuildFinal | private static CustomPropertyDescriptor tryBuildFinal(Field field,
Class<?> clazz) throws IntrospectionException {
String name = field.getName();
String readMethodName;
log.debug("尝试为final类型的字段{}创建字段说明", name);
if (Boolean.class.isAssignableFrom(field.getType())) {
log.debug("字段是boolean类型");
if (name.startsWith("is")) {
readMethodName = name;
} else {
readMethodName = "is" + StringUtils.toFirstUpperCase(name);
}
} else {
log.debug("字段不是boolean类型");
readMethodName = "get" + StringUtils.toFirstUpperCase(name);
}
log.debug("猜测final类型的字段{}的read方法名为{}", name, readMethodName);
return convert(field, new PropertyDescriptor(name, clazz, readMethodName, null), clazz);
} | java | private static CustomPropertyDescriptor tryBuildFinal(Field field,
Class<?> clazz) throws IntrospectionException {
String name = field.getName();
String readMethodName;
log.debug("尝试为final类型的字段{}创建字段说明", name);
if (Boolean.class.isAssignableFrom(field.getType())) {
log.debug("字段是boolean类型");
if (name.startsWith("is")) {
readMethodName = name;
} else {
readMethodName = "is" + StringUtils.toFirstUpperCase(name);
}
} else {
log.debug("字段不是boolean类型");
readMethodName = "get" + StringUtils.toFirstUpperCase(name);
}
log.debug("猜测final类型的字段{}的read方法名为{}", name, readMethodName);
return convert(field, new PropertyDescriptor(name, clazz, readMethodName, null), clazz);
} | [
"private",
"static",
"CustomPropertyDescriptor",
"tryBuildFinal",
"(",
"Field",
"field",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"throws",
"IntrospectionException",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"String",
"readMethodName"... | 尝试为final类型的字段构建说明
@param field 字段
@param clazz 该字段所属的Class
@return final类型字段的说明,该值不会为null,构建失败时会抛出异常
@throws IntrospectionException 构建失败抛出异常,不会返回null | [
"尝试为final类型的字段构建说明"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/reflect/BeanUtils.java#L418-L437 |
relayrides/pushy | pushy/src/main/java/com/turo/pushy/apns/ApnsClientBuilder.java | ApnsClientBuilder.setClientCredentials | public ApnsClientBuilder setClientCredentials(final File p12File, final String p12Password) throws SSLException, IOException {
try (final InputStream p12InputStream = new FileInputStream(p12File)) {
return this.setClientCredentials(p12InputStream, p12Password);
}
} | java | public ApnsClientBuilder setClientCredentials(final File p12File, final String p12Password) throws SSLException, IOException {
try (final InputStream p12InputStream = new FileInputStream(p12File)) {
return this.setClientCredentials(p12InputStream, p12Password);
}
} | [
"public",
"ApnsClientBuilder",
"setClientCredentials",
"(",
"final",
"File",
"p12File",
",",
"final",
"String",
"p12Password",
")",
"throws",
"SSLException",
",",
"IOException",
"{",
"try",
"(",
"final",
"InputStream",
"p12InputStream",
"=",
"new",
"FileInputStream",
... | <p>Sets the TLS credentials for the client under construction using the contents of the given PKCS#12 file.
Clients constructed with TLS credentials will use TLS-based authentication when sending push notifications. The
PKCS#12 file <em>must</em> contain a certificate/private key pair.</p>
<p>Clients may not have both TLS credentials and a signing key.</p>
@param p12File a PKCS#12-formatted file containing the certificate and private key to be used to identify the
client to the APNs server
@param p12Password the password to be used to decrypt the contents of the given PKCS#12 file; passwords may be
blank (i.e. {@code ""}), but must not be {@code null}
@throws SSLException if the given PKCS#12 file could not be loaded or if any other SSL-related problem arises
when constructing the context
@throws IOException if any IO problem occurred while attempting to read the given PKCS#12 file, or the PKCS#12
file could not be found
@return a reference to this builder
@since 0.8 | [
"<p",
">",
"Sets",
"the",
"TLS",
"credentials",
"for",
"the",
"client",
"under",
"construction",
"using",
"the",
"contents",
"of",
"the",
"given",
"PKCS#12",
"file",
".",
"Clients",
"constructed",
"with",
"TLS",
"credentials",
"will",
"use",
"TLS",
"-",
"bas... | train | https://github.com/relayrides/pushy/blob/1f6f9a0e07d785c815d74c2320a8d87c80231d36/pushy/src/main/java/com/turo/pushy/apns/ApnsClientBuilder.java#L190-L194 |
florent37/DaVinci | davinci/src/main/java/com/github/florent37/davinci/DaVinci.java | DaVinci.get | public Drawable get() {
final Drawable[] drawables = new Drawable[]{
mPlaceHolder,
new BitmapDrawable(mContext.getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)),
};
final TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
into(new Callback() {
@Override
public void onBitmapLoaded(String path, Bitmap bitmap) {
Log.d(TAG, "callback " + path + " called");
if (bitmap != null) {
Log.d(TAG, "bitmap " + path + " loaded");
Drawable drawable = drawables[1];
if (drawable != null && drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawables[1];
try {
Method method = BitmapDrawable.class.getDeclaredMethod("setBitmap", Bitmap.class);
method.setAccessible(true);
method.invoke(bitmapDrawable, bitmap);
Log.d(TAG, "bitmap " + path + " added to transition");
} catch (Exception e) {
e.printStackTrace();
}
}
transitionDrawable.startTransition(500);
Log.d(TAG, "image " + path + " transition started");
}
}
});
return transitionDrawable;
} | java | public Drawable get() {
final Drawable[] drawables = new Drawable[]{
mPlaceHolder,
new BitmapDrawable(mContext.getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)),
};
final TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
into(new Callback() {
@Override
public void onBitmapLoaded(String path, Bitmap bitmap) {
Log.d(TAG, "callback " + path + " called");
if (bitmap != null) {
Log.d(TAG, "bitmap " + path + " loaded");
Drawable drawable = drawables[1];
if (drawable != null && drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawables[1];
try {
Method method = BitmapDrawable.class.getDeclaredMethod("setBitmap", Bitmap.class);
method.setAccessible(true);
method.invoke(bitmapDrawable, bitmap);
Log.d(TAG, "bitmap " + path + " added to transition");
} catch (Exception e) {
e.printStackTrace();
}
}
transitionDrawable.startTransition(500);
Log.d(TAG, "image " + path + " transition started");
}
}
});
return transitionDrawable;
} | [
"public",
"Drawable",
"get",
"(",
")",
"{",
"final",
"Drawable",
"[",
"]",
"drawables",
"=",
"new",
"Drawable",
"[",
"]",
"{",
"mPlaceHolder",
",",
"new",
"BitmapDrawable",
"(",
"mContext",
".",
"getResources",
"(",
")",
",",
"Bitmap",
".",
"createBitmap",... | Load the bitmap into a TransitionDrawable
Starts the treatment, when loaded, execute a transition | [
"Load",
"the",
"bitmap",
"into",
"a",
"TransitionDrawable",
"Starts",
"the",
"treatment",
"when",
"loaded",
"execute",
"a",
"transition"
] | train | https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L269-L307 |
weld/core | impl/src/main/java/org/jboss/weld/util/Beans.java | Beans.getIdentifier | private static BeanIdentifier getIdentifier(Contextual<?> contextual, ContextualStore contextualStore, ServiceRegistry serviceRegistry) {
if (contextual instanceof RIBean<?>) {
return ((RIBean<?>) contextual).getIdentifier();
}
if (contextualStore == null) {
contextualStore = serviceRegistry.get(ContextualStore.class);
}
return contextualStore.putIfAbsent(contextual);
} | java | private static BeanIdentifier getIdentifier(Contextual<?> contextual, ContextualStore contextualStore, ServiceRegistry serviceRegistry) {
if (contextual instanceof RIBean<?>) {
return ((RIBean<?>) contextual).getIdentifier();
}
if (contextualStore == null) {
contextualStore = serviceRegistry.get(ContextualStore.class);
}
return contextualStore.putIfAbsent(contextual);
} | [
"private",
"static",
"BeanIdentifier",
"getIdentifier",
"(",
"Contextual",
"<",
"?",
">",
"contextual",
",",
"ContextualStore",
"contextualStore",
",",
"ServiceRegistry",
"serviceRegistry",
")",
"{",
"if",
"(",
"contextual",
"instanceof",
"RIBean",
"<",
"?",
">",
... | A slightly optimized way to get the bean identifier - there is not need to call ContextualStore.putIfAbsent() for passivation capable beans because it's
already called during bootstrap. See also {@link BeanManagerImpl#addBean(Bean)}.
@param contextual
@param contextualStore
@param serviceRegistry
@return the identifier for the given contextual | [
"A",
"slightly",
"optimized",
"way",
"to",
"get",
"the",
"bean",
"identifier",
"-",
"there",
"is",
"not",
"need",
"to",
"call",
"ContextualStore",
".",
"putIfAbsent",
"()",
"for",
"passivation",
"capable",
"beans",
"because",
"it",
"s",
"already",
"called",
... | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Beans.java#L687-L695 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/user/UserCoreDao.java | UserCoreDao.buildColumnsAs | public String[] buildColumnsAs(List<TColumn> columns, String[] values) {
String[] columnsArray = buildColumnsArray(columns);
return buildColumnsAs(columnsArray, values);
} | java | public String[] buildColumnsAs(List<TColumn> columns, String[] values) {
String[] columnsArray = buildColumnsArray(columns);
return buildColumnsAs(columnsArray, values);
} | [
"public",
"String",
"[",
"]",
"buildColumnsAs",
"(",
"List",
"<",
"TColumn",
">",
"columns",
",",
"String",
"[",
"]",
"values",
")",
"{",
"String",
"[",
"]",
"columnsArray",
"=",
"buildColumnsArray",
"(",
"columns",
")",
";",
"return",
"buildColumnsAs",
"(... | Build "columns as" values for the table columns with the specified
columns as the specified values
@param columns
columns to include as value
@param values
"columns as" values for specified columns
@return "columns as" values
@since 2.0.0 | [
"Build",
"columns",
"as",
"values",
"for",
"the",
"table",
"columns",
"with",
"the",
"specified",
"columns",
"as",
"the",
"specified",
"values"
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/user/UserCoreDao.java#L1605-L1610 |
aws/aws-sdk-java | aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/GetIdRequest.java | GetIdRequest.withLogins | public GetIdRequest withLogins(java.util.Map<String, String> logins) {
setLogins(logins);
return this;
} | java | public GetIdRequest withLogins(java.util.Map<String, String> logins) {
setLogins(logins);
return this;
} | [
"public",
"GetIdRequest",
"withLogins",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"logins",
")",
"{",
"setLogins",
"(",
"logins",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A set of optional name-value pairs that map provider names to provider tokens. The available provider names for
<code>Logins</code> are as follows:
</p>
<ul>
<li>
<p>
Facebook: <code>graph.facebook.com</code>
</p>
</li>
<li>
<p>
Amazon Cognito user pool: <code>cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID></code>, for
example, <code>cognito-idp.us-east-1.amazonaws.com/us-east-1_123456789</code>.
</p>
</li>
<li>
<p>
Google: <code>accounts.google.com</code>
</p>
</li>
<li>
<p>
Amazon: <code>www.amazon.com</code>
</p>
</li>
<li>
<p>
Twitter: <code>api.twitter.com</code>
</p>
</li>
<li>
<p>
Digits: <code>www.digits.com</code>
</p>
</li>
</ul>
@param logins
A set of optional name-value pairs that map provider names to provider tokens. The available provider
names for <code>Logins</code> are as follows:</p>
<ul>
<li>
<p>
Facebook: <code>graph.facebook.com</code>
</p>
</li>
<li>
<p>
Amazon Cognito user pool: <code>cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID></code>,
for example, <code>cognito-idp.us-east-1.amazonaws.com/us-east-1_123456789</code>.
</p>
</li>
<li>
<p>
Google: <code>accounts.google.com</code>
</p>
</li>
<li>
<p>
Amazon: <code>www.amazon.com</code>
</p>
</li>
<li>
<p>
Twitter: <code>api.twitter.com</code>
</p>
</li>
<li>
<p>
Digits: <code>www.digits.com</code>
</p>
</li>
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"set",
"of",
"optional",
"name",
"-",
"value",
"pairs",
"that",
"map",
"provider",
"names",
"to",
"provider",
"tokens",
".",
"The",
"available",
"provider",
"names",
"for",
"<code",
">",
"Logins<",
"/",
"code",
">",
"are",
"as",
"follows"... | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/GetIdRequest.java#L400-L403 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.deletePatternAnyEntityRole | public OperationStatus deletePatternAnyEntityRole(UUID appId, String versionId, UUID entityId, UUID roleId) {
return deletePatternAnyEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId).toBlocking().single().body();
} | java | public OperationStatus deletePatternAnyEntityRole(UUID appId, String versionId, UUID entityId, UUID roleId) {
return deletePatternAnyEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"deletePatternAnyEntityRole",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"UUID",
"roleId",
")",
"{",
"return",
"deletePatternAnyEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
... | Delete an entity role.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity ID.
@param roleId The entity role Id.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Delete",
"an",
"entity",
"role",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L13062-L13064 |
xvik/dropwizard-guicey | src/main/java/ru/vyarus/dropwizard/guice/module/installer/feature/jersey/AbstractJerseyInstaller.java | AbstractJerseyInstaller.isForceSingleton | protected boolean isForceSingleton(final Class<?> type, final boolean hkManaged) {
return ((Boolean) option(ForceSingletonForJerseyExtensions)) && !hasScopeAnnotation(type, hkManaged);
} | java | protected boolean isForceSingleton(final Class<?> type, final boolean hkManaged) {
return ((Boolean) option(ForceSingletonForJerseyExtensions)) && !hasScopeAnnotation(type, hkManaged);
} | [
"protected",
"boolean",
"isForceSingleton",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"boolean",
"hkManaged",
")",
"{",
"return",
"(",
"(",
"Boolean",
")",
"option",
"(",
"ForceSingletonForJerseyExtensions",
")",
")",
"&&",
"!",
"hasScopeAnno... | Singleton binding should not be forced if bean has explicit scope declaration.
@param type bean type
@param hkManaged true if bean is going to be managed by hk, false for guice management
@return true to force singleton bindings for hk extensions (resources, filters etc), false otherwise | [
"Singleton",
"binding",
"should",
"not",
"be",
"forced",
"if",
"bean",
"has",
"explicit",
"scope",
"declaration",
"."
] | train | https://github.com/xvik/dropwizard-guicey/blob/dd39ad77283555be21f606d5ebf0f11207a733d4/src/main/java/ru/vyarus/dropwizard/guice/module/installer/feature/jersey/AbstractJerseyInstaller.java#L80-L82 |
jblas-project/jblas | src/main/java/org/jblas/Singular.java | Singular.SVDValues | public static FloatMatrix SVDValues(ComplexFloatMatrix A) {
int m = A.rows;
int n = A.columns;
FloatMatrix S = new FloatMatrix(min(m, n));
float[] rwork = new float[5*min(m,n)];
int info = NativeBlas.cgesvd('N', 'N', m, n, A.dup().data, 0, m, S.data, 0, null, 0, 1, null, 0, min(m,n), rwork, 0);
if (info > 0) {
throw new LapackConvergenceException("GESVD", info + " superdiagonals of an intermediate bidiagonal form failed to converge.");
}
return S;
} | java | public static FloatMatrix SVDValues(ComplexFloatMatrix A) {
int m = A.rows;
int n = A.columns;
FloatMatrix S = new FloatMatrix(min(m, n));
float[] rwork = new float[5*min(m,n)];
int info = NativeBlas.cgesvd('N', 'N', m, n, A.dup().data, 0, m, S.data, 0, null, 0, 1, null, 0, min(m,n), rwork, 0);
if (info > 0) {
throw new LapackConvergenceException("GESVD", info + " superdiagonals of an intermediate bidiagonal form failed to converge.");
}
return S;
} | [
"public",
"static",
"FloatMatrix",
"SVDValues",
"(",
"ComplexFloatMatrix",
"A",
")",
"{",
"int",
"m",
"=",
"A",
".",
"rows",
";",
"int",
"n",
"=",
"A",
".",
"columns",
";",
"FloatMatrix",
"S",
"=",
"new",
"FloatMatrix",
"(",
"min",
"(",
"m",
",",
"n"... | Compute the singular values of a complex matrix.
@param A ComplexFloatMatrix of dimension m * n
@return A real-valued (!) min(m, n) vector of singular values. | [
"Compute",
"the",
"singular",
"values",
"of",
"a",
"complex",
"matrix",
"."
] | train | https://github.com/jblas-project/jblas/blob/2818f231228e655cda80dfd8e0b87709fdfd8a70/src/main/java/org/jblas/Singular.java#L283-L296 |
apereo/cas | core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/AbstractCasWebflowEventResolver.java | AbstractCasWebflowEventResolver.newEvent | protected Event newEvent(final String id, final Throwable error) {
return newEvent(id, new LocalAttributeMap(CasWebflowConstants.TRANSITION_ID_ERROR, error));
} | java | protected Event newEvent(final String id, final Throwable error) {
return newEvent(id, new LocalAttributeMap(CasWebflowConstants.TRANSITION_ID_ERROR, error));
} | [
"protected",
"Event",
"newEvent",
"(",
"final",
"String",
"id",
",",
"final",
"Throwable",
"error",
")",
"{",
"return",
"newEvent",
"(",
"id",
",",
"new",
"LocalAttributeMap",
"(",
"CasWebflowConstants",
".",
"TRANSITION_ID_ERROR",
",",
"error",
")",
")",
";",... | New event based on the id, which contains an error attribute referring to the exception occurred.
@param id the id
@param error the error
@return the event | [
"New",
"event",
"based",
"on",
"the",
"id",
"which",
"contains",
"an",
"error",
"attribute",
"referring",
"to",
"the",
"exception",
"occurred",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/AbstractCasWebflowEventResolver.java#L50-L52 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/RunsInner.java | RunsInner.beginCancelAsync | public Observable<Void> beginCancelAsync(String resourceGroupName, String registryName, String runId) {
return beginCancelWithServiceResponseAsync(resourceGroupName, registryName, runId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginCancelAsync(String resourceGroupName, String registryName, String runId) {
return beginCancelWithServiceResponseAsync(resourceGroupName, registryName, runId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginCancelAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"runId",
")",
"{",
"return",
"beginCancelWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"run... | Cancel an existing run.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param runId The run ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Cancel",
"an",
"existing",
"run",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/RunsInner.java#L978-L985 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/nephele/jobgraph/AbstractJobVertex.java | AbstractJobVertex.connectTo | public void connectTo(final AbstractJobVertex vertex, final ChannelType channelType) throws JobGraphDefinitionException {
this.connectTo(vertex, channelType, -1, -1, DistributionPattern.BIPARTITE);
} | java | public void connectTo(final AbstractJobVertex vertex, final ChannelType channelType) throws JobGraphDefinitionException {
this.connectTo(vertex, channelType, -1, -1, DistributionPattern.BIPARTITE);
} | [
"public",
"void",
"connectTo",
"(",
"final",
"AbstractJobVertex",
"vertex",
",",
"final",
"ChannelType",
"channelType",
")",
"throws",
"JobGraphDefinitionException",
"{",
"this",
".",
"connectTo",
"(",
"vertex",
",",
"channelType",
",",
"-",
"1",
",",
"-",
"1",
... | Connects the job vertex to the specified job vertex.
@param vertex
the vertex this vertex should connect to
@param channelType
the channel type the two vertices should be connected by at runtime
@param compressionLevel
the compression level the corresponding channel should have at runtime
@throws JobGraphDefinitionException
thrown if the given vertex cannot be connected to <code>vertex</code> in the requested manner | [
"Connects",
"the",
"job",
"vertex",
"to",
"the",
"specified",
"job",
"vertex",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/jobgraph/AbstractJobVertex.java#L158-L160 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/WebReporter.java | WebReporter.queueReport | public void queueReport(WebTarget target, Entity entity) {
queue.add(Pair.makePair(target, entity));
} | java | public void queueReport(WebTarget target, Entity entity) {
queue.add(Pair.makePair(target, entity));
} | [
"public",
"void",
"queueReport",
"(",
"WebTarget",
"target",
",",
"Entity",
"entity",
")",
"{",
"queue",
".",
"add",
"(",
"Pair",
".",
"makePair",
"(",
"target",
",",
"entity",
")",
")",
";",
"}"
] | This method queues UI report for sending
@param target
@param entity | [
"This",
"method",
"queues",
"UI",
"report",
"for",
"sending"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/WebReporter.java#L58-L60 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/GeoBackupPoliciesInner.java | GeoBackupPoliciesInner.createOrUpdateAsync | public Observable<GeoBackupPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, GeoBackupPolicyState state) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, state).map(new Func1<ServiceResponse<GeoBackupPolicyInner>, GeoBackupPolicyInner>() {
@Override
public GeoBackupPolicyInner call(ServiceResponse<GeoBackupPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<GeoBackupPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, GeoBackupPolicyState state) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, state).map(new Func1<ServiceResponse<GeoBackupPolicyInner>, GeoBackupPolicyInner>() {
@Override
public GeoBackupPolicyInner call(ServiceResponse<GeoBackupPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"GeoBackupPolicyInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"GeoBackupPolicyState",
"state",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync... | Updates a database geo backup policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param state The state of the geo backup policy. Possible values include: 'Disabled', 'Enabled'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the GeoBackupPolicyInner object | [
"Updates",
"a",
"database",
"geo",
"backup",
"policy",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/GeoBackupPoliciesInner.java#L113-L120 |
wildfly-swarm-archive/ARCHIVE-wildfly-swarm | logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java | LoggingFraction.customFormatter | public LoggingFraction customFormatter(String name, String module, String className, Properties properties) {
Map<Object, Object> formatterProperties = new HashMap<>();
final Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
final String nextElement = (String) names.nextElement();
formatterProperties.put(nextElement, properties.getProperty(nextElement));
}
customFormatter(new CustomFormatter(name)
.module(module)
.attributeClass(className)
.properties(formatterProperties));
return this;
} | java | public LoggingFraction customFormatter(String name, String module, String className, Properties properties) {
Map<Object, Object> formatterProperties = new HashMap<>();
final Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
final String nextElement = (String) names.nextElement();
formatterProperties.put(nextElement, properties.getProperty(nextElement));
}
customFormatter(new CustomFormatter(name)
.module(module)
.attributeClass(className)
.properties(formatterProperties));
return this;
} | [
"public",
"LoggingFraction",
"customFormatter",
"(",
"String",
"name",
",",
"String",
"module",
",",
"String",
"className",
",",
"Properties",
"properties",
")",
"{",
"Map",
"<",
"Object",
",",
"Object",
">",
"formatterProperties",
"=",
"new",
"HashMap",
"<>",
... | Add a CustomFormatter to this logger
@param name the name of the formatter
@param module the module that the logging handler depends on
@param className the logging handler class to be used
@param properties the properties
@return this fraction | [
"Add",
"a",
"CustomFormatter",
"to",
"this",
"logger"
] | train | https://github.com/wildfly-swarm-archive/ARCHIVE-wildfly-swarm/blob/28ef71bcfa743a7267666e0ed2919c37b356c09b/logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java#L153-L165 |
looly/hutool | hutool-setting/src/main/java/cn/hutool/setting/Setting.java | Setting.init | public boolean init(Resource resource, Charset charset, boolean isUseVariable) {
if (resource == null) {
throw new NullPointerException("Null setting url define!");
}
this.settingUrl = resource.getUrl();
this.charset = charset;
this.isUseVariable = isUseVariable;
return load();
} | java | public boolean init(Resource resource, Charset charset, boolean isUseVariable) {
if (resource == null) {
throw new NullPointerException("Null setting url define!");
}
this.settingUrl = resource.getUrl();
this.charset = charset;
this.isUseVariable = isUseVariable;
return load();
} | [
"public",
"boolean",
"init",
"(",
"Resource",
"resource",
",",
"Charset",
"charset",
",",
"boolean",
"isUseVariable",
")",
"{",
"if",
"(",
"resource",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Null setting url define!\"",
")",
";",
... | 初始化设定文件
@param resource {@link Resource}
@param charset 字符集
@param isUseVariable 是否使用变量
@return 成功初始化与否 | [
"初始化设定文件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/Setting.java#L152-L161 |
iorga-group/iraj | iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java | CacheAwareServlet.checkIfHeaders | protected boolean checkIfHeaders(final HttpServletRequest request, final HttpServletResponse response,
final Attributes resourceAttributes) throws IOException {
return checkIfMatch(request, response, resourceAttributes)
&& checkIfModifiedSince(request, response, resourceAttributes)
&& checkIfNoneMatch(request, response, resourceAttributes)
&& checkIfUnmodifiedSince(request, response, resourceAttributes);
} | java | protected boolean checkIfHeaders(final HttpServletRequest request, final HttpServletResponse response,
final Attributes resourceAttributes) throws IOException {
return checkIfMatch(request, response, resourceAttributes)
&& checkIfModifiedSince(request, response, resourceAttributes)
&& checkIfNoneMatch(request, response, resourceAttributes)
&& checkIfUnmodifiedSince(request, response, resourceAttributes);
} | [
"protected",
"boolean",
"checkIfHeaders",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"throws",
"IOException",
"{",
"return",
"checkIfMatch",
"(",
"request",
",",
... | Check if the conditions specified in the optional If headers are
satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
The resource information
@return boolean true if the resource meets all the specified conditions,
and false if any of the conditions is not satisfied, in which
case request processing is stopped | [
"Check",
"if",
"the",
"conditions",
"specified",
"in",
"the",
"optional",
"If",
"headers",
"are",
"satisfied",
"."
] | train | https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L636-L643 |
landawn/AbacusUtil | src/com/landawn/abacus/util/JdbcUtil.java | JdbcUtil.importData | public static <E extends Exception> long importData(final InputStream is, final long offset, final long count, final PreparedStatement stmt,
final int batchSize, final int batchInterval, final Try.Function<String, Object[], E> func) throws UncheckedSQLException, E {
final Reader reader = new InputStreamReader(is);
return importData(reader, offset, count, stmt, batchSize, batchInterval, func);
} | java | public static <E extends Exception> long importData(final InputStream is, final long offset, final long count, final PreparedStatement stmt,
final int batchSize, final int batchInterval, final Try.Function<String, Object[], E> func) throws UncheckedSQLException, E {
final Reader reader = new InputStreamReader(is);
return importData(reader, offset, count, stmt, batchSize, batchInterval, func);
} | [
"public",
"static",
"<",
"E",
"extends",
"Exception",
">",
"long",
"importData",
"(",
"final",
"InputStream",
"is",
",",
"final",
"long",
"offset",
",",
"final",
"long",
"count",
",",
"final",
"PreparedStatement",
"stmt",
",",
"final",
"int",
"batchSize",
",... | Imports the data from file to database.
@param is
@param offset
@param count
@param stmt
@param batchSize
@param batchInterval
@param func convert line to the parameters for record insert. Returns a <code>null</code> array to skip the line.
@return
@throws UncheckedSQLException | [
"Imports",
"the",
"data",
"from",
"file",
"to",
"database",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/JdbcUtil.java#L2586-L2591 |
xm-online/xm-commons | xm-commons-tenant/src/main/java/com/icthh/xm/commons/tenant/TenantContextUtils.java | TenantContextUtils.setTenant | public static void setTenant(TenantContextHolder holder, TenantKey tenantKey) {
holder.getPrivilegedContext().setTenant(buildTenant(tenantKey));
} | java | public static void setTenant(TenantContextHolder holder, TenantKey tenantKey) {
holder.getPrivilegedContext().setTenant(buildTenant(tenantKey));
} | [
"public",
"static",
"void",
"setTenant",
"(",
"TenantContextHolder",
"holder",
",",
"TenantKey",
"tenantKey",
")",
"{",
"holder",
".",
"getPrivilegedContext",
"(",
")",
".",
"setTenant",
"(",
"buildTenant",
"(",
"tenantKey",
")",
")",
";",
"}"
] | Sets current thread tenant.
@param holder tenant contexts holder
@param tenantKey tenant key | [
"Sets",
"current",
"thread",
"tenant",
"."
] | train | https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-tenant/src/main/java/com/icthh/xm/commons/tenant/TenantContextUtils.java#L77-L79 |
fuinorg/utils4j | src/main/java/org/fuin/utils4j/Utils4J.java | Utils4J.getBackToRootPath | public static String getBackToRootPath(final String relativePath, final char fileSeparatorChar) {
checkNotNull("relativePath", relativePath);
final StringBuilder sb = new StringBuilder();
boolean firstChar = true;
for (int i = 0; i < relativePath.length(); i++) {
final char ch = relativePath.charAt(i);
if (ch == fileSeparatorChar) {
sb.append(ch);
firstChar = true;
} else if (firstChar) {
sb.append("..");
firstChar = false;
}
}
return sb.toString();
} | java | public static String getBackToRootPath(final String relativePath, final char fileSeparatorChar) {
checkNotNull("relativePath", relativePath);
final StringBuilder sb = new StringBuilder();
boolean firstChar = true;
for (int i = 0; i < relativePath.length(); i++) {
final char ch = relativePath.charAt(i);
if (ch == fileSeparatorChar) {
sb.append(ch);
firstChar = true;
} else if (firstChar) {
sb.append("..");
firstChar = false;
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"getBackToRootPath",
"(",
"final",
"String",
"relativePath",
",",
"final",
"char",
"fileSeparatorChar",
")",
"{",
"checkNotNull",
"(",
"\"relativePath\"",
",",
"relativePath",
")",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"Str... | Replaces all directory names in a relative path with "..".<br>
<br>
Examples:<br>
"a/b/c" => "../../.."<br>
"my-dir" => ".."<br>
"my-dir/other/" => "../../".<br>
@param relativePath
Relative path to convert - Expected to be a directory and NOT a file - Cannot be NULL.
@param fileSeparatorChar
See {@link File#separatorChar}.
@return Relative path with ".." (dot dot) | [
"Replaces",
"all",
"directory",
"names",
"in",
"a",
"relative",
"path",
"with",
"..",
".",
"<br",
">",
"<br",
">",
"Examples",
":",
"<br",
">",
"a",
"/",
"b",
"/",
"c",
"=",
">",
";",
"..",
"/",
"..",
"/",
"..",
"<br",
">",
"my",
"-",
"dir",
... | train | https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L597-L614 |
samskivert/pythagoras | src/main/java/pythagoras/d/Matrix3.java | Matrix3.setToTransform | public Matrix3 setToTransform (IVector translation, double rotation, double scale) {
return setToRotation(rotation).set(m00 * scale, m10 * scale, translation.x(),
m01 * scale, m11 * scale, translation.y(),
0f, 0f, 1f);
} | java | public Matrix3 setToTransform (IVector translation, double rotation, double scale) {
return setToRotation(rotation).set(m00 * scale, m10 * scale, translation.x(),
m01 * scale, m11 * scale, translation.y(),
0f, 0f, 1f);
} | [
"public",
"Matrix3",
"setToTransform",
"(",
"IVector",
"translation",
",",
"double",
"rotation",
",",
"double",
"scale",
")",
"{",
"return",
"setToRotation",
"(",
"rotation",
")",
".",
"set",
"(",
"m00",
"*",
"scale",
",",
"m10",
"*",
"scale",
",",
"transl... | 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#L265-L269 |
biojava/biojava | biojava-structure/src/main/java/demo/DemoMMCIFReader.java | DemoMMCIFReader.loadFromDirectAccess | public void loadFromDirectAccess(){
String pdbId = "1A4W";
StructureProvider pdbreader = new MMCIFFileReader();
try {
Structure s = pdbreader.getStructureById(pdbId);
System.out.println("Getting chain H of 1A4W");
List<Chain> hs = s.getNonPolyChainsByPDB("H");
Chain h = hs.get(0);
List<Group> ligands = h.getAtomGroups();
System.out.println("These ligands have been found in chain " + h.getName());
for (Group l:ligands){
System.out.println(l);
}
System.out.println("Accessing QWE directly: ");
Group qwe = s.getNonPolyChainsByPDB("H").get(2).getGroupByPDB(new ResidueNumber("H",373,null));
System.out.println(qwe.getChemComp());
System.out.println(h.getSeqResSequence());
System.out.println(h.getAtomSequence());
System.out.println(h.getAtomGroups(GroupType.HETATM));
System.out.println("Entities: " + s.getEntityInfos());
} catch (Exception e) {
e.printStackTrace();
}
} | java | public void loadFromDirectAccess(){
String pdbId = "1A4W";
StructureProvider pdbreader = new MMCIFFileReader();
try {
Structure s = pdbreader.getStructureById(pdbId);
System.out.println("Getting chain H of 1A4W");
List<Chain> hs = s.getNonPolyChainsByPDB("H");
Chain h = hs.get(0);
List<Group> ligands = h.getAtomGroups();
System.out.println("These ligands have been found in chain " + h.getName());
for (Group l:ligands){
System.out.println(l);
}
System.out.println("Accessing QWE directly: ");
Group qwe = s.getNonPolyChainsByPDB("H").get(2).getGroupByPDB(new ResidueNumber("H",373,null));
System.out.println(qwe.getChemComp());
System.out.println(h.getSeqResSequence());
System.out.println(h.getAtomSequence());
System.out.println(h.getAtomGroups(GroupType.HETATM));
System.out.println("Entities: " + s.getEntityInfos());
} catch (Exception e) {
e.printStackTrace();
}
} | [
"public",
"void",
"loadFromDirectAccess",
"(",
")",
"{",
"String",
"pdbId",
"=",
"\"1A4W\"",
";",
"StructureProvider",
"pdbreader",
"=",
"new",
"MMCIFFileReader",
"(",
")",
";",
"try",
"{",
"Structure",
"s",
"=",
"pdbreader",
".",
"getStructureById",
"(",
"pdb... | An example demonstrating how to directly use the mmCif file parsing classes. This could potentially be used
to use the parser to populate a data-structure that is different from the biojava-structure data model. | [
"An",
"example",
"demonstrating",
"how",
"to",
"directly",
"use",
"the",
"mmCif",
"file",
"parsing",
"classes",
".",
"This",
"could",
"potentially",
"be",
"used",
"to",
"use",
"the",
"parser",
"to",
"populate",
"a",
"data",
"-",
"structure",
"that",
"is",
... | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/demo/DemoMMCIFReader.java#L80-L117 |
Whiley/WhileyCompiler | src/main/java/wyil/type/subtyping/SubtypeOperator.java | SubtypeOperator.isSubtype | public boolean isSubtype(SemanticType lhs, SemanticType rhs, LifetimeRelation lifetimes) {
boolean max = emptinessTest.isVoid(lhs, EmptinessTest.NegativeMax, rhs, EmptinessTest.PositiveMax, lifetimes);
//
// FIXME: I don't think this logic is correct yet for some reason.
if (!max) {
return false;
} else {
boolean min = emptinessTest.isVoid(lhs, EmptinessTest.NegativeMin, rhs, EmptinessTest.PositiveMin,
lifetimes);
if (min) {
return true;
} else {
return false;
}
}
} | java | public boolean isSubtype(SemanticType lhs, SemanticType rhs, LifetimeRelation lifetimes) {
boolean max = emptinessTest.isVoid(lhs, EmptinessTest.NegativeMax, rhs, EmptinessTest.PositiveMax, lifetimes);
//
// FIXME: I don't think this logic is correct yet for some reason.
if (!max) {
return false;
} else {
boolean min = emptinessTest.isVoid(lhs, EmptinessTest.NegativeMin, rhs, EmptinessTest.PositiveMin,
lifetimes);
if (min) {
return true;
} else {
return false;
}
}
} | [
"public",
"boolean",
"isSubtype",
"(",
"SemanticType",
"lhs",
",",
"SemanticType",
"rhs",
",",
"LifetimeRelation",
"lifetimes",
")",
"{",
"boolean",
"max",
"=",
"emptinessTest",
".",
"isVoid",
"(",
"lhs",
",",
"EmptinessTest",
".",
"NegativeMax",
",",
"rhs",
"... | <p>
Determine whether the <code>rhs</code> type is a <i>subtype</i> of the
<code>lhs</code> (denoted <code>lhs :> rhs</code>). In the presence of type
invariants, this operation is undecidable. Therefore, a <i>three-valued</i>
logic is employed. Either it was concluded that the subtype relation
<i>definitely holds</i>, or that it <i>definitely does not hold</i> that it
is <i>unknown</i> whether it holds or not.
</p>
<p>
For example, <code>int|null :> int</code> definitely holds. Likewise,
<code>int :> int|null</code> definitely does not hold. However, whether or
not <code>nat :> pos</code> holds depends on the type invariants given for
<code>nat</code> and <code>pos</code> which this operator cannot reason
about. Observe that, in some cases, we do get effective reasoning about types
with invariants. For example, <code>null|nat :> nat</code> will be determined
to definitely hold, despite the fact that <code>nat</code> has a type
invariant.
</p>
<p>
Depending on the exact language of types involved, this can be a surprisingly
complex operation. For example, in the presence of <i>union</i>,
<i>intersection</i> and <i>negation</i> types, the subtype algorithm is
surprisingly intricate.
</p>
@param lhs
The candidate "supertype". That is, lhs's raw type may be a
supertype of <code>rhs</code>'s raw type.
@param rhs
The candidate "subtype". That is, rhs's raw type may be a subtype
of <code>lhs</code>'s raw type.
@param lifetimes
The within relation between lifetimes that should be used when
determine whether the <code>rhs</code> is a subtype of the
<code>lhs</code>.
@return
@throws ResolutionError
Occurs when a nominal type is encountered whose name cannot be
resolved properly. For example, it resolves to more than one
possible matching declaration, or it cannot be resolved to a
corresponding type declaration. | [
"<p",
">",
"Determine",
"whether",
"the",
"<code",
">",
"rhs<",
"/",
"code",
">",
"type",
"is",
"a",
"<i",
">",
"subtype<",
"/",
"i",
">",
"of",
"the",
"<code",
">",
"lhs<",
"/",
"code",
">",
"(",
"denoted",
"<code",
">",
"lhs",
":",
">",
"rhs<",... | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/type/subtyping/SubtypeOperator.java#L93-L108 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkInterfaceTapConfigurationsInner.java | NetworkInterfaceTapConfigurationsInner.beginCreateOrUpdateAsync | public Observable<NetworkInterfaceTapConfigurationInner> beginCreateOrUpdateAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName, NetworkInterfaceTapConfigurationInner tapConfigurationParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkInterfaceTapConfigurationInner> beginCreateOrUpdateAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName, NetworkInterfaceTapConfigurationInner tapConfigurationParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkInterfaceTapConfigurationInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
",",
"String",
"tapConfigurationName",
",",
"NetworkInterfaceTapConfigurationInner",
"tapConfigurationPa... | Creates or updates a Tap configuration in the specified NetworkInterface.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param tapConfigurationName The name of the tap configuration.
@param tapConfigurationParameters Parameters supplied to the create or update tap configuration operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceTapConfigurationInner object | [
"Creates",
"or",
"updates",
"a",
"Tap",
"configuration",
"in",
"the",
"specified",
"NetworkInterface",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkInterfaceTapConfigurationsInner.java#L473-L480 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/time/SntpClient.java | SntpClient.read32 | private long read32(byte[] buffer, int offset) {
byte b0 = buffer[offset];
byte b1 = buffer[offset + 1];
byte b2 = buffer[offset + 2];
byte b3 = buffer[offset + 3];
// convert signed bytes to unsigned values
int i0 = ((b0 & 0x80) == 0x80 ? (b0 & 0x7F) + 0x80 : b0);
int i1 = ((b1 & 0x80) == 0x80 ? (b1 & 0x7F) + 0x80 : b1);
int i2 = ((b2 & 0x80) == 0x80 ? (b2 & 0x7F) + 0x80 : b2);
int i3 = ((b3 & 0x80) == 0x80 ? (b3 & 0x7F) + 0x80 : b3);
return ((long) i0 << 24) + ((long) i1 << 16) + ((long) i2 << 8) + (long) i3;
} | java | private long read32(byte[] buffer, int offset) {
byte b0 = buffer[offset];
byte b1 = buffer[offset + 1];
byte b2 = buffer[offset + 2];
byte b3 = buffer[offset + 3];
// convert signed bytes to unsigned values
int i0 = ((b0 & 0x80) == 0x80 ? (b0 & 0x7F) + 0x80 : b0);
int i1 = ((b1 & 0x80) == 0x80 ? (b1 & 0x7F) + 0x80 : b1);
int i2 = ((b2 & 0x80) == 0x80 ? (b2 & 0x7F) + 0x80 : b2);
int i3 = ((b3 & 0x80) == 0x80 ? (b3 & 0x7F) + 0x80 : b3);
return ((long) i0 << 24) + ((long) i1 << 16) + ((long) i2 << 8) + (long) i3;
} | [
"private",
"long",
"read32",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"byte",
"b0",
"=",
"buffer",
"[",
"offset",
"]",
";",
"byte",
"b1",
"=",
"buffer",
"[",
"offset",
"+",
"1",
"]",
";",
"byte",
"b2",
"=",
"buffer",
"[",
... | Reads an unsigned 32 bit big endian number from the given offset in the buffer. | [
"Reads",
"an",
"unsigned",
"32",
"bit",
"big",
"endian",
"number",
"from",
"the",
"given",
"offset",
"in",
"the",
"buffer",
"."
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/time/SntpClient.java#L167-L180 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java | VirtualMachinesInner.instanceViewAsync | public Observable<VirtualMachineInstanceViewInner> instanceViewAsync(String resourceGroupName, String vmName) {
return instanceViewWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<VirtualMachineInstanceViewInner>, VirtualMachineInstanceViewInner>() {
@Override
public VirtualMachineInstanceViewInner call(ServiceResponse<VirtualMachineInstanceViewInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualMachineInstanceViewInner> instanceViewAsync(String resourceGroupName, String vmName) {
return instanceViewWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<VirtualMachineInstanceViewInner>, VirtualMachineInstanceViewInner>() {
@Override
public VirtualMachineInstanceViewInner call(ServiceResponse<VirtualMachineInstanceViewInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualMachineInstanceViewInner",
">",
"instanceViewAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
")",
"{",
"return",
"instanceViewWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
")",
".",
"map",
"... | Retrieves information about the run-time state of a virtual machine.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualMachineInstanceViewInner object | [
"Retrieves",
"information",
"about",
"the",
"run",
"-",
"time",
"state",
"of",
"a",
"virtual",
"machine",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java#L1073-L1080 |
JOML-CI/JOML | src/org/joml/Intersectionf.java | Intersectionf.intersectRayPlane | public static float intersectRayPlane(Rayf ray, Planef plane, float epsilon) {
return intersectRayPlane(ray.oX, ray.oY, ray.oZ, ray.dX, ray.dY, ray.dZ, plane.a, plane.b, plane.c, plane.d, epsilon);
} | java | public static float intersectRayPlane(Rayf ray, Planef plane, float epsilon) {
return intersectRayPlane(ray.oX, ray.oY, ray.oZ, ray.dX, ray.dY, ray.dZ, plane.a, plane.b, plane.c, plane.d, epsilon);
} | [
"public",
"static",
"float",
"intersectRayPlane",
"(",
"Rayf",
"ray",
",",
"Planef",
"plane",
",",
"float",
"epsilon",
")",
"{",
"return",
"intersectRayPlane",
"(",
"ray",
".",
"oX",
",",
"ray",
".",
"oY",
",",
"ray",
".",
"oZ",
",",
"ray",
".",
"dX",
... | Test whether the given ray intersects the given plane, and return the
value of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the intersection point.
<p>
This method returns <code>-1.0</code> if the ray does not intersect the plane, because it is either parallel to the plane or its direction points
away from the plane or the ray's origin is on the <i>negative</i> side of the plane (i.e. the plane's normal points away from the ray's origin).
<p>
Reference: <a href="https://www.siggraph.org/education/materials/HyperGraph/raytrace/rayplane_intersection.htm">https://www.siggraph.org/</a>
@param ray
the ray
@param plane
the plane
@param epsilon
some small epsilon for when the ray is parallel to the plane
@return the value of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the intersection point, if the ray
intersects the plane; <code>-1.0</code> otherwise | [
"Test",
"whether",
"the",
"given",
"ray",
"intersects",
"the",
"given",
"plane",
"and",
"return",
"the",
"value",
"of",
"the",
"parameter",
"<i",
">",
"t<",
"/",
"i",
">",
"in",
"the",
"ray",
"equation",
"<i",
">",
"p",
"(",
"t",
")",
"=",
"origin",
... | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Intersectionf.java#L1106-L1108 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/terminal/swing/SwingTerminalFontConfiguration.java | SwingTerminalFontConfiguration.newInstance | @SuppressWarnings("WeakerAccess")
public static SwingTerminalFontConfiguration newInstance(Font... fontsInOrderOfPriority) {
return new SwingTerminalFontConfiguration(true, BoldMode.EVERYTHING_BUT_SYMBOLS, fontsInOrderOfPriority);
} | java | @SuppressWarnings("WeakerAccess")
public static SwingTerminalFontConfiguration newInstance(Font... fontsInOrderOfPriority) {
return new SwingTerminalFontConfiguration(true, BoldMode.EVERYTHING_BUT_SYMBOLS, fontsInOrderOfPriority);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"static",
"SwingTerminalFontConfiguration",
"newInstance",
"(",
"Font",
"...",
"fontsInOrderOfPriority",
")",
"{",
"return",
"new",
"SwingTerminalFontConfiguration",
"(",
"true",
",",
"BoldMode",
".",
"EVE... | Creates a new font configuration from a list of fonts in order of priority. This works by having the terminal
attempt to draw each character with the fonts in the order they are specified in and stop once we find a font
that can actually draw the character. For ASCII characters, it's very likely that the first font will always be
used.
@param fontsInOrderOfPriority Fonts to use when drawing text, in order of priority
@return Font configuration built from the font list | [
"Creates",
"a",
"new",
"font",
"configuration",
"from",
"a",
"list",
"of",
"fonts",
"in",
"order",
"of",
"priority",
".",
"This",
"works",
"by",
"having",
"the",
"terminal",
"attempt",
"to",
"draw",
"each",
"character",
"with",
"the",
"fonts",
"in",
"the",... | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/SwingTerminalFontConfiguration.java#L43-L46 |
OpenNMS/newts | cassandra/search/src/main/java/org/opennms/newts/cassandra/search/CassandraResourceTreeWalker.java | CassandraResourceTreeWalker.breadthFirstSearch | public void breadthFirstSearch(Context context, SearchResultVisitor visitor, Resource root) {
Queue<Resource> queue = Lists.newLinkedList();
queue.add(root);
while (!queue.isEmpty()) {
Resource r = queue.remove();
for (SearchResults.Result result : m_searcher
.search(context, matchKeyAndValue(Constants.PARENT_TERM_FIELD, r.getId()))) {
if (!visitor.visit(result)) {
return;
}
queue.add(result.getResource());
}
}
} | java | public void breadthFirstSearch(Context context, SearchResultVisitor visitor, Resource root) {
Queue<Resource> queue = Lists.newLinkedList();
queue.add(root);
while (!queue.isEmpty()) {
Resource r = queue.remove();
for (SearchResults.Result result : m_searcher
.search(context, matchKeyAndValue(Constants.PARENT_TERM_FIELD, r.getId()))) {
if (!visitor.visit(result)) {
return;
}
queue.add(result.getResource());
}
}
} | [
"public",
"void",
"breadthFirstSearch",
"(",
"Context",
"context",
",",
"SearchResultVisitor",
"visitor",
",",
"Resource",
"root",
")",
"{",
"Queue",
"<",
"Resource",
">",
"queue",
"=",
"Lists",
".",
"newLinkedList",
"(",
")",
";",
"queue",
".",
"add",
"(",
... | Visits all nodes in the resource tree bellow the given resource using
breadth-first search. | [
"Visits",
"all",
"nodes",
"in",
"the",
"resource",
"tree",
"bellow",
"the",
"given",
"resource",
"using",
"breadth",
"-",
"first",
"search",
"."
] | train | https://github.com/OpenNMS/newts/blob/e1b53169d8a7fbc5e9fb826da08d602f628063ea/cassandra/search/src/main/java/org/opennms/newts/cassandra/search/CassandraResourceTreeWalker.java#L74-L87 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java | CmsDefaultXmlContentHandler.initSettings | protected void initSettings(Element root, CmsXmlContentDefinition contentDefinition) {
Iterator<Element> itProperties = CmsXmlGenericWrapper.elementIterator(root, APPINFO_SETTING);
while (itProperties.hasNext()) {
Element element = itProperties.next();
CmsXmlContentProperty setting = new CmsXmlContentProperty(
element.attributeValue(APPINFO_ATTR_NAME),
element.attributeValue(APPINFO_ATTR_TYPE),
element.attributeValue(APPINFO_ATTR_WIDGET),
element.attributeValue(APPINFO_ATTR_WIDGET_CONFIG),
element.attributeValue(APPINFO_ATTR_RULE_REGEX),
element.attributeValue(APPINFO_ATTR_RULE_TYPE),
element.attributeValue(APPINFO_ATTR_DEFAULT),
element.attributeValue(APPINFO_ATTR_NICE_NAME),
element.attributeValue(APPINFO_ATTR_DESCRIPTION),
element.attributeValue(APPINFO_ATTR_ERROR),
element.attributeValue(APPINFO_ATTR_PREFERFOLDER));
String name = setting.getName();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) {
m_settings.put(name, setting);
}
}
} | java | protected void initSettings(Element root, CmsXmlContentDefinition contentDefinition) {
Iterator<Element> itProperties = CmsXmlGenericWrapper.elementIterator(root, APPINFO_SETTING);
while (itProperties.hasNext()) {
Element element = itProperties.next();
CmsXmlContentProperty setting = new CmsXmlContentProperty(
element.attributeValue(APPINFO_ATTR_NAME),
element.attributeValue(APPINFO_ATTR_TYPE),
element.attributeValue(APPINFO_ATTR_WIDGET),
element.attributeValue(APPINFO_ATTR_WIDGET_CONFIG),
element.attributeValue(APPINFO_ATTR_RULE_REGEX),
element.attributeValue(APPINFO_ATTR_RULE_TYPE),
element.attributeValue(APPINFO_ATTR_DEFAULT),
element.attributeValue(APPINFO_ATTR_NICE_NAME),
element.attributeValue(APPINFO_ATTR_DESCRIPTION),
element.attributeValue(APPINFO_ATTR_ERROR),
element.attributeValue(APPINFO_ATTR_PREFERFOLDER));
String name = setting.getName();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) {
m_settings.put(name, setting);
}
}
} | [
"protected",
"void",
"initSettings",
"(",
"Element",
"root",
",",
"CmsXmlContentDefinition",
"contentDefinition",
")",
"{",
"Iterator",
"<",
"Element",
">",
"itProperties",
"=",
"CmsXmlGenericWrapper",
".",
"elementIterator",
"(",
"root",
",",
"APPINFO_SETTING",
")",
... | Initializes the element settings for this content handler.<p>
@param root the "settings" element from the appinfo node of the XML content definition
@param contentDefinition the content definition the element settings belong to | [
"Initializes",
"the",
"element",
"settings",
"for",
"this",
"content",
"handler",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java#L3071-L3093 |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/logging/Logger.java | Logger.logInfo | public final void logInfo(@NonNull final Class<?> tag, @NonNull final String message) {
Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null");
Condition.INSTANCE.ensureNotNull(message, "The message may not be null");
Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty");
if (LogLevel.INFO.getRank() >= getLogLevel().getRank()) {
Log.i(ClassUtil.INSTANCE.getTruncatedName(tag), message);
}
} | java | public final void logInfo(@NonNull final Class<?> tag, @NonNull final String message) {
Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null");
Condition.INSTANCE.ensureNotNull(message, "The message may not be null");
Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty");
if (LogLevel.INFO.getRank() >= getLogLevel().getRank()) {
Log.i(ClassUtil.INSTANCE.getTruncatedName(tag), message);
}
} | [
"public",
"final",
"void",
"logInfo",
"(",
"@",
"NonNull",
"final",
"Class",
"<",
"?",
">",
"tag",
",",
"@",
"NonNull",
"final",
"String",
"message",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"tag",
",",
"\"The tag may not be null\""... | Logs a specific message on the log level INFO.
@param tag
The tag, which identifies the source of the log message, as an instance of the class
{@link Class}. The tag may not be null
@param message
The message, which should be logged, as a {@link String}. The message may neither be
null, nor empty | [
"Logs",
"a",
"specific",
"message",
"on",
"the",
"log",
"level",
"INFO",
"."
] | train | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L172-L180 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsoleFactory.java | GVRConsoleFactory.createTelnetConsoleShell | static Shell createTelnetConsoleShell(String prompt, String appName,
ShellCommandHandler mainHandler, InputStream input, OutputStream output) {
try {
// Set up nvt4j; ignore the initial clear & reposition
final nvt4j.impl.Terminal nvt4jTerminal = new nvt4j.impl.Terminal(input, output) {
private boolean cleared;
private boolean moved;
@Override
public void clear() throws IOException {
if (this.cleared)
super.clear();
this.cleared = true;
}
@Override
public void move(int row, int col) throws IOException {
if (this.moved)
super.move(row, col);
this.moved = true;
}
};
nvt4jTerminal.put(nvt4j.impl.Terminal.AUTO_WRAP_ON);
nvt4jTerminal.setCursor(true);
// Have JLine do input & output through telnet terminal
final InputStream jlineInput = new InputStream() {
@Override
public int read() throws IOException {
return nvt4jTerminal.get();
}
};
final OutputStream jlineOutput = new OutputStream() {
@Override
public void write(int value) throws IOException {
nvt4jTerminal.put(value);
}
};
return createTerminalConsoleShell(prompt, appName, mainHandler, jlineInput, jlineOutput);
} catch (Exception e) {
// Failover: use default shell
BufferedReader in = new BufferedReader(new InputStreamReader(input));
PrintStream out = new PrintStream(output);
return createConsoleShell(prompt, appName, mainHandler, in, out, out, null);
}
} | java | static Shell createTelnetConsoleShell(String prompt, String appName,
ShellCommandHandler mainHandler, InputStream input, OutputStream output) {
try {
// Set up nvt4j; ignore the initial clear & reposition
final nvt4j.impl.Terminal nvt4jTerminal = new nvt4j.impl.Terminal(input, output) {
private boolean cleared;
private boolean moved;
@Override
public void clear() throws IOException {
if (this.cleared)
super.clear();
this.cleared = true;
}
@Override
public void move(int row, int col) throws IOException {
if (this.moved)
super.move(row, col);
this.moved = true;
}
};
nvt4jTerminal.put(nvt4j.impl.Terminal.AUTO_WRAP_ON);
nvt4jTerminal.setCursor(true);
// Have JLine do input & output through telnet terminal
final InputStream jlineInput = new InputStream() {
@Override
public int read() throws IOException {
return nvt4jTerminal.get();
}
};
final OutputStream jlineOutput = new OutputStream() {
@Override
public void write(int value) throws IOException {
nvt4jTerminal.put(value);
}
};
return createTerminalConsoleShell(prompt, appName, mainHandler, jlineInput, jlineOutput);
} catch (Exception e) {
// Failover: use default shell
BufferedReader in = new BufferedReader(new InputStreamReader(input));
PrintStream out = new PrintStream(output);
return createConsoleShell(prompt, appName, mainHandler, in, out, out, null);
}
} | [
"static",
"Shell",
"createTelnetConsoleShell",
"(",
"String",
"prompt",
",",
"String",
"appName",
",",
"ShellCommandHandler",
"mainHandler",
",",
"InputStream",
"input",
",",
"OutputStream",
"output",
")",
"{",
"try",
"{",
"// Set up nvt4j; ignore the initial clear & repo... | Facade method for operating the Telnet Shell supporting line editing and command
history over a socket.
@param prompt Prompt to be displayed
@param appName The app name string
@param mainHandler Main command handler
@param input Input stream.
@param output Output stream.
@return Shell that can be either further customized or run directly by calling commandLoop(). | [
"Facade",
"method",
"for",
"operating",
"the",
"Telnet",
"Shell",
"supporting",
"line",
"editing",
"and",
"command",
"history",
"over",
"a",
"socket",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsoleFactory.java#L141-L188 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsContainerElementBean.java | CmsContainerElementBean.getSettingsHash | private static String getSettingsHash(Map<String, String> individualSettings, boolean createNew) {
if (!individualSettings.isEmpty() || createNew) {
int hash = (individualSettings.toString() + createNew).hashCode();
return CmsADEManager.CLIENT_ID_SEPERATOR + hash;
}
return "";
} | java | private static String getSettingsHash(Map<String, String> individualSettings, boolean createNew) {
if (!individualSettings.isEmpty() || createNew) {
int hash = (individualSettings.toString() + createNew).hashCode();
return CmsADEManager.CLIENT_ID_SEPERATOR + hash;
}
return "";
} | [
"private",
"static",
"String",
"getSettingsHash",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"individualSettings",
",",
"boolean",
"createNew",
")",
"{",
"if",
"(",
"!",
"individualSettings",
".",
"isEmpty",
"(",
")",
"||",
"createNew",
")",
"{",
"int",
... | Gets the hash code for the element settings.<p>
@param individualSettings the individual settings
@param createNew the create new flag
@return the hash code for the element settings | [
"Gets",
"the",
"hash",
"code",
"for",
"the",
"element",
"settings",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsContainerElementBean.java#L344-L351 |
JOML-CI/JOML | src/org/joml/Matrix4f.java | Matrix4f.rotateXYZ | public Matrix4f rotateXYZ(float angleX, float angleY, float angleZ) {
return rotateXYZ(angleX, angleY, angleZ, thisOrNew());
} | java | public Matrix4f rotateXYZ(float angleX, float angleY, float angleZ) {
return rotateXYZ(angleX, angleY, angleZ, thisOrNew());
} | [
"public",
"Matrix4f",
"rotateXYZ",
"(",
"float",
"angleX",
",",
"float",
"angleY",
",",
"float",
"angleZ",
")",
"{",
"return",
"rotateXYZ",
"(",
"angleX",
",",
"angleY",
",",
"angleZ",
",",
"thisOrNew",
"(",
")",
")",
";",
"}"
] | Apply rotation of <code>angleX</code> radians about the X axis, followed by a rotation of <code>angleY</code> radians about the Y axis and
followed by a rotation of <code>angleZ</code> radians about the Z axis.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix,
then the new matrix will be <code>M * R</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * R * v</code>, the
rotation will be applied first!
<p>
This method is equivalent to calling: <code>rotateX(angleX).rotateY(angleY).rotateZ(angleZ)</code>
@param angleX
the angle to rotate about X
@param angleY
the angle to rotate about Y
@param angleZ
the angle to rotate about Z
@return a matrix holding the result | [
"Apply",
"rotation",
"of",
"<code",
">",
"angleX<",
"/",
"code",
">",
"radians",
"about",
"the",
"X",
"axis",
"followed",
"by",
"a",
"rotation",
"of",
"<code",
">",
"angleY<",
"/",
"code",
">",
"radians",
"about",
"the",
"Y",
"axis",
"and",
"followed",
... | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L5314-L5316 |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/network/AESEventEncrypter.java | AESEventEncrypter.setKey | @Inject
public void setKey(@Named(NetworkConfig.AES_KEY) String key) throws Exception {
final byte[] raw = key.getBytes(NetworkConfig.getStringEncodingCharset());
final int keySize = raw.length;
if ((keySize % 16) == 0 || (keySize % 24) == 0 || (keySize % 32) == 0) {
this.skeySpec = new SecretKeySpec(raw, "AES"); //$NON-NLS-1$
// this.cipher = Cipher.getInstance(ALGORITHM);
} else {
throw new IllegalArgumentException(Messages.AESEventEncrypter_0);
}
} | java | @Inject
public void setKey(@Named(NetworkConfig.AES_KEY) String key) throws Exception {
final byte[] raw = key.getBytes(NetworkConfig.getStringEncodingCharset());
final int keySize = raw.length;
if ((keySize % 16) == 0 || (keySize % 24) == 0 || (keySize % 32) == 0) {
this.skeySpec = new SecretKeySpec(raw, "AES"); //$NON-NLS-1$
// this.cipher = Cipher.getInstance(ALGORITHM);
} else {
throw new IllegalArgumentException(Messages.AESEventEncrypter_0);
}
} | [
"@",
"Inject",
"public",
"void",
"setKey",
"(",
"@",
"Named",
"(",
"NetworkConfig",
".",
"AES_KEY",
")",
"String",
"key",
")",
"throws",
"Exception",
"{",
"final",
"byte",
"[",
"]",
"raw",
"=",
"key",
".",
"getBytes",
"(",
"NetworkConfig",
".",
"getStrin... | Change the encryption key.
@param key injected encryption key.
@throws Exception - when the given key is invalid. | [
"Change",
"the",
"encryption",
"key",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/network/AESEventEncrypter.java#L62-L73 |
graylog-labs/syslog4j-graylog2 | src/main/java/org/graylog2/syslog4j/impl/message/processor/structured/StructuredSyslogMessageProcessor.java | StructuredSyslogMessageProcessor.appendTimestamp | @Override
public void appendTimestamp(StringBuffer buffer, Date datetime) {
SimpleDateFormat formatter = new SimpleDateFormat(SyslogConstants.SYSLOG_DATEFORMAT_RFC5424);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(datetime.getTime());
String formatedTimestamp = formatter.format(calendar.getTime());
buffer.append(formatedTimestamp);
buffer.append(' ');
} | java | @Override
public void appendTimestamp(StringBuffer buffer, Date datetime) {
SimpleDateFormat formatter = new SimpleDateFormat(SyslogConstants.SYSLOG_DATEFORMAT_RFC5424);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(datetime.getTime());
String formatedTimestamp = formatter.format(calendar.getTime());
buffer.append(formatedTimestamp);
buffer.append(' ');
} | [
"@",
"Override",
"public",
"void",
"appendTimestamp",
"(",
"StringBuffer",
"buffer",
",",
"Date",
"datetime",
")",
"{",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"SyslogConstants",
".",
"SYSLOG_DATEFORMAT_RFC5424",
")",
";",
"Calendar",
"... | /* (non-Javadoc)
@see org.graylog2.syslog4j.impl.message.processor.AbstractSyslogMessageProcessor#appendTimestamp(java.lang.StringBuffer, java.util.Date)
This is compatible with RFC5424 protocol. | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")",
"@see",
"org",
".",
"graylog2",
".",
"syslog4j",
".",
"impl",
".",
"message",
".",
"processor",
".",
"AbstractSyslogMessageProcessor#appendTimestamp",
"(",
"java",
".",
"lang",
".",
"StringBuffer",
"java",
".",
"uti... | train | https://github.com/graylog-labs/syslog4j-graylog2/blob/374bc20d77c3aaa36a68bec5125dd82ce0a88aab/src/main/java/org/graylog2/syslog4j/impl/message/processor/structured/StructuredSyslogMessageProcessor.java#L97-L105 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/WxaAPI.java | WxaAPI.img_sec_check | public static BaseResult img_sec_check(String access_token,File media){
HttpPost httpPost = new HttpPost(BASE_URI + "/wxa/img_sec_check");
FileBody bin = new FileBody(media);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("media", bin)
.addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.build();
httpPost.setEntity(reqEntity);
return LocalHttpClient.executeJsonResult(httpPost,BaseResult.class);
} | java | public static BaseResult img_sec_check(String access_token,File media){
HttpPost httpPost = new HttpPost(BASE_URI + "/wxa/img_sec_check");
FileBody bin = new FileBody(media);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("media", bin)
.addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.build();
httpPost.setEntity(reqEntity);
return LocalHttpClient.executeJsonResult(httpPost,BaseResult.class);
} | [
"public",
"static",
"BaseResult",
"img_sec_check",
"(",
"String",
"access_token",
",",
"File",
"media",
")",
"{",
"HttpPost",
"httpPost",
"=",
"new",
"HttpPost",
"(",
"BASE_URI",
"+",
"\"/wxa/img_sec_check\"",
")",
";",
"FileBody",
"bin",
"=",
"new",
"FileBody",... | <strong>图片检查</strong><br>
校验一张图片是否含有违法违规内容。<br>
应用场景举例:<br>
1)图片智能鉴黄:涉及拍照的工具类应用(如美拍,识图类应用)用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等;<br>
2)敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等<br>
<br>
频率限制:单个 appId 调用上限为 1000 次/分钟,100,000 次/天
@since 2.8.20
@param access_token access_token
@param media 要检测的图片文件,格式支持PNG、JPEG、JPG、GIF,图片尺寸不超过 750px * 1334px
@return result | [
"<strong",
">",
"图片检查<",
"/",
"strong",
">",
"<br",
">",
"校验一张图片是否含有违法违规内容。<br",
">",
"应用场景举例:<br",
">",
"1)图片智能鉴黄:涉及拍照的工具类应用",
"(",
"如美拍,识图类应用",
")",
"用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等;<br",
">",
"2)敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等<br",
">",
"<br",
">",
"频率限制:单个... | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/WxaAPI.java#L594-L603 |
mangstadt/biweekly | src/main/java/biweekly/io/ICalTimeZone.java | ICalTimeZone.getObservance | private Observance getObservance(int year, int month, int day, int hour, int minute, int second) {
Boundary boundary = getObservanceBoundary(year, month, day, hour, minute, second);
return (boundary == null) ? null : boundary.getObservanceIn();
} | java | private Observance getObservance(int year, int month, int day, int hour, int minute, int second) {
Boundary boundary = getObservanceBoundary(year, month, day, hour, minute, second);
return (boundary == null) ? null : boundary.getObservanceIn();
} | [
"private",
"Observance",
"getObservance",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"day",
",",
"int",
"hour",
",",
"int",
"minute",
",",
"int",
"second",
")",
"{",
"Boundary",
"boundary",
"=",
"getObservanceBoundary",
"(",
"year",
",",
"month",... | Gets the observance that a date is effected by.
@param year the year
@param month the month (1-12)
@param day the day of the month
@param hour the hour
@param minute the minute
@param second the second
@return the observance or null if an observance cannot be found | [
"Gets",
"the",
"observance",
"that",
"a",
"date",
"is",
"effected",
"by",
"."
] | train | https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/io/ICalTimeZone.java#L310-L313 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.add | public static void add(final DMatrixD1 a , final DMatrixD1 b , final DMatrixD1 c )
{
if( a.numCols != b.numCols || a.numRows != b.numRows ) {
throw new MatrixDimensionException("The matrices are not all the same dimension.");
}
c.reshape(a.numRows,a.numCols);
final int length = a.getNumElements();
for( int i = 0; i < length; i++ ) {
c.set(i, a.get(i) + b.get(i));
}
} | java | public static void add(final DMatrixD1 a , final DMatrixD1 b , final DMatrixD1 c )
{
if( a.numCols != b.numCols || a.numRows != b.numRows ) {
throw new MatrixDimensionException("The matrices are not all the same dimension.");
}
c.reshape(a.numRows,a.numCols);
final int length = a.getNumElements();
for( int i = 0; i < length; i++ ) {
c.set(i, a.get(i) + b.get(i));
}
} | [
"public",
"static",
"void",
"add",
"(",
"final",
"DMatrixD1",
"a",
",",
"final",
"DMatrixD1",
"b",
",",
"final",
"DMatrixD1",
"c",
")",
"{",
"if",
"(",
"a",
".",
"numCols",
"!=",
"b",
".",
"numCols",
"||",
"a",
".",
"numRows",
"!=",
"b",
".",
"numR... | <p>Performs the following operation:<br>
<br>
c = a + b <br>
c<sub>ij</sub> = a<sub>ij</sub> + b<sub>ij</sub> <br>
</p>
<p>
Matrix C can be the same instance as Matrix A and/or B.
</p>
@param a A Matrix. Not modified.
@param b A Matrix. Not modified.
@param c A Matrix where the results are stored. Modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"c",
"=",
"a",
"+",
"b",
"<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"ij<",
"/",
"sub",
">",
"+",
"b<sub",
">",
"ij<",
"/",
"sub",
"... | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L2108-L2121 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/history/HistoryStore.java | HistoryStore.getSize | public synchronized int getSize() {
try {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ObjectOutputStream oOut = new ObjectOutputStream(bOut);
oOut.writeObject(historyStore);
bOut.close();
return bOut.size();
} catch (IOException e) {
throw new IllegalStateException("Cannot serialize internal store: " + e,e);
}
} | java | public synchronized int getSize() {
try {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ObjectOutputStream oOut = new ObjectOutputStream(bOut);
oOut.writeObject(historyStore);
bOut.close();
return bOut.size();
} catch (IOException e) {
throw new IllegalStateException("Cannot serialize internal store: " + e,e);
}
} | [
"public",
"synchronized",
"int",
"getSize",
"(",
")",
"{",
"try",
"{",
"ByteArrayOutputStream",
"bOut",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oOut",
"=",
"new",
"ObjectOutputStream",
"(",
"bOut",
")",
";",
"oOut",
".",
"wri... | Get the size of this history store in bytes
@return size in bytes | [
"Get",
"the",
"size",
"of",
"this",
"history",
"store",
"in",
"bytes"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/history/HistoryStore.java#L155-L165 |
groovy/groovy-core | src/main/org/codehaus/groovy/control/SourceUnit.java | SourceUnit.getSample | public String getSample(int line, int column, Janitor janitor) {
String sample = null;
String text = source.getLine(line, janitor);
if (text != null) {
if (column > 0) {
String marker = Utilities.repeatString(" ", column - 1) + "^";
if (column > 40) {
int start = column - 30 - 1;
int end = (column + 10 > text.length() ? text.length() : column + 10 - 1);
sample = " " + text.substring(start, end) + Utilities.eol() + " " +
marker.substring(start, marker.length());
} else {
sample = " " + text + Utilities.eol() + " " + marker;
}
} else {
sample = text;
}
}
return sample;
} | java | public String getSample(int line, int column, Janitor janitor) {
String sample = null;
String text = source.getLine(line, janitor);
if (text != null) {
if (column > 0) {
String marker = Utilities.repeatString(" ", column - 1) + "^";
if (column > 40) {
int start = column - 30 - 1;
int end = (column + 10 > text.length() ? text.length() : column + 10 - 1);
sample = " " + text.substring(start, end) + Utilities.eol() + " " +
marker.substring(start, marker.length());
} else {
sample = " " + text + Utilities.eol() + " " + marker;
}
} else {
sample = text;
}
}
return sample;
} | [
"public",
"String",
"getSample",
"(",
"int",
"line",
",",
"int",
"column",
",",
"Janitor",
"janitor",
")",
"{",
"String",
"sample",
"=",
"null",
";",
"String",
"text",
"=",
"source",
".",
"getLine",
"(",
"line",
",",
"janitor",
")",
";",
"if",
"(",
"... | Returns a sampling of the source at the specified line and column,
of null if it is unavailable. | [
"Returns",
"a",
"sampling",
"of",
"the",
"source",
"at",
"the",
"specified",
"line",
"and",
"column",
"of",
"null",
"if",
"it",
"is",
"unavailable",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/control/SourceUnit.java#L313-L335 |
knowhowlab/org.knowhowlab.osgi.shell | equinox/src/main/java/org/knowhowlab/osgi/shell/equinox/AbstractEquinoxCommandProvider.java | AbstractEquinoxCommandProvider.runCommand | protected void runCommand(String commandName, CommandInterpreter interpreter) {
PrintWriter out = new PrintWriter(new CommandInterpreterWriter(interpreter));
String[] args = fetchCommandParams(interpreter);
try {
Method method = service.getClass().getMethod(commandName, PrintWriter.class, String[].class);
method.invoke(service, out, args);
} catch (NoSuchMethodException e) {
out.println("No such command: " + commandName);
} catch (Exception e) {
LOG.log(Level.WARNING, "Unable to execute command: " + commandName + " with args: " + Arrays.toString(args), e);
e.printStackTrace(out);
}
} | java | protected void runCommand(String commandName, CommandInterpreter interpreter) {
PrintWriter out = new PrintWriter(new CommandInterpreterWriter(interpreter));
String[] args = fetchCommandParams(interpreter);
try {
Method method = service.getClass().getMethod(commandName, PrintWriter.class, String[].class);
method.invoke(service, out, args);
} catch (NoSuchMethodException e) {
out.println("No such command: " + commandName);
} catch (Exception e) {
LOG.log(Level.WARNING, "Unable to execute command: " + commandName + " with args: " + Arrays.toString(args), e);
e.printStackTrace(out);
}
} | [
"protected",
"void",
"runCommand",
"(",
"String",
"commandName",
",",
"CommandInterpreter",
"interpreter",
")",
"{",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"CommandInterpreterWriter",
"(",
"interpreter",
")",
")",
";",
"String",
"[",
"]",
"... | Run command method
@param commandName command name
@param interpreter interpreter | [
"Run",
"command",
"method"
] | train | https://github.com/knowhowlab/org.knowhowlab.osgi.shell/blob/5c3172b1e6b741c753f02af48ab42adc4915a6ae/equinox/src/main/java/org/knowhowlab/osgi/shell/equinox/AbstractEquinoxCommandProvider.java#L76-L88 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.identity_user_user_PUT | public void identity_user_user_PUT(String user, String description, String email, String group) throws IOException {
String qPath = "/me/identity/user/{user}";
StringBuilder sb = path(qPath, user);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "email", email);
addBody(o, "group", group);
exec(qPath, "PUT", sb.toString(), o);
} | java | public void identity_user_user_PUT(String user, String description, String email, String group) throws IOException {
String qPath = "/me/identity/user/{user}";
StringBuilder sb = path(qPath, user);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "email", email);
addBody(o, "group", group);
exec(qPath, "PUT", sb.toString(), o);
} | [
"public",
"void",
"identity_user_user_PUT",
"(",
"String",
"user",
",",
"String",
"description",
",",
"String",
"email",
",",
"String",
"group",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/identity/user/{user}\"",
";",
"StringBuilder",
"sb",
... | Alter a user
REST: PUT /me/identity/user/{user}
@param user [required] User's login
@param email [required] User's email
@param description [required] User's description
@param group [required] User's group | [
"Alter",
"a",
"user"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L232-L240 |
josueeduardo/snappy | plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/JarWriter.java | JarWriter.writeEntry | public void writeEntry(String entryName, InputStream inputStream) throws IOException {
JarEntry entry = new JarEntry(entryName);
writeEntry(entry, new InputStreamEntryWriter(inputStream, true));
} | java | public void writeEntry(String entryName, InputStream inputStream) throws IOException {
JarEntry entry = new JarEntry(entryName);
writeEntry(entry, new InputStreamEntryWriter(inputStream, true));
} | [
"public",
"void",
"writeEntry",
"(",
"String",
"entryName",
",",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"JarEntry",
"entry",
"=",
"new",
"JarEntry",
"(",
"entryName",
")",
";",
"writeEntry",
"(",
"entry",
",",
"new",
"InputStreamEntryWr... | Writes an entry. The {@code inputStream} is closed once the entry has been written
@param entryName The name of the entry
@param inputStream The stream from which the entry's data can be read
@throws IOException if the write fails | [
"Writes",
"an",
"entry",
".",
"The",
"{",
"@code",
"inputStream",
"}",
"is",
"closed",
"once",
"the",
"entry",
"has",
"been",
"written"
] | train | https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/JarWriter.java#L153-L156 |
comapi/comapi-chat-sdk-android | COMAPI/chat/src/main/java/com/comapi/chat/ChatController.java | ChatController.queryMissingEvents | void queryMissingEvents(String conversationId, long from, int limit) {
obsExec.execute(checkState().flatMap(client -> client.service().messaging().queryConversationEvents(conversationId, from, limit))
.flatMap((result) -> processEventsQueryResponse(result, new ArrayList<>())));
} | java | void queryMissingEvents(String conversationId, long from, int limit) {
obsExec.execute(checkState().flatMap(client -> client.service().messaging().queryConversationEvents(conversationId, from, limit))
.flatMap((result) -> processEventsQueryResponse(result, new ArrayList<>())));
} | [
"void",
"queryMissingEvents",
"(",
"String",
"conversationId",
",",
"long",
"from",
",",
"int",
"limit",
")",
"{",
"obsExec",
".",
"execute",
"(",
"checkState",
"(",
")",
".",
"flatMap",
"(",
"client",
"->",
"client",
".",
"service",
"(",
")",
".",
"mess... | Query missing events as {@link com.comapi.chat.internal.MissingEventsTracker} reported.
@param conversationId Unique id of a conversation.
@param from Conversation event id to start from.
@param limit Limit of events in a query. | [
"Query",
"missing",
"events",
"as",
"{",
"@link",
"com",
".",
"comapi",
".",
"chat",
".",
"internal",
".",
"MissingEventsTracker",
"}",
"reported",
"."
] | train | https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/ChatController.java#L721-L724 |
Red5/red5-server-common | src/main/java/org/red5/server/Server.java | Server.getKey | protected String getKey(String hostName, String contextPath) {
return String.format("%s/%s", (hostName == null ? EMPTY : hostName), (contextPath == null ? EMPTY : contextPath));
} | java | protected String getKey(String hostName, String contextPath) {
return String.format("%s/%s", (hostName == null ? EMPTY : hostName), (contextPath == null ? EMPTY : contextPath));
} | [
"protected",
"String",
"getKey",
"(",
"String",
"hostName",
",",
"String",
"contextPath",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s/%s\"",
",",
"(",
"hostName",
"==",
"null",
"?",
"EMPTY",
":",
"hostName",
")",
",",
"(",
"contextPath",
"==",
... | Return scope key. Scope key consists of host name concatenated with context path by slash symbol
@param hostName
Host name
@param contextPath
Context path
@return Scope key as string | [
"Return",
"scope",
"key",
".",
"Scope",
"key",
"consists",
"of",
"host",
"name",
"concatenated",
"with",
"context",
"path",
"by",
"slash",
"symbol"
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/Server.java#L118-L120 |
languagetool-org/languagetool | languagetool-server/src/main/java/org/languagetool/server/UserLimits.java | UserLimits.getLimitsByApiKey | public static UserLimits getLimitsByApiKey(HTTPServerConfig config, String username, String apiKey) {
DatabaseAccess db = DatabaseAccess.getInstance();
Long id = db.getUserId(username, apiKey);
return new UserLimits(config.maxTextLengthWithApiKey, config.maxCheckTimeWithApiKeyMillis, id);
} | java | public static UserLimits getLimitsByApiKey(HTTPServerConfig config, String username, String apiKey) {
DatabaseAccess db = DatabaseAccess.getInstance();
Long id = db.getUserId(username, apiKey);
return new UserLimits(config.maxTextLengthWithApiKey, config.maxCheckTimeWithApiKeyMillis, id);
} | [
"public",
"static",
"UserLimits",
"getLimitsByApiKey",
"(",
"HTTPServerConfig",
"config",
",",
"String",
"username",
",",
"String",
"apiKey",
")",
"{",
"DatabaseAccess",
"db",
"=",
"DatabaseAccess",
".",
"getInstance",
"(",
")",
";",
"Long",
"id",
"=",
"db",
"... | Get limits from the api key itself, database access is needed. | [
"Get",
"limits",
"from",
"the",
"api",
"key",
"itself",
"database",
"access",
"is",
"needed",
"."
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-server/src/main/java/org/languagetool/server/UserLimits.java#L97-L101 |
SQLDroid/SQLDroid | src/main/java/org/sqldroid/SQLDroidPreparedStatement.java | SQLDroidPreparedStatement.setBinaryStream | @Override
public void setBinaryStream(int parameterIndex, InputStream inputStream, long length) throws SQLException {
if ( length > Integer.MAX_VALUE ) {
throw new SQLException ("SQLDroid does not allow input stream data greater than " + Integer.MAX_VALUE );
}
setBinaryStream(parameterIndex, inputStream, (int)length);
} | java | @Override
public void setBinaryStream(int parameterIndex, InputStream inputStream, long length) throws SQLException {
if ( length > Integer.MAX_VALUE ) {
throw new SQLException ("SQLDroid does not allow input stream data greater than " + Integer.MAX_VALUE );
}
setBinaryStream(parameterIndex, inputStream, (int)length);
} | [
"@",
"Override",
"public",
"void",
"setBinaryStream",
"(",
"int",
"parameterIndex",
",",
"InputStream",
"inputStream",
",",
"long",
"length",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"length",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
... | This is a pass through to the integer version of the same method. That is, the long is downcast to an
integer. If the length is greater than Integer.MAX_VALUE this method will throw a SQLException.
@see #setBinaryStream(int, InputStream, int)
@exception SQLException thrown if length is greater than Integer.MAX_VALUE or if there is a database error. | [
"This",
"is",
"a",
"pass",
"through",
"to",
"the",
"integer",
"version",
"of",
"the",
"same",
"method",
".",
"That",
"is",
"the",
"long",
"is",
"downcast",
"to",
"an",
"integer",
".",
"If",
"the",
"length",
"is",
"greater",
"than",
"Integer",
".",
"MAX... | train | https://github.com/SQLDroid/SQLDroid/blob/4fb38ee40338673cb0205044571e4379573762c4/src/main/java/org/sqldroid/SQLDroidPreparedStatement.java#L747-L753 |
liferay/com-liferay-commerce | commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java | CPDefinitionVirtualSettingPersistenceImpl.findAll | @Override
public List<CPDefinitionVirtualSetting> findAll(int start, int end) {
return findAll(start, end, null);
} | java | @Override
public List<CPDefinitionVirtualSetting> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CPDefinitionVirtualSetting",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the cp definition virtual settings.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPDefinitionVirtualSettingModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of cp definition virtual settings
@param end the upper bound of the range of cp definition virtual settings (not inclusive)
@return the range of cp definition virtual settings | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"cp",
"definition",
"virtual",
"settings",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java#L2402-L2405 |
liuyukuai/commons | commons-security/src/main/java/com/itxiaoer/commons/security/JwtTokenContext.java | JwtTokenContext.validate | public Boolean validate(String token, JwtUserDetail userDetails) {
if (StringUtils.isBlank(token) || userDetails == null) {
return false;
}
String key = jwtProperties.getPrefix() + Md5Utils.digestMD5(token);
JwtToken jwtToken = cacheService.get(key);
// 判断是否在黑名单中
if (jwtToken != null) {
//销毁状态
if (JwtToken.Operation.destroy.getValue() == jwtToken.getType()) {
return false;
}
Long refreshTime = jwtToken.getRefreshTime();
if (refreshTime != null && jwtToken.getType() == JwtToken.Operation.refresh.getValue()) {
// 刷新token二分钟内可以使用
return Instant.now().toEpochMilli() - refreshTime < 1000 * 60 * 2;
}
}
final Instant created = jwtBuilder.getCreatedTimeFromToken(token);
final String loginName = jwtBuilder.getLoginNameFromToken(token);
LocalDateTime modifyPasswordTime = userDetails.getModifyPasswordTime();
if (Objects.isNull(modifyPasswordTime)) {
return Objects.equals(loginName, userDetails.getUsername())
&& !jwtBuilder.isExpired(token);
}
return Objects.equals(loginName, userDetails.getUsername())
&& !jwtBuilder.isExpired(token) && validate(created, modifyPasswordTime);
} | java | public Boolean validate(String token, JwtUserDetail userDetails) {
if (StringUtils.isBlank(token) || userDetails == null) {
return false;
}
String key = jwtProperties.getPrefix() + Md5Utils.digestMD5(token);
JwtToken jwtToken = cacheService.get(key);
// 判断是否在黑名单中
if (jwtToken != null) {
//销毁状态
if (JwtToken.Operation.destroy.getValue() == jwtToken.getType()) {
return false;
}
Long refreshTime = jwtToken.getRefreshTime();
if (refreshTime != null && jwtToken.getType() == JwtToken.Operation.refresh.getValue()) {
// 刷新token二分钟内可以使用
return Instant.now().toEpochMilli() - refreshTime < 1000 * 60 * 2;
}
}
final Instant created = jwtBuilder.getCreatedTimeFromToken(token);
final String loginName = jwtBuilder.getLoginNameFromToken(token);
LocalDateTime modifyPasswordTime = userDetails.getModifyPasswordTime();
if (Objects.isNull(modifyPasswordTime)) {
return Objects.equals(loginName, userDetails.getUsername())
&& !jwtBuilder.isExpired(token);
}
return Objects.equals(loginName, userDetails.getUsername())
&& !jwtBuilder.isExpired(token) && validate(created, modifyPasswordTime);
} | [
"public",
"Boolean",
"validate",
"(",
"String",
"token",
",",
"JwtUserDetail",
"userDetails",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"token",
")",
"||",
"userDetails",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"key",
... | 校验token是否合法
@param token token的值
@param userDetails 用户信息
@return true:合法,false:非法 | [
"校验token是否合法"
] | train | https://github.com/liuyukuai/commons/blob/ba67eddb542446b12f419f1866dbaa82e47fbf35/commons-security/src/main/java/com/itxiaoer/commons/security/JwtTokenContext.java#L91-L119 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/repo/map/UpgradableLock.java | UpgradableLock.tryLockForRead | public final boolean tryLockForRead(L locker, long timeout, TimeUnit unit)
throws InterruptedException
{
if (Thread.interrupted()) {
throw new InterruptedException();
}
if (!tryLockForRead(locker)) {
return lockForReadQueuedInterruptibly(locker, addReadWaiter(), unit.toNanos(timeout));
}
return true;
} | java | public final boolean tryLockForRead(L locker, long timeout, TimeUnit unit)
throws InterruptedException
{
if (Thread.interrupted()) {
throw new InterruptedException();
}
if (!tryLockForRead(locker)) {
return lockForReadQueuedInterruptibly(locker, addReadWaiter(), unit.toNanos(timeout));
}
return true;
} | [
"public",
"final",
"boolean",
"tryLockForRead",
"(",
"L",
"locker",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"{",
"throw",
"new",
"InterruptedException"... | Attempt to acquire a shared read lock, waiting a maximum amount of
time.
@param locker object which might be write or upgrade lock owner
@return true if acquired | [
"Attempt",
"to",
"acquire",
"a",
"shared",
"read",
"lock",
"waiting",
"a",
"maximum",
"amount",
"of",
"time",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/UpgradableLock.java#L203-L213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.