repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.branch | public MethodHandle branch(MethodHandle test, MethodHandle truePath, MethodHandle falsePath) {
return invoke(MethodHandles.guardWithTest(test, truePath, falsePath));
} | java | public MethodHandle branch(MethodHandle test, MethodHandle truePath, MethodHandle falsePath) {
return invoke(MethodHandles.guardWithTest(test, truePath, falsePath));
} | [
"public",
"MethodHandle",
"branch",
"(",
"MethodHandle",
"test",
",",
"MethodHandle",
"truePath",
",",
"MethodHandle",
"falsePath",
")",
"{",
"return",
"invoke",
"(",
"MethodHandles",
".",
"guardWithTest",
"(",
"test",
",",
"truePath",
",",
"falsePath",
")",
")"... | Apply the chain of transforms and bind them to a boolean branch as from
java.lang.invoke.MethodHandles.guardWithTest. As with GWT, the current endpoint
signature must match the given target and fallback signatures.
@param test the test handle
@param truePath the target handle
@param falsePath the fallback handle
@return the full handle chain bound to a branch | [
"Apply",
"the",
"chain",
"of",
"transforms",
"and",
"bind",
"them",
"to",
"a",
"boolean",
"branch",
"as",
"from",
"java",
".",
"lang",
".",
"invoke",
".",
"MethodHandles",
".",
"guardWithTest",
".",
"As",
"with",
"GWT",
"the",
"current",
"endpoint",
"signa... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1650-L1652 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.toJava | public String toJava(MethodType incoming) {
StringBuilder builder = new StringBuilder();
boolean second = false;
for (Transform transform : transforms) {
if (second) builder.append('\n');
second = true;
builder.append(transform.toJava(incoming));
}
return builder.toString();
} | java | public String toJava(MethodType incoming) {
StringBuilder builder = new StringBuilder();
boolean second = false;
for (Transform transform : transforms) {
if (second) builder.append('\n');
second = true;
builder.append(transform.toJava(incoming));
}
return builder.toString();
} | [
"public",
"String",
"toJava",
"(",
"MethodType",
"incoming",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"second",
"=",
"false",
";",
"for",
"(",
"Transform",
"transform",
":",
"transforms",
")",
"{",
"if",
... | Produce Java code that would perform equivalent operations to this binder.
@return Java code for the handle adaptations this Binder would produce. | [
"Produce",
"Java",
"code",
"that",
"would",
"perform",
"equivalent",
"operations",
"to",
"this",
"binder",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1669-L1678 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/GraphRequestBuilder.java | GraphRequestBuilder.execute | @Override
public HttpResponse execute() throws IOException {
if (this.method == HttpMethod.GET) {
String url = this.toString();
if (url.length() > this.cutoff) {
if (log.isLoggable(Level.FINER))
log.finer("URL length " + url.length() + " too long, converting GET to POST: " + url);
String rebase = this.baseURL + "?method=GET";
return this.execute(HttpMethod.POST, rebase);
}
}
return super.execute();
} | java | @Override
public HttpResponse execute() throws IOException {
if (this.method == HttpMethod.GET) {
String url = this.toString();
if (url.length() > this.cutoff) {
if (log.isLoggable(Level.FINER))
log.finer("URL length " + url.length() + " too long, converting GET to POST: " + url);
String rebase = this.baseURL + "?method=GET";
return this.execute(HttpMethod.POST, rebase);
}
}
return super.execute();
} | [
"@",
"Override",
"public",
"HttpResponse",
"execute",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"method",
"==",
"HttpMethod",
".",
"GET",
")",
"{",
"String",
"url",
"=",
"this",
".",
"toString",
"(",
")",
";",
"if",
"(",
"url",
... | Replace excessively-long GET requests with a POST. | [
"Replace",
"excessively",
"-",
"long",
"GET",
"requests",
"with",
"a",
"POST",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/GraphRequestBuilder.java#L82-L96 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.graph | private <T> GraphRequest<T> graph(String object, JavaType type, Param... params) {
this.checkForBatchExecution();
// The data is transformed through a chain of wrappers
GraphRequest<T> req =
new GraphRequest<T>(object, params, this.mapper, this.<T>createMappingChain(type));
this.graphRequests.add(req);
return req;
} | java | private <T> GraphRequest<T> graph(String object, JavaType type, Param... params) {
this.checkForBatchExecution();
// The data is transformed through a chain of wrappers
GraphRequest<T> req =
new GraphRequest<T>(object, params, this.mapper, this.<T>createMappingChain(type));
this.graphRequests.add(req);
return req;
} | [
"private",
"<",
"T",
">",
"GraphRequest",
"<",
"T",
">",
"graph",
"(",
"String",
"object",
",",
"JavaType",
"type",
",",
"Param",
"...",
"params",
")",
"{",
"this",
".",
"checkForBatchExecution",
"(",
")",
";",
"// The data is transformed through a chain of wrap... | The actual implementation of this, after we've converted to proper Jackson JavaType | [
"The",
"actual",
"implementation",
"of",
"this",
"after",
"we",
"ve",
"converted",
"to",
"proper",
"Jackson",
"JavaType"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L187-L196 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.query | private <T> QueryRequest<T> query(String fql, JavaType type) {
this.checkForBatchExecution();
if (this.multiqueryRequest == null) {
this.multiqueryRequest = new MultiqueryRequest(mapper, this.createUnmappedChain());
this.graphRequests.add(this.multiqueryRequest);
}
// There is a circular reference between the extractor and request, so construction of the chain
// is a little complicated
QueryNodeExtractor extractor = new QueryNodeExtractor(this.multiqueryRequest);
String name = "__q" + this.generatedQueryNameIndex++;
QueryRequest<T> q =
new QueryRequest<T>(fql, name,
new MapperWrapper<T>(type, this.mapper,
extractor));
extractor.setRequest(q);
this.multiqueryRequest.addQuery(q);
return q;
} | java | private <T> QueryRequest<T> query(String fql, JavaType type) {
this.checkForBatchExecution();
if (this.multiqueryRequest == null) {
this.multiqueryRequest = new MultiqueryRequest(mapper, this.createUnmappedChain());
this.graphRequests.add(this.multiqueryRequest);
}
// There is a circular reference between the extractor and request, so construction of the chain
// is a little complicated
QueryNodeExtractor extractor = new QueryNodeExtractor(this.multiqueryRequest);
String name = "__q" + this.generatedQueryNameIndex++;
QueryRequest<T> q =
new QueryRequest<T>(fql, name,
new MapperWrapper<T>(type, this.mapper,
extractor));
extractor.setRequest(q);
this.multiqueryRequest.addQuery(q);
return q;
} | [
"private",
"<",
"T",
">",
"QueryRequest",
"<",
"T",
">",
"query",
"(",
"String",
"fql",
",",
"JavaType",
"type",
")",
"{",
"this",
".",
"checkForBatchExecution",
"(",
")",
";",
"if",
"(",
"this",
".",
"multiqueryRequest",
"==",
"null",
")",
"{",
"this"... | Implementation now that we have chosen a Jackson JavaType for the return value | [
"Implementation",
"now",
"that",
"we",
"have",
"chosen",
"a",
"Jackson",
"JavaType",
"for",
"the",
"return",
"value"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L233-L255 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.createMappingChain | private <T> MapperWrapper<T> createMappingChain(JavaType type) {
return new MapperWrapper<T>(type, this.mapper, this.createUnmappedChain());
} | java | private <T> MapperWrapper<T> createMappingChain(JavaType type) {
return new MapperWrapper<T>(type, this.mapper, this.createUnmappedChain());
} | [
"private",
"<",
"T",
">",
"MapperWrapper",
"<",
"T",
">",
"createMappingChain",
"(",
"JavaType",
"type",
")",
"{",
"return",
"new",
"MapperWrapper",
"<",
"T",
">",
"(",
"type",
",",
"this",
".",
"mapper",
",",
"this",
".",
"createUnmappedChain",
"(",
")"... | Adds mapping to the basic unmapped chain. | [
"Adds",
"mapping",
"to",
"the",
"basic",
"unmapped",
"chain",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L332-L334 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.createUnmappedChain | private ErrorDetectingWrapper createUnmappedChain() {
int nextIndex = this.graphRequests.size();
return
new ErrorDetectingWrapper(
new GraphNodeExtractor(nextIndex, this.mapper,
new ErrorDetectingWrapper(this)));
} | java | private ErrorDetectingWrapper createUnmappedChain() {
int nextIndex = this.graphRequests.size();
return
new ErrorDetectingWrapper(
new GraphNodeExtractor(nextIndex, this.mapper,
new ErrorDetectingWrapper(this)));
} | [
"private",
"ErrorDetectingWrapper",
"createUnmappedChain",
"(",
")",
"{",
"int",
"nextIndex",
"=",
"this",
".",
"graphRequests",
".",
"size",
"(",
")",
";",
"return",
"new",
"ErrorDetectingWrapper",
"(",
"new",
"GraphNodeExtractor",
"(",
"nextIndex",
",",
"this",
... | Creates the common chain of wrappers that will select out one graph request
from the batch and error check it both at the batch level and at the individual
request level. Result will be an unmapped JsonNode. | [
"Creates",
"the",
"common",
"chain",
"of",
"wrappers",
"that",
"will",
"select",
"out",
"one",
"graph",
"request",
"from",
"the",
"batch",
"and",
"error",
"check",
"it",
"both",
"at",
"the",
"batch",
"level",
"and",
"at",
"the",
"individual",
"request",
"l... | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L341-L348 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.getRawBatchResult | private Later<JsonNode> getRawBatchResult() {
if (this.rawBatchResult == null) {
// Use LaterWrapper to cache the result so we don't fetch over and over
this.rawBatchResult = new LaterWrapper<JsonNode, JsonNode>(this.createFetcher());
// Also let the master know it's time to kick off any other batches and
// remove us as a valid batch to add to.
// This must be called *after* the rawBatchResult is set otherwise we
// will have endless recursion when the master tries to execute us.
this.master.execute();
}
return this.rawBatchResult;
} | java | private Later<JsonNode> getRawBatchResult() {
if (this.rawBatchResult == null) {
// Use LaterWrapper to cache the result so we don't fetch over and over
this.rawBatchResult = new LaterWrapper<JsonNode, JsonNode>(this.createFetcher());
// Also let the master know it's time to kick off any other batches and
// remove us as a valid batch to add to.
// This must be called *after* the rawBatchResult is set otherwise we
// will have endless recursion when the master tries to execute us.
this.master.execute();
}
return this.rawBatchResult;
} | [
"private",
"Later",
"<",
"JsonNode",
">",
"getRawBatchResult",
"(",
")",
"{",
"if",
"(",
"this",
".",
"rawBatchResult",
"==",
"null",
")",
"{",
"// Use LaterWrapper to cache the result so we don't fetch over and over\r",
"this",
".",
"rawBatchResult",
"=",
"new",
"Lat... | Get the batch result, firing it off if necessary | [
"Get",
"the",
"batch",
"result",
"firing",
"it",
"off",
"if",
"necessary"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L370-L383 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/Batch.java | Batch.createFetcher | private Later<JsonNode> createFetcher() {
final RequestBuilder call = new GraphRequestBuilder(getGraphEndpoint(), HttpMethod.POST, this.timeout, this.retries);
// This actually creates the correct JSON structure as an array
String batchValue = JSONUtils.toJSON(this.graphRequests, this.mapper);
if (log.isLoggable(Level.FINEST))
log.finest("Batch request is: " + batchValue);
this.addParams(call, new Param[] { new Param("batch", batchValue) });
final HttpResponse response;
try {
response = call.execute();
} catch (IOException ex) {
throw new IOFacebookException(ex);
}
return new Later<JsonNode>() {
@Override
public JsonNode get() throws FacebookException
{
try {
if (response.getResponseCode() == HttpURLConnection.HTTP_OK
|| response.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST
|| response.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
// If it was an error, we will recognize it in the content later.
// It's possible we should capture all 4XX codes here.
JsonNode result = mapper.readTree(response.getContentStream());
if (log.isLoggable(Level.FINEST))
log.finest("Response is: " + result);
return result;
} else {
throw new IOFacebookException(
"Unrecognized error " + response.getResponseCode() + " from "
+ call + " :: " + StringUtils.read(response.getContentStream()));
}
} catch (IOException e) {
throw new IOFacebookException("Error calling " + call, e);
}
}
};
} | java | private Later<JsonNode> createFetcher() {
final RequestBuilder call = new GraphRequestBuilder(getGraphEndpoint(), HttpMethod.POST, this.timeout, this.retries);
// This actually creates the correct JSON structure as an array
String batchValue = JSONUtils.toJSON(this.graphRequests, this.mapper);
if (log.isLoggable(Level.FINEST))
log.finest("Batch request is: " + batchValue);
this.addParams(call, new Param[] { new Param("batch", batchValue) });
final HttpResponse response;
try {
response = call.execute();
} catch (IOException ex) {
throw new IOFacebookException(ex);
}
return new Later<JsonNode>() {
@Override
public JsonNode get() throws FacebookException
{
try {
if (response.getResponseCode() == HttpURLConnection.HTTP_OK
|| response.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST
|| response.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
// If it was an error, we will recognize it in the content later.
// It's possible we should capture all 4XX codes here.
JsonNode result = mapper.readTree(response.getContentStream());
if (log.isLoggable(Level.FINEST))
log.finest("Response is: " + result);
return result;
} else {
throw new IOFacebookException(
"Unrecognized error " + response.getResponseCode() + " from "
+ call + " :: " + StringUtils.read(response.getContentStream()));
}
} catch (IOException e) {
throw new IOFacebookException("Error calling " + call, e);
}
}
};
} | [
"private",
"Later",
"<",
"JsonNode",
">",
"createFetcher",
"(",
")",
"{",
"final",
"RequestBuilder",
"call",
"=",
"new",
"GraphRequestBuilder",
"(",
"getGraphEndpoint",
"(",
")",
",",
"HttpMethod",
".",
"POST",
",",
"this",
".",
"timeout",
",",
"this",
".",
... | Constructs the batch query and executes it, possibly asynchronously.
@return an asynchronous handle to the raw batch result, whatever it may be. | [
"Constructs",
"the",
"batch",
"query",
"and",
"executes",
"it",
"possibly",
"asynchronously",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/Batch.java#L398-L442 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java | ErrorDetectingWrapper.throwPageMigratedException | private void throwPageMigratedException(String msg, int code, int subcode, String userTitle, String userMsg) {
// This SUCKS ASS. Messages look like:
// (#21) Page ID 114267748588304 was migrated to page ID 111013272313096. Please update your API calls to the new ID
Matcher matcher = ID_PATTERN.matcher(msg);
long oldId = this.extractNextId(matcher, msg);
long newId = this.extractNextId(matcher, msg);
throw new PageMigratedException(msg, code, subcode, userTitle, userMsg, oldId, newId);
} | java | private void throwPageMigratedException(String msg, int code, int subcode, String userTitle, String userMsg) {
// This SUCKS ASS. Messages look like:
// (#21) Page ID 114267748588304 was migrated to page ID 111013272313096. Please update your API calls to the new ID
Matcher matcher = ID_PATTERN.matcher(msg);
long oldId = this.extractNextId(matcher, msg);
long newId = this.extractNextId(matcher, msg);
throw new PageMigratedException(msg, code, subcode, userTitle, userMsg, oldId, newId);
} | [
"private",
"void",
"throwPageMigratedException",
"(",
"String",
"msg",
",",
"int",
"code",
",",
"int",
"subcode",
",",
"String",
"userTitle",
",",
"String",
"userMsg",
")",
"{",
"// This SUCKS ASS. Messages look like:\r",
"// (#21) Page ID 114267748588304 was migrated to p... | Builds the proper exception and throws it.
@throws PageMigratedException always | [
"Builds",
"the",
"proper",
"exception",
"and",
"throws",
"it",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java#L138-L148 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java | ErrorDetectingWrapper.extractNextId | private long extractNextId(Matcher matcher, String msg) {
if (!matcher.find())
throw new IllegalStateException("Facebook changed the error msg for page migration to something unfamiliar. The new msg is: " + msg);
String idStr = matcher.group().substring("ID ".length());
return Long.parseLong(idStr);
} | java | private long extractNextId(Matcher matcher, String msg) {
if (!matcher.find())
throw new IllegalStateException("Facebook changed the error msg for page migration to something unfamiliar. The new msg is: " + msg);
String idStr = matcher.group().substring("ID ".length());
return Long.parseLong(idStr);
} | [
"private",
"long",
"extractNextId",
"(",
"Matcher",
"matcher",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"!",
"matcher",
".",
"find",
"(",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Facebook changed the error msg for page migration to something unfami... | Gets the next id out of the matcher | [
"Gets",
"the",
"next",
"id",
"out",
"of",
"the",
"matcher"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java#L153-L159 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java | ErrorDetectingWrapper.throwCodeAndMessage | protected void throwCodeAndMessage(int code, String msg) {
switch (code) {
case 0:
case 101:
case 102:
case 190: throw new OAuthException(msg, "OAuthException", code, null, null, null);
default: throw new ErrorFacebookException(msg + " (code " + code +")", null, code, null, null, null);
}
} | java | protected void throwCodeAndMessage(int code, String msg) {
switch (code) {
case 0:
case 101:
case 102:
case 190: throw new OAuthException(msg, "OAuthException", code, null, null, null);
default: throw new ErrorFacebookException(msg + " (code " + code +")", null, code, null, null, null);
}
} | [
"protected",
"void",
"throwCodeAndMessage",
"(",
"int",
"code",
",",
"String",
"msg",
")",
"{",
"switch",
"(",
"code",
")",
"{",
"case",
"0",
":",
"case",
"101",
":",
"case",
"102",
":",
"case",
"190",
":",
"throw",
"new",
"OAuthException",
"(",
"msg",... | Throw the appropriate exception for the given legacy code and message.
Always throws, never returns. | [
"Throw",
"the",
"appropriate",
"exception",
"for",
"the",
"given",
"legacy",
"code",
"and",
"message",
".",
"Always",
"throws",
"never",
"returns",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/ErrorDetectingWrapper.java#L227-L236 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/repeaters/AjaxListSetView.java | AjaxListSetView.newItem | protected ListSetItem<T> newItem(IModel<T> itemModel)
{
ListSetItem<T> item = new ListSetItem<T>(Integer.toString(counter++), itemModel);
populateItem(item);
return item;
} | java | protected ListSetItem<T> newItem(IModel<T> itemModel)
{
ListSetItem<T> item = new ListSetItem<T>(Integer.toString(counter++), itemModel);
populateItem(item);
return item;
} | [
"protected",
"ListSetItem",
"<",
"T",
">",
"newItem",
"(",
"IModel",
"<",
"T",
">",
"itemModel",
")",
"{",
"ListSetItem",
"<",
"T",
">",
"item",
"=",
"new",
"ListSetItem",
"<",
"T",
">",
"(",
"Integer",
".",
"toString",
"(",
"counter",
"++",
")",
","... | Create a new ListSetItem for list item.
@param itemModel object in the list that the item represents
@return ListSetItem | [
"Create",
"a",
"new",
"ListSetItem",
"for",
"list",
"item",
"."
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/repeaters/AjaxListSetView.java#L175-L180 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDatePicker.java | BootstrapDatePicker.getDateTextField | public DateTextField getDateTextField(){
DateTextField component = visitChildren(DateTextField.class, new IVisitor<DateTextField, DateTextField>() {
@Override
public void component(DateTextField arg0, IVisit<DateTextField> arg1) {
arg1.stop(arg0);
}
});
if (component == null)
throw new WicketRuntimeException("BootstrapDatepicker didn't have any DateTextField child!");
return component;
} | java | public DateTextField getDateTextField(){
DateTextField component = visitChildren(DateTextField.class, new IVisitor<DateTextField, DateTextField>() {
@Override
public void component(DateTextField arg0, IVisit<DateTextField> arg1) {
arg1.stop(arg0);
}
});
if (component == null)
throw new WicketRuntimeException("BootstrapDatepicker didn't have any DateTextField child!");
return component;
} | [
"public",
"DateTextField",
"getDateTextField",
"(",
")",
"{",
"DateTextField",
"component",
"=",
"visitChildren",
"(",
"DateTextField",
".",
"class",
",",
"new",
"IVisitor",
"<",
"DateTextField",
",",
"DateTextField",
">",
"(",
")",
"{",
"@",
"Override",
"public... | Gets the DateTextField inside this datepicker wrapper.
@return the date field | [
"Gets",
"the",
"DateTextField",
"inside",
"this",
"datepicker",
"wrapper",
"."
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDatePicker.java#L85-L97 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/proxy/internal/BestMatchingConstructor.java | BestMatchingConstructor.typesAreCompatible | private boolean typesAreCompatible(Class<?>[] paramTypes, Class<?>[] constructorParamTypes) {
boolean matches = true;
for (int i = 0; i < paramTypes.length; i++) {
Class<?> paramType = paramTypes[i];
if (paramType != null) {
Class<?> inputParamType = translateFromPrimitive(paramType);
Class<?> constructorParamType = translateFromPrimitive(constructorParamTypes[i]);
if (inputParamType.isArray() && Collection.class.isAssignableFrom(constructorParamType)) {
continue;
}
if (!constructorParamType.isAssignableFrom(inputParamType)) {
matches = false;
break;
}
}
}
return matches;
} | java | private boolean typesAreCompatible(Class<?>[] paramTypes, Class<?>[] constructorParamTypes) {
boolean matches = true;
for (int i = 0; i < paramTypes.length; i++) {
Class<?> paramType = paramTypes[i];
if (paramType != null) {
Class<?> inputParamType = translateFromPrimitive(paramType);
Class<?> constructorParamType = translateFromPrimitive(constructorParamTypes[i]);
if (inputParamType.isArray() && Collection.class.isAssignableFrom(constructorParamType)) {
continue;
}
if (!constructorParamType.isAssignableFrom(inputParamType)) {
matches = false;
break;
}
}
}
return matches;
} | [
"private",
"boolean",
"typesAreCompatible",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"paramTypes",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"constructorParamTypes",
")",
"{",
"boolean",
"matches",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Checks if a set of types are compatible with the given set of constructor parameter types. If an input type is
null, then it is considered as a wildcard for matching purposes, and always matches.
@param paramTypes A set of input types that are to be matched against constructor parameters.
@param constructorParamTypes The constructor parameters to match against.
@return whether the input types are compatible or not. | [
"Checks",
"if",
"a",
"set",
"of",
"types",
"are",
"compatible",
"with",
"the",
"given",
"set",
"of",
"constructor",
"parameter",
"types",
".",
"If",
"an",
"input",
"type",
"is",
"null",
"then",
"it",
"is",
"considered",
"as",
"a",
"wildcard",
"for",
"mat... | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/proxy/internal/BestMatchingConstructor.java#L112-L132 | train |
rbuck/java-retry | src/main/java/com/github/rbuck/retry/RetryPolicy.java | RetryPolicy.action | public V action(Callable<V> callable) throws Exception {
Exception re;
RetryState retryState = retryStrategy.getRetryState();
do {
try {
return callable.call();
} catch (Exception e) {
re = e;
if (Thread.interrupted() || isInterruptTransitively(e)) {
re = new InterruptedException(e.getMessage());
break;
}
if (!transientExceptionDetector.isTransient(e)) {
break;
}
}
enqueueRetryEvent(new RetryEvent(this, retryState, re));
retryState.delayRetry();
} while (retryState.hasRetries());
throw re;
} | java | public V action(Callable<V> callable) throws Exception {
Exception re;
RetryState retryState = retryStrategy.getRetryState();
do {
try {
return callable.call();
} catch (Exception e) {
re = e;
if (Thread.interrupted() || isInterruptTransitively(e)) {
re = new InterruptedException(e.getMessage());
break;
}
if (!transientExceptionDetector.isTransient(e)) {
break;
}
}
enqueueRetryEvent(new RetryEvent(this, retryState, re));
retryState.delayRetry();
} while (retryState.hasRetries());
throw re;
} | [
"public",
"V",
"action",
"(",
"Callable",
"<",
"V",
">",
"callable",
")",
"throws",
"Exception",
"{",
"Exception",
"re",
";",
"RetryState",
"retryState",
"=",
"retryStrategy",
".",
"getRetryState",
"(",
")",
";",
"do",
"{",
"try",
"{",
"return",
"callable"... | Perform the specified action under the defined retry semantics.
@param callable the action to perform under retry
@return the result of the action
@throws Exception inspect cause to determine reason, or interrupt status | [
"Perform",
"the",
"specified",
"action",
"under",
"the",
"defined",
"retry",
"semantics",
"."
] | 660137ac6226bc3dd1ee6544efa4a02be27aaa66 | https://github.com/rbuck/java-retry/blob/660137ac6226bc3dd1ee6544efa4a02be27aaa66/src/main/java/com/github/rbuck/retry/RetryPolicy.java#L35-L55 | train |
rbuck/java-retry | src/main/java/com/github/rbuck/retry/RetryPolicy.java | RetryPolicy.isInterruptTransitively | private boolean isInterruptTransitively(Throwable e) {
do {
if (e instanceof InterruptedException) {
return true;
}
e = e.getCause();
} while (e != null);
return false;
} | java | private boolean isInterruptTransitively(Throwable e) {
do {
if (e instanceof InterruptedException) {
return true;
}
e = e.getCause();
} while (e != null);
return false;
} | [
"private",
"boolean",
"isInterruptTransitively",
"(",
"Throwable",
"e",
")",
"{",
"do",
"{",
"if",
"(",
"e",
"instanceof",
"InterruptedException",
")",
"{",
"return",
"true",
";",
"}",
"e",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"while",
"(",
"... | Special case during shutdown.
@param e possible instance of, or has cause for, an InterruptedException
@return true if it is transitively an InterruptedException | [
"Special",
"case",
"during",
"shutdown",
"."
] | 660137ac6226bc3dd1ee6544efa4a02be27aaa66 | https://github.com/rbuck/java-retry/blob/660137ac6226bc3dd1ee6544efa4a02be27aaa66/src/main/java/com/github/rbuck/retry/RetryPolicy.java#L63-L71 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/RedisClient.java | RedisClient.getSet | public Object getSet(String key, Object value, Integer expiration) throws Exception {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
long begin = System.currentTimeMillis();
// 操作expire成功返回1,失败返回0,仅当均返回1时,实际操作成功
byte[] val = jedis.getSet(SafeEncoder.encode(key), serialize(value));
Object result = deserialize(val);
boolean success = true;
if (expiration > 0) {
Long res = jedis.expire(key, expiration);
if (res == 0L) {
success = false;
}
}
long end = System.currentTimeMillis();
if (success) {
logger.info("getset key:" + key + ", spends: " + (end - begin) + "ms");
} else {
logger.info("getset key: " + key + " failed, key has already exists! ");
}
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
} | java | public Object getSet(String key, Object value, Integer expiration) throws Exception {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
long begin = System.currentTimeMillis();
// 操作expire成功返回1,失败返回0,仅当均返回1时,实际操作成功
byte[] val = jedis.getSet(SafeEncoder.encode(key), serialize(value));
Object result = deserialize(val);
boolean success = true;
if (expiration > 0) {
Long res = jedis.expire(key, expiration);
if (res == 0L) {
success = false;
}
}
long end = System.currentTimeMillis();
if (success) {
logger.info("getset key:" + key + ", spends: " + (end - begin) + "ms");
} else {
logger.info("getset key: " + key + " failed, key has already exists! ");
}
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
} | [
"public",
"Object",
"getSet",
"(",
"String",
"key",
",",
"Object",
"value",
",",
"Integer",
"expiration",
")",
"throws",
"Exception",
"{",
"Jedis",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"this",
".",
"jedisPool",
".",
"getResource",
"(",
")... | get old value and set new value
@param key
@param value
@param expiration
@return false if redis did not execute the option
@throws Exception
@author wangchongjie | [
"get",
"old",
"value",
"and",
"set",
"new",
"value"
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/RedisClient.java#L162-L197 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/RedisClient.java | RedisClient.add | public boolean add(String key, Object value, Integer expiration) throws Exception {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
long begin = System.currentTimeMillis();
// 操作setnx与expire成功返回1,失败返回0,仅当均返回1时,实际操作成功
Long result = jedis.setnx(SafeEncoder.encode(key), serialize(value));
if (expiration > 0) {
result = result & jedis.expire(key, expiration);
}
long end = System.currentTimeMillis();
if (result == 1L) {
logger.info("add key:" + key + ", spends: " + (end - begin) + "ms");
} else {
logger.info("add key: " + key + " failed, key has already exists! ");
}
return result == 1L;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
} | java | public boolean add(String key, Object value, Integer expiration) throws Exception {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
long begin = System.currentTimeMillis();
// 操作setnx与expire成功返回1,失败返回0,仅当均返回1时,实际操作成功
Long result = jedis.setnx(SafeEncoder.encode(key), serialize(value));
if (expiration > 0) {
result = result & jedis.expire(key, expiration);
}
long end = System.currentTimeMillis();
if (result == 1L) {
logger.info("add key:" + key + ", spends: " + (end - begin) + "ms");
} else {
logger.info("add key: " + key + " failed, key has already exists! ");
}
return result == 1L;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
} | [
"public",
"boolean",
"add",
"(",
"String",
"key",
",",
"Object",
"value",
",",
"Integer",
"expiration",
")",
"throws",
"Exception",
"{",
"Jedis",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"this",
".",
"jedisPool",
".",
"getResource",
"(",
")",... | add if not exists
@param key
@param value
@param expiration
@return false if redis did not execute the option
@throws Exception | [
"add",
"if",
"not",
"exists"
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/RedisClient.java#L293-L322 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/RedisClient.java | RedisClient.exists | public boolean exists(String key) throws Exception {
boolean isExist = false;
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
isExist = jedis.exists(SafeEncoder.encode(key));
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return isExist;
} | java | public boolean exists(String key) throws Exception {
boolean isExist = false;
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
isExist = jedis.exists(SafeEncoder.encode(key));
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
throw e;
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return isExist;
} | [
"public",
"boolean",
"exists",
"(",
"String",
"key",
")",
"throws",
"Exception",
"{",
"boolean",
"isExist",
"=",
"false",
";",
"Jedis",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"this",
".",
"jedisPool",
".",
"getResource",
"(",
")",
";",
"i... | Test if the specified key exists.
@param key
@return
@throws Exception | [
"Test",
"if",
"the",
"specified",
"key",
"exists",
"."
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/RedisClient.java#L347-L364 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/RedisClient.java | RedisClient.delete | public boolean delete(String key) {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
jedis.del(SafeEncoder.encode(key));
logger.info("delete key:" + key);
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return false;
} | java | public boolean delete(String key) {
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
jedis.del(SafeEncoder.encode(key));
logger.info("delete key:" + key);
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return false;
} | [
"public",
"boolean",
"delete",
"(",
"String",
"key",
")",
"{",
"Jedis",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"this",
".",
"jedisPool",
".",
"getResource",
"(",
")",
";",
"jedis",
".",
"del",
"(",
"SafeEncoder",
".",
"encode",
"(",
"ke... | Remove the specified keys.
@param key
@return false if redis did not execute the option | [
"Remove",
"the",
"specified",
"keys",
"."
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/RedisClient.java#L373-L390 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/RedisClient.java | RedisClient.flushall | public boolean flushall() {
String result = "";
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
result = jedis.flushAll();
logger.info("redis client name: " + this.getCacheName() + " flushall.");
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return "OK".equalsIgnoreCase(result);
} | java | public boolean flushall() {
String result = "";
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
result = jedis.flushAll();
logger.info("redis client name: " + this.getCacheName() + " flushall.");
} catch (Exception e) {
logger.error(e.getMessage(), e);
this.jedisPool.returnBrokenResource(jedis);
} finally {
if (jedis != null) {
this.jedisPool.returnResource(jedis);
}
}
return "OK".equalsIgnoreCase(result);
} | [
"public",
"boolean",
"flushall",
"(",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"Jedis",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"this",
".",
"jedisPool",
".",
"getResource",
"(",
")",
";",
"result",
"=",
"jedis",
".",
"flushAll",
... | Delete all the keys of all the existing databases, not just the currently selected one.
@return false if redis did not execute the option | [
"Delete",
"all",
"the",
"keys",
"of",
"all",
"the",
"existing",
"databases",
"not",
"just",
"the",
"currently",
"selected",
"one",
"."
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/RedisClient.java#L423-L440 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/reflect/Property.java | Property.get | public Object get(Object obj) throws ReflectionException {
try {
if (isPublic(readMethod)) {
return readMethod.invoke(obj);
} else {
throw new ReflectionException("Cannot get the value of " + this + ", as it is write-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot get the value of " + this + " in object " + obj, e);
}
} | java | public Object get(Object obj) throws ReflectionException {
try {
if (isPublic(readMethod)) {
return readMethod.invoke(obj);
} else {
throw new ReflectionException("Cannot get the value of " + this + ", as it is write-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot get the value of " + this + " in object " + obj, e);
}
} | [
"public",
"Object",
"get",
"(",
"Object",
"obj",
")",
"throws",
"ReflectionException",
"{",
"try",
"{",
"if",
"(",
"isPublic",
"(",
"readMethod",
")",
")",
"{",
"return",
"readMethod",
".",
"invoke",
"(",
"obj",
")",
";",
"}",
"else",
"{",
"throw",
"ne... | Returns the value of the representation of this property from the specified object.
<p> The underlying property's value is obtained trying to invoke the {@code readMethod}.
<p> If this {@link Property} object has no public {@code readMethod},
it is considered write-only, and the action will be prevented throwing
a {@link ReflectionException}.
<p> The value is automatically wrapped in an object if it has a primitive type.
@param obj object from which the property's value is to be extracted
@return the value of the represented property in object {@code obj}
@throws ReflectionException if access to the underlying method throws an exception
@throws ReflectionException if this property is write-only (no public readMethod) | [
"Returns",
"the",
"value",
"of",
"the",
"representation",
"of",
"this",
"property",
"from",
"the",
"specified",
"object",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/reflect/Property.java#L403-L413 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/reflect/Property.java | Property.set | public void set(Object obj, Object value) throws ReflectionException {
try {
if (isPublic(writeMethod)) {
writeMethod.invoke(obj, value);
} else {
throw new ReflectionException("Cannot set the value of " + this + ", as it is read-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot set the value of " + this + " to object " + obj, e);
}
} | java | public void set(Object obj, Object value) throws ReflectionException {
try {
if (isPublic(writeMethod)) {
writeMethod.invoke(obj, value);
} else {
throw new ReflectionException("Cannot set the value of " + this + ", as it is read-only.");
}
} catch (Exception e) {
throw new ReflectionException("Cannot set the value of " + this + " to object " + obj, e);
}
} | [
"public",
"void",
"set",
"(",
"Object",
"obj",
",",
"Object",
"value",
")",
"throws",
"ReflectionException",
"{",
"try",
"{",
"if",
"(",
"isPublic",
"(",
"writeMethod",
")",
")",
"{",
"writeMethod",
".",
"invoke",
"(",
"obj",
",",
"value",
")",
";",
"}... | Sets a new value to the representation of this property on the specified object.
<p> The underlying property's value will be updated trying
to invoke the {@code writeMethod}.
<p> If this {@link Property} object has no public {@code writeMethod}, it is considered read-only,
and the action will be prevented throwing a {@link ReflectionException}.
<p>The new value is automatically unwrapped if the property has a primitive type.
@param obj the object whose property should be modified
@param value the new value for the property of {@code obj}, can be {@code null}
@throws ReflectionException if accessing to the underlying method throws an exception
@throws ReflectionException if this property is read-only (no public writeMethod) | [
"Sets",
"a",
"new",
"value",
"to",
"the",
"representation",
"of",
"this",
"property",
"on",
"the",
"specified",
"object",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/reflect/Property.java#L431-L441 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/TemporalTextField.java | TemporalTextField.getConverter | @SuppressWarnings("unchecked")
@Override
public <C> IConverter<C> getConverter(final Class<C> type)
{
if (Temporal.class.isAssignableFrom(type))
{
return (IConverter<C>)converter;
}
else
{
return super.getConverter(type);
}
} | java | @SuppressWarnings("unchecked")
@Override
public <C> IConverter<C> getConverter(final Class<C> type)
{
if (Temporal.class.isAssignableFrom(type))
{
return (IConverter<C>)converter;
}
else
{
return super.getConverter(type);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"<",
"C",
">",
"IConverter",
"<",
"C",
">",
"getConverter",
"(",
"final",
"Class",
"<",
"C",
">",
"type",
")",
"{",
"if",
"(",
"Temporal",
".",
"class",
".",
"isAssignableFrom... | Returns the default converter if created without pattern; otherwise it returns a
pattern-specific converter.
@param type
The type for which the convertor should work
@return A pattern-specific converter
@see org.apache.wicket.markup.html.form.TextField | [
"Returns",
"the",
"default",
"converter",
"if",
"created",
"without",
"pattern",
";",
"otherwise",
"it",
"returns",
"a",
"pattern",
"-",
"specific",
"converter",
"."
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/TemporalTextField.java#L111-L123 | train |
rbuck/java-retry | src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java | SqlTransientExceptionDetector.isSqlStateDuplicateValueInUniqueIndex | public static boolean isSqlStateDuplicateValueInUniqueIndex(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && (sqlState.equals("23505") || se.getMessage().contains("duplicate value in unique index"));
} | java | public static boolean isSqlStateDuplicateValueInUniqueIndex(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && (sqlState.equals("23505") || se.getMessage().contains("duplicate value in unique index"));
} | [
"public",
"static",
"boolean",
"isSqlStateDuplicateValueInUniqueIndex",
"(",
"SQLException",
"se",
")",
"{",
"String",
"sqlState",
"=",
"se",
".",
"getSQLState",
"(",
")",
";",
"return",
"sqlState",
"!=",
"null",
"&&",
"(",
"sqlState",
".",
"equals",
"(",
"\"2... | Determines if the SQL exception a duplicate value in unique index.
@param se the exception
@return true if it is a code 23505, otherwise false | [
"Determines",
"if",
"the",
"SQL",
"exception",
"a",
"duplicate",
"value",
"in",
"unique",
"index",
"."
] | 660137ac6226bc3dd1ee6544efa4a02be27aaa66 | https://github.com/rbuck/java-retry/blob/660137ac6226bc3dd1ee6544efa4a02be27aaa66/src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java#L51-L54 | train |
rbuck/java-retry | src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java | SqlTransientExceptionDetector.isSqlStateConnectionException | public static boolean isSqlStateConnectionException(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && sqlState.startsWith("08");
} | java | public static boolean isSqlStateConnectionException(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && sqlState.startsWith("08");
} | [
"public",
"static",
"boolean",
"isSqlStateConnectionException",
"(",
"SQLException",
"se",
")",
"{",
"String",
"sqlState",
"=",
"se",
".",
"getSQLState",
"(",
")",
";",
"return",
"sqlState",
"!=",
"null",
"&&",
"sqlState",
".",
"startsWith",
"(",
"\"08\"",
")"... | Determines if the SQL exception is a connection exception
@param se the exception
@return true if it is a code 08nnn, otherwise false | [
"Determines",
"if",
"the",
"SQL",
"exception",
"is",
"a",
"connection",
"exception"
] | 660137ac6226bc3dd1ee6544efa4a02be27aaa66 | https://github.com/rbuck/java-retry/blob/660137ac6226bc3dd1ee6544efa4a02be27aaa66/src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java#L62-L65 | train |
rbuck/java-retry | src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java | SqlTransientExceptionDetector.isSqlStateRollbackException | public static boolean isSqlStateRollbackException(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && sqlState.startsWith("40");
} | java | public static boolean isSqlStateRollbackException(SQLException se) {
String sqlState = se.getSQLState();
return sqlState != null && sqlState.startsWith("40");
} | [
"public",
"static",
"boolean",
"isSqlStateRollbackException",
"(",
"SQLException",
"se",
")",
"{",
"String",
"sqlState",
"=",
"se",
".",
"getSQLState",
"(",
")",
";",
"return",
"sqlState",
"!=",
"null",
"&&",
"sqlState",
".",
"startsWith",
"(",
"\"40\"",
")",
... | Determines if the SQL exception is a rollback exception
@param se the exception
@return true if it is a code 40nnn, otherwise false | [
"Determines",
"if",
"the",
"SQL",
"exception",
"is",
"a",
"rollback",
"exception"
] | 660137ac6226bc3dd1ee6544efa4a02be27aaa66 | https://github.com/rbuck/java-retry/blob/660137ac6226bc3dd1ee6544efa4a02be27aaa66/src/main/java/com/github/rbuck/retry/SqlTransientExceptionDetector.java#L73-L76 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java | DateUtils.getPreviousDay | public static Date getPreviousDay(Date dt) {
if (dt == null) {
return dt;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(Calendar.DAY_OF_YEAR, -1);
return cal.getTime();
} | java | public static Date getPreviousDay(Date dt) {
if (dt == null) {
return dt;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(Calendar.DAY_OF_YEAR, -1);
return cal.getTime();
} | [
"public",
"static",
"Date",
"getPreviousDay",
"(",
"Date",
"dt",
")",
"{",
"if",
"(",
"dt",
"==",
"null",
")",
"{",
"return",
"dt",
";",
"}",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"dt",
"... | added by zhuqian 2009-03-25 | [
"added",
"by",
"zhuqian",
"2009",
"-",
"03",
"-",
"25"
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java#L559-L568 | train |
knightliao/apollo | src/main/java/com/github/knightliao/apollo/redis/eviction/EvictionTimer.java | EvictionTimer.cancel | public static synchronized void cancel(TimerTask task) {
if (task == null) {
return;
}
task.cancel();
usageCount.decrementAndGet();
if (usageCount.get() == 0) {
timer.cancel();
timer = null;
}
} | java | public static synchronized void cancel(TimerTask task) {
if (task == null) {
return;
}
task.cancel();
usageCount.decrementAndGet();
if (usageCount.get() == 0) {
timer.cancel();
timer = null;
}
} | [
"public",
"static",
"synchronized",
"void",
"cancel",
"(",
"TimerTask",
"task",
")",
"{",
"if",
"(",
"task",
"==",
"null",
")",
"{",
"return",
";",
"}",
"task",
".",
"cancel",
"(",
")",
";",
"usageCount",
".",
"decrementAndGet",
"(",
")",
";",
"if",
... | Remove the specified eviction task from the timer.
@param task Task to be scheduled | [
"Remove",
"the",
"specified",
"eviction",
"task",
"from",
"the",
"timer",
"."
] | d7a283659fa3e67af6375db8969b2d065a8ce6eb | https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/redis/eviction/EvictionTimer.java#L45-L55 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java | DrawerManager.push | public void push(AbstractDrawer drawer, AjaxRequestTarget target, String cssClass) {
ListItem item = new ListItem("next", drawer, this, cssClass);
drawers.push(item);
if (first == null) {
first = item;
addOrReplace(first);
} else {
ListItem iter = first;
while (iter.next != null) {
iter = iter.next;
}
iter.add(item);
}
if (target!=null) {
target.add(item);
target.appendJavaScript("$('#"+item.item.getMarkupId()+"').modaldrawer('show');");
if (item.previous!=null) {
target.appendJavaScript("$('#"+item.previous.item.getMarkupId()+"').removeClass('shown-modal');");
target.appendJavaScript("$('#"+item.previous.item.getMarkupId()+"').addClass('hidden-modal');");
}
}
drawer.setManager(this);
} | java | public void push(AbstractDrawer drawer, AjaxRequestTarget target, String cssClass) {
ListItem item = new ListItem("next", drawer, this, cssClass);
drawers.push(item);
if (first == null) {
first = item;
addOrReplace(first);
} else {
ListItem iter = first;
while (iter.next != null) {
iter = iter.next;
}
iter.add(item);
}
if (target!=null) {
target.add(item);
target.appendJavaScript("$('#"+item.item.getMarkupId()+"').modaldrawer('show');");
if (item.previous!=null) {
target.appendJavaScript("$('#"+item.previous.item.getMarkupId()+"').removeClass('shown-modal');");
target.appendJavaScript("$('#"+item.previous.item.getMarkupId()+"').addClass('hidden-modal');");
}
}
drawer.setManager(this);
} | [
"public",
"void",
"push",
"(",
"AbstractDrawer",
"drawer",
",",
"AjaxRequestTarget",
"target",
",",
"String",
"cssClass",
")",
"{",
"ListItem",
"item",
"=",
"new",
"ListItem",
"(",
"\"next\"",
",",
"drawer",
",",
"this",
",",
"cssClass",
")",
";",
"drawers",... | Push and display a drawer on the page during an AJAX request,
and inject an optional CSS class onto the drawer's immediate container.
@param drawer
The drawer to be pushed. Cannot be null.
@param target
The current AJAX target.
@param cssClass
The name of the class to be injected. | [
"Push",
"and",
"display",
"a",
"drawer",
"on",
"the",
"page",
"during",
"an",
"AJAX",
"request",
"and",
"inject",
"an",
"optional",
"CSS",
"class",
"onto",
"the",
"drawer",
"s",
"immediate",
"container",
"."
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java#L158-L184 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java | DrawerManager.replaceLast | public void replaceLast(AbstractDrawer newDrawer, AjaxRequestTarget target) {
if (!drawers.isEmpty()) {
ListItem last = drawers.getFirst();
last.drawer.replaceWith(newDrawer);
last.drawer = newDrawer;
newDrawer.setManager(this);
target.add(newDrawer);
}
} | java | public void replaceLast(AbstractDrawer newDrawer, AjaxRequestTarget target) {
if (!drawers.isEmpty()) {
ListItem last = drawers.getFirst();
last.drawer.replaceWith(newDrawer);
last.drawer = newDrawer;
newDrawer.setManager(this);
target.add(newDrawer);
}
} | [
"public",
"void",
"replaceLast",
"(",
"AbstractDrawer",
"newDrawer",
",",
"AjaxRequestTarget",
"target",
")",
"{",
"if",
"(",
"!",
"drawers",
".",
"isEmpty",
"(",
")",
")",
"{",
"ListItem",
"last",
"=",
"drawers",
".",
"getFirst",
"(",
")",
";",
"last",
... | Replaces the topmost open drawer with a new one. If there is no open drawer, this method does nothing.
This method requires an AJAX request. DrawerManager does not support swapping drawers during page construction.
@param newDrawer
The new drawer to open. Cannot be null.
@param target
The current AJAX target. Cannot be null. | [
"Replaces",
"the",
"topmost",
"open",
"drawer",
"with",
"a",
"new",
"one",
".",
"If",
"there",
"is",
"no",
"open",
"drawer",
"this",
"method",
"does",
"nothing",
".",
"This",
"method",
"requires",
"an",
"AJAX",
"request",
".",
"DrawerManager",
"does",
"not... | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java#L220-L228 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java | DrawerManager.renderHead | @Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptHeaderItem.forReference(DRAWER_JAVASCRIPT));
response.render(JavaScriptHeaderItem.forReference(MANAGER_JAVASCRIPT));
response.render(CssHeaderItem.forReference(DRAWER_CSS));
Iterator<ListItem> iter = drawers.descendingIterator();
WebMarkupContainer drawer;
while (iter.hasNext()) {
drawer=iter.next().item;
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').modaldrawer('show');"));
if (drawers.getFirst().item.equals(drawer)) {
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').addClass('shown-modal');"));
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').removeClass('hidden-modal');"));
} else {
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').removeClass('shown-modal');"));
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').addClass('hidden-modal');"));
}
}
} | java | @Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptHeaderItem.forReference(DRAWER_JAVASCRIPT));
response.render(JavaScriptHeaderItem.forReference(MANAGER_JAVASCRIPT));
response.render(CssHeaderItem.forReference(DRAWER_CSS));
Iterator<ListItem> iter = drawers.descendingIterator();
WebMarkupContainer drawer;
while (iter.hasNext()) {
drawer=iter.next().item;
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').modaldrawer('show');"));
if (drawers.getFirst().item.equals(drawer)) {
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').addClass('shown-modal');"));
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').removeClass('hidden-modal');"));
} else {
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').removeClass('shown-modal');"));
response.render(OnDomReadyHeaderItem.forScript("$('#"+drawer.getMarkupId()+"').addClass('hidden-modal');"));
}
}
} | [
"@",
"Override",
"public",
"void",
"renderHead",
"(",
"IHeaderResponse",
"response",
")",
"{",
"super",
".",
"renderHead",
"(",
"response",
")",
";",
"response",
".",
"render",
"(",
"JavaScriptHeaderItem",
".",
"forReference",
"(",
"DRAWER_JAVASCRIPT",
")",
")",... | pressing the Back button and landing on a page with open drawers. | [
"pressing",
"the",
"Back",
"button",
"and",
"landing",
"on",
"a",
"page",
"with",
"open",
"drawers",
"."
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/drawer/DrawerManager.java#L309-L330 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/ObjectWrapper.java | ObjectWrapper.setWrappedObject | public void setWrappedObject(Object obj) {
if (obj == null) {
throw new IllegalArgumentException("Cannot warp a 'null' object.");
}
this.object = obj;
this.bean = Bean.forClass(obj.getClass());
} | java | public void setWrappedObject(Object obj) {
if (obj == null) {
throw new IllegalArgumentException("Cannot warp a 'null' object.");
}
this.object = obj;
this.bean = Bean.forClass(obj.getClass());
} | [
"public",
"void",
"setWrappedObject",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot warp a 'null' object.\"",
")",
";",
"}",
"this",
".",
"object",
"=",
"obj",
";",
"this"... | Changes, at any time, the wrapped object with a new object.
@param obj the new object to wrap
@throws IllegalArgumentException if the obj parameter is {@code null} | [
"Changes",
"at",
"any",
"time",
"the",
"wrapped",
"object",
"with",
"a",
"new",
"object",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/ObjectWrapper.java#L91-L98 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/ObjectWrapper.java | ObjectWrapper.getIndexedValue | public Object getIndexedValue(String propertyName, int index) {
return getIndexedValue(object, getPropertyOrThrow(bean, propertyName), index, this);
} | java | public Object getIndexedValue(String propertyName, int index) {
return getIndexedValue(object, getPropertyOrThrow(bean, propertyName), index, this);
} | [
"public",
"Object",
"getIndexedValue",
"(",
"String",
"propertyName",
",",
"int",
"index",
")",
"{",
"return",
"getIndexedValue",
"(",
"object",
",",
"getPropertyOrThrow",
"(",
"bean",
",",
"propertyName",
")",
",",
"index",
",",
"this",
")",
";",
"}"
] | Returns the value of the specified indexed property from the wrapped object.
@param propertyName the name of the indexed property whose value is to be extracted, cannot be {@code null}
@param index the index of the property value to be extracted
@return the indexed property value
@throws ReflectionException if a reflection error occurs
@throws IllegalArgumentException if the propertyName parameter is {@code null}
@throws IllegalArgumentException if the indexed object in the wrapped object is not a {@link List}, {@link Iterable} or {@code array}
@throws NullPointerException if the indexed {@link List}, {@link Iterable} or {@code array} is {@code null} in the given object
@throws NullPointerException if the wrapped object does not have a property with the given name
@throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying indexed property | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"indexed",
"property",
"from",
"the",
"wrapped",
"object",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/ObjectWrapper.java#L237-L239 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/beans/ObjectWrapper.java | ObjectWrapper.setSimpleValue | public void setSimpleValue(String propertyName, Object value) {
setSimpleValue(object, getPropertyOrThrow(bean, propertyName), value);
} | java | public void setSimpleValue(String propertyName, Object value) {
setSimpleValue(object, getPropertyOrThrow(bean, propertyName), value);
} | [
"public",
"void",
"setSimpleValue",
"(",
"String",
"propertyName",
",",
"Object",
"value",
")",
"{",
"setSimpleValue",
"(",
"object",
",",
"getPropertyOrThrow",
"(",
"bean",
",",
"propertyName",
")",
",",
"value",
")",
";",
"}"
] | Sets the value of the specified property in the wrapped object.
@param propertyName the name of the simple property whose value is to be updated, cannot be {@code null}
@param value the value to set, can be {@code null}
@throws IllegalArgumentException if the property parameter is {@code null}
@throws NullPointerException if the wrapped object does not have a property with the given name | [
"Sets",
"the",
"value",
"of",
"the",
"specified",
"property",
"in",
"the",
"wrapped",
"object",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/beans/ObjectWrapper.java#L314-L316 | train |
davidmarquis/fluent-interface-proxy | src/main/java/com/fluentinterface/utils/TypeConversionUtils.java | TypeConversionUtils.translateFromPrimitive | public static Class<?> translateFromPrimitive(Class<?> paramType) {
if (paramType == int.class) {
return Integer.class;
} else if (paramType == char.class) {
return Character.class;
} else if (paramType == byte.class) {
return Byte.class;
} else if (paramType == long.class) {
return Long.class;
} else if (paramType == short.class) {
return Short.class;
} else if (paramType == boolean.class) {
return Boolean.class;
} else if (paramType == double.class) {
return Double.class;
} else if (paramType == float.class) {
return Float.class;
} else {
return paramType;
}
} | java | public static Class<?> translateFromPrimitive(Class<?> paramType) {
if (paramType == int.class) {
return Integer.class;
} else if (paramType == char.class) {
return Character.class;
} else if (paramType == byte.class) {
return Byte.class;
} else if (paramType == long.class) {
return Long.class;
} else if (paramType == short.class) {
return Short.class;
} else if (paramType == boolean.class) {
return Boolean.class;
} else if (paramType == double.class) {
return Double.class;
} else if (paramType == float.class) {
return Float.class;
} else {
return paramType;
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"translateFromPrimitive",
"(",
"Class",
"<",
"?",
">",
"paramType",
")",
"{",
"if",
"(",
"paramType",
"==",
"int",
".",
"class",
")",
"{",
"return",
"Integer",
".",
"class",
";",
"}",
"else",
"if",
"(",
"pa... | From a primitive type class, tries to return the corresponding wrapper class.
@param paramType a primitive type (ex: int, short, float, etc.) to convert
@return the corresponding wrapper class for the type, or the type itself if not a known primitive. | [
"From",
"a",
"primitive",
"type",
"class",
"tries",
"to",
"return",
"the",
"corresponding",
"wrapper",
"class",
"."
] | 8e72fff6cd1f496c76a01773269caead994fea65 | https://github.com/davidmarquis/fluent-interface-proxy/blob/8e72fff6cd1f496c76a01773269caead994fea65/src/main/java/com/fluentinterface/utils/TypeConversionUtils.java#L10-L31 | train |
premium-minds/pm-wicket-utils | src/main/java/com/premiumminds/webapp/wicket/repeaters/AbstractRepeater2.java | AbstractRepeater2.onRender | @Override
protected final void onRender()
{
Iterator<? extends Component> it = renderIterator();
while (it.hasNext())
{
Component child = it.next();
if (child == null)
{
throw new IllegalStateException(
"The render iterator returned null for a child. Container: " + this.toString() +
"; Iterator=" + it.toString());
}
renderChild(child);
}
} | java | @Override
protected final void onRender()
{
Iterator<? extends Component> it = renderIterator();
while (it.hasNext())
{
Component child = it.next();
if (child == null)
{
throw new IllegalStateException(
"The render iterator returned null for a child. Container: " + this.toString() +
"; Iterator=" + it.toString());
}
renderChild(child);
}
} | [
"@",
"Override",
"protected",
"final",
"void",
"onRender",
"(",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"Component",
">",
"it",
"=",
"renderIterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Component",
"child",
"=",
... | Renders all child items in no specified order | [
"Renders",
"all",
"child",
"items",
"in",
"no",
"specified",
"order"
] | ed28f4bfb2084dfb2649d9fa283754cb76894d2d | https://github.com/premium-minds/pm-wicket-utils/blob/ed28f4bfb2084dfb2649d9fa283754cb76894d2d/src/main/java/com/premiumminds/webapp/wicket/repeaters/AbstractRepeater2.java#L81-L96 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java | TSDataScanDir.metadata_end_cmp_ | private static int metadata_end_cmp_(MetaData x, MetaData y) {
return x.getEnd().compareTo(y.getEnd());
} | java | private static int metadata_end_cmp_(MetaData x, MetaData y) {
return x.getEnd().compareTo(y.getEnd());
} | [
"private",
"static",
"int",
"metadata_end_cmp_",
"(",
"MetaData",
"x",
",",
"MetaData",
"y",
")",
"{",
"return",
"x",
".",
"getEnd",
"(",
")",
".",
"compareTo",
"(",
"y",
".",
"getEnd",
"(",
")",
")",
";",
"}"
] | Comparator, in order to sort MetaData based on the end timestamp.
@param x One of the MetaData to compare.
@param y Another one of the MetaData to compare.
@return Comparator result. | [
"Comparator",
"in",
"order",
"to",
"sort",
"MetaData",
"based",
"on",
"the",
"end",
"timestamp",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java#L186-L188 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java | TSDataScanDir.file_listing_ | private static List<Path> file_listing_(Path dir) throws IOException {
try (Stream<Path> files = Files.list(dir)) {
return files.collect(Collectors.toList());
}
} | java | private static List<Path> file_listing_(Path dir) throws IOException {
try (Stream<Path> files = Files.list(dir)) {
return files.collect(Collectors.toList());
}
} | [
"private",
"static",
"List",
"<",
"Path",
">",
"file_listing_",
"(",
"Path",
"dir",
")",
"throws",
"IOException",
"{",
"try",
"(",
"Stream",
"<",
"Path",
">",
"files",
"=",
"Files",
".",
"list",
"(",
"dir",
")",
")",
"{",
"return",
"files",
".",
"col... | Scan a directory for files. This method reads the entire stream and
closes it immediately.
@param dir The directory to scan for files.
@throws IOException if the directory cannot be listed. | [
"Scan",
"a",
"directory",
"for",
"files",
".",
"This",
"method",
"reads",
"the",
"entire",
"stream",
"and",
"closes",
"it",
"immediately",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java#L208-L212 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java | TSDataScanDir.filterUpgradable | public TSDataScanDir filterUpgradable() {
return new TSDataScanDir(getDir(), getFiles().stream().filter(MetaData::isUpgradable).collect(Collectors.toList()));
} | java | public TSDataScanDir filterUpgradable() {
return new TSDataScanDir(getDir(), getFiles().stream().filter(MetaData::isUpgradable).collect(Collectors.toList()));
} | [
"public",
"TSDataScanDir",
"filterUpgradable",
"(",
")",
"{",
"return",
"new",
"TSDataScanDir",
"(",
"getDir",
"(",
")",
",",
"getFiles",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"MetaData",
"::",
"isUpgradable",
")",
".",
"collect",
"(",
"... | Filter the list of files to contain only upgradable files.
Note that the current instance is untouched and a new instance is
returned.
@return A new instance of TSDataScanDir, describing only files that are
upgradable. | [
"Filter",
"the",
"list",
"of",
"files",
"to",
"contain",
"only",
"upgradable",
"files",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataScanDir.java#L251-L253 | train |
threerings/nenya | core/src/main/java/com/threerings/media/animation/ExplodeAnimation.java | ExplodeAnimation.init | protected void init (ExplodeInfo info, int x, int y, int width, int height)
{
_info = info;
_ox = x;
_oy = y;
_owid = width;
_ohei = height;
_info.rvel = (float)((2.0f * Math.PI) * _info.rvel);
_chunkcount = (_info.xchunk * _info.ychunk);
_cxpos = new int[_chunkcount];
_cypos = new int[_chunkcount];
_sxvel = new float[_chunkcount];
_syvel = new float[_chunkcount];
// determine chunk dimensions
_cwid = _owid / _info.xchunk;
_chei = _ohei / _info.ychunk;
_hcwid = _cwid / 2;
_hchei = _chei / 2;
// initialize all chunks
for (int ii = 0; ii < _chunkcount; ii++) {
// initialize chunk position
int xpos = ii % _info.xchunk;
int ypos = ii / _info.xchunk;
_cxpos[ii] = _ox + (xpos * _cwid);
_cypos[ii] = _oy + (ypos * _chei);
// initialize chunk velocity
_sxvel[ii] = RandomUtil.getFloat(_info.xvel) *
((xpos < (_info.xchunk / 2)) ? -1.0f : 1.0f);
_syvel[ii] = -(RandomUtil.getFloat(_info.yvel));
}
// initialize the chunk rotation angle
_angle = 0.0f;
} | java | protected void init (ExplodeInfo info, int x, int y, int width, int height)
{
_info = info;
_ox = x;
_oy = y;
_owid = width;
_ohei = height;
_info.rvel = (float)((2.0f * Math.PI) * _info.rvel);
_chunkcount = (_info.xchunk * _info.ychunk);
_cxpos = new int[_chunkcount];
_cypos = new int[_chunkcount];
_sxvel = new float[_chunkcount];
_syvel = new float[_chunkcount];
// determine chunk dimensions
_cwid = _owid / _info.xchunk;
_chei = _ohei / _info.ychunk;
_hcwid = _cwid / 2;
_hchei = _chei / 2;
// initialize all chunks
for (int ii = 0; ii < _chunkcount; ii++) {
// initialize chunk position
int xpos = ii % _info.xchunk;
int ypos = ii / _info.xchunk;
_cxpos[ii] = _ox + (xpos * _cwid);
_cypos[ii] = _oy + (ypos * _chei);
// initialize chunk velocity
_sxvel[ii] = RandomUtil.getFloat(_info.xvel) *
((xpos < (_info.xchunk / 2)) ? -1.0f : 1.0f);
_syvel[ii] = -(RandomUtil.getFloat(_info.yvel));
}
// initialize the chunk rotation angle
_angle = 0.0f;
} | [
"protected",
"void",
"init",
"(",
"ExplodeInfo",
"info",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"_info",
"=",
"info",
";",
"_ox",
"=",
"x",
";",
"_oy",
"=",
"y",
";",
"_owid",
"=",
"width",
";",
"... | Initializes the animation with the attributes of the given explode info object. | [
"Initializes",
"the",
"animation",
"with",
"the",
"attributes",
"of",
"the",
"given",
"explode",
"info",
"object",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/ExplodeAnimation.java#L112-L149 | train |
groupon/monsoon | intf/src/main/java/com/groupon/lex/metrics/MetricValue.java | MetricValue.fromNumberValue | public static MetricValue fromNumberValue(Number number) {
if (number == null) {
return EMPTY;
} else if (number instanceof Float || number instanceof Double) {
return fromDblValue(number.doubleValue());
} else if (number instanceof Byte || number instanceof Short || number instanceof Integer || number instanceof Long) {
return fromIntValue(number.longValue());
} else {
throw new IllegalArgumentException("Unrecognized number type: " + number.getClass());
}
} | java | public static MetricValue fromNumberValue(Number number) {
if (number == null) {
return EMPTY;
} else if (number instanceof Float || number instanceof Double) {
return fromDblValue(number.doubleValue());
} else if (number instanceof Byte || number instanceof Short || number instanceof Integer || number instanceof Long) {
return fromIntValue(number.longValue());
} else {
throw new IllegalArgumentException("Unrecognized number type: " + number.getClass());
}
} | [
"public",
"static",
"MetricValue",
"fromNumberValue",
"(",
"Number",
"number",
")",
"{",
"if",
"(",
"number",
"==",
"null",
")",
"{",
"return",
"EMPTY",
";",
"}",
"else",
"if",
"(",
"number",
"instanceof",
"Float",
"||",
"number",
"instanceof",
"Double",
"... | Construct a metric value from a Number implementation.
@param number A floating point or integral type.
@return a MetricValue holding the specified number.
@throws IllegalArgumentException if the derived type of Number is not recognized. | [
"Construct",
"a",
"metric",
"value",
"from",
"a",
"Number",
"implementation",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/MetricValue.java#L75-L85 | train |
threerings/nenya | core/src/main/java/com/threerings/media/animation/AnimationArranger.java | AnimationArranger.positionAvoidAnimation | public void positionAvoidAnimation (Animation anim, Rectangle viewBounds)
{
Rectangle abounds = new Rectangle(anim.getBounds());
@SuppressWarnings("unchecked") ArrayList<Animation> avoidables =
(ArrayList<Animation>) _avoidAnims.clone();
// if we are able to place it somewhere, do so
if (SwingUtil.positionRect(abounds, viewBounds, avoidables)) {
anim.setLocation(abounds.x, abounds.y);
}
// add the animation to the list of avoidables
_avoidAnims.add(anim);
// keep an eye on it so that we can remove it when it's finished
anim.addAnimationObserver(_avoidAnimObs);
} | java | public void positionAvoidAnimation (Animation anim, Rectangle viewBounds)
{
Rectangle abounds = new Rectangle(anim.getBounds());
@SuppressWarnings("unchecked") ArrayList<Animation> avoidables =
(ArrayList<Animation>) _avoidAnims.clone();
// if we are able to place it somewhere, do so
if (SwingUtil.positionRect(abounds, viewBounds, avoidables)) {
anim.setLocation(abounds.x, abounds.y);
}
// add the animation to the list of avoidables
_avoidAnims.add(anim);
// keep an eye on it so that we can remove it when it's finished
anim.addAnimationObserver(_avoidAnimObs);
} | [
"public",
"void",
"positionAvoidAnimation",
"(",
"Animation",
"anim",
",",
"Rectangle",
"viewBounds",
")",
"{",
"Rectangle",
"abounds",
"=",
"new",
"Rectangle",
"(",
"anim",
".",
"getBounds",
"(",
")",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
"... | Position the specified animation so that it is not overlapping
any still-running animations previously passed to this method. | [
"Position",
"the",
"specified",
"animation",
"so",
"that",
"it",
"is",
"not",
"overlapping",
"any",
"still",
"-",
"running",
"animations",
"previously",
"passed",
"to",
"this",
"method",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/AnimationArranger.java#L41-L55 | train |
threerings/nenya | core/src/main/java/com/threerings/media/RegionManager.java | RegionManager.invalidateRegion | public void invalidateRegion (int x, int y, int width, int height)
{
if (isValidSize(width, height)) {
addDirtyRegion(new Rectangle(x, y, width, height));
}
} | java | public void invalidateRegion (int x, int y, int width, int height)
{
if (isValidSize(width, height)) {
addDirtyRegion(new Rectangle(x, y, width, height));
}
} | [
"public",
"void",
"invalidateRegion",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"if",
"(",
"isValidSize",
"(",
"width",
",",
"height",
")",
")",
"{",
"addDirtyRegion",
"(",
"new",
"Rectangle",
"(",
"x",
",... | Invalidates the specified region. | [
"Invalidates",
"the",
"specified",
"region",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/RegionManager.java#L40-L45 | train |
threerings/nenya | core/src/main/java/com/threerings/media/RegionManager.java | RegionManager.isValidSize | protected final boolean isValidSize (int width, int height)
{
if (width < 0 || height < 0) {
log.warning("Attempt to add invalid dirty region?!",
"size", (width + "x" + height), new Exception());
return false;
} else if (width == 0 || height == 0) {
// no need to complain about zero sized rectangles, just ignore them
return false;
} else {
return true;
}
} | java | protected final boolean isValidSize (int width, int height)
{
if (width < 0 || height < 0) {
log.warning("Attempt to add invalid dirty region?!",
"size", (width + "x" + height), new Exception());
return false;
} else if (width == 0 || height == 0) {
// no need to complain about zero sized rectangles, just ignore them
return false;
} else {
return true;
}
} | [
"protected",
"final",
"boolean",
"isValidSize",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"if",
"(",
"width",
"<",
"0",
"||",
"height",
"<",
"0",
")",
"{",
"log",
".",
"warning",
"(",
"\"Attempt to add invalid dirty region?!\"",
",",
"\"size\"",
... | Used to ensure our dirty regions are not invalid. | [
"Used",
"to",
"ensure",
"our",
"dirty",
"regions",
"are",
"not",
"invalid",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/RegionManager.java#L90-L104 | train |
threerings/nenya | core/src/main/java/com/threerings/media/RegionManager.java | RegionManager.getDirtyRegions | public Rectangle[] getDirtyRegions ()
{
List<Rectangle> merged = Lists.newArrayList();
for (int ii = _dirty.size() - 1; ii >= 0; ii--) {
// pop the next rectangle from the dirty list
Rectangle mr = _dirty.remove(ii);
// merge in any overlapping rectangles
for (int jj = ii - 1; jj >= 0; jj--) {
Rectangle r = _dirty.get(jj);
if (mr.intersects(r)) {
// remove the overlapping rectangle from the list
_dirty.remove(jj);
ii--;
// grow the merged dirty rectangle
mr.add(r);
}
}
// add the merged rectangle to the list
merged.add(mr);
}
return merged.toArray(new Rectangle[merged.size()]);
} | java | public Rectangle[] getDirtyRegions ()
{
List<Rectangle> merged = Lists.newArrayList();
for (int ii = _dirty.size() - 1; ii >= 0; ii--) {
// pop the next rectangle from the dirty list
Rectangle mr = _dirty.remove(ii);
// merge in any overlapping rectangles
for (int jj = ii - 1; jj >= 0; jj--) {
Rectangle r = _dirty.get(jj);
if (mr.intersects(r)) {
// remove the overlapping rectangle from the list
_dirty.remove(jj);
ii--;
// grow the merged dirty rectangle
mr.add(r);
}
}
// add the merged rectangle to the list
merged.add(mr);
}
return merged.toArray(new Rectangle[merged.size()]);
} | [
"public",
"Rectangle",
"[",
"]",
"getDirtyRegions",
"(",
")",
"{",
"List",
"<",
"Rectangle",
">",
"merged",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"_dirty",
".",
"size",
"(",
")",
"-",
"1",
";",
"ii",
">=",
... | Merges all outstanding dirty regions into a single list of rectangles and returns that to
the caller. Internally, the list of accumulated dirty regions is cleared out and prepared
for the next frame. | [
"Merges",
"all",
"outstanding",
"dirty",
"regions",
"into",
"a",
"single",
"list",
"of",
"rectangles",
"and",
"returns",
"that",
"to",
"the",
"caller",
".",
"Internally",
"the",
"list",
"of",
"accumulated",
"dirty",
"regions",
"is",
"cleared",
"out",
"and",
... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/RegionManager.java#L130-L155 | train |
groupon/monsoon | intf/src/main/java/com/groupon/lex/metrics/lib/StringTemplate.java | StringTemplate.getArguments | public List<Any2<Integer, String>> getArguments() {
final List<Any2<Integer, String>> result = new ArrayList<>();
elements_.forEach(elem -> elem.keys(result::add));
return result;
} | java | public List<Any2<Integer, String>> getArguments() {
final List<Any2<Integer, String>> result = new ArrayList<>();
elements_.forEach(elem -> elem.keys(result::add));
return result;
} | [
"public",
"List",
"<",
"Any2",
"<",
"Integer",
",",
"String",
">",
">",
"getArguments",
"(",
")",
"{",
"final",
"List",
"<",
"Any2",
"<",
"Integer",
",",
"String",
">",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"elements_",
".",
... | Retrieve the variables used to render this string.
@return The list of variables used to render this string. | [
"Retrieve",
"the",
"variables",
"used",
"to",
"render",
"this",
"string",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/lib/StringTemplate.java#L210-L214 | train |
threerings/nenya | core/src/main/java/com/threerings/media/tile/TrimmedObjectTileSet.java | TrimmedObjectTileSet.hasConstraint | public boolean hasConstraint (int tileIdx, String constraint)
{
return (_bits == null || _bits[tileIdx].constraints == null) ? false :
ListUtil.contains(_bits[tileIdx].constraints, constraint);
} | java | public boolean hasConstraint (int tileIdx, String constraint)
{
return (_bits == null || _bits[tileIdx].constraints == null) ? false :
ListUtil.contains(_bits[tileIdx].constraints, constraint);
} | [
"public",
"boolean",
"hasConstraint",
"(",
"int",
"tileIdx",
",",
"String",
"constraint",
")",
"{",
"return",
"(",
"_bits",
"==",
"null",
"||",
"_bits",
"[",
"tileIdx",
"]",
".",
"constraints",
"==",
"null",
")",
"?",
"false",
":",
"ListUtil",
".",
"cont... | Checks whether the tile at the specified index has the given constraint. | [
"Checks",
"whether",
"the",
"tile",
"at",
"the",
"specified",
"index",
"has",
"the",
"given",
"constraint",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/TrimmedObjectTileSet.java#L96-L100 | train |
threerings/nenya | core/src/main/java/com/threerings/media/tile/TrimmedObjectTileSet.java | TrimmedObjectTileSet.trimObjectTileSet | public static TrimmedObjectTileSet trimObjectTileSet (
ObjectTileSet source, OutputStream destImage)
throws IOException
{
return trimObjectTileSet(source, destImage, FastImageIO.FILE_SUFFIX);
} | java | public static TrimmedObjectTileSet trimObjectTileSet (
ObjectTileSet source, OutputStream destImage)
throws IOException
{
return trimObjectTileSet(source, destImage, FastImageIO.FILE_SUFFIX);
} | [
"public",
"static",
"TrimmedObjectTileSet",
"trimObjectTileSet",
"(",
"ObjectTileSet",
"source",
",",
"OutputStream",
"destImage",
")",
"throws",
"IOException",
"{",
"return",
"trimObjectTileSet",
"(",
"source",
",",
"destImage",
",",
"FastImageIO",
".",
"FILE_SUFFIX",
... | Convenience function to trim the tile set to a file using FastImageIO. | [
"Convenience",
"function",
"to",
"trim",
"the",
"tile",
"set",
"to",
"a",
"file",
"using",
"FastImageIO",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/TrimmedObjectTileSet.java#L174-L179 | train |
threerings/nenya | core/src/main/java/com/threerings/media/AbstractMedia.java | AbstractMedia.renderCompareTo | public int renderCompareTo (AbstractMedia other)
{
int result = Ints.compare(_renderOrder, other._renderOrder);
return (result != 0) ? result : naturalCompareTo(other);
} | java | public int renderCompareTo (AbstractMedia other)
{
int result = Ints.compare(_renderOrder, other._renderOrder);
return (result != 0) ? result : naturalCompareTo(other);
} | [
"public",
"int",
"renderCompareTo",
"(",
"AbstractMedia",
"other",
")",
"{",
"int",
"result",
"=",
"Ints",
".",
"compare",
"(",
"_renderOrder",
",",
"other",
".",
"_renderOrder",
")",
";",
"return",
"(",
"result",
"!=",
"0",
")",
"?",
"result",
":",
"nat... | Compares this media to the specified media by render order. | [
"Compares",
"this",
"media",
"to",
"the",
"specified",
"media",
"by",
"render",
"order",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMedia.java#L167-L171 | train |
threerings/nenya | core/src/main/java/com/threerings/media/AbstractMedia.java | AbstractMedia.queueNotification | public void queueNotification (ObserverList.ObserverOp<Object> amop)
{
if (_observers != null) {
if (_mgr != null) {
_mgr.queueNotification(_observers, amop);
} else {
log.warning("Have no manager, dropping notification", "media", this, "op", amop);
}
}
} | java | public void queueNotification (ObserverList.ObserverOp<Object> amop)
{
if (_observers != null) {
if (_mgr != null) {
_mgr.queueNotification(_observers, amop);
} else {
log.warning("Have no manager, dropping notification", "media", this, "op", amop);
}
}
} | [
"public",
"void",
"queueNotification",
"(",
"ObserverList",
".",
"ObserverOp",
"<",
"Object",
">",
"amop",
")",
"{",
"if",
"(",
"_observers",
"!=",
"null",
")",
"{",
"if",
"(",
"_mgr",
"!=",
"null",
")",
"{",
"_mgr",
".",
"queueNotification",
"(",
"_obse... | Queues the supplied notification up to be dispatched to this abstract media's observers. | [
"Queues",
"the",
"supplied",
"notification",
"up",
"to",
"be",
"dispatched",
"to",
"this",
"abstract",
"media",
"s",
"observers",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMedia.java#L205-L214 | train |
threerings/nenya | core/src/main/java/com/threerings/media/AbstractMedia.java | AbstractMedia.addObserver | protected void addObserver (Object obs)
{
if (_observers == null) {
_observers = ObserverList.newFastUnsafe();
}
_observers.add(obs);
} | java | protected void addObserver (Object obs)
{
if (_observers == null) {
_observers = ObserverList.newFastUnsafe();
}
_observers.add(obs);
} | [
"protected",
"void",
"addObserver",
"(",
"Object",
"obs",
")",
"{",
"if",
"(",
"_observers",
"==",
"null",
")",
"{",
"_observers",
"=",
"ObserverList",
".",
"newFastUnsafe",
"(",
")",
";",
"}",
"_observers",
".",
"add",
"(",
"obs",
")",
";",
"}"
] | Add the specified observer to this media element. | [
"Add",
"the",
"specified",
"observer",
"to",
"this",
"media",
"element",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMedia.java#L314-L320 | train |
kaazing/java.client | bridge/src/main/java/org/kaazing/gateway/bridge/CrossOriginProxy.java | CrossOriginProxy.dispatchEvent | private void dispatchEvent(XoaEvent event) {
LOG.entering(CLASS_NAME, "dispatchEvent", event);
try {
Integer handlerId = event.getHandlerId();
XoaEventKind eventKind = event.getEvent();
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("XOA --> SOA: " + handlerId + " event: " + eventKind.name());
}
BridgeDelegate handler = xoaObjectMap.get(handlerId);
if (handler == null) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("No handler for handler id: " + handlerId);
}
return;
}
/* Allow only one bridge crossing per handler at a time */
synchronized (handler) {
// dispatch to SOA
Object[] args = { handlerId, eventKind.toString(), event.getParams() };
firePropertyChange(XOP_MESSAGE, null, args);
}
} catch (Exception e) {
LOG.log(Level.FINE, "While dispatching event: "+e.getMessage(), e);
throw new IllegalStateException("Unable to dispatch an event from the cross origin proxy", e);
}
} | java | private void dispatchEvent(XoaEvent event) {
LOG.entering(CLASS_NAME, "dispatchEvent", event);
try {
Integer handlerId = event.getHandlerId();
XoaEventKind eventKind = event.getEvent();
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("XOA --> SOA: " + handlerId + " event: " + eventKind.name());
}
BridgeDelegate handler = xoaObjectMap.get(handlerId);
if (handler == null) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("No handler for handler id: " + handlerId);
}
return;
}
/* Allow only one bridge crossing per handler at a time */
synchronized (handler) {
// dispatch to SOA
Object[] args = { handlerId, eventKind.toString(), event.getParams() };
firePropertyChange(XOP_MESSAGE, null, args);
}
} catch (Exception e) {
LOG.log(Level.FINE, "While dispatching event: "+e.getMessage(), e);
throw new IllegalStateException("Unable to dispatch an event from the cross origin proxy", e);
}
} | [
"private",
"void",
"dispatchEvent",
"(",
"XoaEvent",
"event",
")",
"{",
"LOG",
".",
"entering",
"(",
"CLASS_NAME",
",",
"\"dispatchEvent\"",
",",
"event",
")",
";",
"try",
"{",
"Integer",
"handlerId",
"=",
"event",
".",
"getHandlerId",
"(",
")",
";",
"XoaE... | Dispatch an event to Source Origin
@param event | [
"Dispatch",
"an",
"event",
"to",
"Source",
"Origin"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/bridge/src/main/java/org/kaazing/gateway/bridge/CrossOriginProxy.java#L140-L171 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/BobblePath.java | BobblePath.setVariance | public void setVariance (int dx, int dy)
{
if ((dx < 0) || (dy < 0) || ((dx == 0) && (dy == 0))) {
throw new IllegalArgumentException(
"Variance values must be positive, and at least one must be non-zero.");
} else {
_dx = dx;
_dy = dy;
}
} | java | public void setVariance (int dx, int dy)
{
if ((dx < 0) || (dy < 0) || ((dx == 0) && (dy == 0))) {
throw new IllegalArgumentException(
"Variance values must be positive, and at least one must be non-zero.");
} else {
_dx = dx;
_dy = dy;
}
} | [
"public",
"void",
"setVariance",
"(",
"int",
"dx",
",",
"int",
"dy",
")",
"{",
"if",
"(",
"(",
"dx",
"<",
"0",
")",
"||",
"(",
"dy",
"<",
"0",
")",
"||",
"(",
"(",
"dx",
"==",
"0",
")",
"&&",
"(",
"dy",
"==",
"0",
")",
")",
")",
"{",
"t... | Set the variance of bobblin' in each direction. | [
"Set",
"the",
"variance",
"of",
"bobblin",
"in",
"each",
"direction",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/BobblePath.java#L62-L71 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/BobblePath.java | BobblePath.updatePositionTo | protected boolean updatePositionTo (Pathable pable, int x, int y)
{
if ((pable.getX() == x) && (pable.getY() == y)) {
return false;
} else {
pable.setLocation(x, y);
return true;
}
} | java | protected boolean updatePositionTo (Pathable pable, int x, int y)
{
if ((pable.getX() == x) && (pable.getY() == y)) {
return false;
} else {
pable.setLocation(x, y);
return true;
}
} | [
"protected",
"boolean",
"updatePositionTo",
"(",
"Pathable",
"pable",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"(",
"pable",
".",
"getX",
"(",
")",
"==",
"x",
")",
"&&",
"(",
"pable",
".",
"getY",
"(",
")",
"==",
"y",
")",
")",
"{... | Update the position of the pathable or return false if it's already there. | [
"Update",
"the",
"position",
"of",
"the",
"pathable",
"or",
"return",
"false",
"if",
"it",
"s",
"already",
"there",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/BobblePath.java#L156-L164 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/ModeUtil.java | ModeUtil.getDisplayMode | public static DisplayMode getDisplayMode (
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth)
{
DisplayMode[] modes = gd.getDisplayModes();
final int ddepth = desiredDepth;
// we sort modes in order of desirability
Comparator<DisplayMode> mcomp = new Comparator<DisplayMode>() {
public int compare (DisplayMode m1, DisplayMode m2) {
int bd1 = m1.getBitDepth(), bd2 = m2.getBitDepth();
int rr1 = m1.getRefreshRate(), rr2 = m2.getRefreshRate();
// prefer the desired depth
if (bd1 == ddepth && bd2 != ddepth) {
return -1;
} else if (bd2 == ddepth && bd1 != ddepth) {
return 1;
}
// otherwise prefer higher depths
if (bd1 != bd2) {
return bd2 - bd1;
}
// for same bitrates, prefer higher refresh rates
return rr2 - rr1;
}
};
// but we only add modes that meet our minimum requirements
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
for (DisplayMode mode : modes) {
if (mode.getWidth() == width &&
mode.getHeight() == height &&
mode.getBitDepth() >= minimumDepth &&
mode.getRefreshRate() <= 75) {
mset.add(mode);
}
}
return (mset.size() > 0) ? mset.first() : null;
} | java | public static DisplayMode getDisplayMode (
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth)
{
DisplayMode[] modes = gd.getDisplayModes();
final int ddepth = desiredDepth;
// we sort modes in order of desirability
Comparator<DisplayMode> mcomp = new Comparator<DisplayMode>() {
public int compare (DisplayMode m1, DisplayMode m2) {
int bd1 = m1.getBitDepth(), bd2 = m2.getBitDepth();
int rr1 = m1.getRefreshRate(), rr2 = m2.getRefreshRate();
// prefer the desired depth
if (bd1 == ddepth && bd2 != ddepth) {
return -1;
} else if (bd2 == ddepth && bd1 != ddepth) {
return 1;
}
// otherwise prefer higher depths
if (bd1 != bd2) {
return bd2 - bd1;
}
// for same bitrates, prefer higher refresh rates
return rr2 - rr1;
}
};
// but we only add modes that meet our minimum requirements
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
for (DisplayMode mode : modes) {
if (mode.getWidth() == width &&
mode.getHeight() == height &&
mode.getBitDepth() >= minimumDepth &&
mode.getRefreshRate() <= 75) {
mset.add(mode);
}
}
return (mset.size() > 0) ? mset.first() : null;
} | [
"public",
"static",
"DisplayMode",
"getDisplayMode",
"(",
"GraphicsDevice",
"gd",
",",
"int",
"width",
",",
"int",
"height",
",",
"int",
"desiredDepth",
",",
"int",
"minimumDepth",
")",
"{",
"DisplayMode",
"[",
"]",
"modes",
"=",
"gd",
".",
"getDisplayModes",
... | Gets a display mode that matches the specified parameters. The
screen resolution must match the specified resolution exactly, the
specified desired depth will be used if it is available, and if
not, the highest depth greater than or equal to the specified
minimum depth is used. The highest refresh rate available for the
desired mode is also used. | [
"Gets",
"a",
"display",
"mode",
"that",
"matches",
"the",
"specified",
"parameters",
".",
"The",
"screen",
"resolution",
"must",
"match",
"the",
"specified",
"resolution",
"exactly",
"the",
"specified",
"desired",
"depth",
"will",
"be",
"used",
"if",
"it",
"is... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/ModeUtil.java#L41-L82 | train |
threerings/nenya | core/src/main/java/com/threerings/cast/util/CastUtil.java | CastUtil.getRandomDescriptor | public static CharacterDescriptor getRandomDescriptor (
ComponentRepository crepo, String gender, String[] COMP_CLASSES,
ColorPository cpos, String[] COLOR_CLASSES)
{
// get all available classes
ArrayList<ComponentClass> classes = Lists.newArrayList();
for (String element : COMP_CLASSES) {
String cname = gender + "/" + element;
ComponentClass cclass = crepo.getComponentClass(cname);
// make sure the component class exists
if (cclass == null) {
log.warning("Missing definition for component class", "class", cname);
continue;
}
// make sure there are some components in this class
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
if (!iter.hasNext()) {
log.info("Skipping class for which we have no components", "class", cclass);
continue;
}
classes.add(cclass);
}
// select the components
int[] components = new int[classes.size()];
Colorization[][] zations = new Colorization[components.length][];
for (int ii = 0; ii < components.length; ii++) {
ComponentClass cclass = classes.get(ii);
// get the components available for this class
ArrayList<Integer> choices = Lists.newArrayList();
Iterators.addAll(choices, crepo.enumerateComponentIds(cclass));
// each of our components has up to four colorizations: two "global" skin colorizations
// and potentially a primary and secondary clothing colorization; in a real system one
// would probably keep a separate database of which character component required which
// colorizations, but here we just assume everything could have any of the four
// colorizations; it *usually* doesn't hose an image if you apply a recoloring that it
// does not support, but it can match stray colors unnecessarily
zations[ii] = new Colorization[COLOR_CLASSES.length];
for (int zz = 0; zz < COLOR_CLASSES.length; zz++) {
zations[ii][zz] = cpos.getRandomStartingColor(COLOR_CLASSES[zz]).getColorization();
}
// choose a random component
if (choices.size() > 0) {
int idx = RandomUtil.getInt(choices.size());
components[ii] = choices.get(idx).intValue();
} else {
log.info("Have no components in class", "class", cclass);
}
}
return new CharacterDescriptor(components, zations);
} | java | public static CharacterDescriptor getRandomDescriptor (
ComponentRepository crepo, String gender, String[] COMP_CLASSES,
ColorPository cpos, String[] COLOR_CLASSES)
{
// get all available classes
ArrayList<ComponentClass> classes = Lists.newArrayList();
for (String element : COMP_CLASSES) {
String cname = gender + "/" + element;
ComponentClass cclass = crepo.getComponentClass(cname);
// make sure the component class exists
if (cclass == null) {
log.warning("Missing definition for component class", "class", cname);
continue;
}
// make sure there are some components in this class
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
if (!iter.hasNext()) {
log.info("Skipping class for which we have no components", "class", cclass);
continue;
}
classes.add(cclass);
}
// select the components
int[] components = new int[classes.size()];
Colorization[][] zations = new Colorization[components.length][];
for (int ii = 0; ii < components.length; ii++) {
ComponentClass cclass = classes.get(ii);
// get the components available for this class
ArrayList<Integer> choices = Lists.newArrayList();
Iterators.addAll(choices, crepo.enumerateComponentIds(cclass));
// each of our components has up to four colorizations: two "global" skin colorizations
// and potentially a primary and secondary clothing colorization; in a real system one
// would probably keep a separate database of which character component required which
// colorizations, but here we just assume everything could have any of the four
// colorizations; it *usually* doesn't hose an image if you apply a recoloring that it
// does not support, but it can match stray colors unnecessarily
zations[ii] = new Colorization[COLOR_CLASSES.length];
for (int zz = 0; zz < COLOR_CLASSES.length; zz++) {
zations[ii][zz] = cpos.getRandomStartingColor(COLOR_CLASSES[zz]).getColorization();
}
// choose a random component
if (choices.size() > 0) {
int idx = RandomUtil.getInt(choices.size());
components[ii] = choices.get(idx).intValue();
} else {
log.info("Have no components in class", "class", cclass);
}
}
return new CharacterDescriptor(components, zations);
} | [
"public",
"static",
"CharacterDescriptor",
"getRandomDescriptor",
"(",
"ComponentRepository",
"crepo",
",",
"String",
"gender",
",",
"String",
"[",
"]",
"COMP_CLASSES",
",",
"ColorPository",
"cpos",
",",
"String",
"[",
"]",
"COLOR_CLASSES",
")",
"{",
"// get all ava... | Returns a new character descriptor populated with a random set of components. | [
"Returns",
"a",
"new",
"character",
"descriptor",
"populated",
"with",
"a",
"random",
"set",
"of",
"components",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/util/CastUtil.java#L47-L104 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java | TSDataOptimizerTask.run | public CompletableFuture<NewFile> run() {
LOG.log(Level.FINE, "starting optimized file creation for {0} files", files.size());
CompletableFuture<NewFile> fileCreation = new CompletableFuture<>();
final List<TSData> fjpFiles = this.files; // We clear out files below, which makes createTmpFile see an empty map if we don't use a separate variable.
TASK_POOL.execute(() -> createTmpFile(fileCreation, destDir, fjpFiles, getCompression()));
synchronized (OUTSTANDING) {
OUTSTANDING.add(fileCreation);
}
this.files = new LinkedList<>(); // Do not use clear! This instance is now shared with the createTmpFile task.
return fileCreation;
} | java | public CompletableFuture<NewFile> run() {
LOG.log(Level.FINE, "starting optimized file creation for {0} files", files.size());
CompletableFuture<NewFile> fileCreation = new CompletableFuture<>();
final List<TSData> fjpFiles = this.files; // We clear out files below, which makes createTmpFile see an empty map if we don't use a separate variable.
TASK_POOL.execute(() -> createTmpFile(fileCreation, destDir, fjpFiles, getCompression()));
synchronized (OUTSTANDING) {
OUTSTANDING.add(fileCreation);
}
this.files = new LinkedList<>(); // Do not use clear! This instance is now shared with the createTmpFile task.
return fileCreation;
} | [
"public",
"CompletableFuture",
"<",
"NewFile",
">",
"run",
"(",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"starting optimized file creation for {0} files\"",
",",
"files",
".",
"size",
"(",
")",
")",
";",
"CompletableFuture",
"<",
"NewFile... | Start creating the optimized file. This operation resets the state of the
optimizer task, so it can be re-used for subsequent invocations.
@return A completeable future that yields the newly created file. | [
"Start",
"creating",
"the",
"optimized",
"file",
".",
"This",
"operation",
"resets",
"the",
"state",
"of",
"the",
"optimizer",
"task",
"so",
"it",
"can",
"be",
"re",
"-",
"used",
"for",
"subsequent",
"invocations",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java#L186-L196 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java | TSDataOptimizerTask.createTmpFile | private static void createTmpFile(CompletableFuture<NewFile> fileCreation, Path destDir, List<TSData> files, Compression compression) {
LOG.log(Level.FINE, "starting temporary file creation...");
try {
Collections.sort(files, Comparator.comparing(TSData::getBegin));
final FileChannel fd = FileUtil.createTempFile(destDir, "monsoon-", ".optimize-tmp");
try {
final DateTime begin;
try (ToXdrTables output = new ToXdrTables()) {
while (!files.isEmpty()) {
TSData tsdata = files.remove(0);
if (fileCreation.isCancelled())
throw new IOException("aborted due to canceled execution");
output.addAll(tsdata); // Takes a long time.
}
if (fileCreation.isCancelled())
throw new IOException("aborted due to canceled execution");
begin = output.build(fd, compression); // Writing output takes a lot of time.
}
if (fileCreation.isCancelled()) // Recheck after closing output.
throw new IOException("aborted due to canceled execution");
// Forward the temporary file to the installation, which will complete the operation.
INSTALL_POOL.execute(() -> install(fileCreation, destDir, fd, begin));
} catch (Error | RuntimeException | IOException ex) {
try {
fd.close();
} catch (Error | RuntimeException | IOException ex1) {
ex.addSuppressed(ex1);
}
throw ex;
}
} catch (Error | RuntimeException | IOException ex) {
LOG.log(Level.WARNING, "temporary file for optimization failure", ex);
synchronized (OUTSTANDING) {
OUTSTANDING.remove(fileCreation);
}
fileCreation.completeExceptionally(ex); // Propagate exceptions.
}
} | java | private static void createTmpFile(CompletableFuture<NewFile> fileCreation, Path destDir, List<TSData> files, Compression compression) {
LOG.log(Level.FINE, "starting temporary file creation...");
try {
Collections.sort(files, Comparator.comparing(TSData::getBegin));
final FileChannel fd = FileUtil.createTempFile(destDir, "monsoon-", ".optimize-tmp");
try {
final DateTime begin;
try (ToXdrTables output = new ToXdrTables()) {
while (!files.isEmpty()) {
TSData tsdata = files.remove(0);
if (fileCreation.isCancelled())
throw new IOException("aborted due to canceled execution");
output.addAll(tsdata); // Takes a long time.
}
if (fileCreation.isCancelled())
throw new IOException("aborted due to canceled execution");
begin = output.build(fd, compression); // Writing output takes a lot of time.
}
if (fileCreation.isCancelled()) // Recheck after closing output.
throw new IOException("aborted due to canceled execution");
// Forward the temporary file to the installation, which will complete the operation.
INSTALL_POOL.execute(() -> install(fileCreation, destDir, fd, begin));
} catch (Error | RuntimeException | IOException ex) {
try {
fd.close();
} catch (Error | RuntimeException | IOException ex1) {
ex.addSuppressed(ex1);
}
throw ex;
}
} catch (Error | RuntimeException | IOException ex) {
LOG.log(Level.WARNING, "temporary file for optimization failure", ex);
synchronized (OUTSTANDING) {
OUTSTANDING.remove(fileCreation);
}
fileCreation.completeExceptionally(ex); // Propagate exceptions.
}
} | [
"private",
"static",
"void",
"createTmpFile",
"(",
"CompletableFuture",
"<",
"NewFile",
">",
"fileCreation",
",",
"Path",
"destDir",
",",
"List",
"<",
"TSData",
">",
"files",
",",
"Compression",
"compression",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
... | The fork-join task that creates a new file. This function creates a
temporary file with the result contents, then passes it on to the install
thread which will put the final file in place.
@param fileCreation the future that is to be completed after the
operation.
@param destDir the destination directory for the result; also used for
temporary file creation.
@param files the list of files that make up the resulting file. | [
"The",
"fork",
"-",
"join",
"task",
"that",
"creates",
"a",
"new",
"file",
".",
"This",
"function",
"creates",
"a",
"temporary",
"file",
"with",
"the",
"result",
"contents",
"then",
"passes",
"it",
"on",
"to",
"the",
"install",
"thread",
"which",
"will",
... | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java#L209-L251 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java | TSDataOptimizerTask.install | private static void install(CompletableFuture<NewFile> fileCreation, Path destDir, FileChannel tmpFile, DateTime begin) {
try {
try {
synchronized (OUTSTANDING) {
OUTSTANDING.remove(fileCreation);
}
if (fileCreation.isCancelled())
throw new IOException("Installation aborted, due to cancellation.");
final FileUtil.NamedFileChannel newFile = FileUtil.createNewFile(destDir, prefixForTimestamp(begin), ".optimized");
try (Releaseable<FileChannel> out = new Releaseable<>(newFile.getFileChannel())) {
final long fileSize = tmpFile.size();
LOG.log(Level.INFO, "installing {0} ({1} MB)", new Object[]{newFile.getFileName(), fileSize / 1024.0 / 1024.0});
// Copy tmpFile to out.
long offset = 0;
while (offset < fileSize)
offset += tmpFile.transferTo(offset, fileSize - offset, out.get());
out.get().force(true); // Ensure new file is safely written to permanent storage.
// Complete future with newly created file.
fileCreation.complete(new NewFile(newFile.getFileName(), new ReadonlyTableFile(new GCCloseable<>(out.release()))));
} catch (Error | RuntimeException | IOException | OncRpcException ex) {
// Ensure new file gets destroyed if an error occurs during copying.
try {
Files.delete(newFile.getFileName());
} catch (Error | RuntimeException | IOException ex1) {
ex.addSuppressed(ex1);
}
throw ex;
}
} finally {
// Close tmp file that we got from fjpCreateTmpFile.
tmpFile.close();
}
} catch (Error | RuntimeException | IOException | OncRpcException ex) {
LOG.log(Level.WARNING, "unable to install new file", ex);
fileCreation.completeExceptionally(ex); // Propagate error to future.
}
} | java | private static void install(CompletableFuture<NewFile> fileCreation, Path destDir, FileChannel tmpFile, DateTime begin) {
try {
try {
synchronized (OUTSTANDING) {
OUTSTANDING.remove(fileCreation);
}
if (fileCreation.isCancelled())
throw new IOException("Installation aborted, due to cancellation.");
final FileUtil.NamedFileChannel newFile = FileUtil.createNewFile(destDir, prefixForTimestamp(begin), ".optimized");
try (Releaseable<FileChannel> out = new Releaseable<>(newFile.getFileChannel())) {
final long fileSize = tmpFile.size();
LOG.log(Level.INFO, "installing {0} ({1} MB)", new Object[]{newFile.getFileName(), fileSize / 1024.0 / 1024.0});
// Copy tmpFile to out.
long offset = 0;
while (offset < fileSize)
offset += tmpFile.transferTo(offset, fileSize - offset, out.get());
out.get().force(true); // Ensure new file is safely written to permanent storage.
// Complete future with newly created file.
fileCreation.complete(new NewFile(newFile.getFileName(), new ReadonlyTableFile(new GCCloseable<>(out.release()))));
} catch (Error | RuntimeException | IOException | OncRpcException ex) {
// Ensure new file gets destroyed if an error occurs during copying.
try {
Files.delete(newFile.getFileName());
} catch (Error | RuntimeException | IOException ex1) {
ex.addSuppressed(ex1);
}
throw ex;
}
} finally {
// Close tmp file that we got from fjpCreateTmpFile.
tmpFile.close();
}
} catch (Error | RuntimeException | IOException | OncRpcException ex) {
LOG.log(Level.WARNING, "unable to install new file", ex);
fileCreation.completeExceptionally(ex); // Propagate error to future.
}
} | [
"private",
"static",
"void",
"install",
"(",
"CompletableFuture",
"<",
"NewFile",
">",
"fileCreation",
",",
"Path",
"destDir",
",",
"FileChannel",
"tmpFile",
",",
"DateTime",
"begin",
")",
"{",
"try",
"{",
"try",
"{",
"synchronized",
"(",
"OUTSTANDING",
")",
... | Installs the newly created file. This function runs on the install thread
and essentially performs a copy-operation from the temporary file to the
final file.
@param fileCreation the completeable future that receives the newly
created file.
@param destDir the destination directory in which to install the result
file.
@param tmpFile the temporary file used to create the data; will be closed
by this function.
@param begin a timestamp indicating where this file begins; used to
generate a pretty file name. | [
"Installs",
"the",
"newly",
"created",
"file",
".",
"This",
"function",
"runs",
"on",
"the",
"install",
"thread",
"and",
"essentially",
"performs",
"a",
"copy",
"-",
"operation",
"from",
"the",
"temporary",
"file",
"to",
"the",
"final",
"file",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java#L267-L306 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java | TSDataOptimizerTask.prefixForTimestamp | private static String prefixForTimestamp(DateTime timestamp) {
return String.format("monsoon-%04d%02d%02d-%02d%02d", timestamp.getYear(), timestamp.getMonthOfYear(), timestamp.getDayOfMonth(), timestamp.getHourOfDay(), timestamp.getMinuteOfHour());
} | java | private static String prefixForTimestamp(DateTime timestamp) {
return String.format("monsoon-%04d%02d%02d-%02d%02d", timestamp.getYear(), timestamp.getMonthOfYear(), timestamp.getDayOfMonth(), timestamp.getHourOfDay(), timestamp.getMinuteOfHour());
} | [
"private",
"static",
"String",
"prefixForTimestamp",
"(",
"DateTime",
"timestamp",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"monsoon-%04d%02d%02d-%02d%02d\"",
",",
"timestamp",
".",
"getYear",
"(",
")",
",",
"timestamp",
".",
"getMonthOfYear",
"(",
")",... | Compute a prefix for a to-be-installed file.
@param timestamp the timestamp on which to base the prefix.
@return a file prefix that represents the timestamp in its name. | [
"Compute",
"a",
"prefix",
"for",
"a",
"to",
"-",
"be",
"-",
"installed",
"file",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/xdr/TSDataOptimizerTask.java#L314-L316 | train |
jboss/jboss-jsp-api_spec | src/main/java/javax/servlet/jsp/PageContext.java | PageContext.getErrorData | public ErrorData getErrorData() {
return new ErrorData(
(Throwable)getRequest().getAttribute( "javax.servlet.error.exception" ),
((Integer)getRequest().getAttribute(
"javax.servlet.error.status_code" )).intValue(),
(String)getRequest().getAttribute( "javax.servlet.error.request_uri" ),
(String)getRequest().getAttribute( "javax.servlet.error.servlet_name" ) );
} | java | public ErrorData getErrorData() {
return new ErrorData(
(Throwable)getRequest().getAttribute( "javax.servlet.error.exception" ),
((Integer)getRequest().getAttribute(
"javax.servlet.error.status_code" )).intValue(),
(String)getRequest().getAttribute( "javax.servlet.error.request_uri" ),
(String)getRequest().getAttribute( "javax.servlet.error.servlet_name" ) );
} | [
"public",
"ErrorData",
"getErrorData",
"(",
")",
"{",
"return",
"new",
"ErrorData",
"(",
"(",
"Throwable",
")",
"getRequest",
"(",
")",
".",
"getAttribute",
"(",
"\"javax.servlet.error.exception\"",
")",
",",
"(",
"(",
"Integer",
")",
"getRequest",
"(",
")",
... | Provides convenient access to error information.
@return an ErrorData instance containing information about the
error, as obtained from the request attributes, as per the
Servlet specification. If this is not an error page (that is,
if the isErrorPage attribute of the page directive is not set
to "true"), the information is meaningless.
@since JSP 2.0 | [
"Provides",
"convenient",
"access",
"to",
"error",
"information",
"."
] | da53166619f33a5134dc3315a3264990cc1f541f | https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/PageContext.java#L551-L558 | train |
groupon/robo-remote | RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/Device.java | Device.storeLogs | public static void storeLogs(String sourceLogFileName, String destLogFileName) throws Exception {
// assumes eventmanager is running
// store logs
String tmpdir = System.getProperty("java.io.tmpdir");
if (tmpdir == null || tmpdir == "null") {
tmpdir = "/tmp";
}
File tmpLogFile = new File(tmpdir + File.separator + sourceLogFileName);
File destFile = new File(current_log_dir + File.separator + destLogFileName);
Files.copy(tmpLogFile, destFile);
} | java | public static void storeLogs(String sourceLogFileName, String destLogFileName) throws Exception {
// assumes eventmanager is running
// store logs
String tmpdir = System.getProperty("java.io.tmpdir");
if (tmpdir == null || tmpdir == "null") {
tmpdir = "/tmp";
}
File tmpLogFile = new File(tmpdir + File.separator + sourceLogFileName);
File destFile = new File(current_log_dir + File.separator + destLogFileName);
Files.copy(tmpLogFile, destFile);
} | [
"public",
"static",
"void",
"storeLogs",
"(",
"String",
"sourceLogFileName",
",",
"String",
"destLogFileName",
")",
"throws",
"Exception",
"{",
"// assumes eventmanager is running",
"// store logs",
"String",
"tmpdir",
"=",
"System",
".",
"getProperty",
"(",
"\"java.io.... | Stores the specified log for this test
@throws Exception | [
"Stores",
"the",
"specified",
"log",
"for",
"this",
"test"
] | 12d242faad50bf90f98657ca9a0c0c3ae1993f07 | https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/Device.java#L61-L72 | train |
threerings/nenya | core/src/main/java/com/threerings/cast/builder/ClassEditor.java | ClassEditor.setSelectedComponent | protected void setSelectedComponent (int idx)
{
int cid = _components.get(idx).intValue();
_model.setSelectedComponent(_cclass, cid);
} | java | protected void setSelectedComponent (int idx)
{
int cid = _components.get(idx).intValue();
_model.setSelectedComponent(_cclass, cid);
} | [
"protected",
"void",
"setSelectedComponent",
"(",
"int",
"idx",
")",
"{",
"int",
"cid",
"=",
"_components",
".",
"get",
"(",
"idx",
")",
".",
"intValue",
"(",
")",
";",
"_model",
".",
"setSelectedComponent",
"(",
"_cclass",
",",
"cid",
")",
";",
"}"
] | Sets the selected component in the builder model for the
component class associated with this editor to the component at
the given index in this editor's list of available components. | [
"Sets",
"the",
"selected",
"component",
"in",
"the",
"builder",
"model",
"for",
"the",
"component",
"class",
"associated",
"with",
"this",
"editor",
"to",
"the",
"component",
"at",
"the",
"given",
"index",
"in",
"this",
"editor",
"s",
"list",
"of",
"availabl... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/ClassEditor.java#L91-L95 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/ChannelEvent.java | ChannelEvent.isFlowActive | public boolean isFlowActive() {
Object val = this.getArgument("active");
if (val instanceof Integer) {
return ((Integer)val).intValue() == 1;
}
else {
throw new IllegalStateException("ChannelEvent does not contain the 'active' argument");
}
} | java | public boolean isFlowActive() {
Object val = this.getArgument("active");
if (val instanceof Integer) {
return ((Integer)val).intValue() == 1;
}
else {
throw new IllegalStateException("ChannelEvent does not contain the 'active' argument");
}
} | [
"public",
"boolean",
"isFlowActive",
"(",
")",
"{",
"Object",
"val",
"=",
"this",
".",
"getArgument",
"(",
"\"active\"",
")",
";",
"if",
"(",
"val",
"instanceof",
"Integer",
")",
"{",
"return",
"(",
"(",
"Integer",
")",
"val",
")",
".",
"intValue",
"("... | Returns For flow events, returns true if flow is active
@return boolean true if event specifies flow is active
@throws IllegalStateException if this event is not a flow event | [
"Returns",
"For",
"flow",
"events",
"returns",
"true",
"if",
"flow",
"is",
"active"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/ChannelEvent.java#L219-L227 | train |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/internal/RedmineJSONBuilder.java | RedmineJSONBuilder.writeTracker | static void writeTracker(JSONWriter writer, Tracker tracker)
throws JSONException {
writer.key("id");
writer.value(tracker.getId());
writer.key("name");
writer.value(tracker.getName());
} | java | static void writeTracker(JSONWriter writer, Tracker tracker)
throws JSONException {
writer.key("id");
writer.value(tracker.getId());
writer.key("name");
writer.value(tracker.getName());
} | [
"static",
"void",
"writeTracker",
"(",
"JSONWriter",
"writer",
",",
"Tracker",
"tracker",
")",
"throws",
"JSONException",
"{",
"writer",
".",
"key",
"(",
"\"id\"",
")",
";",
"writer",
".",
"value",
"(",
"tracker",
".",
"getId",
"(",
")",
")",
";",
"write... | Writes a tracker.
@param writer
used writer.
@param tracker
tracker to writer.
@throws JSONException
if error occurs. | [
"Writes",
"a",
"tracker",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONBuilder.java#L161-L167 | train |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/internal/RedmineJSONBuilder.java | RedmineJSONBuilder.addFull | public static void addFull(JSONWriter writer, String field, Date value)
throws JSONException {
final SimpleDateFormat format = RedmineDateUtils.FULL_DATE_FORMAT.get();
JsonOutput.add(writer, field, value, format);
} | java | public static void addFull(JSONWriter writer, String field, Date value)
throws JSONException {
final SimpleDateFormat format = RedmineDateUtils.FULL_DATE_FORMAT.get();
JsonOutput.add(writer, field, value, format);
} | [
"public",
"static",
"void",
"addFull",
"(",
"JSONWriter",
"writer",
",",
"String",
"field",
",",
"Date",
"value",
")",
"throws",
"JSONException",
"{",
"final",
"SimpleDateFormat",
"format",
"=",
"RedmineDateUtils",
".",
"FULL_DATE_FORMAT",
".",
"get",
"(",
")",
... | Adds a value to a writer.
@param writer
writer to add object to.
@param field
field name to set.
@param value
field value.
@throws JSONException
if io error occurs. | [
"Adds",
"a",
"value",
"to",
"a",
"writer",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONBuilder.java#L383-L387 | train |
groupon/monsoon | lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java | MemoidOne.match_ | private Optional<Data<Input, Output>> match_(Input input) {
return Optional.ofNullable(recent_.get())
.filter((Data<Input, Output> data) -> equality_.test(data.getInput(), input));
} | java | private Optional<Data<Input, Output>> match_(Input input) {
return Optional.ofNullable(recent_.get())
.filter((Data<Input, Output> data) -> equality_.test(data.getInput(), input));
} | [
"private",
"Optional",
"<",
"Data",
"<",
"Input",
",",
"Output",
">",
">",
"match_",
"(",
"Input",
"input",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"recent_",
".",
"get",
"(",
")",
")",
".",
"filter",
"(",
"(",
"Data",
"<",
"Input",
... | Try to match an input against the most recent calculation.
@param input The most recent input.
@return An optional Data object, if the input matches the remembered calculation. | [
"Try",
"to",
"match",
"an",
"input",
"against",
"the",
"most",
"recent",
"calculation",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java#L93-L96 | train |
groupon/monsoon | lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java | MemoidOne.derive_ | private Data<Input, Output> derive_(Input input) {
Data<Input, Output> result = new Data<>(input, fn_.apply(input));
recent_.set(result);
return result;
} | java | private Data<Input, Output> derive_(Input input) {
Data<Input, Output> result = new Data<>(input, fn_.apply(input));
recent_.set(result);
return result;
} | [
"private",
"Data",
"<",
"Input",
",",
"Output",
">",
"derive_",
"(",
"Input",
"input",
")",
"{",
"Data",
"<",
"Input",
",",
"Output",
">",
"result",
"=",
"new",
"Data",
"<>",
"(",
"input",
",",
"fn_",
".",
"apply",
"(",
"input",
")",
")",
";",
"r... | Derive and remember a calculation.
Future invocations of match_(input) will return the returned Data instance.
@param input The input for the calculation.
@return A data object, holding the result of the calculation. | [
"Derive",
"and",
"remember",
"a",
"calculation",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java#L105-L109 | train |
groupon/monsoon | lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java | MemoidOne.apply | @Override
public Output apply(Input input) {
if (input == null) return fn_.apply(input);
return match_(input)
.orElseGet(() -> derive_(input))
.getOutput();
} | java | @Override
public Output apply(Input input) {
if (input == null) return fn_.apply(input);
return match_(input)
.orElseGet(() -> derive_(input))
.getOutput();
} | [
"@",
"Override",
"public",
"Output",
"apply",
"(",
"Input",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"return",
"fn_",
".",
"apply",
"(",
"input",
")",
";",
"return",
"match_",
"(",
"input",
")",
".",
"orElseGet",
"(",
"(",
")",
"->... | Functional implementation.
The actual calculation will only be performed if the input doesn't match
the input from the most recent invocation.
Null inputs are never remembered.
@param input Argument to the calculation.
@return The output of the calculation. | [
"Functional",
"implementation",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/lib/src/main/java/com/groupon/lex/metrics/lib/MemoidOne.java#L121-L127 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.setWarning | public void setWarning (float warnPercent, ResultListener<TimerView> warner)
{
// This warning hasn't triggered yet
_warned = false;
// Here are the details
_warnPercent = warnPercent;
_warner = warner;
} | java | public void setWarning (float warnPercent, ResultListener<TimerView> warner)
{
// This warning hasn't triggered yet
_warned = false;
// Here are the details
_warnPercent = warnPercent;
_warner = warner;
} | [
"public",
"void",
"setWarning",
"(",
"float",
"warnPercent",
",",
"ResultListener",
"<",
"TimerView",
">",
"warner",
")",
"{",
"// This warning hasn't triggered yet",
"_warned",
"=",
"false",
";",
"// Here are the details",
"_warnPercent",
"=",
"warnPercent",
";",
"_w... | Setup a warning to trigger after the timer is "warnPercent"
or more completed. If "warner" is non-null, it will be
called at that time. | [
"Setup",
"a",
"warning",
"to",
"trigger",
"after",
"the",
"timer",
"is",
"warnPercent",
"or",
"more",
"completed",
".",
"If",
"warner",
"is",
"non",
"-",
"null",
"it",
"will",
"be",
"called",
"at",
"that",
"time",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L93-L101 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.start | public void start (float startPercent, long duration, ResultListener<TimerView> finisher)
{
// Sanity check input arguments
if (startPercent < 0.0f || startPercent >= 1.0f) {
throw new IllegalArgumentException(
"Invalid starting percent " + startPercent);
}
if (duration < 0) {
throw new IllegalArgumentException("Invalid duration " + duration);
}
// Stop any current processing
stop();
// Record the timer's full duration and effective start time
_duration = duration;
// Change the completion percent and make sure the starting
// time gets updated on the next tick
changeComplete(startPercent);
_start = Long.MIN_VALUE;
// Thank you sir; would you kindly take a chair in the waiting room?
_finisher = finisher;
// The warning and completion handlers haven't been triggered yet
_warned = false;
_completed = false;
// Start things running
_running = true;
} | java | public void start (float startPercent, long duration, ResultListener<TimerView> finisher)
{
// Sanity check input arguments
if (startPercent < 0.0f || startPercent >= 1.0f) {
throw new IllegalArgumentException(
"Invalid starting percent " + startPercent);
}
if (duration < 0) {
throw new IllegalArgumentException("Invalid duration " + duration);
}
// Stop any current processing
stop();
// Record the timer's full duration and effective start time
_duration = duration;
// Change the completion percent and make sure the starting
// time gets updated on the next tick
changeComplete(startPercent);
_start = Long.MIN_VALUE;
// Thank you sir; would you kindly take a chair in the waiting room?
_finisher = finisher;
// The warning and completion handlers haven't been triggered yet
_warned = false;
_completed = false;
// Start things running
_running = true;
} | [
"public",
"void",
"start",
"(",
"float",
"startPercent",
",",
"long",
"duration",
",",
"ResultListener",
"<",
"TimerView",
">",
"finisher",
")",
"{",
"// Sanity check input arguments",
"if",
"(",
"startPercent",
"<",
"0.0f",
"||",
"startPercent",
">=",
"1.0f",
"... | Start the timer running from the specified percentage complete,
to expire at the specified time.
@param startPercent a value in [0f, 1f) indicating how much
hourglass time has already elapsed when the timer starts.
@param duration The time interval over which the timer would
run if it started at 0%.
@param finisher a listener that will be notified when the timer
finishes, or null if nothing should be notified. | [
"Start",
"the",
"timer",
"running",
"from",
"the",
"specified",
"percentage",
"complete",
"to",
"expire",
"at",
"the",
"specified",
"time",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L131-L162 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.unpause | public void unpause ()
{
// Don't unpause the timer if it wasn't paused to begin with
if (_lastUpdate == Long.MIN_VALUE || _start == Long.MIN_VALUE) {
return;
}
// Adjust the starting time when the timer next ticks
_processUnpause = true;
// Start things running again
_running = true;
} | java | public void unpause ()
{
// Don't unpause the timer if it wasn't paused to begin with
if (_lastUpdate == Long.MIN_VALUE || _start == Long.MIN_VALUE) {
return;
}
// Adjust the starting time when the timer next ticks
_processUnpause = true;
// Start things running again
_running = true;
} | [
"public",
"void",
"unpause",
"(",
")",
"{",
"// Don't unpause the timer if it wasn't paused to begin with",
"if",
"(",
"_lastUpdate",
"==",
"Long",
".",
"MIN_VALUE",
"||",
"_start",
"==",
"Long",
".",
"MIN_VALUE",
")",
"{",
"return",
";",
"}",
"// Adjust the startin... | Unpause the timer. | [
"Unpause",
"the",
"timer",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L200-L212 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.changeComplete | public void changeComplete (float complete)
{
// Store the new state
_complete = complete;
// Determine the percentage difference between the "actual"
// completion state and the completion amount to render during
// the smooth interpolation
_renderOffset = _renderComplete - _complete;
// When the timer next ticks, find out when this interpolation
// should start
_renderOffsetTime = Long.MIN_VALUE;
} | java | public void changeComplete (float complete)
{
// Store the new state
_complete = complete;
// Determine the percentage difference between the "actual"
// completion state and the completion amount to render during
// the smooth interpolation
_renderOffset = _renderComplete - _complete;
// When the timer next ticks, find out when this interpolation
// should start
_renderOffsetTime = Long.MIN_VALUE;
} | [
"public",
"void",
"changeComplete",
"(",
"float",
"complete",
")",
"{",
"// Store the new state",
"_complete",
"=",
"complete",
";",
"// Determine the percentage difference between the \"actual\"",
"// completion state and the completion amount to render during",
"// the smooth interpo... | Generate an unexpected change in the timer's completion and
set up the necessary details to render interpolation from the old
to new states | [
"Generate",
"an",
"unexpected",
"change",
"in",
"the",
"timer",
"s",
"completion",
"and",
"set",
"up",
"the",
"necessary",
"details",
"to",
"render",
"interpolation",
"from",
"the",
"old",
"to",
"new",
"states"
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L219-L232 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.invalidate | protected void invalidate ()
{
// Schedule the timer's location on screen to get repainted
_invalidated = true;
_host.repaint(_bounds.x, _bounds.y, _bounds.width, _bounds.height);
} | java | protected void invalidate ()
{
// Schedule the timer's location on screen to get repainted
_invalidated = true;
_host.repaint(_bounds.x, _bounds.y, _bounds.width, _bounds.height);
} | [
"protected",
"void",
"invalidate",
"(",
")",
"{",
"// Schedule the timer's location on screen to get repainted",
"_invalidated",
"=",
"true",
";",
"_host",
".",
"repaint",
"(",
"_bounds",
".",
"x",
",",
"_bounds",
".",
"y",
",",
"_bounds",
".",
"width",
",",
"_b... | Invalidates this view's bounds via the host component. | [
"Invalidates",
"this",
"view",
"s",
"bounds",
"via",
"the",
"host",
"component",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L294-L299 | train |
threerings/nenya | core/src/main/java/com/threerings/media/TimerView.java | TimerView.checkFrameParticipation | public void checkFrameParticipation ()
{
// Determine whether or not the timer should participate in
// media ticks
boolean participate = _host.isShowing();
// Start participating if necessary
if (participate && !_participating)
{
_fmgr.registerFrameParticipant(this);
_participating = true;
}
// Stop participating if necessary
else if (!participate && _participating)
{
_fmgr.removeFrameParticipant(this);
_participating = false;
}
} | java | public void checkFrameParticipation ()
{
// Determine whether or not the timer should participate in
// media ticks
boolean participate = _host.isShowing();
// Start participating if necessary
if (participate && !_participating)
{
_fmgr.registerFrameParticipant(this);
_participating = true;
}
// Stop participating if necessary
else if (!participate && _participating)
{
_fmgr.removeFrameParticipant(this);
_participating = false;
}
} | [
"public",
"void",
"checkFrameParticipation",
"(",
")",
"{",
"// Determine whether or not the timer should participate in",
"// media ticks",
"boolean",
"participate",
"=",
"_host",
".",
"isShowing",
"(",
")",
";",
"// Start participating if necessary",
"if",
"(",
"participate... | Check that the frame knows about the timer. | [
"Check",
"that",
"the",
"frame",
"knows",
"about",
"the",
"timer",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/TimerView.java#L418-L437 | train |
threerings/nenya | core/src/main/java/com/threerings/media/tile/TileUtil.java | TileUtil.getTileHash | public static int getTileHash (int x, int y)
{
long seed = (((x << 2) ^ y) ^ MULTIPLIER) & MASK;
long hash = (seed * MULTIPLIER + ADDEND) & MASK;
return (int) (hash >>> 30);
} | java | public static int getTileHash (int x, int y)
{
long seed = (((x << 2) ^ y) ^ MULTIPLIER) & MASK;
long hash = (seed * MULTIPLIER + ADDEND) & MASK;
return (int) (hash >>> 30);
} | [
"public",
"static",
"int",
"getTileHash",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"long",
"seed",
"=",
"(",
"(",
"(",
"x",
"<<",
"2",
")",
"^",
"y",
")",
"^",
"MULTIPLIER",
")",
"&",
"MASK",
";",
"long",
"hash",
"=",
"(",
"seed",
"*",
"MU... | Compute some hash value for "randomizing" tileset picks
based on x and y coordinates.
@return a positive, seemingly random number based on x and y. | [
"Compute",
"some",
"hash",
"value",
"for",
"randomizing",
"tileset",
"picks",
"based",
"on",
"x",
"and",
"y",
"coordinates",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/TileUtil.java#L58-L63 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/v2/xdr/Util.java | Util.fixSequence | public static ObjectSequence<TimeSeriesCollection> fixSequence(ObjectSequence<TimeSeriesCollection> seq) {
seq = seq.sort(); // Does nothing if already sorted.
if (!seq.isDistinct() && !seq.isEmpty()) {
List<ObjectSequence<TimeSeriesCollection>> toConcat = new ArrayList<>();
int lastGoodIdx = 0;
int curIdx = 0;
while (curIdx < seq.size()) {
final TimeSeriesCollection curElem = seq.get(curIdx);
// Find first item with different timestamp.
int nextIdx = curIdx + 1;
while (nextIdx < seq.size()
&& curElem.getTimestamp().equals(seq.get(nextIdx).getTimestamp())) {
++nextIdx;
}
// If more than 1 adjecent element share timestamp, merge them together.
if (curIdx + 1 < nextIdx) {
toConcat.add(seq.limit(curIdx).skip(lastGoodIdx));
TimeSeriesCollection replacement = new LazyMergedTSC(seq.limit(nextIdx).skip(curIdx));
toConcat.add(ObjectSequence.of(true, true, true, replacement));
lastGoodIdx = curIdx = nextIdx;
} else {
// Advance curIdx.
++curIdx;
}
}
if (lastGoodIdx < curIdx)
toConcat.add(seq.skip(lastGoodIdx));
seq = ObjectSequence.concat(toConcat, true, true);
}
return seq;
} | java | public static ObjectSequence<TimeSeriesCollection> fixSequence(ObjectSequence<TimeSeriesCollection> seq) {
seq = seq.sort(); // Does nothing if already sorted.
if (!seq.isDistinct() && !seq.isEmpty()) {
List<ObjectSequence<TimeSeriesCollection>> toConcat = new ArrayList<>();
int lastGoodIdx = 0;
int curIdx = 0;
while (curIdx < seq.size()) {
final TimeSeriesCollection curElem = seq.get(curIdx);
// Find first item with different timestamp.
int nextIdx = curIdx + 1;
while (nextIdx < seq.size()
&& curElem.getTimestamp().equals(seq.get(nextIdx).getTimestamp())) {
++nextIdx;
}
// If more than 1 adjecent element share timestamp, merge them together.
if (curIdx + 1 < nextIdx) {
toConcat.add(seq.limit(curIdx).skip(lastGoodIdx));
TimeSeriesCollection replacement = new LazyMergedTSC(seq.limit(nextIdx).skip(curIdx));
toConcat.add(ObjectSequence.of(true, true, true, replacement));
lastGoodIdx = curIdx = nextIdx;
} else {
// Advance curIdx.
++curIdx;
}
}
if (lastGoodIdx < curIdx)
toConcat.add(seq.skip(lastGoodIdx));
seq = ObjectSequence.concat(toConcat, true, true);
}
return seq;
} | [
"public",
"static",
"ObjectSequence",
"<",
"TimeSeriesCollection",
">",
"fixSequence",
"(",
"ObjectSequence",
"<",
"TimeSeriesCollection",
">",
"seq",
")",
"{",
"seq",
"=",
"seq",
".",
"sort",
"(",
")",
";",
"// Does nothing if already sorted.",
"if",
"(",
"!",
... | Fix a sequence to contain only distinct, sorted elements. | [
"Fix",
"a",
"sequence",
"to",
"contain",
"only",
"distinct",
"sorted",
"elements",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/v2/xdr/Util.java#L92-L129 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/v2/xdr/Util.java | Util.mergeSequences | public static ObjectSequence<TimeSeriesCollection> mergeSequences(ObjectSequence<TimeSeriesCollection>... tsSeq) {
if (tsSeq.length == 0)
return ObjectSequence.empty();
if (tsSeq.length == 1)
return tsSeq[0];
// Sort sequences and remove any that are empty.
final Queue<ObjectSequence<TimeSeriesCollection>> seq = new PriorityQueue<>(Comparator.comparing(ObjectSequence::first));
seq.addAll(Arrays.stream(tsSeq)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList()));
// It's possible the filtering reduced the number of elements to 0 or 1...
if (seq.isEmpty())
return ObjectSequence.empty();
if (seq.size() == 1)
return seq.element();
final List<ObjectSequence<TimeSeriesCollection>> output = new ArrayList<>(tsSeq.length);
while (!seq.isEmpty()) {
final ObjectSequence<TimeSeriesCollection> head = seq.remove();
if (seq.isEmpty()) {
output.add(head);
continue;
}
if (head.last().compareTo(seq.element().first()) < 0) {
output.add(head);
continue;
}
final List<ObjectSequence<TimeSeriesCollection>> toMerge = new ArrayList<>();
// Find the intersecting range.
final int headProblemStart = head.equalRange(tsc -> tsc.compareTo(seq.element().first())).getBegin();
output.add(head.limit(headProblemStart)); // Add non-intersecting range to output.
toMerge.add(head.skip(headProblemStart)); // Add problematic area to 'toMerge' collection.
// Find all remaining intersecting ranges and add them to 'toMerge', replacing them with their non-intersecting ranges.
final TimeSeriesCollection headLast = head.last();
while (!seq.isEmpty() && seq.element().first().compareTo(headLast) <= 0) {
final ObjectSequence<TimeSeriesCollection> succ = seq.remove();
TimeSeriesCollection succFirst = succ.first();
System.err.println("succ.first: " + succ.first() + ", head.last: " + headLast);
// Add intersecting range of succ to 'toMerge'.
final int succProblemEnd = succ.equalRange(tsc -> tsc.compareTo(headLast)).getEnd();
assert succProblemEnd > 0;
toMerge.add(succ.limit(succProblemEnd));
// Add non-intersecting range of succ back to 'seq'.
ObjectSequence<TimeSeriesCollection> succNoProblem = succ.skip(succProblemEnd);
if (!succNoProblem.isEmpty())
seq.add(succNoProblem);
}
assert (toMerge.size() > 1);
output.add(fixSequence(ObjectSequence.concat(toMerge, false, false)));
}
return ObjectSequence.concat(output, true, true);
} | java | public static ObjectSequence<TimeSeriesCollection> mergeSequences(ObjectSequence<TimeSeriesCollection>... tsSeq) {
if (tsSeq.length == 0)
return ObjectSequence.empty();
if (tsSeq.length == 1)
return tsSeq[0];
// Sort sequences and remove any that are empty.
final Queue<ObjectSequence<TimeSeriesCollection>> seq = new PriorityQueue<>(Comparator.comparing(ObjectSequence::first));
seq.addAll(Arrays.stream(tsSeq)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList()));
// It's possible the filtering reduced the number of elements to 0 or 1...
if (seq.isEmpty())
return ObjectSequence.empty();
if (seq.size() == 1)
return seq.element();
final List<ObjectSequence<TimeSeriesCollection>> output = new ArrayList<>(tsSeq.length);
while (!seq.isEmpty()) {
final ObjectSequence<TimeSeriesCollection> head = seq.remove();
if (seq.isEmpty()) {
output.add(head);
continue;
}
if (head.last().compareTo(seq.element().first()) < 0) {
output.add(head);
continue;
}
final List<ObjectSequence<TimeSeriesCollection>> toMerge = new ArrayList<>();
// Find the intersecting range.
final int headProblemStart = head.equalRange(tsc -> tsc.compareTo(seq.element().first())).getBegin();
output.add(head.limit(headProblemStart)); // Add non-intersecting range to output.
toMerge.add(head.skip(headProblemStart)); // Add problematic area to 'toMerge' collection.
// Find all remaining intersecting ranges and add them to 'toMerge', replacing them with their non-intersecting ranges.
final TimeSeriesCollection headLast = head.last();
while (!seq.isEmpty() && seq.element().first().compareTo(headLast) <= 0) {
final ObjectSequence<TimeSeriesCollection> succ = seq.remove();
TimeSeriesCollection succFirst = succ.first();
System.err.println("succ.first: " + succ.first() + ", head.last: " + headLast);
// Add intersecting range of succ to 'toMerge'.
final int succProblemEnd = succ.equalRange(tsc -> tsc.compareTo(headLast)).getEnd();
assert succProblemEnd > 0;
toMerge.add(succ.limit(succProblemEnd));
// Add non-intersecting range of succ back to 'seq'.
ObjectSequence<TimeSeriesCollection> succNoProblem = succ.skip(succProblemEnd);
if (!succNoProblem.isEmpty())
seq.add(succNoProblem);
}
assert (toMerge.size() > 1);
output.add(fixSequence(ObjectSequence.concat(toMerge, false, false)));
}
return ObjectSequence.concat(output, true, true);
} | [
"public",
"static",
"ObjectSequence",
"<",
"TimeSeriesCollection",
">",
"mergeSequences",
"(",
"ObjectSequence",
"<",
"TimeSeriesCollection",
">",
"...",
"tsSeq",
")",
"{",
"if",
"(",
"tsSeq",
".",
"length",
"==",
"0",
")",
"return",
"ObjectSequence",
".",
"empt... | Given zero or more sequences, that are all sorted and distinct, merge
them together.
@param tsSeq Zero or more sequences to process.
@return A merged sequence. | [
"Given",
"zero",
"or",
"more",
"sequences",
"that",
"are",
"all",
"sorted",
"and",
"distinct",
"merge",
"them",
"together",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/v2/xdr/Util.java#L138-L198 | train |
threerings/nenya | core/src/main/java/com/threerings/openal/ResourceStream.java | ResourceStream.queueResource | public void queueResource (String bundle, String resource, boolean loop)
{
try {
queueURL(new URL("resource://" + bundle + "/" + resource), loop);
} catch (MalformedURLException e) {
log.warning("Invalid resource url.", "resource", resource, e);
}
} | java | public void queueResource (String bundle, String resource, boolean loop)
{
try {
queueURL(new URL("resource://" + bundle + "/" + resource), loop);
} catch (MalformedURLException e) {
log.warning("Invalid resource url.", "resource", resource, e);
}
} | [
"public",
"void",
"queueResource",
"(",
"String",
"bundle",
",",
"String",
"resource",
",",
"boolean",
"loop",
")",
"{",
"try",
"{",
"queueURL",
"(",
"new",
"URL",
"(",
"\"resource://\"",
"+",
"bundle",
"+",
"\"/\"",
"+",
"resource",
")",
",",
"loop",
")... | Adds a resource to the queue of files to play.
@param loop if true, play this file in a loop if there's nothing else
on the queue | [
"Adds",
"a",
"resource",
"to",
"the",
"queue",
"of",
"files",
"to",
"play",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/ResourceStream.java#L76-L83 | train |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java | MoreInetAddresses.isMappedIPv4Address | public static boolean isMappedIPv4Address(Inet6Address ip) {
byte bytes[] = ip.getAddress();
return ((bytes[0] == 0x00) && (bytes[1] == 0x00) &&
(bytes[2] == 0x00) && (bytes[3] == 0x00) &&
(bytes[4] == 0x00) && (bytes[5] == 0x00) &&
(bytes[6] == 0x00) && (bytes[7] == 0x00) &&
(bytes[8] == 0x00) && (bytes[9] == 0x00) &&
(bytes[10] == (byte)0xff) && (bytes[11] == (byte)0xff));
} | java | public static boolean isMappedIPv4Address(Inet6Address ip) {
byte bytes[] = ip.getAddress();
return ((bytes[0] == 0x00) && (bytes[1] == 0x00) &&
(bytes[2] == 0x00) && (bytes[3] == 0x00) &&
(bytes[4] == 0x00) && (bytes[5] == 0x00) &&
(bytes[6] == 0x00) && (bytes[7] == 0x00) &&
(bytes[8] == 0x00) && (bytes[9] == 0x00) &&
(bytes[10] == (byte)0xff) && (bytes[11] == (byte)0xff));
} | [
"public",
"static",
"boolean",
"isMappedIPv4Address",
"(",
"Inet6Address",
"ip",
")",
"{",
"byte",
"bytes",
"[",
"]",
"=",
"ip",
".",
"getAddress",
"(",
")",
";",
"return",
"(",
"(",
"bytes",
"[",
"0",
"]",
"==",
"0x00",
")",
"&&",
"(",
"bytes",
"[",... | Evaluates whether the argument is an IPv6 "mapped" address.
<p>An "IPv4 mapped", or "mapped", address is one with 80 leading
bits of zero followed by 16 bits of 1, with the remaining 32 bits interpreted as an
IPv4 address. These are conventionally represented in string
literals as {@code "::ffff:192.168.0.1"}, though {@code "::ffff:c0a8:1"} is
also considered an IPv4 compatible address (and equivalent to
{@code "::192.168.0.1"}).
@param ip {@link Inet6Address} to be examined for embedded IPv4 mapped address format
@return {@code true} if the argument is a valid "mapped" address | [
"Evaluates",
"whether",
"the",
"argument",
"is",
"an",
"IPv6",
"mapped",
"address",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java#L167-L175 | train |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java | MoreInetAddresses.getMappedIPv4Address | public static Inet4Address getMappedIPv4Address(Inet6Address ip) {
if (!isMappedIPv4Address(ip))
throw new IllegalArgumentException(String.format("Address '%s' is not IPv4-mapped.", toAddrString(ip)));
return getInet4Address(copyOfRange(ip.getAddress(), 12, 16));
} | java | public static Inet4Address getMappedIPv4Address(Inet6Address ip) {
if (!isMappedIPv4Address(ip))
throw new IllegalArgumentException(String.format("Address '%s' is not IPv4-mapped.", toAddrString(ip)));
return getInet4Address(copyOfRange(ip.getAddress(), 12, 16));
} | [
"public",
"static",
"Inet4Address",
"getMappedIPv4Address",
"(",
"Inet6Address",
"ip",
")",
"{",
"if",
"(",
"!",
"isMappedIPv4Address",
"(",
"ip",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Address '%s' is not IPv4-ma... | Returns the IPv4 address embedded in an IPv4 mapped address.
@param ip {@link Inet6Address} to be examined for an embedded IPv4 address
@return {@link Inet4Address} of the embedded IPv4 address
@throws IllegalArgumentException if the argument is not a valid IPv4 mapped address | [
"Returns",
"the",
"IPv4",
"address",
"embedded",
"in",
"an",
"IPv4",
"mapped",
"address",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java#L184-L189 | train |
threerings/nenya | core/src/main/java/com/threerings/util/IdleTracker.java | IdleTracker.checkIdle | protected void checkIdle ()
{
long now = getTimeStamp();
switch (_state) {
case ACTIVE:
// check whether they've idled out
if (now >= (_lastEvent + _toIdleTime)) {
log.info("User idle for " + (now-_lastEvent) + "ms.");
_state = IDLE;
idledOut();
}
break;
case IDLE:
// check whether they've been idle for too long
if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) {
log.info("User idle for " + (now-_lastEvent) + "ms. " +
"Abandoning ship.");
_state = ABANDONED;
abandonedShip();
}
break;
}
} | java | protected void checkIdle ()
{
long now = getTimeStamp();
switch (_state) {
case ACTIVE:
// check whether they've idled out
if (now >= (_lastEvent + _toIdleTime)) {
log.info("User idle for " + (now-_lastEvent) + "ms.");
_state = IDLE;
idledOut();
}
break;
case IDLE:
// check whether they've been idle for too long
if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) {
log.info("User idle for " + (now-_lastEvent) + "ms. " +
"Abandoning ship.");
_state = ABANDONED;
abandonedShip();
}
break;
}
} | [
"protected",
"void",
"checkIdle",
"(",
")",
"{",
"long",
"now",
"=",
"getTimeStamp",
"(",
")",
";",
"switch",
"(",
"_state",
")",
"{",
"case",
"ACTIVE",
":",
"// check whether they've idled out",
"if",
"(",
"now",
">=",
"(",
"_lastEvent",
"+",
"_toIdleTime",... | Checks the last user event time and posts a command to idle them
out if they've been inactive for too long, or log them out if
they've been idle for too long. | [
"Checks",
"the",
"last",
"user",
"event",
"time",
"and",
"posts",
"a",
"command",
"to",
"idle",
"them",
"out",
"if",
"they",
"ve",
"been",
"inactive",
"for",
"too",
"long",
"or",
"log",
"them",
"out",
"if",
"they",
"ve",
"been",
"idle",
"for",
"too",
... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/IdleTracker.java#L144-L168 | train |
groupon/monsoon | impl/src/main/java/com/groupon/lex/metrics/PushProcessorPipeline.java | PushProcessorPipeline.run_implementation_ | private void run_implementation_(PushProcessor p) throws Exception {
final Map<GroupName, Alert> alerts = registry_.getCollectionAlerts();
final TimeSeriesCollection tsdata = registry_.getCollectionData();
p.accept(tsdata, unmodifiableMap(alerts), registry_.getFailedCollections());
} | java | private void run_implementation_(PushProcessor p) throws Exception {
final Map<GroupName, Alert> alerts = registry_.getCollectionAlerts();
final TimeSeriesCollection tsdata = registry_.getCollectionData();
p.accept(tsdata, unmodifiableMap(alerts), registry_.getFailedCollections());
} | [
"private",
"void",
"run_implementation_",
"(",
"PushProcessor",
"p",
")",
"throws",
"Exception",
"{",
"final",
"Map",
"<",
"GroupName",
",",
"Alert",
">",
"alerts",
"=",
"registry_",
".",
"getCollectionAlerts",
"(",
")",
";",
"final",
"TimeSeriesCollection",
"ts... | Run the implementation of uploading the values and alerts.
@throws java.lang.Exception thrown by implementation. | [
"Run",
"the",
"implementation",
"of",
"uploading",
"the",
"values",
"and",
"alerts",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushProcessorPipeline.java#L81-L85 | train |
groupon/monsoon | impl/src/main/java/com/groupon/lex/metrics/PushProcessorPipeline.java | PushProcessorPipeline.run | @Override
public final void run() {
try {
registry_.updateCollection();
final long t0 = System.nanoTime();
processors_.forEach(p -> {
try {
run_implementation_(p);
} catch (Exception ex) {
logger.log(Level.SEVERE, p.getClass().getName() + " failed to run properly, some or all metrics may be missed this cycle", ex);
}
});
final long t_processor = System.nanoTime();
registry_.updateProcessorDuration(Duration.millis(TimeUnit.NANOSECONDS.toMillis(t_processor - t0)));
} catch (Throwable t) {
/*
* We catch any and all throwables.
* If we don't and let an exception or error escape,
* the scheduled executor service will _silently_ drop our task.
*/
logger.log(Level.SEVERE, "failed to perform collection", t);
}
} | java | @Override
public final void run() {
try {
registry_.updateCollection();
final long t0 = System.nanoTime();
processors_.forEach(p -> {
try {
run_implementation_(p);
} catch (Exception ex) {
logger.log(Level.SEVERE, p.getClass().getName() + " failed to run properly, some or all metrics may be missed this cycle", ex);
}
});
final long t_processor = System.nanoTime();
registry_.updateProcessorDuration(Duration.millis(TimeUnit.NANOSECONDS.toMillis(t_processor - t0)));
} catch (Throwable t) {
/*
* We catch any and all throwables.
* If we don't and let an exception or error escape,
* the scheduled executor service will _silently_ drop our task.
*/
logger.log(Level.SEVERE, "failed to perform collection", t);
}
} | [
"@",
"Override",
"public",
"final",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"registry_",
".",
"updateCollection",
"(",
")",
";",
"final",
"long",
"t0",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"processors_",
".",
"forEach",
"(",
"p",
"->",
"{... | Run the collection cycle. | [
"Run",
"the",
"collection",
"cycle",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushProcessorPipeline.java#L90-L115 | train |
threerings/nenya | core/src/main/java/com/threerings/miso/client/SceneBlockResolver.java | SceneBlockResolver.resolveBlock | public void resolveBlock (SceneBlock block, boolean hipri)
{
log.debug("Queueing block for resolution", "block", block, "hipri", hipri);
if (hipri) {
_queue.prepend(block);
} else {
_queue.append(block);
}
} | java | public void resolveBlock (SceneBlock block, boolean hipri)
{
log.debug("Queueing block for resolution", "block", block, "hipri", hipri);
if (hipri) {
_queue.prepend(block);
} else {
_queue.append(block);
}
} | [
"public",
"void",
"resolveBlock",
"(",
"SceneBlock",
"block",
",",
"boolean",
"hipri",
")",
"{",
"log",
".",
"debug",
"(",
"\"Queueing block for resolution\"",
",",
"\"block\"",
",",
"block",
",",
"\"hipri\"",
",",
"hipri",
")",
";",
"if",
"(",
"hipri",
")",... | Queues up a scene block for resolution. | [
"Queues",
"up",
"a",
"scene",
"block",
"for",
"resolution",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/SceneBlockResolver.java#L43-L51 | train |
groupon/robo-remote | UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/UiDevice.java | UiDevice.openNotification | public static boolean openNotification() throws Exception {
boolean success = false;
// get API level
int apiLevel = Client.getInstance().mapField("android.os.Build$VERSION", "SDK_INT").getInt(0);
if (apiLevel >= 18) {
success = Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "openNotification").getBoolean(0);
} else {
// try a brute force method
int displayHeight = getDisplayHeight();
// Calculated a Y position to pull down to that is the display height minus 10%
int pullTo = displayHeight - (int)((double)displayHeight * .1);
Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "swipe", 10, 0, 10, pullTo, 100);
success = true;
}
return success;
} | java | public static boolean openNotification() throws Exception {
boolean success = false;
// get API level
int apiLevel = Client.getInstance().mapField("android.os.Build$VERSION", "SDK_INT").getInt(0);
if (apiLevel >= 18) {
success = Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "openNotification").getBoolean(0);
} else {
// try a brute force method
int displayHeight = getDisplayHeight();
// Calculated a Y position to pull down to that is the display height minus 10%
int pullTo = displayHeight - (int)((double)displayHeight * .1);
Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "swipe", 10, 0, 10, pullTo, 100);
success = true;
}
return success;
} | [
"public",
"static",
"boolean",
"openNotification",
"(",
")",
"throws",
"Exception",
"{",
"boolean",
"success",
"=",
"false",
";",
"// get API level",
"int",
"apiLevel",
"=",
"Client",
".",
"getInstance",
"(",
")",
".",
"mapField",
"(",
"\"android.os.Build$VERSION\... | Open notification shade
@return
@throws Exception | [
"Open",
"notification",
"shade"
] | 12d242faad50bf90f98657ca9a0c0c3ae1993f07 | https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/UiDevice.java#L44-L63 | train |
groupon/robo-remote | UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/UiDevice.java | UiDevice.click | public static boolean click(int x, int y) throws Exception {
return Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "click", x, y).getBoolean(0);
} | java | public static boolean click(int x, int y) throws Exception {
return Client.getInstance().map(Constants.UIAUTOMATOR_UIDEVICE, "click", x, y).getBoolean(0);
} | [
"public",
"static",
"boolean",
"click",
"(",
"int",
"x",
",",
"int",
"y",
")",
"throws",
"Exception",
"{",
"return",
"Client",
".",
"getInstance",
"(",
")",
".",
"map",
"(",
"Constants",
".",
"UIAUTOMATOR_UIDEVICE",
",",
"\"click\"",
",",
"x",
",",
"y",
... | Click at x,y position
@param x
@param y
@return
@throws Exception | [
"Click",
"at",
"x",
"y",
"position"
] | 12d242faad50bf90f98657ca9a0c0c3ae1993f07 | https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/UiDevice.java#L72-L74 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java | FadableImageSprite.moveAndFadeIn | public void moveAndFadeIn (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(0.0f);
_fadeInDuration = (long)(pathDuration * fadePortion);
} | java | public void moveAndFadeIn (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(0.0f);
_fadeInDuration = (long)(pathDuration * fadePortion);
} | [
"public",
"void",
"moveAndFadeIn",
"(",
"Path",
"path",
",",
"long",
"pathDuration",
",",
"float",
"fadePortion",
")",
"{",
"move",
"(",
"path",
")",
";",
"setAlpha",
"(",
"0.0f",
")",
";",
"_fadeInDuration",
"=",
"(",
"long",
")",
"(",
"pathDuration",
"... | Puts this sprite on the specified path and fades it in over the specified duration.
@param path the path to move along
@param fadePortion the portion of time to spend fading in, from 0.0f (no time) to 1.0f (the
entire time) | [
"Puts",
"this",
"sprite",
"on",
"the",
"specified",
"path",
"and",
"fades",
"it",
"in",
"over",
"the",
"specified",
"duration",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java#L89-L96 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java | FadableImageSprite.moveAndFadeOut | public void moveAndFadeOut (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(1.0f);
_fadeStamp = 0;
_pathDuration = pathDuration;
_fadeOutDuration = (long)(pathDuration * fadePortion);
_fadeDelay = _pathDuration - _fadeOutDuration;
} | java | public void moveAndFadeOut (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(1.0f);
_fadeStamp = 0;
_pathDuration = pathDuration;
_fadeOutDuration = (long)(pathDuration * fadePortion);
_fadeDelay = _pathDuration - _fadeOutDuration;
} | [
"public",
"void",
"moveAndFadeOut",
"(",
"Path",
"path",
",",
"long",
"pathDuration",
",",
"float",
"fadePortion",
")",
"{",
"move",
"(",
"path",
")",
";",
"setAlpha",
"(",
"1.0f",
")",
";",
"_fadeStamp",
"=",
"0",
";",
"_pathDuration",
"=",
"pathDuration"... | Puts this sprite on the specified path and fades it out over the specified duration.
@param path the path to move along
@param pathDuration the duration of the path
@param fadePortion the portion of time to spend fading out, from 0.0f (no time) to 1.0f
(the entire time) | [
"Puts",
"this",
"sprite",
"on",
"the",
"specified",
"path",
"and",
"fades",
"it",
"out",
"over",
"the",
"specified",
"duration",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java#L106-L116 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java | FadableImageSprite.moveAndFadeInAndOut | public void moveAndFadeInAndOut (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(0.0f);
_pathDuration = pathDuration;
_fadeInDuration = _fadeOutDuration = (long)(pathDuration * fadePortion);
} | java | public void moveAndFadeInAndOut (Path path, long pathDuration, float fadePortion)
{
move(path);
setAlpha(0.0f);
_pathDuration = pathDuration;
_fadeInDuration = _fadeOutDuration = (long)(pathDuration * fadePortion);
} | [
"public",
"void",
"moveAndFadeInAndOut",
"(",
"Path",
"path",
",",
"long",
"pathDuration",
",",
"float",
"fadePortion",
")",
"{",
"move",
"(",
"path",
")",
";",
"setAlpha",
"(",
"0.0f",
")",
";",
"_pathDuration",
"=",
"pathDuration",
";",
"_fadeInDuration",
... | Puts this sprite on the specified path, fading it in over the specified duration at the
beginning and fading it out at the end.
@param path the path to move along
@param pathDuration the duration of the path
@param fadePortion the portion of time to spend fading in/out, from 0.0f (no time) to 1.0f
(the entire time) | [
"Puts",
"this",
"sprite",
"on",
"the",
"specified",
"path",
"fading",
"it",
"in",
"over",
"the",
"specified",
"duration",
"at",
"the",
"beginning",
"and",
"fading",
"it",
"out",
"at",
"the",
"end",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java#L127-L135 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java | FadableImageSprite.setAlpha | public void setAlpha (float alpha)
{
if (alpha < 0.0f) {
alpha = 0.0f;
} else if (alpha > 1.0f) {
alpha = 1.0f;
}
if (alpha != _alphaComposite.getAlpha()) {
_alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
if (_mgr != null) {
_mgr.getRegionManager().invalidateRegion(_bounds);
}
}
} | java | public void setAlpha (float alpha)
{
if (alpha < 0.0f) {
alpha = 0.0f;
} else if (alpha > 1.0f) {
alpha = 1.0f;
}
if (alpha != _alphaComposite.getAlpha()) {
_alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
if (_mgr != null) {
_mgr.getRegionManager().invalidateRegion(_bounds);
}
}
} | [
"public",
"void",
"setAlpha",
"(",
"float",
"alpha",
")",
"{",
"if",
"(",
"alpha",
"<",
"0.0f",
")",
"{",
"alpha",
"=",
"0.0f",
";",
"}",
"else",
"if",
"(",
"alpha",
">",
"1.0f",
")",
"{",
"alpha",
"=",
"1.0f",
";",
"}",
"if",
"(",
"alpha",
"!=... | Sets the alpha value of this sprite. | [
"Sets",
"the",
"alpha",
"value",
"of",
"this",
"sprite",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/FadableImageSprite.java#L229-L243 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/PerformanceMonitor.java | PerformanceMonitor.register | public static void register (PerformanceObserver obs, String name, long delta)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
// create it if it didn't exist
_observers.put(obs, actions = Maps.newHashMap());
}
// add the action to the set we're tracking
actions.put(name, new PerformanceAction(obs, name, delta));
} | java | public static void register (PerformanceObserver obs, String name, long delta)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
// create it if it didn't exist
_observers.put(obs, actions = Maps.newHashMap());
}
// add the action to the set we're tracking
actions.put(name, new PerformanceAction(obs, name, delta));
} | [
"public",
"static",
"void",
"register",
"(",
"PerformanceObserver",
"obs",
",",
"String",
"name",
",",
"long",
"delta",
")",
"{",
"// get the observer's action hashtable",
"Map",
"<",
"String",
",",
"PerformanceAction",
">",
"actions",
"=",
"_observers",
".",
"get... | Register a new action with an observer, the action name, and the milliseconds to wait
between checkpointing the action's performance.
@param obs the action observer.
@param name the action name.
@param delta the milliseconds between checkpoints. | [
"Register",
"a",
"new",
"action",
"with",
"an",
"observer",
"the",
"action",
"name",
"and",
"the",
"milliseconds",
"to",
"wait",
"between",
"checkpointing",
"the",
"action",
"s",
"performance",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/PerformanceMonitor.java#L58-L69 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/PerformanceMonitor.java | PerformanceMonitor.unregister | public static void unregister (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to unregister by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// attempt to remove the specified action
PerformanceAction action = actions.remove(name);
if (action == null) {
log.warning("Attempt to unregister unknown action " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// if the observer has no actions left, remove the observer's action
// hash in its entirety
if (actions.size() == 0) {
_observers.remove(obs);
}
} | java | public static void unregister (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to unregister by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// attempt to remove the specified action
PerformanceAction action = actions.remove(name);
if (action == null) {
log.warning("Attempt to unregister unknown action " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// if the observer has no actions left, remove the observer's action
// hash in its entirety
if (actions.size() == 0) {
_observers.remove(obs);
}
} | [
"public",
"static",
"void",
"unregister",
"(",
"PerformanceObserver",
"obs",
",",
"String",
"name",
")",
"{",
"// get the observer's action hashtable",
"Map",
"<",
"String",
",",
"PerformanceAction",
">",
"actions",
"=",
"_observers",
".",
"get",
"(",
"obs",
")",
... | Un-register the named action associated with the given observer.
@param obs the action observer.
@param name the action name. | [
"Un",
"-",
"register",
"the",
"named",
"action",
"associated",
"with",
"the",
"given",
"observer",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/PerformanceMonitor.java#L77-L100 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/PerformanceMonitor.java | PerformanceMonitor.tick | public static void tick (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to tick by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// get the specified action
PerformanceAction action = actions.get(name);
if (action == null) {
log.warning("Attempt to tick unknown value " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// tick the action
action.tick();
} | java | public static void tick (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to tick by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// get the specified action
PerformanceAction action = actions.get(name);
if (action == null) {
log.warning("Attempt to tick unknown value " +
"[observer=" + obs + ", name=" + name + "].");
return;
}
// tick the action
action.tick();
} | [
"public",
"static",
"void",
"tick",
"(",
"PerformanceObserver",
"obs",
",",
"String",
"name",
")",
"{",
"// get the observer's action hashtable",
"Map",
"<",
"String",
",",
"PerformanceAction",
">",
"actions",
"=",
"_observers",
".",
"get",
"(",
"obs",
")",
";",... | Tick the named action associated with the given observer.
@param obs the action observer.
@param name the action name. | [
"Tick",
"the",
"named",
"action",
"associated",
"with",
"the",
"given",
"observer",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/PerformanceMonitor.java#L108-L128 | train |
kaazing/java.client | ws/ws/src/main/java/org/kaazing/net/ws/impl/url/WsURLStreamHandlerImpl.java | WsURLStreamHandlerImpl._getSpecURI | private URI _getSpecURI(String spec) {
URI specURI = URI.create(spec);
if (_scheme.indexOf(':') == -1) {
return specURI;
}
String schemeSpecificPart = specURI.getSchemeSpecificPart();
return URI.create(schemeSpecificPart);
} | java | private URI _getSpecURI(String spec) {
URI specURI = URI.create(spec);
if (_scheme.indexOf(':') == -1) {
return specURI;
}
String schemeSpecificPart = specURI.getSchemeSpecificPart();
return URI.create(schemeSpecificPart);
} | [
"private",
"URI",
"_getSpecURI",
"(",
"String",
"spec",
")",
"{",
"URI",
"specURI",
"=",
"URI",
".",
"create",
"(",
"spec",
")",
";",
"if",
"(",
"_scheme",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"return",
"specURI",
";",
"}... | the appropriate URI that can be used to retrieve the needed parts. | [
"the",
"appropriate",
"URI",
"that",
"can",
"be",
"used",
"to",
"retrieve",
"the",
"needed",
"parts",
"."
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/net/ws/impl/url/WsURLStreamHandlerImpl.java#L81-L90 | train |
threerings/nenya | core/src/main/java/com/threerings/media/tile/TileSet.java | TileSet.checkTileIndex | protected boolean checkTileIndex (int tileIndex)
{
int tcount = getTileCount();
if (tileIndex >= 0 && tileIndex < tcount) {
return true;
} else {
log.warning("Requested invalid tile [tset=" + this + ", index=" + tileIndex + "].",
new Exception());
return false;
}
} | java | protected boolean checkTileIndex (int tileIndex)
{
int tcount = getTileCount();
if (tileIndex >= 0 && tileIndex < tcount) {
return true;
} else {
log.warning("Requested invalid tile [tset=" + this + ", index=" + tileIndex + "].",
new Exception());
return false;
}
} | [
"protected",
"boolean",
"checkTileIndex",
"(",
"int",
"tileIndex",
")",
"{",
"int",
"tcount",
"=",
"getTileCount",
"(",
")",
";",
"if",
"(",
"tileIndex",
">=",
"0",
"&&",
"tileIndex",
"<",
"tcount",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"l... | Used to ensure that the specified tile index is valid. | [
"Used",
"to",
"ensure",
"that",
"the",
"specified",
"tile",
"index",
"is",
"valid",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/TileSet.java#L332-L342 | train |
jboss/jboss-jsp-api_spec | src/main/java/javax/servlet/jsp/tagext/TagLibraryInfo.java | TagLibraryInfo.getTag | public TagInfo getTag(String shortname) {
TagInfo tags[] = getTags();
if (tags == null || tags.length == 0) {
return null;
}
for (int i=0; i < tags.length; i++) {
if (tags[i].getTagName().equals(shortname)) {
return tags[i];
}
}
return null;
} | java | public TagInfo getTag(String shortname) {
TagInfo tags[] = getTags();
if (tags == null || tags.length == 0) {
return null;
}
for (int i=0; i < tags.length; i++) {
if (tags[i].getTagName().equals(shortname)) {
return tags[i];
}
}
return null;
} | [
"public",
"TagInfo",
"getTag",
"(",
"String",
"shortname",
")",
"{",
"TagInfo",
"tags",
"[",
"]",
"=",
"getTags",
"(",
")",
";",
"if",
"(",
"tags",
"==",
"null",
"||",
"tags",
".",
"length",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"for",
... | Get the TagInfo for a given tag name, looking through all the
tags in this tag library.
@param shortname The short name (no prefix) of the tag
@return the TagInfo for the tag with the specified short name, or
null if no such tag is found | [
"Get",
"the",
"TagInfo",
"for",
"a",
"given",
"tag",
"name",
"looking",
"through",
"all",
"the",
"tags",
"in",
"this",
"tag",
"library",
"."
] | da53166619f33a5134dc3315a3264990cc1f541f | https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/tagext/TagLibraryInfo.java#L185-L198 | train |
jboss/jboss-jsp-api_spec | src/main/java/javax/servlet/jsp/tagext/TagLibraryInfo.java | TagLibraryInfo.getTagFile | public TagFileInfo getTagFile(String shortname) {
TagFileInfo tagFiles[] = getTagFiles();
if (tagFiles == null || tagFiles.length == 0) {
return null;
}
for (int i=0; i < tagFiles.length; i++) {
if (tagFiles[i].getName().equals(shortname)) {
return tagFiles[i];
}
}
return null;
} | java | public TagFileInfo getTagFile(String shortname) {
TagFileInfo tagFiles[] = getTagFiles();
if (tagFiles == null || tagFiles.length == 0) {
return null;
}
for (int i=0; i < tagFiles.length; i++) {
if (tagFiles[i].getName().equals(shortname)) {
return tagFiles[i];
}
}
return null;
} | [
"public",
"TagFileInfo",
"getTagFile",
"(",
"String",
"shortname",
")",
"{",
"TagFileInfo",
"tagFiles",
"[",
"]",
"=",
"getTagFiles",
"(",
")",
";",
"if",
"(",
"tagFiles",
"==",
"null",
"||",
"tagFiles",
".",
"length",
"==",
"0",
")",
"{",
"return",
"nul... | Get the TagFileInfo for a given tag name, looking through all the
tag files in this tag library.
@param shortname The short name (no prefix) of the tag
@return the TagFileInfo for the specified Tag file, or null
if no Tag file is found
@since JSP 2.0 | [
"Get",
"the",
"TagFileInfo",
"for",
"a",
"given",
"tag",
"name",
"looking",
"through",
"all",
"the",
"tag",
"files",
"in",
"this",
"tag",
"library",
"."
] | da53166619f33a5134dc3315a3264990cc1f541f | https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/tagext/TagLibraryInfo.java#L209-L222 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.