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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
stephenc/redmine-java-api | src/main/java/org/redmine/ta/RedmineManager.java | RedmineManager.unwrapIO | private void unwrapIO(RedmineException orig, String tag) throws IOException {
Throwable e = orig;
while (e != null) {
if (e instanceof MarkedIOException) {
final MarkedIOException marked = (MarkedIOException) e;
if (tag.equals(marked.getTag()))
throw marked.getIOException();
}
e = e.getCause();
}
} | java | private void unwrapIO(RedmineException orig, String tag) throws IOException {
Throwable e = orig;
while (e != null) {
if (e instanceof MarkedIOException) {
final MarkedIOException marked = (MarkedIOException) e;
if (tag.equals(marked.getTag()))
throw marked.getIOException();
}
e = e.getCause();
}
} | [
"private",
"void",
"unwrapIO",
"(",
"RedmineException",
"orig",
",",
"String",
"tag",
")",
"throws",
"IOException",
"{",
"Throwable",
"e",
"=",
"orig",
";",
"while",
"(",
"e",
"!=",
"null",
")",
"{",
"if",
"(",
"e",
"instanceof",
"MarkedIOException",
")",
... | Unwraps an IO.
@param e
exception to unwrap.
@param tag
target tag.
@throws IOException
@throws RedmineException | [
"Unwraps",
"an",
"IO",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/RedmineManager.java#L721-L731 | train |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/RedmineManager.java | RedmineManager.addMembership | public void addMembership(Membership membership) throws RedmineException {
final Project project = membership.getProject();
if (project == null)
throw new IllegalArgumentException("Project must be set");
if (membership.getUser() == null)
throw new IllegalArgumentException("User must be set");
transport.addChildEntry(Project.class, getProjectKey(project),
membership);
} | java | public void addMembership(Membership membership) throws RedmineException {
final Project project = membership.getProject();
if (project == null)
throw new IllegalArgumentException("Project must be set");
if (membership.getUser() == null)
throw new IllegalArgumentException("User must be set");
transport.addChildEntry(Project.class, getProjectKey(project),
membership);
} | [
"public",
"void",
"addMembership",
"(",
"Membership",
"membership",
")",
"throws",
"RedmineException",
"{",
"final",
"Project",
"project",
"=",
"membership",
".",
"getProject",
"(",
")",
";",
"if",
"(",
"project",
"==",
"null",
")",
"throw",
"new",
"IllegalArg... | Add a membership.
@param membership
membership.
@throws RedmineException | [
"Add",
"a",
"membership",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/RedmineManager.java#L807-L815 | train |
Systemdir/GML-Writer-for-yED | GMLWriter/src/com/github/systemdir/gml/YedGmlWriter.java | YedGmlWriter.export | public void export(Writer output, UndirectedGraph<V, E> g) {
export(output, g, false);
} | java | public void export(Writer output, UndirectedGraph<V, E> g) {
export(output, g, false);
} | [
"public",
"void",
"export",
"(",
"Writer",
"output",
",",
"UndirectedGraph",
"<",
"V",
",",
"E",
">",
"g",
")",
"{",
"export",
"(",
"output",
",",
"g",
",",
"false",
")",
";",
"}"
] | Exports an undirected graph into a PLAIN text file in GML format.
@param output the writer to which the graph to be exported
@param g the undirected graph to be exported | [
"Exports",
"an",
"undirected",
"graph",
"into",
"a",
"PLAIN",
"text",
"file",
"in",
"GML",
"format",
"."
] | 353ecf132929889cb15968865283ee511f7c8d87 | https://github.com/Systemdir/GML-Writer-for-yED/blob/353ecf132929889cb15968865283ee511f7c8d87/GMLWriter/src/com/github/systemdir/gml/YedGmlWriter.java#L407-L409 | train |
Systemdir/GML-Writer-for-yED | GMLWriter/src/com/github/systemdir/gml/YedGmlWriter.java | YedGmlWriter.export | public void export(Writer output, DirectedGraph<V, E> g) {
export(output, g, true);
} | java | public void export(Writer output, DirectedGraph<V, E> g) {
export(output, g, true);
} | [
"public",
"void",
"export",
"(",
"Writer",
"output",
",",
"DirectedGraph",
"<",
"V",
",",
"E",
">",
"g",
")",
"{",
"export",
"(",
"output",
",",
"g",
",",
"true",
")",
";",
"}"
] | Exports a directed graph into a PLAIN text file in GML format.
@param output the writer to which the graph to be exported
@param g the directed graph to be exported | [
"Exports",
"a",
"directed",
"graph",
"into",
"a",
"PLAIN",
"text",
"file",
"in",
"GML",
"format",
"."
] | 353ecf132929889cb15968865283ee511f7c8d87 | https://github.com/Systemdir/GML-Writer-for-yED/blob/353ecf132929889cb15968865283ee511f7c8d87/GMLWriter/src/com/github/systemdir/gml/YedGmlWriter.java#L417-L419 | train |
jdillon/gshell | gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java | StringsCompleter2.set | public void set(final Iterable<String> strings) {
checkNotNull(strings);
candidates.clear();
addAll(strings);
} | java | public void set(final Iterable<String> strings) {
checkNotNull(strings);
candidates.clear();
addAll(strings);
} | [
"public",
"void",
"set",
"(",
"final",
"Iterable",
"<",
"String",
">",
"strings",
")",
"{",
"checkNotNull",
"(",
"strings",
")",
";",
"candidates",
".",
"clear",
"(",
")",
";",
"addAll",
"(",
"strings",
")",
";",
"}"
] | Set completion strings; replacing any existing. | [
"Set",
"completion",
"strings",
";",
"replacing",
"any",
"existing",
"."
] | b587c1a4672d2e4905871462fa3b38a1f7b94e90 | https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java#L57-L61 | train |
jdillon/gshell | gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java | StringsCompleter2.addAll | public void addAll(final Iterable<String> strings) {
checkNotNull(strings);
for (String string : strings) {
add(string);
}
} | java | public void addAll(final Iterable<String> strings) {
checkNotNull(strings);
for (String string : strings) {
add(string);
}
} | [
"public",
"void",
"addAll",
"(",
"final",
"Iterable",
"<",
"String",
">",
"strings",
")",
"{",
"checkNotNull",
"(",
"strings",
")",
";",
"for",
"(",
"String",
"string",
":",
"strings",
")",
"{",
"add",
"(",
"string",
")",
";",
"}",
"}"
] | Add all strings to existing candidates. | [
"Add",
"all",
"strings",
"to",
"existing",
"candidates",
"."
] | b587c1a4672d2e4905871462fa3b38a1f7b94e90 | https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java#L66-L71 | train |
jdillon/gshell | gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java | StringsCompleter2.add | public void add(final String string) {
checkNotNull(string);
candidates.put(string, candidate(string));
} | java | public void add(final String string) {
checkNotNull(string);
candidates.put(string, candidate(string));
} | [
"public",
"void",
"add",
"(",
"final",
"String",
"string",
")",
"{",
"checkNotNull",
"(",
"string",
")",
";",
"candidates",
".",
"put",
"(",
"string",
",",
"candidate",
"(",
"string",
")",
")",
";",
"}"
] | Add a string to existing candidates. | [
"Add",
"a",
"string",
"to",
"existing",
"candidates",
"."
] | b587c1a4672d2e4905871462fa3b38a1f7b94e90 | https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java#L84-L87 | train |
jdillon/gshell | gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java | StringsCompleter2.add | public void add(final String string, final Candidate candidate) {
checkNotNull(string);
checkNotNull(candidate);
candidates.put(string, candidate);
} | java | public void add(final String string, final Candidate candidate) {
checkNotNull(string);
checkNotNull(candidate);
candidates.put(string, candidate);
} | [
"public",
"void",
"add",
"(",
"final",
"String",
"string",
",",
"final",
"Candidate",
"candidate",
")",
"{",
"checkNotNull",
"(",
"string",
")",
";",
"checkNotNull",
"(",
"candidate",
")",
";",
"candidates",
".",
"put",
"(",
"string",
",",
"candidate",
")"... | Add string with specific completer. | [
"Add",
"string",
"with",
"specific",
"completer",
"."
] | b587c1a4672d2e4905871462fa3b38a1f7b94e90 | https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/jline/StringsCompleter2.java#L100-L104 | train |
threerings/nenya | core/src/main/java/com/threerings/media/util/PathSequence.java | PathSequence.initNextPath | protected void initNextPath (long initStamp, long tickStamp)
{
if (_paths.size() == 0) {
_pable.pathCompleted(tickStamp);
} else {
_curPath = _paths.remove(0);
_lastInit = initStamp;
_curPath.init(_pableRep, initStamp);
_curPath.tick(_pableRep, tickStamp);
}
} | java | protected void initNextPath (long initStamp, long tickStamp)
{
if (_paths.size() == 0) {
_pable.pathCompleted(tickStamp);
} else {
_curPath = _paths.remove(0);
_lastInit = initStamp;
_curPath.init(_pableRep, initStamp);
_curPath.tick(_pableRep, tickStamp);
}
} | [
"protected",
"void",
"initNextPath",
"(",
"long",
"initStamp",
",",
"long",
"tickStamp",
")",
"{",
"if",
"(",
"_paths",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"_pable",
".",
"pathCompleted",
"(",
"tickStamp",
")",
";",
"}",
"else",
"{",
"_curPath"... | Initialize and start the next path in the sequence. | [
"Initialize",
"and",
"start",
"the",
"next",
"path",
"in",
"the",
"sequence",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/PathSequence.java#L120-L132 | train |
vdurmont/etaprinter | src/main/java/com/vdurmont/etaprinter/ETAStatusGenerator.java | ETAStatusGenerator.getStatus | public static String getStatus(String elementName, long percentage, double speed, String speedUnit, Duration eta) {
StringBuilder sb = new StringBuilder(getBar(percentage));
sb.append((long) speed);
if (elementName != null) {
sb.append(" ").append(elementName);
}
sb.append("/").append(speedUnit);
sb.append(" ETA ").append(FORMATTER.print(eta.toPeriod()));
return sb.toString();
} | java | public static String getStatus(String elementName, long percentage, double speed, String speedUnit, Duration eta) {
StringBuilder sb = new StringBuilder(getBar(percentage));
sb.append((long) speed);
if (elementName != null) {
sb.append(" ").append(elementName);
}
sb.append("/").append(speedUnit);
sb.append(" ETA ").append(FORMATTER.print(eta.toPeriod()));
return sb.toString();
} | [
"public",
"static",
"String",
"getStatus",
"(",
"String",
"elementName",
",",
"long",
"percentage",
",",
"double",
"speed",
",",
"String",
"speedUnit",
",",
"Duration",
"eta",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"getBar",
"(",
... | Generate the full status.
@param elementName the optional name of the element that is processed
@param percentage the progression percentage
@param speed the speed of the processing (in number of element by speed unit)
@param speedUnit the unit of the given speed
@param eta the estimated remaining duration for the processing
@return the status string | [
"Generate",
"the",
"full",
"status",
"."
] | 19039bdbbece8b05ceab2a23757f4e1e8b6872cb | https://github.com/vdurmont/etaprinter/blob/19039bdbbece8b05ceab2a23757f4e1e8b6872cb/src/main/java/com/vdurmont/etaprinter/ETAStatusGenerator.java#L46-L55 | train |
vdurmont/etaprinter | src/main/java/com/vdurmont/etaprinter/ETAStatusGenerator.java | ETAStatusGenerator.getBar | protected static String getBar(long percentage) {
StringBuilder sb = new StringBuilder();
sb.append(percentage);
sb.append("% [");
for (int i = 0; i < 100; i++) {
if (percentage == 100 || i < percentage - 1) {
sb.append("=");
} else if (i == percentage - 1) {
sb.append(">");
} else {
sb.append(" ");
}
}
sb.append("] ");
return sb.toString();
} | java | protected static String getBar(long percentage) {
StringBuilder sb = new StringBuilder();
sb.append(percentage);
sb.append("% [");
for (int i = 0; i < 100; i++) {
if (percentage == 100 || i < percentage - 1) {
sb.append("=");
} else if (i == percentage - 1) {
sb.append(">");
} else {
sb.append(" ");
}
}
sb.append("] ");
return sb.toString();
} | [
"protected",
"static",
"String",
"getBar",
"(",
"long",
"percentage",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"percentage",
")",
";",
"sb",
".",
"append",
"(",
"\"% [\"",
")",
";",
"for",
"... | Generates the progress bar for the given percentage
@param percentage the progression percentage
@return the progress bar as a string | [
"Generates",
"the",
"progress",
"bar",
"for",
"the",
"given",
"percentage"
] | 19039bdbbece8b05ceab2a23757f4e1e8b6872cb | https://github.com/vdurmont/etaprinter/blob/19039bdbbece8b05ceab2a23757f4e1e8b6872cb/src/main/java/com/vdurmont/etaprinter/ETAStatusGenerator.java#L64-L79 | train |
kaazing/java.client | ws/ws/src/main/java/org/kaazing/gateway/client/impl/WebSocketHandlerAdapter.java | WebSocketHandlerAdapter.processConnect | @Override
public void processConnect(WebSocketChannel channel, WSURI location, String[] protocols) {
nextHandler.processConnect(channel, location, protocols);
} | java | @Override
public void processConnect(WebSocketChannel channel, WSURI location, String[] protocols) {
nextHandler.processConnect(channel, location, protocols);
} | [
"@",
"Override",
"public",
"void",
"processConnect",
"(",
"WebSocketChannel",
"channel",
",",
"WSURI",
"location",
",",
"String",
"[",
"]",
"protocols",
")",
"{",
"nextHandler",
".",
"processConnect",
"(",
"channel",
",",
"location",
",",
"protocols",
")",
";"... | Process connect request to uri and protocol specified | [
"Process",
"connect",
"request",
"to",
"uri",
"and",
"protocol",
"specified"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/gateway/client/impl/WebSocketHandlerAdapter.java#L29-L32 | train |
kaazing/java.client | ws/ws/src/main/java/org/kaazing/gateway/client/impl/WebSocketHandlerAdapter.java | WebSocketHandlerAdapter.processAuthorize | @Override
public synchronized void processAuthorize(WebSocketChannel channel, String authorizeToken) {
nextHandler.processAuthorize(channel, authorizeToken);
} | java | @Override
public synchronized void processAuthorize(WebSocketChannel channel, String authorizeToken) {
nextHandler.processAuthorize(channel, authorizeToken);
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"processAuthorize",
"(",
"WebSocketChannel",
"channel",
",",
"String",
"authorizeToken",
")",
"{",
"nextHandler",
".",
"processAuthorize",
"(",
"channel",
",",
"authorizeToken",
")",
";",
"}"
] | Send authorize token to the Gateway | [
"Send",
"authorize",
"token",
"to",
"the",
"Gateway"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/gateway/client/impl/WebSocketHandlerAdapter.java#L37-L40 | train |
groupon/monsoon | history/src/main/java/com/groupon/lex/metrics/history/v1/xdr/ToXdr.java | ToXdr.data | public tsfile_data data(TimeSeriesCollection ts_data) {
final dictionary_delta dict_delta = new dictionary_delta();
dict_delta.gdd = new path_dictionary_delta[0];
dict_delta.mdd = new path_dictionary_delta[0];
dict_delta.sdd = new strval_dictionary_delta[0];
dict_delta.tdd = new tag_dictionary_delta[0];
final List<tsfile_record> records = new ArrayList<>();
final Iterator<TimeSeriesValue> tsv_iter = ts_data.getTSValues().stream().iterator();
while (tsv_iter.hasNext()) {
final TimeSeriesValue tsv = tsv_iter.next();
tsfile_record record = new tsfile_record();
record.group_ref = simpleGroupPath_index(dict_delta, tsv.getGroup().getPath());
record.tag_ref = tags_index(dict_delta, tsv.getGroup().getTags());
record.metrics = tsv.getMetrics().entrySet().stream()
.map(entry -> {
tsfile_record_entry tre = new tsfile_record_entry();
tre.metric_ref = metricName_index(dict_delta, entry.getKey());
tre.v = metric_value_(dict_delta, entry.getValue());
return tre;
})
.toArray(tsfile_record_entry[]::new);
records.add(record);
}
tsfile_data result = new tsfile_data();
result.records = records.stream().toArray(tsfile_record[]::new);
result.ts = timestamp(ts_data.getTimestamp());
if (dict_delta.gdd.length > 0 || dict_delta.mdd.length > 0 || dict_delta.sdd.length > 0 || dict_delta.tdd.length > 0)
result.dd = dict_delta;
return result;
} | java | public tsfile_data data(TimeSeriesCollection ts_data) {
final dictionary_delta dict_delta = new dictionary_delta();
dict_delta.gdd = new path_dictionary_delta[0];
dict_delta.mdd = new path_dictionary_delta[0];
dict_delta.sdd = new strval_dictionary_delta[0];
dict_delta.tdd = new tag_dictionary_delta[0];
final List<tsfile_record> records = new ArrayList<>();
final Iterator<TimeSeriesValue> tsv_iter = ts_data.getTSValues().stream().iterator();
while (tsv_iter.hasNext()) {
final TimeSeriesValue tsv = tsv_iter.next();
tsfile_record record = new tsfile_record();
record.group_ref = simpleGroupPath_index(dict_delta, tsv.getGroup().getPath());
record.tag_ref = tags_index(dict_delta, tsv.getGroup().getTags());
record.metrics = tsv.getMetrics().entrySet().stream()
.map(entry -> {
tsfile_record_entry tre = new tsfile_record_entry();
tre.metric_ref = metricName_index(dict_delta, entry.getKey());
tre.v = metric_value_(dict_delta, entry.getValue());
return tre;
})
.toArray(tsfile_record_entry[]::new);
records.add(record);
}
tsfile_data result = new tsfile_data();
result.records = records.stream().toArray(tsfile_record[]::new);
result.ts = timestamp(ts_data.getTimestamp());
if (dict_delta.gdd.length > 0 || dict_delta.mdd.length > 0 || dict_delta.sdd.length > 0 || dict_delta.tdd.length > 0)
result.dd = dict_delta;
return result;
} | [
"public",
"tsfile_data",
"data",
"(",
"TimeSeriesCollection",
"ts_data",
")",
"{",
"final",
"dictionary_delta",
"dict_delta",
"=",
"new",
"dictionary_delta",
"(",
")",
";",
"dict_delta",
".",
"gdd",
"=",
"new",
"path_dictionary_delta",
"[",
"0",
"]",
";",
"dict_... | Transform a TimeSeriesCollection into the XDR serialized form. | [
"Transform",
"a",
"TimeSeriesCollection",
"into",
"the",
"XDR",
"serialized",
"form",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/history/src/main/java/com/groupon/lex/metrics/history/v1/xdr/ToXdr.java#L79-L111 | train |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/collect/Iterables2.java | Iterables2.simpleIterable | public static <T> Iterable<T> simpleIterable(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> iterable.iterator();
} | java | public static <T> Iterable<T> simpleIterable(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> iterable.iterator();
} | [
"public",
"static",
"<",
"T",
">",
"Iterable",
"<",
"T",
">",
"simpleIterable",
"(",
"final",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"requireNonNull",
"(",
"iterable",
")",
";",
"return",
"(",
")",
"->",
"iterable",
".",
"iterator",
"(",
")",... | Wraps any iterable into a generic iterable object. This is useful for using complex iterables such as FluentIterable
with libraries that use reflection to determine bean definitions such as Jackson. | [
"Wraps",
"any",
"iterable",
"into",
"a",
"generic",
"iterable",
"object",
".",
"This",
"is",
"useful",
"for",
"using",
"complex",
"iterables",
"such",
"as",
"FluentIterable",
"with",
"libraries",
"that",
"use",
"reflection",
"to",
"determine",
"bean",
"definitio... | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/collect/Iterables2.java#L34-L37 | train |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/collect/Iterables2.java | Iterables2.distinct | public static <T> Iterable<T> distinct(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> Iterators2.distinct(iterable.iterator());
} | java | public static <T> Iterable<T> distinct(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> Iterators2.distinct(iterable.iterator());
} | [
"public",
"static",
"<",
"T",
">",
"Iterable",
"<",
"T",
">",
"distinct",
"(",
"final",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"requireNonNull",
"(",
"iterable",
")",
";",
"return",
"(",
")",
"->",
"Iterators2",
".",
"distinct",
"(",
"iterabl... | If we can assume the iterable is sorted, return the distinct elements. This only works
if the data provided is sorted. | [
"If",
"we",
"can",
"assume",
"the",
"iterable",
"is",
"sorted",
"return",
"the",
"distinct",
"elements",
".",
"This",
"only",
"works",
"if",
"the",
"data",
"provided",
"is",
"sorted",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/collect/Iterables2.java#L43-L46 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java | AmqpBuffer.encodeAuthAmqPlain | public String encodeAuthAmqPlain(String username, String password)
{
AmqpBuffer bytes = new AmqpBuffer();
bytes.putShortString("LOGIN");
bytes.putTypeIdentifier("Longstr");
bytes.putLongString(username);
bytes.putShortString("PASSWORD");
bytes.putTypeIdentifier("Longstr");
bytes.putLongString(password);
bytes.flip();
int len = bytes.remaining();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < len; i++)
{
builder.append((char)(bytes.getUnsigned()));
}
String s = builder.toString();
return s;
} | java | public String encodeAuthAmqPlain(String username, String password)
{
AmqpBuffer bytes = new AmqpBuffer();
bytes.putShortString("LOGIN");
bytes.putTypeIdentifier("Longstr");
bytes.putLongString(username);
bytes.putShortString("PASSWORD");
bytes.putTypeIdentifier("Longstr");
bytes.putLongString(password);
bytes.flip();
int len = bytes.remaining();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < len; i++)
{
builder.append((char)(bytes.getUnsigned()));
}
String s = builder.toString();
return s;
} | [
"public",
"String",
"encodeAuthAmqPlain",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"AmqpBuffer",
"bytes",
"=",
"new",
"AmqpBuffer",
"(",
")",
";",
"bytes",
".",
"putShortString",
"(",
"\"LOGIN\"",
")",
";",
"bytes",
".",
"putTypeIdentifi... | Encodes the AMQPLAIN authentication response as an AmqpArguments | [
"Encodes",
"the",
"AMQPLAIN",
"authentication",
"response",
"as",
"an",
"AmqpArguments"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java#L92-L113 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java | AmqpBuffer.getMethodArguments | private Arg[] getMethodArguments(List<Parameter> param)
{
Arg[] val = new Arg[param.size()];
for (int i = 0; i < param.size(); i++)
{
String type = param.get(i).type;
Arg arg = new Arg();
arg.type = type;
arg.name = param.get(i).name;
Object v = null;
String type1 = null;
try
{
type1 = this.getMappedType(type);
v = getObjectOfType(type1);
}
catch (Exception e)
{
throw new IllegalStateException("type codec failed for type " + type + " for domain " + e.getMessage());
}
// support unpacking of consecutive bits from a single byte
this.bitCount = (byte)((type1 == "Bit") ? this.bitCount + 1 : 0);
arg.value = v;
val[i]=arg;
}
return val;
} | java | private Arg[] getMethodArguments(List<Parameter> param)
{
Arg[] val = new Arg[param.size()];
for (int i = 0; i < param.size(); i++)
{
String type = param.get(i).type;
Arg arg = new Arg();
arg.type = type;
arg.name = param.get(i).name;
Object v = null;
String type1 = null;
try
{
type1 = this.getMappedType(type);
v = getObjectOfType(type1);
}
catch (Exception e)
{
throw new IllegalStateException("type codec failed for type " + type + " for domain " + e.getMessage());
}
// support unpacking of consecutive bits from a single byte
this.bitCount = (byte)((type1 == "Bit") ? this.bitCount + 1 : 0);
arg.value = v;
val[i]=arg;
}
return val;
} | [
"private",
"Arg",
"[",
"]",
"getMethodArguments",
"(",
"List",
"<",
"Parameter",
">",
"param",
")",
"{",
"Arg",
"[",
"]",
"val",
"=",
"new",
"Arg",
"[",
"param",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | Decodes arguments given a method's parameter list | [
"Decodes",
"arguments",
"given",
"a",
"method",
"s",
"parameter",
"list"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java#L359-L390 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java | AmqpBuffer.getFrame | public AmqpFrame getFrame()
{
int pos = this.position();
AmqpMethod method = new AmqpMethod();
int classIndex;
AmqpFrame frame = new AmqpFrame();
// If there is at least one Frame in the buffer, attempt to decode it.
if (this.remaining() > 7)
{
frame.setHeader(this.getFrameHeader());
frame.setChannelId((short) frame.getHeader().channel);
frame.setType((short) frame.getHeader().frameType);
// the buffer must have an additional byte for the Frame end marker
if (this.remaining() >= frame.getHeader().size + 1)
{
switch (frame.getType())
{
case AmqpConstants.FRAME_BODY:
WrappedByteBuffer body = new AmqpBuffer();
// copy body into new Buffer
int end = this.position() + (int)frame.getHeader().size;
while (position() < end)
{
body.put(get());
}
frame.setBody(body);
frame.setMethodName("body");
break;
case AmqpConstants.FRAME_HEADER:
classIndex = this.getUnsignedShort();
@SuppressWarnings("unused")
short weight = (short)this.getUnsignedShort();
@SuppressWarnings("unused")
long bodySize = this.getUnsignedLong();
frame.setContentProperties(this.getContentProperties());
frame.setMethodName("header");
break;
case AmqpConstants.FRAME_METHOD:
classIndex = this.getUnsignedShort();
int methodIndex = this.getUnsignedShort();
String indexes = String.valueOf(classIndex) + String.valueOf(methodIndex);
method = MethodLookup.LookupMethod(indexes);
// pull parameter list off of method
List<Parameter> params = method.allParameters;
frame.setMethodName(method.name);
frame.setArgs(this.getMethodArguments(params));
break;
case AmqpConstants.FRAME_HEARTBEAT:
case AmqpConstants.FRAME_RABBITMQ_HEARTBEAT:
throw new IllegalStateException("Received heartbeat frame even though the client has expressed no interest in heartbeat via tune-ok method.");
default:
throw new IllegalStateException("Unrecognized AMQP 0-9-1 Frame type = " + frame.getType());
}
short frameEnd = (short) this.getUnsigned();
if (frameEnd != AmqpConstants.FRAME_END)
{
throw new IllegalStateException("Invalid end of AMQP method frame");
}
}
else
{
this.position(pos);
return null;
}
return frame;
}
return null;
} | java | public AmqpFrame getFrame()
{
int pos = this.position();
AmqpMethod method = new AmqpMethod();
int classIndex;
AmqpFrame frame = new AmqpFrame();
// If there is at least one Frame in the buffer, attempt to decode it.
if (this.remaining() > 7)
{
frame.setHeader(this.getFrameHeader());
frame.setChannelId((short) frame.getHeader().channel);
frame.setType((short) frame.getHeader().frameType);
// the buffer must have an additional byte for the Frame end marker
if (this.remaining() >= frame.getHeader().size + 1)
{
switch (frame.getType())
{
case AmqpConstants.FRAME_BODY:
WrappedByteBuffer body = new AmqpBuffer();
// copy body into new Buffer
int end = this.position() + (int)frame.getHeader().size;
while (position() < end)
{
body.put(get());
}
frame.setBody(body);
frame.setMethodName("body");
break;
case AmqpConstants.FRAME_HEADER:
classIndex = this.getUnsignedShort();
@SuppressWarnings("unused")
short weight = (short)this.getUnsignedShort();
@SuppressWarnings("unused")
long bodySize = this.getUnsignedLong();
frame.setContentProperties(this.getContentProperties());
frame.setMethodName("header");
break;
case AmqpConstants.FRAME_METHOD:
classIndex = this.getUnsignedShort();
int methodIndex = this.getUnsignedShort();
String indexes = String.valueOf(classIndex) + String.valueOf(methodIndex);
method = MethodLookup.LookupMethod(indexes);
// pull parameter list off of method
List<Parameter> params = method.allParameters;
frame.setMethodName(method.name);
frame.setArgs(this.getMethodArguments(params));
break;
case AmqpConstants.FRAME_HEARTBEAT:
case AmqpConstants.FRAME_RABBITMQ_HEARTBEAT:
throw new IllegalStateException("Received heartbeat frame even though the client has expressed no interest in heartbeat via tune-ok method.");
default:
throw new IllegalStateException("Unrecognized AMQP 0-9-1 Frame type = " + frame.getType());
}
short frameEnd = (short) this.getUnsigned();
if (frameEnd != AmqpConstants.FRAME_END)
{
throw new IllegalStateException("Invalid end of AMQP method frame");
}
}
else
{
this.position(pos);
return null;
}
return frame;
}
return null;
} | [
"public",
"AmqpFrame",
"getFrame",
"(",
")",
"{",
"int",
"pos",
"=",
"this",
".",
"position",
"(",
")",
";",
"AmqpMethod",
"method",
"=",
"new",
"AmqpMethod",
"(",
")",
";",
"int",
"classIndex",
";",
"AmqpFrame",
"frame",
"=",
"new",
"AmqpFrame",
"(",
... | Parses the ByteBuffer and returns an AMQP frame
@return AmqpFrame | [
"Parses",
"the",
"ByteBuffer",
"and",
"returns",
"an",
"AMQP",
"frame"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java#L396-L473 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java | AmqpBuffer.putMethodArguments | AmqpBuffer putMethodArguments(Object[] args, List<Parameter> formalParams)
{
for (int i = 0; i < formalParams.size(); i++)
{
String type = formalParams.get(i).type;
if (type == null)
{
throw new IllegalStateException("Unknown AMQP domain " + type);
}
String typeMap = getMappedType(type);
putObjectOfType(typeMap, args[i]);
// support packing of consecutive bits into a single byte
this.bitCount = (byte)((typeMap == "Bit") ? this.bitCount + 1 : 0);
}
return this;
} | java | AmqpBuffer putMethodArguments(Object[] args, List<Parameter> formalParams)
{
for (int i = 0; i < formalParams.size(); i++)
{
String type = formalParams.get(i).type;
if (type == null)
{
throw new IllegalStateException("Unknown AMQP domain " + type);
}
String typeMap = getMappedType(type);
putObjectOfType(typeMap, args[i]);
// support packing of consecutive bits into a single byte
this.bitCount = (byte)((typeMap == "Bit") ? this.bitCount + 1 : 0);
}
return this;
} | [
"AmqpBuffer",
"putMethodArguments",
"(",
"Object",
"[",
"]",
"args",
",",
"List",
"<",
"Parameter",
">",
"formalParams",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"formalParams",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"St... | Encodes arguments given a method's parameter list and the provided arguments | [
"Encodes",
"arguments",
"given",
"a",
"method",
"s",
"parameter",
"list",
"and",
"the",
"provided",
"arguments"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/impl/AmqpBuffer.java#L531-L550 | train |
threerings/nenya | core/src/main/java/com/threerings/media/ManagedJFrame.java | ManagedJFrame.update | @Override
public void update (Graphics g)
{
Shape clip = g.getClip();
Rectangle dirty;
if (clip != null) {
dirty = clip.getBounds();
} else {
dirty = getRootPane().getBounds();
// account for our frame insets
Insets insets = getInsets();
dirty.x += insets.left;
dirty.y += insets.top;
}
if (_fmgr != null) {
_fmgr.restoreFromBack(dirty);
}
} | java | @Override
public void update (Graphics g)
{
Shape clip = g.getClip();
Rectangle dirty;
if (clip != null) {
dirty = clip.getBounds();
} else {
dirty = getRootPane().getBounds();
// account for our frame insets
Insets insets = getInsets();
dirty.x += insets.left;
dirty.y += insets.top;
}
if (_fmgr != null) {
_fmgr.restoreFromBack(dirty);
}
} | [
"@",
"Override",
"public",
"void",
"update",
"(",
"Graphics",
"g",
")",
"{",
"Shape",
"clip",
"=",
"g",
".",
"getClip",
"(",
")",
";",
"Rectangle",
"dirty",
";",
"if",
"(",
"clip",
"!=",
"null",
")",
"{",
"dirty",
"=",
"clip",
".",
"getBounds",
"("... | We catch update requests and forward them on to the repaint infrastructure. | [
"We",
"catch",
"update",
"requests",
"and",
"forward",
"them",
"on",
"to",
"the",
"repaint",
"infrastructure",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/ManagedJFrame.java#L93-L111 | train |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/io/Serializables.java | Serializables.deserialize | public static <T extends Serializable> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
return deserialize(bytes, false);
} | java | public static <T extends Serializable> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
return deserialize(bytes, false);
} | [
"public",
"static",
"<",
"T",
"extends",
"Serializable",
">",
"T",
"deserialize",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"return",
"deserialize",
"(",
"bytes",
",",
"false",
")",
";",
"}"
] | Utility for returning a Serializable object from a byte array. | [
"Utility",
"for",
"returning",
"a",
"Serializable",
"object",
"from",
"a",
"byte",
"array",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/io/Serializables.java#L58-L60 | train |
groupon/monsoon | impl/src/main/java/com/groupon/lex/metrics/PipelineBuilder.java | PipelineBuilder.build | public PushProcessorPipeline build(List<PushProcessorSupplier> processor_suppliers) throws Exception {
ApiServer api = null;
PushMetricRegistryInstance registry = null;
final List<PushProcessor> processors = new ArrayList<>(processor_suppliers.size());
try {
final EndpointRegistration epr;
if (epr_ == null)
epr = api = new ApiServer(api_sockaddr_);
else
epr = epr_;
registry = cfg_.create(PushMetricRegistryInstance::new, epr);
for (PushProcessorSupplier pps : processor_suppliers)
processors.add(pps.build(epr));
if (history_ != null)
registry.setHistory(history_);
if (api != null) api.start();
return new PushProcessorPipeline(registry, collect_interval_seconds_, processors);
} catch (Exception ex) {
try {
if (api != null) api.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
try {
if (registry != null) registry.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
for (PushProcessor pp : processors) {
try {
pp.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
}
throw ex;
}
} | java | public PushProcessorPipeline build(List<PushProcessorSupplier> processor_suppliers) throws Exception {
ApiServer api = null;
PushMetricRegistryInstance registry = null;
final List<PushProcessor> processors = new ArrayList<>(processor_suppliers.size());
try {
final EndpointRegistration epr;
if (epr_ == null)
epr = api = new ApiServer(api_sockaddr_);
else
epr = epr_;
registry = cfg_.create(PushMetricRegistryInstance::new, epr);
for (PushProcessorSupplier pps : processor_suppliers)
processors.add(pps.build(epr));
if (history_ != null)
registry.setHistory(history_);
if (api != null) api.start();
return new PushProcessorPipeline(registry, collect_interval_seconds_, processors);
} catch (Exception ex) {
try {
if (api != null) api.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
try {
if (registry != null) registry.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
for (PushProcessor pp : processors) {
try {
pp.close();
} catch (Exception ex1) {
ex.addSuppressed(ex1);
}
}
throw ex;
}
} | [
"public",
"PushProcessorPipeline",
"build",
"(",
"List",
"<",
"PushProcessorSupplier",
">",
"processor_suppliers",
")",
"throws",
"Exception",
"{",
"ApiServer",
"api",
"=",
"null",
";",
"PushMetricRegistryInstance",
"registry",
"=",
"null",
";",
"final",
"List",
"<"... | Creates a push processor.
The API server is started by this method.
The returned push processor is not started.
@param processor_suppliers A list of PushProcessorSupplier, that will instantiate the push processors.
@return A Push Processor pipeline. You'll need to start it yourself.
@throws Exception indicating construction failed.
Push Processors that were created before the exception was thrown, will be closed. | [
"Creates",
"a",
"push",
"processor",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PipelineBuilder.java#L124-L166 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.createCompatibleImage | public static BufferedImage createCompatibleImage (BufferedImage source, int width, int height)
{
WritableRaster raster = source.getRaster().createCompatibleWritableRaster(width, height);
return new BufferedImage(source.getColorModel(), raster, false, null);
} | java | public static BufferedImage createCompatibleImage (BufferedImage source, int width, int height)
{
WritableRaster raster = source.getRaster().createCompatibleWritableRaster(width, height);
return new BufferedImage(source.getColorModel(), raster, false, null);
} | [
"public",
"static",
"BufferedImage",
"createCompatibleImage",
"(",
"BufferedImage",
"source",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"WritableRaster",
"raster",
"=",
"source",
".",
"getRaster",
"(",
")",
".",
"createCompatibleWritableRaster",
"(",
"w... | Creates a new buffered image with the same sample model and color model as the source image
but with the new width and height. | [
"Creates",
"a",
"new",
"buffered",
"image",
"with",
"the",
"same",
"sample",
"model",
"and",
"color",
"model",
"as",
"the",
"source",
"image",
"but",
"with",
"the",
"new",
"width",
"and",
"height",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L62-L66 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.createErrorImage | public static BufferedImage createErrorImage (int width, int height)
{
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D g = (Graphics2D)img.getGraphics();
g.setColor(Color.red);
Label l = new Label("Error");
l.layout(g);
Dimension d = l.getSize();
// fill that sucker with errors
for (int yy = 0; yy < height; yy += d.height) {
for (int xx = 0; xx < width; xx += (d.width+5)) {
l.render(g, xx, yy);
}
}
g.dispose();
return img;
} | java | public static BufferedImage createErrorImage (int width, int height)
{
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D g = (Graphics2D)img.getGraphics();
g.setColor(Color.red);
Label l = new Label("Error");
l.layout(g);
Dimension d = l.getSize();
// fill that sucker with errors
for (int yy = 0; yy < height; yy += d.height) {
for (int xx = 0; xx < width; xx += (d.width+5)) {
l.render(g, xx, yy);
}
}
g.dispose();
return img;
} | [
"public",
"static",
"BufferedImage",
"createErrorImage",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"BufferedImage",
"img",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"BufferedImage",
".",
"TYPE_BYTE_INDEXED",
")",
";",
"Graphics2D"... | Creates an image with the word "Error" written in it. | [
"Creates",
"an",
"image",
"with",
"the",
"word",
"Error",
"written",
"in",
"it",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L71-L87 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.recolorImage | public static BufferedImage recolorImage (BufferedImage image, Colorization[] zations)
{
ColorModel cm = image.getColorModel();
if (!(cm instanceof IndexColorModel)) {
throw new RuntimeException(Logger.format(
"Unable to recolor images with non-index color model", "cm", cm.getClass()));
}
// now process the image
IndexColorModel icm = (IndexColorModel)cm;
int size = icm.getMapSize();
int zcount = zations.length;
int[] rgbs = new int[size];
// fetch the color data
icm.getRGBs(rgbs);
// convert the colors to HSV
float[] hsv = new float[3];
int[] fhsv = new int[3];
for (int ii = 0; ii < size; ii++) {
int value = rgbs[ii];
// don't fiddle with alpha pixels
if ((value & 0xFF000000) == 0) {
continue;
}
// convert the color to HSV
int red = (value >> 16) & 0xFF;
int green = (value >> 8) & 0xFF;
int blue = (value >> 0) & 0xFF;
Color.RGBtoHSB(red, green, blue, hsv);
Colorization.toFixedHSV(hsv, fhsv);
// see if this color matches and of our colorizations and recolor it if it does
for (int z = 0; z < zcount; z++) {
Colorization cz = zations[z];
if (cz != null && cz.matches(hsv, fhsv)) {
// massage the HSV bands and update the RGBs array
rgbs[ii] = cz.recolorColor(hsv);
break;
}
}
}
// create a new image with the adjusted color palette
IndexColorModel nicm = new IndexColorModel(
icm.getPixelSize(), size, rgbs, 0, icm.hasAlpha(),
icm.getTransparentPixel(), icm.getTransferType());
return new BufferedImage(nicm, image.getRaster(), false, null);
} | java | public static BufferedImage recolorImage (BufferedImage image, Colorization[] zations)
{
ColorModel cm = image.getColorModel();
if (!(cm instanceof IndexColorModel)) {
throw new RuntimeException(Logger.format(
"Unable to recolor images with non-index color model", "cm", cm.getClass()));
}
// now process the image
IndexColorModel icm = (IndexColorModel)cm;
int size = icm.getMapSize();
int zcount = zations.length;
int[] rgbs = new int[size];
// fetch the color data
icm.getRGBs(rgbs);
// convert the colors to HSV
float[] hsv = new float[3];
int[] fhsv = new int[3];
for (int ii = 0; ii < size; ii++) {
int value = rgbs[ii];
// don't fiddle with alpha pixels
if ((value & 0xFF000000) == 0) {
continue;
}
// convert the color to HSV
int red = (value >> 16) & 0xFF;
int green = (value >> 8) & 0xFF;
int blue = (value >> 0) & 0xFF;
Color.RGBtoHSB(red, green, blue, hsv);
Colorization.toFixedHSV(hsv, fhsv);
// see if this color matches and of our colorizations and recolor it if it does
for (int z = 0; z < zcount; z++) {
Colorization cz = zations[z];
if (cz != null && cz.matches(hsv, fhsv)) {
// massage the HSV bands and update the RGBs array
rgbs[ii] = cz.recolorColor(hsv);
break;
}
}
}
// create a new image with the adjusted color palette
IndexColorModel nicm = new IndexColorModel(
icm.getPixelSize(), size, rgbs, 0, icm.hasAlpha(),
icm.getTransparentPixel(), icm.getTransferType());
return new BufferedImage(nicm, image.getRaster(), false, null);
} | [
"public",
"static",
"BufferedImage",
"recolorImage",
"(",
"BufferedImage",
"image",
",",
"Colorization",
"[",
"]",
"zations",
")",
"{",
"ColorModel",
"cm",
"=",
"image",
".",
"getColorModel",
"(",
")",
";",
"if",
"(",
"!",
"(",
"cm",
"instanceof",
"IndexColo... | Recolors the supplied image using the supplied colorizations. | [
"Recolors",
"the",
"supplied",
"image",
"using",
"the",
"supplied",
"colorizations",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L114-L165 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.tileImage | public static void tileImage (Graphics2D gfx, Mirage image, int x, int y, int width, int height)
{
int iwidth = image.getWidth(), iheight = image.getHeight();
int xnum = width / iwidth, xplus = width % iwidth;
int ynum = height / iheight, yplus = height % iheight;
Shape oclip = gfx.getClip();
for (int ii=0; ii < ynum; ii++) {
// draw the full copies of the image across
int xx = x;
for (int jj=0; jj < xnum; jj++) {
image.paint(gfx, xx, y);
xx += iwidth;
}
if (xplus > 0) {
gfx.clipRect(xx, y, xplus, iheight);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
}
y += iheight;
}
if (yplus > 0) {
int xx = x;
for (int jj=0; jj < xnum; jj++) {
gfx.clipRect(xx, y, iwidth, yplus);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
xx += iwidth;
}
if (xplus > 0) {
gfx.clipRect(xx, y, xplus, yplus);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
}
}
} | java | public static void tileImage (Graphics2D gfx, Mirage image, int x, int y, int width, int height)
{
int iwidth = image.getWidth(), iheight = image.getHeight();
int xnum = width / iwidth, xplus = width % iwidth;
int ynum = height / iheight, yplus = height % iheight;
Shape oclip = gfx.getClip();
for (int ii=0; ii < ynum; ii++) {
// draw the full copies of the image across
int xx = x;
for (int jj=0; jj < xnum; jj++) {
image.paint(gfx, xx, y);
xx += iwidth;
}
if (xplus > 0) {
gfx.clipRect(xx, y, xplus, iheight);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
}
y += iheight;
}
if (yplus > 0) {
int xx = x;
for (int jj=0; jj < xnum; jj++) {
gfx.clipRect(xx, y, iwidth, yplus);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
xx += iwidth;
}
if (xplus > 0) {
gfx.clipRect(xx, y, xplus, yplus);
image.paint(gfx, xx, y);
gfx.setClip(oclip);
}
}
} | [
"public",
"static",
"void",
"tileImage",
"(",
"Graphics2D",
"gfx",
",",
"Mirage",
"image",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"int",
"iwidth",
"=",
"image",
".",
"getWidth",
"(",
")",
",",
"iheight"... | Paints multiple copies of the supplied image using the supplied graphics context such that
the requested area is filled with the image. | [
"Paints",
"multiple",
"copies",
"of",
"the",
"supplied",
"image",
"using",
"the",
"supplied",
"graphics",
"context",
"such",
"that",
"the",
"requested",
"area",
"is",
"filled",
"with",
"the",
"image",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L171-L210 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.tileImageAcross | public static void tileImageAcross (Graphics2D gfx, Mirage image, int x, int y, int width)
{
tileImage(gfx, image, x, y, width, image.getHeight());
} | java | public static void tileImageAcross (Graphics2D gfx, Mirage image, int x, int y, int width)
{
tileImage(gfx, image, x, y, width, image.getHeight());
} | [
"public",
"static",
"void",
"tileImageAcross",
"(",
"Graphics2D",
"gfx",
",",
"Mirage",
"image",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
")",
"{",
"tileImage",
"(",
"gfx",
",",
"image",
",",
"x",
",",
"y",
",",
"width",
",",
"image",
... | Paints multiple copies of the supplied image using the supplied graphics context such that
the requested width is filled with the image. | [
"Paints",
"multiple",
"copies",
"of",
"the",
"supplied",
"image",
"using",
"the",
"supplied",
"graphics",
"context",
"such",
"that",
"the",
"requested",
"width",
"is",
"filled",
"with",
"the",
"image",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L216-L219 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.tileImageDown | public static void tileImageDown (Graphics2D gfx, Mirage image, int x, int y, int height)
{
tileImage(gfx, image, x, y, image.getWidth(), height);
} | java | public static void tileImageDown (Graphics2D gfx, Mirage image, int x, int y, int height)
{
tileImage(gfx, image, x, y, image.getWidth(), height);
} | [
"public",
"static",
"void",
"tileImageDown",
"(",
"Graphics2D",
"gfx",
",",
"Mirage",
"image",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"height",
")",
"{",
"tileImage",
"(",
"gfx",
",",
"image",
",",
"x",
",",
"y",
",",
"image",
".",
"getWidth",... | Paints multiple copies of the supplied image using the supplied graphics context such that
the requested height is filled with the image. | [
"Paints",
"multiple",
"copies",
"of",
"the",
"supplied",
"image",
"using",
"the",
"supplied",
"graphics",
"context",
"such",
"that",
"the",
"requested",
"height",
"is",
"filled",
"with",
"the",
"image",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L225-L228 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.createTracedImage | public static BufferedImage createTracedImage (
ImageCreator isrc, BufferedImage src, Color tcolor, int thickness)
{
return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
} | java | public static BufferedImage createTracedImage (
ImageCreator isrc, BufferedImage src, Color tcolor, int thickness)
{
return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
} | [
"public",
"static",
"BufferedImage",
"createTracedImage",
"(",
"ImageCreator",
"isrc",
",",
"BufferedImage",
"src",
",",
"Color",
"tcolor",
",",
"int",
"thickness",
")",
"{",
"return",
"createTracedImage",
"(",
"isrc",
",",
"src",
",",
"tcolor",
",",
"thickness"... | Creates and returns a new image consisting of the supplied image traced with the given
color and thickness. | [
"Creates",
"and",
"returns",
"a",
"new",
"image",
"consisting",
"of",
"the",
"supplied",
"image",
"traced",
"with",
"the",
"given",
"color",
"and",
"thickness",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L261-L265 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.bordersNonTransparentPixel | protected static boolean bordersNonTransparentPixel (
BufferedImage data, int wid, int hei, boolean[] traced, int x, int y)
{
// check the three-pixel row above the pixel
if (y > 0) {
for (int rxx = x - 1; rxx <= x + 1; rxx++) {
if (rxx < 0 || rxx >= wid || traced[((y-1)*wid)+rxx]) {
continue;
}
if ((data.getRGB(rxx, y - 1) & TRANS_MASK) != 0) {
return true;
}
}
}
// check the pixel to the left
if (x > 0 && !traced[(y*wid)+(x-1)]) {
if ((data.getRGB(x - 1, y) & TRANS_MASK) != 0) {
return true;
}
}
// check the pixel to the right
if (x < wid - 1 && !traced[(y*wid)+(x+1)]) {
if ((data.getRGB(x + 1, y) & TRANS_MASK) != 0) {
return true;
}
}
// check the three-pixel row below the pixel
if (y < hei - 1) {
for (int rxx = x - 1; rxx <= x + 1; rxx++) {
if (rxx < 0 || rxx >= wid || traced[((y+1)*wid)+rxx]) {
continue;
}
if ((data.getRGB(rxx, y + 1) & TRANS_MASK) != 0) {
return true;
}
}
}
return false;
} | java | protected static boolean bordersNonTransparentPixel (
BufferedImage data, int wid, int hei, boolean[] traced, int x, int y)
{
// check the three-pixel row above the pixel
if (y > 0) {
for (int rxx = x - 1; rxx <= x + 1; rxx++) {
if (rxx < 0 || rxx >= wid || traced[((y-1)*wid)+rxx]) {
continue;
}
if ((data.getRGB(rxx, y - 1) & TRANS_MASK) != 0) {
return true;
}
}
}
// check the pixel to the left
if (x > 0 && !traced[(y*wid)+(x-1)]) {
if ((data.getRGB(x - 1, y) & TRANS_MASK) != 0) {
return true;
}
}
// check the pixel to the right
if (x < wid - 1 && !traced[(y*wid)+(x+1)]) {
if ((data.getRGB(x + 1, y) & TRANS_MASK) != 0) {
return true;
}
}
// check the three-pixel row below the pixel
if (y < hei - 1) {
for (int rxx = x - 1; rxx <= x + 1; rxx++) {
if (rxx < 0 || rxx >= wid || traced[((y+1)*wid)+rxx]) {
continue;
}
if ((data.getRGB(rxx, y + 1) & TRANS_MASK) != 0) {
return true;
}
}
}
return false;
} | [
"protected",
"static",
"boolean",
"bordersNonTransparentPixel",
"(",
"BufferedImage",
"data",
",",
"int",
"wid",
",",
"int",
"hei",
",",
"boolean",
"[",
"]",
"traced",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"// check the three-pixel row above the pixel",
"i... | Returns whether the given pixel is bordered by any non-transparent pixel. | [
"Returns",
"whether",
"the",
"given",
"pixel",
"is",
"bordered",
"by",
"any",
"non",
"-",
"transparent",
"pixel",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L340-L384 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.composeMaskedImage | public static BufferedImage composeMaskedImage (
ImageCreator isrc, BufferedImage mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
Raster maskdata = mask.getData();
Raster basedata = base.getData();
// create a new image using the rasters if possible
if (maskdata.getNumBands() == 4 && basedata.getNumBands() >= 3) {
WritableRaster target = basedata.createCompatibleWritableRaster(wid, hei);
// copy the alpha from the mask image
int[] adata = maskdata.getSamples(0, 0, wid, hei, 3, (int[]) null);
target.setSamples(0, 0, wid, hei, 3, adata);
// copy the RGB from the base image
for (int ii=0; ii < 3; ii++) {
int[] cdata = basedata.getSamples(0, 0, wid, hei, ii, (int[]) null);
target.setSamples(0, 0, wid, hei, ii, cdata);
}
return new BufferedImage(mask.getColorModel(), target, true, null);
} else {
// otherwise composite them by rendering them with an alpha
// rule
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.drawImage(mask, 0, 0, null);
g2.setComposite(AlphaComposite.SrcIn);
g2.drawImage(base, 0, 0, null);
} finally {
g2.dispose();
}
return target;
}
} | java | public static BufferedImage composeMaskedImage (
ImageCreator isrc, BufferedImage mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
Raster maskdata = mask.getData();
Raster basedata = base.getData();
// create a new image using the rasters if possible
if (maskdata.getNumBands() == 4 && basedata.getNumBands() >= 3) {
WritableRaster target = basedata.createCompatibleWritableRaster(wid, hei);
// copy the alpha from the mask image
int[] adata = maskdata.getSamples(0, 0, wid, hei, 3, (int[]) null);
target.setSamples(0, 0, wid, hei, 3, adata);
// copy the RGB from the base image
for (int ii=0; ii < 3; ii++) {
int[] cdata = basedata.getSamples(0, 0, wid, hei, ii, (int[]) null);
target.setSamples(0, 0, wid, hei, ii, cdata);
}
return new BufferedImage(mask.getColorModel(), target, true, null);
} else {
// otherwise composite them by rendering them with an alpha
// rule
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.drawImage(mask, 0, 0, null);
g2.setComposite(AlphaComposite.SrcIn);
g2.drawImage(base, 0, 0, null);
} finally {
g2.dispose();
}
return target;
}
} | [
"public",
"static",
"BufferedImage",
"composeMaskedImage",
"(",
"ImageCreator",
"isrc",
",",
"BufferedImage",
"mask",
",",
"BufferedImage",
"base",
")",
"{",
"int",
"wid",
"=",
"base",
".",
"getWidth",
"(",
")",
";",
"int",
"hei",
"=",
"base",
".",
"getHeigh... | Create an image using the alpha channel from the first and the RGB values from the second. | [
"Create",
"an",
"image",
"using",
"the",
"alpha",
"channel",
"from",
"the",
"first",
"and",
"the",
"RGB",
"values",
"from",
"the",
"second",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L389-L428 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.composeMaskedImage | public static BufferedImage composeMaskedImage (
ImageCreator isrc, Shape mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
// alternate method for composition:
// 1. create WriteableRaster with base data
// 2. test each pixel with mask.contains() and set the alpha channel to fully-alpha if false
// 3. create buffered image from raster
// (I didn't use this method because it depends on the colormodel of the source image, and
// was booching when the souce image was a cut-up from a tileset, and it seems like it
// would take longer than the method we are using. But it's something to consider)
// composite them by rendering them with an alpha rule
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.setColor(Color.BLACK); // whatever, really
g2.fill(mask);
g2.setComposite(AlphaComposite.SrcIn);
g2.drawImage(base, 0, 0, null);
} finally {
g2.dispose();
}
return target;
} | java | public static BufferedImage composeMaskedImage (
ImageCreator isrc, Shape mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
// alternate method for composition:
// 1. create WriteableRaster with base data
// 2. test each pixel with mask.contains() and set the alpha channel to fully-alpha if false
// 3. create buffered image from raster
// (I didn't use this method because it depends on the colormodel of the source image, and
// was booching when the souce image was a cut-up from a tileset, and it seems like it
// would take longer than the method we are using. But it's something to consider)
// composite them by rendering them with an alpha rule
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.setColor(Color.BLACK); // whatever, really
g2.fill(mask);
g2.setComposite(AlphaComposite.SrcIn);
g2.drawImage(base, 0, 0, null);
} finally {
g2.dispose();
}
return target;
} | [
"public",
"static",
"BufferedImage",
"composeMaskedImage",
"(",
"ImageCreator",
"isrc",
",",
"Shape",
"mask",
",",
"BufferedImage",
"base",
")",
"{",
"int",
"wid",
"=",
"base",
".",
"getWidth",
"(",
")",
";",
"int",
"hei",
"=",
"base",
".",
"getHeight",
"(... | Create a new image using the supplied shape as a mask from which to cut out pixels from the
supplied image. Pixels inside the shape will be added to the final image, pixels outside
the shape will be clear. | [
"Create",
"a",
"new",
"image",
"using",
"the",
"supplied",
"shape",
"as",
"a",
"mask",
"from",
"which",
"to",
"cut",
"out",
"pixels",
"from",
"the",
"supplied",
"image",
".",
"Pixels",
"inside",
"the",
"shape",
"will",
"be",
"added",
"to",
"the",
"final"... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L435-L461 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.computeTrimmedBounds | public static void computeTrimmedBounds (BufferedImage image, Rectangle tbounds)
{
// this could be more efficient, but it's run as a batch process and doesn't really take
// that long anyway
int width = image.getWidth(), height = image.getHeight();
int firstrow = -1, lastrow = -1, minx = width, maxx = 0;
for (int yy = 0; yy < height; yy++) {
int firstidx = -1, lastidx = -1;
for (int xx = 0; xx < width; xx++) {
// if this pixel is transparent, do nothing
int argb = image.getRGB(xx, yy);
if ((argb >> 24) == 0) {
continue;
}
// otherwise, if we've not seen a non-transparent pixel, make a note that this is
// the first non-transparent pixel in the row
if (firstidx == -1) {
firstidx = xx;
}
// keep track of the last non-transparent pixel we saw
lastidx = xx;
}
// if we saw no pixels on this row, we can bail now
if (firstidx == -1) {
continue;
}
// update our min and maxx
minx = Math.min(firstidx, minx);
maxx = Math.max(lastidx, maxx);
// otherwise keep track of the first row on which we see pixels and the last row on
// which we see pixels
if (firstrow == -1) {
firstrow = yy;
}
lastrow = yy;
}
// fill in the dimensions
if (firstrow != -1) {
tbounds.x = minx;
tbounds.y = firstrow;
tbounds.width = maxx - minx + 1;
tbounds.height = lastrow - firstrow + 1;
} else {
// Entirely blank image. Return 1x1 blank image.
tbounds.x = 0;
tbounds.y = 0;
tbounds.width = 1;
tbounds.height = 1;
}
} | java | public static void computeTrimmedBounds (BufferedImage image, Rectangle tbounds)
{
// this could be more efficient, but it's run as a batch process and doesn't really take
// that long anyway
int width = image.getWidth(), height = image.getHeight();
int firstrow = -1, lastrow = -1, minx = width, maxx = 0;
for (int yy = 0; yy < height; yy++) {
int firstidx = -1, lastidx = -1;
for (int xx = 0; xx < width; xx++) {
// if this pixel is transparent, do nothing
int argb = image.getRGB(xx, yy);
if ((argb >> 24) == 0) {
continue;
}
// otherwise, if we've not seen a non-transparent pixel, make a note that this is
// the first non-transparent pixel in the row
if (firstidx == -1) {
firstidx = xx;
}
// keep track of the last non-transparent pixel we saw
lastidx = xx;
}
// if we saw no pixels on this row, we can bail now
if (firstidx == -1) {
continue;
}
// update our min and maxx
minx = Math.min(firstidx, minx);
maxx = Math.max(lastidx, maxx);
// otherwise keep track of the first row on which we see pixels and the last row on
// which we see pixels
if (firstrow == -1) {
firstrow = yy;
}
lastrow = yy;
}
// fill in the dimensions
if (firstrow != -1) {
tbounds.x = minx;
tbounds.y = firstrow;
tbounds.width = maxx - minx + 1;
tbounds.height = lastrow - firstrow + 1;
} else {
// Entirely blank image. Return 1x1 blank image.
tbounds.x = 0;
tbounds.y = 0;
tbounds.width = 1;
tbounds.height = 1;
}
} | [
"public",
"static",
"void",
"computeTrimmedBounds",
"(",
"BufferedImage",
"image",
",",
"Rectangle",
"tbounds",
")",
"{",
"// this could be more efficient, but it's run as a batch process and doesn't really take",
"// that long anyway",
"int",
"width",
"=",
"image",
".",
"getWi... | Computes the bounds of the smallest rectangle that contains all non-transparent pixels of
this image. This isn't extremely efficient, so you shouldn't be doing this anywhere
exciting. | [
"Computes",
"the",
"bounds",
"of",
"the",
"smallest",
"rectangle",
"that",
"contains",
"all",
"non",
"-",
"transparent",
"pixels",
"of",
"this",
"image",
".",
"This",
"isn",
"t",
"extremely",
"efficient",
"so",
"you",
"shouldn",
"t",
"be",
"doing",
"this",
... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L479-L535 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.getEstimatedMemoryUsage | public static long getEstimatedMemoryUsage (Raster raster)
{
// we assume that the data buffer stores each element in a byte-rounded memory element;
// maybe the buffer is smarter about things than this, but we're better to err on the safe
// side
DataBuffer db = raster.getDataBuffer();
int bpe = (int)Math.ceil(DataBuffer.getDataTypeSize(db.getDataType()) / 8f);
return bpe * db.getSize();
} | java | public static long getEstimatedMemoryUsage (Raster raster)
{
// we assume that the data buffer stores each element in a byte-rounded memory element;
// maybe the buffer is smarter about things than this, but we're better to err on the safe
// side
DataBuffer db = raster.getDataBuffer();
int bpe = (int)Math.ceil(DataBuffer.getDataTypeSize(db.getDataType()) / 8f);
return bpe * db.getSize();
} | [
"public",
"static",
"long",
"getEstimatedMemoryUsage",
"(",
"Raster",
"raster",
")",
"{",
"// we assume that the data buffer stores each element in a byte-rounded memory element;",
"// maybe the buffer is smarter about things than this, but we're better to err on the safe",
"// side",
"DataB... | Returns the estimated memory usage in bytes for the specified raster. | [
"Returns",
"the",
"estimated",
"memory",
"usage",
"in",
"bytes",
"for",
"the",
"specified",
"raster",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L552-L560 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.getEstimatedMemoryUsage | public static long getEstimatedMemoryUsage (Iterator<BufferedImage> iter)
{
long size = 0;
while (iter.hasNext()) {
BufferedImage image = iter.next();
size += getEstimatedMemoryUsage(image);
}
return size;
} | java | public static long getEstimatedMemoryUsage (Iterator<BufferedImage> iter)
{
long size = 0;
while (iter.hasNext()) {
BufferedImage image = iter.next();
size += getEstimatedMemoryUsage(image);
}
return size;
} | [
"public",
"static",
"long",
"getEstimatedMemoryUsage",
"(",
"Iterator",
"<",
"BufferedImage",
">",
"iter",
")",
"{",
"long",
"size",
"=",
"0",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"BufferedImage",
"image",
"=",
"iter",
".",
"nex... | Returns the estimated memory usage in bytes for all buffered images in the supplied
iterator. | [
"Returns",
"the",
"estimated",
"memory",
"usage",
"in",
"bytes",
"for",
"all",
"buffered",
"images",
"in",
"the",
"supplied",
"iterator",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L566-L574 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.getDefGC | protected static GraphicsConfiguration getDefGC ()
{
if (_gc == null) {
// obtain information on our graphics environment
try {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
_gc = gd.getDefaultConfiguration();
} catch (HeadlessException e) {
// no problem, just return null
}
}
return _gc;
} | java | protected static GraphicsConfiguration getDefGC ()
{
if (_gc == null) {
// obtain information on our graphics environment
try {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
_gc = gd.getDefaultConfiguration();
} catch (HeadlessException e) {
// no problem, just return null
}
}
return _gc;
} | [
"protected",
"static",
"GraphicsConfiguration",
"getDefGC",
"(",
")",
"{",
"if",
"(",
"_gc",
"==",
"null",
")",
"{",
"// obtain information on our graphics environment",
"try",
"{",
"GraphicsEnvironment",
"env",
"=",
"GraphicsEnvironment",
".",
"getLocalGraphicsEnvironmen... | Obtains the default graphics configuration for this VM. If the JVM is in headless mode,
this method will return null. | [
"Obtains",
"the",
"default",
"graphics",
"configuration",
"for",
"this",
"VM",
".",
"If",
"the",
"JVM",
"is",
"in",
"headless",
"mode",
"this",
"method",
"will",
"return",
"null",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L580-L593 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.getIntersectingSprites | public void getIntersectingSprites (List<Sprite> list, Shape shape)
{
int size = _sprites.size();
for (int ii = 0; ii < size; ii++) {
Sprite sprite = _sprites.get(ii);
if (sprite.intersects(shape)) {
list.add(sprite);
}
}
} | java | public void getIntersectingSprites (List<Sprite> list, Shape shape)
{
int size = _sprites.size();
for (int ii = 0; ii < size; ii++) {
Sprite sprite = _sprites.get(ii);
if (sprite.intersects(shape)) {
list.add(sprite);
}
}
} | [
"public",
"void",
"getIntersectingSprites",
"(",
"List",
"<",
"Sprite",
">",
"list",
",",
"Shape",
"shape",
")",
"{",
"int",
"size",
"=",
"_sprites",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"size",
";",
"ii",
... | When an animated view processes its dirty rectangles, it may require an expansion of the
dirty region which may in turn require the invalidation of more sprites than were originally
invalid. In such cases, the animated view can call back to the sprite manager, asking it to
append the sprites that intersect a particular region to the given list.
@param list the list to fill with any intersecting sprites.
@param shape the shape in which we have interest. | [
"When",
"an",
"animated",
"view",
"processes",
"its",
"dirty",
"rectangles",
"it",
"may",
"require",
"an",
"expansion",
"of",
"the",
"dirty",
"region",
"which",
"may",
"in",
"turn",
"require",
"the",
"invalidation",
"of",
"more",
"sprites",
"than",
"were",
"... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L50-L59 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.getHitSprites | public void getHitSprites (List<Sprite> list, int x, int y)
{
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
list.add(sprite);
}
}
} | java | public void getHitSprites (List<Sprite> list, int x, int y)
{
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
list.add(sprite);
}
}
} | [
"public",
"void",
"getHitSprites",
"(",
"List",
"<",
"Sprite",
">",
"list",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"for",
"(",
"int",
"ii",
"=",
"_sprites",
".",
"size",
"(",
")",
"-",
"1",
";",
"ii",
">=",
"0",
";",
"ii",
"--",
")",
"{"... | When an animated view is determining what entity in its view is under the mouse pointer, it
may require a list of sprites that are "hit" by a particular pixel. The sprites' bounds are
first checked and sprites with bounds that contain the supplied point are further checked
for a non-transparent at the specified location.
@param list the list to fill with any intersecting sprites, the sprites with the highest
render order provided first.
@param x the x (screen) coordinate to be checked.
@param y the y (screen) coordinate to be checked. | [
"When",
"an",
"animated",
"view",
"is",
"determining",
"what",
"entity",
"in",
"its",
"view",
"is",
"under",
"the",
"mouse",
"pointer",
"it",
"may",
"require",
"a",
"list",
"of",
"sprites",
"that",
"are",
"hit",
"by",
"a",
"particular",
"pixel",
".",
"Th... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L72-L80 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.getHighestHitSprite | public Sprite getHighestHitSprite (int x, int y)
{
// since they're stored in lowest -> highest order..
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
return sprite;
}
}
return null;
} | java | public Sprite getHighestHitSprite (int x, int y)
{
// since they're stored in lowest -> highest order..
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
return sprite;
}
}
return null;
} | [
"public",
"Sprite",
"getHighestHitSprite",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"// since they're stored in lowest -> highest order..",
"for",
"(",
"int",
"ii",
"=",
"_sprites",
".",
"size",
"(",
")",
"-",
"1",
";",
"ii",
">=",
"0",
";",
"ii",
"--",... | Finds the sprite with the highest render order that hits the specified pixel.
@param x the x (screen) coordinate to be checked
@param y the y (screen) coordinate to be checked
@return the highest sprite hit | [
"Finds",
"the",
"sprite",
"with",
"the",
"highest",
"render",
"order",
"that",
"hits",
"the",
"specified",
"pixel",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L89-L99 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/SpriteManager.java | SpriteManager.removeSprites | public void removeSprites (Predicate<Sprite> pred)
{
int idxoff = 0;
for (int ii = 0, ll = _sprites.size(); ii < ll; ii++) {
Sprite sprite = _sprites.get(ii-idxoff);
if (pred.apply(sprite)) {
_sprites.remove(sprite);
sprite.invalidate();
sprite.shutdown();
// we need to preserve the original "index" relative to the current tick position,
// so we don't decrement ii directly
idxoff++;
if (ii <= _tickpos) {
_tickpos--;
}
}
}
} | java | public void removeSprites (Predicate<Sprite> pred)
{
int idxoff = 0;
for (int ii = 0, ll = _sprites.size(); ii < ll; ii++) {
Sprite sprite = _sprites.get(ii-idxoff);
if (pred.apply(sprite)) {
_sprites.remove(sprite);
sprite.invalidate();
sprite.shutdown();
// we need to preserve the original "index" relative to the current tick position,
// so we don't decrement ii directly
idxoff++;
if (ii <= _tickpos) {
_tickpos--;
}
}
}
} | [
"public",
"void",
"removeSprites",
"(",
"Predicate",
"<",
"Sprite",
">",
"pred",
")",
"{",
"int",
"idxoff",
"=",
"0",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
",",
"ll",
"=",
"_sprites",
".",
"size",
"(",
")",
";",
"ii",
"<",
"ll",
";",
"ii",
"+... | Removes all sprites that match the supplied predicate. | [
"Removes",
"all",
"sprites",
"that",
"match",
"the",
"supplied",
"predicate",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/SpriteManager.java#L145-L162 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/Sprite.java | Sprite.cancelMove | public void cancelMove ()
{
if (_path != null) {
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CancelledOp(this, oldpath));
}
}
} | java | public void cancelMove ()
{
if (_path != null) {
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CancelledOp(this, oldpath));
}
}
} | [
"public",
"void",
"cancelMove",
"(",
")",
"{",
"if",
"(",
"_path",
"!=",
"null",
")",
"{",
"Path",
"oldpath",
"=",
"_path",
";",
"_path",
"=",
"null",
";",
"oldpath",
".",
"wasRemoved",
"(",
"this",
")",
";",
"if",
"(",
"_observers",
"!=",
"null",
... | Cancels any path that the sprite may currently be moving along. | [
"Cancels",
"any",
"path",
"that",
"the",
"sprite",
"may",
"currently",
"be",
"moving",
"along",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/Sprite.java#L240-L250 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/Sprite.java | Sprite.pathCompleted | public void pathCompleted (long timestamp)
{
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CompletedOp(this, oldpath, timestamp));
}
} | java | public void pathCompleted (long timestamp)
{
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CompletedOp(this, oldpath, timestamp));
}
} | [
"public",
"void",
"pathCompleted",
"(",
"long",
"timestamp",
")",
"{",
"Path",
"oldpath",
"=",
"_path",
";",
"_path",
"=",
"null",
";",
"oldpath",
".",
"wasRemoved",
"(",
"this",
")",
";",
"if",
"(",
"_observers",
"!=",
"null",
")",
"{",
"_observers",
... | Called by the active path when it has completed. | [
"Called",
"by",
"the",
"active",
"path",
"when",
"it",
"has",
"completed",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/Sprite.java#L271-L279 | train |
threerings/nenya | core/src/main/java/com/threerings/media/sprite/Sprite.java | Sprite.tickPath | protected boolean tickPath (long tickStamp)
{
if (_path == null) {
return false;
}
// initialize the path if we haven't yet
if (_pathStamp == 0) {
_path.init(this, _pathStamp = tickStamp);
}
// it's possible that as a result of init() the path completed and removed itself with a
// call to pathCompleted(), so we have to be careful here
return (_path == null) ? true : _path.tick(this, tickStamp);
} | java | protected boolean tickPath (long tickStamp)
{
if (_path == null) {
return false;
}
// initialize the path if we haven't yet
if (_pathStamp == 0) {
_path.init(this, _pathStamp = tickStamp);
}
// it's possible that as a result of init() the path completed and removed itself with a
// call to pathCompleted(), so we have to be careful here
return (_path == null) ? true : _path.tick(this, tickStamp);
} | [
"protected",
"boolean",
"tickPath",
"(",
"long",
"tickStamp",
")",
"{",
"if",
"(",
"_path",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// initialize the path if we haven't yet",
"if",
"(",
"_pathStamp",
"==",
"0",
")",
"{",
"_path",
".",
"init",
... | Ticks any path assigned to this sprite.
@return true if the path relocated the sprite as a result of this tick, false if it
remained in the same position. | [
"Ticks",
"any",
"path",
"assigned",
"to",
"this",
"sprite",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/Sprite.java#L293-L307 | train |
threerings/nenya | core/src/main/java/com/threerings/miso/client/SceneObjectTip.java | SceneObjectTip.layout | public void layout (Graphics2D gfx, SceneObject tipFor, Rectangle boundary)
{
layout(gfx, ICON_PAD, EXTRA_PAD);
bounds = new Rectangle(_size);
// locate the most appropriate tip layout
for (int ii = 0, ll = _layouts.size(); ii < ll; ii++) {
LayoutReg reg = _layouts.get(ii);
String act = tipFor.info.action == null ? "" : tipFor.info.action;
if (act.startsWith(reg.prefix)) {
reg.layout.layout(gfx, boundary, tipFor, this);
break;
}
}
} | java | public void layout (Graphics2D gfx, SceneObject tipFor, Rectangle boundary)
{
layout(gfx, ICON_PAD, EXTRA_PAD);
bounds = new Rectangle(_size);
// locate the most appropriate tip layout
for (int ii = 0, ll = _layouts.size(); ii < ll; ii++) {
LayoutReg reg = _layouts.get(ii);
String act = tipFor.info.action == null ? "" : tipFor.info.action;
if (act.startsWith(reg.prefix)) {
reg.layout.layout(gfx, boundary, tipFor, this);
break;
}
}
} | [
"public",
"void",
"layout",
"(",
"Graphics2D",
"gfx",
",",
"SceneObject",
"tipFor",
",",
"Rectangle",
"boundary",
")",
"{",
"layout",
"(",
"gfx",
",",
"ICON_PAD",
",",
"EXTRA_PAD",
")",
";",
"bounds",
"=",
"new",
"Rectangle",
"(",
"_size",
")",
";",
"// ... | Called to initialize the tip so that it can be painted.
@param tipFor the scene object that we're a tip for.
@param boundary the boundary of all displayable space. | [
"Called",
"to",
"initialize",
"the",
"tip",
"so",
"that",
"it",
"can",
"be",
"painted",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/SceneObjectTip.java#L87-L101 | train |
threerings/nenya | core/src/main/java/com/threerings/miso/client/SceneObjectTip.java | SceneObjectTip.registerTipLayout | public static void registerTipLayout (String prefix, TipLayout layout)
{
LayoutReg reg = new LayoutReg();
reg.prefix = prefix;
reg.layout = layout;
_layouts.insertSorted(reg);
} | java | public static void registerTipLayout (String prefix, TipLayout layout)
{
LayoutReg reg = new LayoutReg();
reg.prefix = prefix;
reg.layout = layout;
_layouts.insertSorted(reg);
} | [
"public",
"static",
"void",
"registerTipLayout",
"(",
"String",
"prefix",
",",
"TipLayout",
"layout",
")",
"{",
"LayoutReg",
"reg",
"=",
"new",
"LayoutReg",
"(",
")",
";",
"reg",
".",
"prefix",
"=",
"prefix",
";",
"reg",
".",
"layout",
"=",
"layout",
";"... | It may be desirable to layout object tips specially depending on
what sort of actions they represent, so we allow different tip
layout algorithms to be registered for particular object prefixes.
The registration is simply a list searched from longest string to
shortest string for the first match to an object's action. | [
"It",
"may",
"be",
"desirable",
"to",
"layout",
"object",
"tips",
"specially",
"depending",
"on",
"what",
"sort",
"of",
"actions",
"they",
"represent",
"so",
"we",
"allow",
"different",
"tip",
"layout",
"algorithms",
"to",
"be",
"registered",
"for",
"particula... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/SceneObjectTip.java#L144-L150 | train |
calrissian/mango | mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java | NodeUtils.isLeaf | public static boolean isLeaf(Node node) {
return node instanceof Leaf || node.children() == null || node.children().size() == 0;
} | java | public static boolean isLeaf(Node node) {
return node instanceof Leaf || node.children() == null || node.children().size() == 0;
} | [
"public",
"static",
"boolean",
"isLeaf",
"(",
"Node",
"node",
")",
"{",
"return",
"node",
"instanceof",
"Leaf",
"||",
"node",
".",
"children",
"(",
")",
"==",
"null",
"||",
"node",
".",
"children",
"(",
")",
".",
"size",
"(",
")",
"==",
"0",
";",
"... | Returns true if a node is a leaf. Note that a leaf can also be a parent node that does not have any children. | [
"Returns",
"true",
"if",
"a",
"node",
"is",
"a",
"leaf",
".",
"Note",
"that",
"a",
"leaf",
"can",
"also",
"be",
"a",
"parent",
"node",
"that",
"does",
"not",
"have",
"any",
"children",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java#L32-L34 | train |
calrissian/mango | mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java | NodeUtils.isEmpty | public static boolean isEmpty(Node node) {
return (node == null || (node.children() != null && node.children().size() == 0));
} | java | public static boolean isEmpty(Node node) {
return (node == null || (node.children() != null && node.children().size() == 0));
} | [
"public",
"static",
"boolean",
"isEmpty",
"(",
"Node",
"node",
")",
"{",
"return",
"(",
"node",
"==",
"null",
"||",
"(",
"node",
".",
"children",
"(",
")",
"!=",
"null",
"&&",
"node",
".",
"children",
"(",
")",
".",
"size",
"(",
")",
"==",
"0",
"... | Determines if a node is null, or a single parent node without children. | [
"Determines",
"if",
"a",
"node",
"is",
"null",
"or",
"a",
"single",
"parent",
"node",
"without",
"children",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java#L39-L41 | train |
calrissian/mango | mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java | NodeUtils.parentContainsOnlyLeaves | public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
for (Node child : parentNode.children()) {
if (!isLeaf(child)) return false;
}
return true;
} | java | public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
for (Node child : parentNode.children()) {
if (!isLeaf(child)) return false;
}
return true;
} | [
"public",
"static",
"boolean",
"parentContainsOnlyLeaves",
"(",
"ParentNode",
"parentNode",
")",
"{",
"for",
"(",
"Node",
"child",
":",
"parentNode",
".",
"children",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isLeaf",
"(",
"child",
")",
")",
"return",
"false",
... | Determines if parent node has children that are all leaves | [
"Determines",
"if",
"parent",
"node",
"has",
"children",
"that",
"are",
"all",
"leaves"
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java#L46-L51 | train |
calrissian/mango | mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java | NodeUtils.criteriaFromNode | public static Criteria criteriaFromNode(Node node, Comparator rangeComparator) {
return criteriaFromNode(node, rangeComparator, null);
} | java | public static Criteria criteriaFromNode(Node node, Comparator rangeComparator) {
return criteriaFromNode(node, rangeComparator, null);
} | [
"public",
"static",
"Criteria",
"criteriaFromNode",
"(",
"Node",
"node",
",",
"Comparator",
"rangeComparator",
")",
"{",
"return",
"criteriaFromNode",
"(",
"node",
",",
"rangeComparator",
",",
"null",
")",
";",
"}"
] | Creates criteria from a node. A Comparator is injected into all nodes which need to determine order or equality. | [
"Creates",
"criteria",
"from",
"a",
"node",
".",
"A",
"Comparator",
"is",
"injected",
"into",
"all",
"nodes",
"which",
"need",
"to",
"determine",
"order",
"or",
"equality",
"."
] | a95aa5e77af9aa0e629787228d80806560023452 | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-criteria/src/main/java/org/calrissian/mango/criteria/support/NodeUtils.java#L71-L73 | train |
threerings/nenya | tools/src/main/java/com/threerings/media/tile/tools/RenameTileSet.java | RenameTileSet.renameTileSet | public static void renameTileSet (
String mapPath, String oldName, String newName)
throws PersistenceException
{
MapFileTileSetIDBroker broker =
new MapFileTileSetIDBroker(new File(mapPath));
if (!broker.renameTileSet(oldName, newName)) {
throw new PersistenceException(
"No such old tileset '" + oldName + "'.");
}
broker.commit();
} | java | public static void renameTileSet (
String mapPath, String oldName, String newName)
throws PersistenceException
{
MapFileTileSetIDBroker broker =
new MapFileTileSetIDBroker(new File(mapPath));
if (!broker.renameTileSet(oldName, newName)) {
throw new PersistenceException(
"No such old tileset '" + oldName + "'.");
}
broker.commit();
} | [
"public",
"static",
"void",
"renameTileSet",
"(",
"String",
"mapPath",
",",
"String",
"oldName",
",",
"String",
"newName",
")",
"throws",
"PersistenceException",
"{",
"MapFileTileSetIDBroker",
"broker",
"=",
"new",
"MapFileTileSetIDBroker",
"(",
"new",
"File",
"(",
... | Loads up the tileset map file with the specified path and copies
the tileset ID from the old tileset name to the new tileset name.
This is necessary when a tileset is renamed so that the new name
does not cause the tileset to be assigned a new tileset ID. Bear in
mind that the old name should never again be used as it will
conflict with a tileset provided under the new name. | [
"Loads",
"up",
"the",
"tileset",
"map",
"file",
"with",
"the",
"specified",
"path",
"and",
"copies",
"the",
"tileset",
"ID",
"from",
"the",
"old",
"tileset",
"name",
"to",
"the",
"new",
"tileset",
"name",
".",
"This",
"is",
"necessary",
"when",
"a",
"til... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/media/tile/tools/RenameTileSet.java#L44-L55 | train |
threerings/nenya | tools/src/main/java/com/threerings/cast/bundle/tools/ComponentBundler.java | ComponentBundler.trim | protected TrimmedTileSet trim (TileSet aset, OutputStream fout) throws IOException
{
return TrimmedTileSet.trimTileSet(aset, fout);
} | java | protected TrimmedTileSet trim (TileSet aset, OutputStream fout) throws IOException
{
return TrimmedTileSet.trimTileSet(aset, fout);
} | [
"protected",
"TrimmedTileSet",
"trim",
"(",
"TileSet",
"aset",
",",
"OutputStream",
"fout",
")",
"throws",
"IOException",
"{",
"return",
"TrimmedTileSet",
".",
"trimTileSet",
"(",
"aset",
",",
"fout",
")",
";",
"}"
] | Converts the tileset to a trimmed tile set and saves it at the specified location. | [
"Converts",
"the",
"tileset",
"to",
"a",
"trimmed",
"tile",
"set",
"and",
"saves",
"it",
"at",
"the",
"specified",
"location",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/cast/bundle/tools/ComponentBundler.java#L363-L366 | train |
threerings/nenya | tools/src/main/java/com/threerings/cast/bundle/tools/ComponentBundler.java | ComponentBundler.saveBroker | protected void saveBroker (File mapfile, HashMapIDBroker broker)
throws RuntimeException
{
// bail if the broker wasn't modified
if (!broker.isModified()) {
return;
}
try {
BufferedWriter bout = new BufferedWriter(new FileWriter(mapfile));
broker.writeTo(bout);
bout.close();
} catch (IOException ioe) {
throw new RuntimeException(
"Unable to store component ID map [mapfile=" + mapfile + "]", ioe);
}
} | java | protected void saveBroker (File mapfile, HashMapIDBroker broker)
throws RuntimeException
{
// bail if the broker wasn't modified
if (!broker.isModified()) {
return;
}
try {
BufferedWriter bout = new BufferedWriter(new FileWriter(mapfile));
broker.writeTo(bout);
bout.close();
} catch (IOException ioe) {
throw new RuntimeException(
"Unable to store component ID map [mapfile=" + mapfile + "]", ioe);
}
} | [
"protected",
"void",
"saveBroker",
"(",
"File",
"mapfile",
",",
"HashMapIDBroker",
"broker",
")",
"throws",
"RuntimeException",
"{",
"// bail if the broker wasn't modified",
"if",
"(",
"!",
"broker",
".",
"isModified",
"(",
")",
")",
"{",
"return",
";",
"}",
"tr... | Stores a persistent representation of the supplied hashmap ID
broker in the specified file. | [
"Stores",
"a",
"persistent",
"representation",
"of",
"the",
"supplied",
"hashmap",
"ID",
"broker",
"in",
"the",
"specified",
"file",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/cast/bundle/tools/ComponentBundler.java#L372-L388 | train |
groupon/monsoon | collectors/jmx/src/main/java/com/groupon/lex/metrics/jmx/MBeanGroup.java | MBeanGroup.nameFromObjectName | private static GroupName nameFromObjectName(ObjectName obj_name, NamedResolverMap resolvedMap) {
String name = obj_name.getKeyProperty("name");
String type = obj_name.getKeyProperty("type");
String domain = obj_name.getDomain();
Map<String, MetricValue> tags = obj_name.getKeyPropertyList().entrySet().stream()
.filter((entry) -> !entry.getKey().equals("name"))
.filter((entry) -> !entry.getKey().equals("type"))
.map(Tag::valueOf)
.collect(Collectors.toMap((Tag t) -> t.getName(), (Tag t) -> t.getValue()));
final List<String> path = new ArrayList<>();
if (name != null) {
path.addAll(Arrays.asList(name.split("\\.")));
} else if (type != null) {
path.addAll(Arrays.asList(domain.split("\\.")));
path.add(type);
} else {
path.addAll(Arrays.asList(domain.split("\\.")));
}
return resolvedMap.getGroupName(path, tags);
} | java | private static GroupName nameFromObjectName(ObjectName obj_name, NamedResolverMap resolvedMap) {
String name = obj_name.getKeyProperty("name");
String type = obj_name.getKeyProperty("type");
String domain = obj_name.getDomain();
Map<String, MetricValue> tags = obj_name.getKeyPropertyList().entrySet().stream()
.filter((entry) -> !entry.getKey().equals("name"))
.filter((entry) -> !entry.getKey().equals("type"))
.map(Tag::valueOf)
.collect(Collectors.toMap((Tag t) -> t.getName(), (Tag t) -> t.getValue()));
final List<String> path = new ArrayList<>();
if (name != null) {
path.addAll(Arrays.asList(name.split("\\.")));
} else if (type != null) {
path.addAll(Arrays.asList(domain.split("\\.")));
path.add(type);
} else {
path.addAll(Arrays.asList(domain.split("\\.")));
}
return resolvedMap.getGroupName(path, tags);
} | [
"private",
"static",
"GroupName",
"nameFromObjectName",
"(",
"ObjectName",
"obj_name",
",",
"NamedResolverMap",
"resolvedMap",
")",
"{",
"String",
"name",
"=",
"obj_name",
".",
"getKeyProperty",
"(",
"\"name\"",
")",
";",
"String",
"type",
"=",
"obj_name",
".",
... | Extract a metric group name from a JMX ObjectName.
@param obj_name a JMX object name from which to derive a metric name.
@param resolvedMap a resolver map to use when generating the group name.
@return A metric name for the given ObjectName, with tags. | [
"Extract",
"a",
"metric",
"group",
"name",
"from",
"a",
"JMX",
"ObjectName",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/collectors/jmx/src/main/java/com/groupon/lex/metrics/jmx/MBeanGroup.java#L131-L152 | train |
groupon/monsoon | extra/influx/src/main/java/com/github/groupon/monsoon/history/influx/InfluxUtil.java | InfluxUtil.isSorted | static boolean isSorted(Iterable<? extends TimeSeriesCollection> tscIterable) {
final Iterator<? extends TimeSeriesCollection> iter = tscIterable.iterator();
if (!iter.hasNext()) return true; // Empty collection is ordered.
DateTime timestamp = iter.next().getTimestamp();
while (iter.hasNext()) {
final DateTime nextTimestamp = iter.next().getTimestamp();
if (!nextTimestamp.isAfter(timestamp)) return false;
timestamp = nextTimestamp;
}
return true;
} | java | static boolean isSorted(Iterable<? extends TimeSeriesCollection> tscIterable) {
final Iterator<? extends TimeSeriesCollection> iter = tscIterable.iterator();
if (!iter.hasNext()) return true; // Empty collection is ordered.
DateTime timestamp = iter.next().getTimestamp();
while (iter.hasNext()) {
final DateTime nextTimestamp = iter.next().getTimestamp();
if (!nextTimestamp.isAfter(timestamp)) return false;
timestamp = nextTimestamp;
}
return true;
} | [
"static",
"boolean",
"isSorted",
"(",
"Iterable",
"<",
"?",
"extends",
"TimeSeriesCollection",
">",
"tscIterable",
")",
"{",
"final",
"Iterator",
"<",
"?",
"extends",
"TimeSeriesCollection",
">",
"iter",
"=",
"tscIterable",
".",
"iterator",
"(",
")",
";",
"if"... | Validation function, to check if an iterable is sorted with ascending
timestamps.
@param tscIterable An iterable type.
@return True iff the iterable is sorted, false otherwise. | [
"Validation",
"function",
"to",
"check",
"if",
"an",
"iterable",
"is",
"sorted",
"with",
"ascending",
"timestamps",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/extra/influx/src/main/java/com/github/groupon/monsoon/history/influx/InfluxUtil.java#L95-L106 | train |
threerings/nenya | core/src/main/java/com/threerings/openal/ClipBuffer.java | ClipBuffer.resolve | public void resolve (Observer observer)
{
// if we were waiting to unload, cancel that
if (_state == UNLOADING) {
_state = LOADED;
_manager.restoreClip(this);
}
// if we're already loaded, this is easy
if (_state == LOADED) {
if (observer != null) {
observer.clipLoaded(this);
}
return;
}
// queue up the observer
if (observer != null) {
_observers.add(observer);
}
// if we're already loading, we can stop here
if (_state == LOADING) {
return;
}
// create our OpenAL buffer and then queue ourselves up to have
// our clip data loaded
AL10.alGetError(); // throw away any unchecked error prior to an op we want to check
_buffer = new Buffer(_manager);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
log.warning("Failed to create buffer [key=" + getKey() +
", errno=" + errno + "].");
_buffer = null;
// queue up a failure notification so that we properly return
// from this method and our sound has a chance to register
// itself as an observer before we jump up and declare failure
_manager.queueClipFailure(this);
} else {
_state = LOADING;
_manager.queueClipLoad(this);
}
} | java | public void resolve (Observer observer)
{
// if we were waiting to unload, cancel that
if (_state == UNLOADING) {
_state = LOADED;
_manager.restoreClip(this);
}
// if we're already loaded, this is easy
if (_state == LOADED) {
if (observer != null) {
observer.clipLoaded(this);
}
return;
}
// queue up the observer
if (observer != null) {
_observers.add(observer);
}
// if we're already loading, we can stop here
if (_state == LOADING) {
return;
}
// create our OpenAL buffer and then queue ourselves up to have
// our clip data loaded
AL10.alGetError(); // throw away any unchecked error prior to an op we want to check
_buffer = new Buffer(_manager);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
log.warning("Failed to create buffer [key=" + getKey() +
", errno=" + errno + "].");
_buffer = null;
// queue up a failure notification so that we properly return
// from this method and our sound has a chance to register
// itself as an observer before we jump up and declare failure
_manager.queueClipFailure(this);
} else {
_state = LOADING;
_manager.queueClipLoad(this);
}
} | [
"public",
"void",
"resolve",
"(",
"Observer",
"observer",
")",
"{",
"// if we were waiting to unload, cancel that",
"if",
"(",
"_state",
"==",
"UNLOADING",
")",
"{",
"_state",
"=",
"LOADED",
";",
"_manager",
".",
"restoreClip",
"(",
"this",
")",
";",
"}",
"// ... | Instructs this buffer to resolve its underlying clip and be ready
to be played ASAP. | [
"Instructs",
"this",
"buffer",
"to",
"resolve",
"its",
"underlying",
"clip",
"and",
"be",
"ready",
"to",
"be",
"played",
"ASAP",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/ClipBuffer.java#L120-L164 | train |
threerings/nenya | core/src/main/java/com/threerings/openal/ClipBuffer.java | ClipBuffer.dispose | public void dispose ()
{
if (_buffer != null) {
// if there are sources bound to this buffer, we must wait
// for them to be unbound
if (_bound > 0) {
_state = UNLOADING;
return;
}
// free up our buffer
_buffer.delete();
_buffer = null;
_state = UNLOADED;
}
} | java | public void dispose ()
{
if (_buffer != null) {
// if there are sources bound to this buffer, we must wait
// for them to be unbound
if (_bound > 0) {
_state = UNLOADING;
return;
}
// free up our buffer
_buffer.delete();
_buffer = null;
_state = UNLOADED;
}
} | [
"public",
"void",
"dispose",
"(",
")",
"{",
"if",
"(",
"_buffer",
"!=",
"null",
")",
"{",
"// if there are sources bound to this buffer, we must wait",
"// for them to be unbound",
"if",
"(",
"_bound",
">",
"0",
")",
"{",
"_state",
"=",
"UNLOADING",
";",
"return",... | Frees up the internal audio buffers associated with this clip. | [
"Frees",
"up",
"the",
"internal",
"audio",
"buffers",
"associated",
"with",
"this",
"clip",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/ClipBuffer.java#L169-L184 | train |
threerings/nenya | core/src/main/java/com/threerings/openal/ClipBuffer.java | ClipBuffer.bind | protected boolean bind (Clip clip)
{
AL10.alGetError(); // throw away any unchecked error prior to an op we want to check
_buffer.setData(clip.format, clip.data, clip.frequency);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
log.warning("Failed to bind clip", "key", getKey(), "errno", errno);
failed();
return false;
}
_state = LOADED;
_size = _buffer.getSize();
_observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Observer observer) {
observer.clipLoaded(ClipBuffer.this);
return true;
}
});
_observers.clear();
return true;
} | java | protected boolean bind (Clip clip)
{
AL10.alGetError(); // throw away any unchecked error prior to an op we want to check
_buffer.setData(clip.format, clip.data, clip.frequency);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
log.warning("Failed to bind clip", "key", getKey(), "errno", errno);
failed();
return false;
}
_state = LOADED;
_size = _buffer.getSize();
_observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Observer observer) {
observer.clipLoaded(ClipBuffer.this);
return true;
}
});
_observers.clear();
return true;
} | [
"protected",
"boolean",
"bind",
"(",
"Clip",
"clip",
")",
"{",
"AL10",
".",
"alGetError",
"(",
")",
";",
"// throw away any unchecked error prior to an op we want to check",
"_buffer",
".",
"setData",
"(",
"clip",
".",
"format",
",",
"clip",
".",
"data",
",",
"c... | This method is called back on the main thread and instructs this
buffer to bind the clip data to this buffer's OpenAL buffer.
@return true if the binding succeeded, false if we were unable to
load the sound data into OpenAL. | [
"This",
"method",
"is",
"called",
"back",
"on",
"the",
"main",
"thread",
"and",
"instructs",
"this",
"buffer",
"to",
"bind",
"the",
"clip",
"data",
"to",
"this",
"buffer",
"s",
"OpenAL",
"buffer",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/ClipBuffer.java#L203-L224 | train |
threerings/nenya | core/src/main/java/com/threerings/openal/ClipBuffer.java | ClipBuffer.failed | protected void failed ()
{
if (_buffer != null) {
_buffer.delete();
_buffer = null;
}
_state = UNLOADED;
_observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Observer observer) {
observer.clipFailed(ClipBuffer.this);
return true;
}
});
_observers.clear();
} | java | protected void failed ()
{
if (_buffer != null) {
_buffer.delete();
_buffer = null;
}
_state = UNLOADED;
_observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Observer observer) {
observer.clipFailed(ClipBuffer.this);
return true;
}
});
_observers.clear();
} | [
"protected",
"void",
"failed",
"(",
")",
"{",
"if",
"(",
"_buffer",
"!=",
"null",
")",
"{",
"_buffer",
".",
"delete",
"(",
")",
";",
"_buffer",
"=",
"null",
";",
"}",
"_state",
"=",
"UNLOADED",
";",
"_observers",
".",
"apply",
"(",
"new",
"ObserverLi... | Called when we fail in some part of the process in resolving our
clip data. Notifies our observers and resets the clip to the
UNLOADED state. | [
"Called",
"when",
"we",
"fail",
"in",
"some",
"part",
"of",
"the",
"process",
"in",
"resolving",
"our",
"clip",
"data",
".",
"Notifies",
"our",
"observers",
"and",
"resets",
"the",
"clip",
"to",
"the",
"UNLOADED",
"state",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/ClipBuffer.java#L231-L246 | train |
threerings/nenya | core/src/main/java/com/threerings/media/image/VolatileMirage.java | VolatileMirage.createVolatileImage | protected void createVolatileImage ()
{
// release any previous volatile image we might hold
if (_image != null) {
_image.flush();
}
// create a new, compatible, volatile image
// _image = _imgr.createVolatileImage(
// _bounds.width, _bounds.height, getTransparency());
_image = _imgr.createImage(
_bounds.width, _bounds.height, getTransparency());
// render our source image into the volatile image
refreshVolatileImage();
} | java | protected void createVolatileImage ()
{
// release any previous volatile image we might hold
if (_image != null) {
_image.flush();
}
// create a new, compatible, volatile image
// _image = _imgr.createVolatileImage(
// _bounds.width, _bounds.height, getTransparency());
_image = _imgr.createImage(
_bounds.width, _bounds.height, getTransparency());
// render our source image into the volatile image
refreshVolatileImage();
} | [
"protected",
"void",
"createVolatileImage",
"(",
")",
"{",
"// release any previous volatile image we might hold",
"if",
"(",
"_image",
"!=",
"null",
")",
"{",
"_image",
".",
"flush",
"(",
")",
";",
"}",
"// create a new, compatible, volatile image",
"// _image = ... | Creates our volatile image from the information in our source
image. | [
"Creates",
"our",
"volatile",
"image",
"from",
"the",
"information",
"in",
"our",
"source",
"image",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/VolatileMirage.java#L140-L155 | train |
jdillon/gshell | gshell-util/src/main/java/com/planet57/gshell/util/io/PromptHelper.java | PromptHelper.askBoolean | public boolean askBoolean(final String question) {
checkNotNull(question);
log.trace("Ask boolean; question={}", question);
String result = readLine(String.format("%s (yes/no): ", question));
return result.equalsIgnoreCase("yes");
} | java | public boolean askBoolean(final String question) {
checkNotNull(question);
log.trace("Ask boolean; question={}", question);
String result = readLine(String.format("%s (yes/no): ", question));
return result.equalsIgnoreCase("yes");
} | [
"public",
"boolean",
"askBoolean",
"(",
"final",
"String",
"question",
")",
"{",
"checkNotNull",
"(",
"question",
")",
";",
"log",
".",
"trace",
"(",
"\"Ask boolean; question={}\"",
",",
"question",
")",
";",
"String",
"result",
"=",
"readLine",
"(",
"String",... | Ask a question which results in a boolean result. | [
"Ask",
"a",
"question",
"which",
"results",
"in",
"a",
"boolean",
"result",
"."
] | b587c1a4672d2e4905871462fa3b38a1f7b94e90 | https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/io/PromptHelper.java#L63-L68 | train |
threerings/nenya | core/src/main/java/com/threerings/util/KeyTranslatorImpl.java | KeyTranslatorImpl.addPressCommand | public void addPressCommand (int keyCode, String command, int rate)
{
addPressCommand(keyCode, command, rate, DEFAULT_REPEAT_DELAY);
} | java | public void addPressCommand (int keyCode, String command, int rate)
{
addPressCommand(keyCode, command, rate, DEFAULT_REPEAT_DELAY);
} | [
"public",
"void",
"addPressCommand",
"(",
"int",
"keyCode",
",",
"String",
"command",
",",
"int",
"rate",
")",
"{",
"addPressCommand",
"(",
"keyCode",
",",
"command",
",",
"rate",
",",
"DEFAULT_REPEAT_DELAY",
")",
";",
"}"
] | Adds a mapping from a key press to an action command string that will auto-repeat at the
specified repeat rate. Overwrites any existing mapping and repeat rate that may have
already been registered.
@param rate the number of times each second that the key press should be repeated while the
key is down, or <code>0</code> to disable auto-repeat for the key. | [
"Adds",
"a",
"mapping",
"from",
"a",
"key",
"press",
"to",
"an",
"action",
"command",
"string",
"that",
"will",
"auto",
"-",
"repeat",
"at",
"the",
"specified",
"repeat",
"rate",
".",
"Overwrites",
"any",
"existing",
"mapping",
"and",
"repeat",
"rate",
"th... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/KeyTranslatorImpl.java#L55-L58 | train |
threerings/nenya | core/src/main/java/com/threerings/util/KeyTranslatorImpl.java | KeyTranslatorImpl.addPressCommand | public void addPressCommand (int keyCode, String command, int rate, long repeatDelay)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.pressCommand = command;
krec.repeatRate = rate;
krec.repeatDelay = repeatDelay;
} | java | public void addPressCommand (int keyCode, String command, int rate, long repeatDelay)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.pressCommand = command;
krec.repeatRate = rate;
krec.repeatDelay = repeatDelay;
} | [
"public",
"void",
"addPressCommand",
"(",
"int",
"keyCode",
",",
"String",
"command",
",",
"int",
"rate",
",",
"long",
"repeatDelay",
")",
"{",
"KeyRecord",
"krec",
"=",
"getKeyRecord",
"(",
"keyCode",
")",
";",
"krec",
".",
"pressCommand",
"=",
"command",
... | Adds a mapping from a key press to an action command string that will auto-repeat at the
specified repeat rate after the specified auto-repeat delay has expired. Overwrites any
existing mapping for the specified key code that may have already been registered.
@param rate the number of times each second that the key press should be repeated while the
key is down; passing <code>0</code> will result in no repeating.
@param repeatDelay the delay in milliseconds before auto-repeating key press events will be
generated for the key. | [
"Adds",
"a",
"mapping",
"from",
"a",
"key",
"press",
"to",
"an",
"action",
"command",
"string",
"that",
"will",
"auto",
"-",
"repeat",
"at",
"the",
"specified",
"repeat",
"rate",
"after",
"the",
"specified",
"auto",
"-",
"repeat",
"delay",
"has",
"expired"... | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/KeyTranslatorImpl.java#L70-L76 | train |
threerings/nenya | core/src/main/java/com/threerings/util/KeyTranslatorImpl.java | KeyTranslatorImpl.addReleaseCommand | public void addReleaseCommand (int keyCode, String command)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.releaseCommand = command;
} | java | public void addReleaseCommand (int keyCode, String command)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.releaseCommand = command;
} | [
"public",
"void",
"addReleaseCommand",
"(",
"int",
"keyCode",
",",
"String",
"command",
")",
"{",
"KeyRecord",
"krec",
"=",
"getKeyRecord",
"(",
"keyCode",
")",
";",
"krec",
".",
"releaseCommand",
"=",
"command",
";",
"}"
] | Adds a mapping from a key release to an action command string. Overwrites any existing
mapping that may already have been registered. | [
"Adds",
"a",
"mapping",
"from",
"a",
"key",
"release",
"to",
"an",
"action",
"command",
"string",
".",
"Overwrites",
"any",
"existing",
"mapping",
"that",
"may",
"already",
"have",
"been",
"registered",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/KeyTranslatorImpl.java#L82-L86 | train |
threerings/nenya | core/src/main/java/com/threerings/util/KeyTranslatorImpl.java | KeyTranslatorImpl.getKeyRecord | protected KeyRecord getKeyRecord (int keyCode)
{
KeyRecord krec = _keys.get(keyCode);
if (krec == null) {
krec = new KeyRecord();
_keys.put(keyCode, krec);
}
return krec;
} | java | protected KeyRecord getKeyRecord (int keyCode)
{
KeyRecord krec = _keys.get(keyCode);
if (krec == null) {
krec = new KeyRecord();
_keys.put(keyCode, krec);
}
return krec;
} | [
"protected",
"KeyRecord",
"getKeyRecord",
"(",
"int",
"keyCode",
")",
"{",
"KeyRecord",
"krec",
"=",
"_keys",
".",
"get",
"(",
"keyCode",
")",
";",
"if",
"(",
"krec",
"==",
"null",
")",
"{",
"krec",
"=",
"new",
"KeyRecord",
"(",
")",
";",
"_keys",
".... | Returns the key record for the specified key, creating it and inserting it in the key table
if necessary. | [
"Returns",
"the",
"key",
"record",
"for",
"the",
"specified",
"key",
"creating",
"it",
"and",
"inserting",
"it",
"in",
"the",
"key",
"table",
"if",
"necessary",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/KeyTranslatorImpl.java#L92-L100 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.addSprite | public void addSprite (Sprite sprite)
{
_metamgr.addSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (_actionSpriteCount++ == 0)) {
if (_actionHandler == null) {
_actionHandler = createActionSpriteHandler();
}
addMouseListener(_actionHandler);
addMouseMotionListener(_actionHandler);
}
} | java | public void addSprite (Sprite sprite)
{
_metamgr.addSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (_actionSpriteCount++ == 0)) {
if (_actionHandler == null) {
_actionHandler = createActionSpriteHandler();
}
addMouseListener(_actionHandler);
addMouseMotionListener(_actionHandler);
}
} | [
"public",
"void",
"addSprite",
"(",
"Sprite",
"sprite",
")",
"{",
"_metamgr",
".",
"addSprite",
"(",
"sprite",
")",
";",
"if",
"(",
"(",
"(",
"sprite",
"instanceof",
"ActionSprite",
")",
"||",
"(",
"sprite",
"instanceof",
"HoverSprite",
")",
")",
"&&",
"... | Adds a sprite to this panel. | [
"Adds",
"a",
"sprite",
"to",
"this",
"panel",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L166-L178 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.removeSprite | public void removeSprite (Sprite sprite)
{
_metamgr.removeSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (--_actionSpriteCount == 0)) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
}
} | java | public void removeSprite (Sprite sprite)
{
_metamgr.removeSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (--_actionSpriteCount == 0)) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
}
} | [
"public",
"void",
"removeSprite",
"(",
"Sprite",
"sprite",
")",
"{",
"_metamgr",
".",
"removeSprite",
"(",
"sprite",
")",
";",
"if",
"(",
"(",
"(",
"sprite",
"instanceof",
"ActionSprite",
")",
"||",
"(",
"sprite",
"instanceof",
"HoverSprite",
")",
")",
"&&... | Removes a sprite from this panel. | [
"Removes",
"a",
"sprite",
"from",
"this",
"panel",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L191-L200 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.clearSprites | public void clearSprites ()
{
_metamgr.clearSprites();
if (_actionHandler != null) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
_actionSpriteCount = 0;
}
} | java | public void clearSprites ()
{
_metamgr.clearSprites();
if (_actionHandler != null) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
_actionSpriteCount = 0;
}
} | [
"public",
"void",
"clearSprites",
"(",
")",
"{",
"_metamgr",
".",
"clearSprites",
"(",
")",
";",
"if",
"(",
"_actionHandler",
"!=",
"null",
")",
"{",
"removeMouseListener",
"(",
"_actionHandler",
")",
";",
"removeMouseMotionListener",
"(",
"_actionHandler",
")",... | Removes all sprites from this panel. | [
"Removes",
"all",
"sprites",
"from",
"this",
"panel",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L205-L214 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.tick | public void tick (long tickStamp)
{
if (_metamgr.isPaused()) {
return;
}
// let derived classes do their business
willTick(tickStamp);
// tick our meta manager which will tick our sprites and animations
_metamgr.tick(tickStamp);
// let derived classes do their business
didTick(tickStamp);
// make a note that the next paint will correspond to a call to tick()
_tickPaintPending = true;
} | java | public void tick (long tickStamp)
{
if (_metamgr.isPaused()) {
return;
}
// let derived classes do their business
willTick(tickStamp);
// tick our meta manager which will tick our sprites and animations
_metamgr.tick(tickStamp);
// let derived classes do their business
didTick(tickStamp);
// make a note that the next paint will correspond to a call to tick()
_tickPaintPending = true;
} | [
"public",
"void",
"tick",
"(",
"long",
"tickStamp",
")",
"{",
"if",
"(",
"_metamgr",
".",
"isPaused",
"(",
")",
")",
"{",
"return",
";",
"}",
"// let derived classes do their business",
"willTick",
"(",
"tickStamp",
")",
";",
"// tick our meta manager which will t... | from interface FrameParticipant | [
"from",
"interface",
"FrameParticipant"
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L256-L273 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.addObscurer | public void addObscurer (Obscurer obscurer) {
if (_obscurerList == null) {
_obscurerList = Lists.newArrayList();
}
_obscurerList.add(obscurer);
} | java | public void addObscurer (Obscurer obscurer) {
if (_obscurerList == null) {
_obscurerList = Lists.newArrayList();
}
_obscurerList.add(obscurer);
} | [
"public",
"void",
"addObscurer",
"(",
"Obscurer",
"obscurer",
")",
"{",
"if",
"(",
"_obscurerList",
"==",
"null",
")",
"{",
"_obscurerList",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"}",
"_obscurerList",
".",
"add",
"(",
"obscurer",
")",
";",
"}... | Adds an element that could be obscuring the panel and thus requires extra redrawing. | [
"Adds",
"an",
"element",
"that",
"could",
"be",
"obscuring",
"the",
"panel",
"and",
"thus",
"requires",
"extra",
"redrawing",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L366-L371 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.addObscurerDirtyRegions | protected void addObscurerDirtyRegions (boolean changedOnly)
{
if (_obscurerList != null) {
for (Obscurer obscurer : _obscurerList) {
Rectangle obscured = obscurer.getObscured(changedOnly);
if (obscured != null) {
Point pt = new Point(obscured.x, obscured.y);
SwingUtilities.convertPointFromScreen(pt, this);
addObscurerDirtyRegion(
new Rectangle(pt.x, pt.y, obscured.width, obscured.height));
}
}
}
} | java | protected void addObscurerDirtyRegions (boolean changedOnly)
{
if (_obscurerList != null) {
for (Obscurer obscurer : _obscurerList) {
Rectangle obscured = obscurer.getObscured(changedOnly);
if (obscured != null) {
Point pt = new Point(obscured.x, obscured.y);
SwingUtilities.convertPointFromScreen(pt, this);
addObscurerDirtyRegion(
new Rectangle(pt.x, pt.y, obscured.width, obscured.height));
}
}
}
} | [
"protected",
"void",
"addObscurerDirtyRegions",
"(",
"boolean",
"changedOnly",
")",
"{",
"if",
"(",
"_obscurerList",
"!=",
"null",
")",
"{",
"for",
"(",
"Obscurer",
"obscurer",
":",
"_obscurerList",
")",
"{",
"Rectangle",
"obscured",
"=",
"obscurer",
".",
"get... | Add dirty regions for all our obscurers. | [
"Add",
"dirty",
"regions",
"for",
"all",
"our",
"obscurers",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L385-L398 | train |
threerings/nenya | core/src/main/java/com/threerings/media/MediaPanel.java | MediaPanel.paintDirtyRect | protected void paintDirtyRect (Graphics2D gfx, Rectangle rect)
{
// paint the behind the scenes stuff
paintBehind(gfx, rect);
// paint back sprites and animations
paintBits(gfx, AnimationManager.BACK, rect);
// paint the between the scenes stuff
paintBetween(gfx, rect);
// paint front sprites and animations
paintBits(gfx, AnimationManager.FRONT, rect);
// paint anything in front
paintInFront(gfx, rect);
} | java | protected void paintDirtyRect (Graphics2D gfx, Rectangle rect)
{
// paint the behind the scenes stuff
paintBehind(gfx, rect);
// paint back sprites and animations
paintBits(gfx, AnimationManager.BACK, rect);
// paint the between the scenes stuff
paintBetween(gfx, rect);
// paint front sprites and animations
paintBits(gfx, AnimationManager.FRONT, rect);
// paint anything in front
paintInFront(gfx, rect);
} | [
"protected",
"void",
"paintDirtyRect",
"(",
"Graphics2D",
"gfx",
",",
"Rectangle",
"rect",
")",
"{",
"// paint the behind the scenes stuff",
"paintBehind",
"(",
"gfx",
",",
"rect",
")",
";",
"// paint back sprites and animations",
"paintBits",
"(",
"gfx",
",",
"Animat... | Paints all the layers of the specified dirty region. | [
"Paints",
"all",
"the",
"layers",
"of",
"the",
"specified",
"dirty",
"region",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/MediaPanel.java#L460-L476 | train |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/internal/comm/HttpUtil.java | HttpUtil.getEntityEncoding | public static String getEntityEncoding(HttpEntity entity) {
final Header header = entity.getContentEncoding();
if (header == null)
return null;
return header.getValue();
} | java | public static String getEntityEncoding(HttpEntity entity) {
final Header header = entity.getContentEncoding();
if (header == null)
return null;
return header.getValue();
} | [
"public",
"static",
"String",
"getEntityEncoding",
"(",
"HttpEntity",
"entity",
")",
"{",
"final",
"Header",
"header",
"=",
"entity",
".",
"getContentEncoding",
"(",
")",
";",
"if",
"(",
"header",
"==",
"null",
")",
"return",
"null",
";",
"return",
"header",... | Returns entity encoding.
@param entity
entitity to get encoding.
@return entity encoding string. | [
"Returns",
"entity",
"encoding",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/comm/HttpUtil.java#L98-L103 | train |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/internal/comm/HttpUtil.java | HttpUtil.getCharset | public static String getCharset(HttpEntity entity) {
final String guess = EntityUtils.getContentCharSet(entity);
return guess == null ? HTTP.DEFAULT_CONTENT_CHARSET : guess;
} | java | public static String getCharset(HttpEntity entity) {
final String guess = EntityUtils.getContentCharSet(entity);
return guess == null ? HTTP.DEFAULT_CONTENT_CHARSET : guess;
} | [
"public",
"static",
"String",
"getCharset",
"(",
"HttpEntity",
"entity",
")",
"{",
"final",
"String",
"guess",
"=",
"EntityUtils",
".",
"getContentCharSet",
"(",
"entity",
")",
";",
"return",
"guess",
"==",
"null",
"?",
"HTTP",
".",
"DEFAULT_CONTENT_CHARSET",
... | Returns entity charset to use.
@param entity
entity to check.
@return entity charset to use in decoding. | [
"Returns",
"entity",
"charset",
"to",
"use",
"."
] | 7e5270c84aba32d74a506260ec47ff86ab6c9d84 | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/comm/HttpUtil.java#L112-L115 | train |
threerings/nenya | core/src/main/java/com/threerings/chat/ChatLogic.java | ChatLogic.decodeFormat | public Tuple<String, Boolean> decodeFormat (int type, String format)
{
boolean quotes = true;
switch (placeOf(type)) {
// derived classes may wish to change the format here based on the place
case PLACE:
switch (modeOf(type)) {
case EMOTE:
quotes = false;
break;
}
break;
}
return Tuple.newTuple(format, quotes);
} | java | public Tuple<String, Boolean> decodeFormat (int type, String format)
{
boolean quotes = true;
switch (placeOf(type)) {
// derived classes may wish to change the format here based on the place
case PLACE:
switch (modeOf(type)) {
case EMOTE:
quotes = false;
break;
}
break;
}
return Tuple.newTuple(format, quotes);
} | [
"public",
"Tuple",
"<",
"String",
",",
"Boolean",
">",
"decodeFormat",
"(",
"int",
"type",
",",
"String",
"format",
")",
"{",
"boolean",
"quotes",
"=",
"true",
";",
"switch",
"(",
"placeOf",
"(",
"type",
")",
")",
"{",
"// derived classes may wish to change ... | Determines the format string and whether to use quotes based on the chat type. | [
"Determines",
"the",
"format",
"string",
"and",
"whether",
"to",
"use",
"quotes",
"based",
"on",
"the",
"chat",
"type",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatLogic.java#L99-L113 | train |
threerings/nenya | core/src/main/java/com/threerings/chat/ChatLogic.java | ChatLogic.decodeType | public int decodeType (String localtype)
{
if (ChatCodes.USER_CHAT_TYPE.equals(localtype)) {
return TELL;
} else if (ChatCodes.PLACE_CHAT_TYPE.equals(localtype)) {
return PLACE;
} else {
return 0;
}
} | java | public int decodeType (String localtype)
{
if (ChatCodes.USER_CHAT_TYPE.equals(localtype)) {
return TELL;
} else if (ChatCodes.PLACE_CHAT_TYPE.equals(localtype)) {
return PLACE;
} else {
return 0;
}
} | [
"public",
"int",
"decodeType",
"(",
"String",
"localtype",
")",
"{",
"if",
"(",
"ChatCodes",
".",
"USER_CHAT_TYPE",
".",
"equals",
"(",
"localtype",
")",
")",
"{",
"return",
"TELL",
";",
"}",
"else",
"if",
"(",
"ChatCodes",
".",
"PLACE_CHAT_TYPE",
".",
"... | Decodes the main chat type given the supplied localtype provided by the chat system. | [
"Decodes",
"the",
"main",
"chat",
"type",
"given",
"the",
"supplied",
"localtype",
"provided",
"by",
"the",
"chat",
"system",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatLogic.java#L118-L127 | train |
threerings/nenya | core/src/main/java/com/threerings/chat/ChatLogic.java | ChatLogic.adjustTypeByMode | public int adjustTypeByMode (int mode, int type)
{
switch (mode) {
case ChatCodes.DEFAULT_MODE:
return type | SPEAK;
case ChatCodes.EMOTE_MODE:
return type | EMOTE;
case ChatCodes.THINK_MODE:
return type | THINK;
case ChatCodes.SHOUT_MODE:
return type | SHOUT;
case ChatCodes.BROADCAST_MODE:
return BROADCAST; // broadcast always looks like broadcast
default:
return type;
}
} | java | public int adjustTypeByMode (int mode, int type)
{
switch (mode) {
case ChatCodes.DEFAULT_MODE:
return type | SPEAK;
case ChatCodes.EMOTE_MODE:
return type | EMOTE;
case ChatCodes.THINK_MODE:
return type | THINK;
case ChatCodes.SHOUT_MODE:
return type | SHOUT;
case ChatCodes.BROADCAST_MODE:
return BROADCAST; // broadcast always looks like broadcast
default:
return type;
}
} | [
"public",
"int",
"adjustTypeByMode",
"(",
"int",
"mode",
",",
"int",
"type",
")",
"{",
"switch",
"(",
"mode",
")",
"{",
"case",
"ChatCodes",
".",
"DEFAULT_MODE",
":",
"return",
"type",
"|",
"SPEAK",
";",
"case",
"ChatCodes",
".",
"EMOTE_MODE",
":",
"retu... | Adjust the chat type based on the mode of the chat message. | [
"Adjust",
"the",
"chat",
"type",
"based",
"on",
"the",
"mode",
"of",
"the",
"chat",
"message",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatLogic.java#L132-L148 | train |
threerings/nenya | core/src/main/java/com/threerings/chat/ChatLogic.java | ChatLogic.getOutlineColor | public Color getOutlineColor (int type)
{
switch (type) {
case BROADCAST:
return BROADCAST_COLOR;
case TELL:
return TELL_COLOR;
case TELLFEEDBACK:
return TELLFEEDBACK_COLOR;
case INFO:
return INFO_COLOR;
case FEEDBACK:
return FEEDBACK_COLOR;
case ATTENTION:
return ATTENTION_COLOR;
default:
return Color.black;
}
} | java | public Color getOutlineColor (int type)
{
switch (type) {
case BROADCAST:
return BROADCAST_COLOR;
case TELL:
return TELL_COLOR;
case TELLFEEDBACK:
return TELLFEEDBACK_COLOR;
case INFO:
return INFO_COLOR;
case FEEDBACK:
return FEEDBACK_COLOR;
case ATTENTION:
return ATTENTION_COLOR;
default:
return Color.black;
}
} | [
"public",
"Color",
"getOutlineColor",
"(",
"int",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BROADCAST",
":",
"return",
"BROADCAST_COLOR",
";",
"case",
"TELL",
":",
"return",
"TELL_COLOR",
";",
"case",
"TELLFEEDBACK",
":",
"return",
"TELLFEE... | Computes the chat glyph outline color from the chat message type. | [
"Computes",
"the",
"chat",
"glyph",
"outline",
"color",
"from",
"the",
"chat",
"message",
"type",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatLogic.java#L169-L187 | train |
threerings/nenya | tools/src/main/java/com/threerings/miso/tools/xml/SparseMisoSceneParser.java | SparseMisoSceneParser.parseScene | public SparseMisoSceneModel parseScene (String path)
throws IOException, SAXException
{
_model = null;
_digester.push(this);
FileInputStream stream = null;
try {
stream = new FileInputStream(path);
_digester.parse(stream);
} finally {
StreamUtil.close(stream);
}
return _model;
} | java | public SparseMisoSceneModel parseScene (String path)
throws IOException, SAXException
{
_model = null;
_digester.push(this);
FileInputStream stream = null;
try {
stream = new FileInputStream(path);
_digester.parse(stream);
} finally {
StreamUtil.close(stream);
}
return _model;
} | [
"public",
"SparseMisoSceneModel",
"parseScene",
"(",
"String",
"path",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"_model",
"=",
"null",
";",
"_digester",
".",
"push",
"(",
"this",
")",
";",
"FileInputStream",
"stream",
"=",
"null",
";",
"try",
... | Parses the XML file at the specified path into a scene model
instance. | [
"Parses",
"the",
"XML",
"file",
"at",
"the",
"specified",
"path",
"into",
"a",
"scene",
"model",
"instance",
"."
] | 3165a012fd859009db3367f87bd2a5b820cc760a | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/miso/tools/xml/SparseMisoSceneParser.java#L70-L83 | train |
groupon/monsoon | expr/src/main/java/com/groupon/lex/metrics/PathMatcher.java | PathMatcher.valueOf | public static PathMatcher valueOf(String str) throws ParseException {
try {
return valueOf(new StringReader(str));
} catch (IOException ex) {
throw new IllegalStateException("StringReader IO error?", ex);
}
} | java | public static PathMatcher valueOf(String str) throws ParseException {
try {
return valueOf(new StringReader(str));
} catch (IOException ex) {
throw new IllegalStateException("StringReader IO error?", ex);
}
} | [
"public",
"static",
"PathMatcher",
"valueOf",
"(",
"String",
"str",
")",
"throws",
"ParseException",
"{",
"try",
"{",
"return",
"valueOf",
"(",
"new",
"StringReader",
"(",
"str",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"... | Read path matcher from string.
@param str A string containing a path expression.
@return A PathMatcher corresponding to the parsed input
from the string.
@throws
com.groupon.lex.metrics.PathMatcher.ParseException
on invalid path expression. | [
"Read",
"path",
"matcher",
"from",
"string",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/PathMatcher.java#L386-L392 | train |
groupon/monsoon | expr/src/main/java/com/groupon/lex/metrics/PathMatcher.java | PathMatcher.valueOf | public static PathMatcher valueOf(Reader reader) throws IOException, ParseException {
class DescriptiveErrorListener extends BaseErrorListener {
public List<String> errors = new ArrayList<>();
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
int line, int charPositionInLine,
String msg, org.antlr.v4.runtime.RecognitionException e) {
LOG.log(Level.INFO, "Parse error: {0}:{1} -> {2}", new Object[]{line, charPositionInLine, msg});
errors.add(String.format("%d:%d: %s", line, charPositionInLine, msg));
}
}
final DescriptiveErrorListener error_listener = new DescriptiveErrorListener();
final PathMatcherLexer lexer = new PathMatcherLexer(CharStreams.fromReader(reader));
lexer.removeErrorListeners();
lexer.addErrorListener(error_listener);
final PathMatcherGrammar parser = new PathMatcherGrammar(new BufferedTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(error_listener);
final PathMatcherGrammar.ExprContext expr;
try {
expr = parser.expr();
} catch (Exception ex) {
LOG.log(Level.SEVERE, "parser yielded exceptional return", ex);
if (!error_listener.errors.isEmpty())
throw new ParseException(error_listener.errors, ex);
else
throw ex;
}
if (!error_listener.errors.isEmpty()) {
if (expr.exception != null)
throw new ParseException(error_listener.errors, expr.exception);
throw new ParseException(error_listener.errors);
} else if (expr.exception != null) {
throw new ParseException(expr.exception);
}
return expr.s;
} | java | public static PathMatcher valueOf(Reader reader) throws IOException, ParseException {
class DescriptiveErrorListener extends BaseErrorListener {
public List<String> errors = new ArrayList<>();
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
int line, int charPositionInLine,
String msg, org.antlr.v4.runtime.RecognitionException e) {
LOG.log(Level.INFO, "Parse error: {0}:{1} -> {2}", new Object[]{line, charPositionInLine, msg});
errors.add(String.format("%d:%d: %s", line, charPositionInLine, msg));
}
}
final DescriptiveErrorListener error_listener = new DescriptiveErrorListener();
final PathMatcherLexer lexer = new PathMatcherLexer(CharStreams.fromReader(reader));
lexer.removeErrorListeners();
lexer.addErrorListener(error_listener);
final PathMatcherGrammar parser = new PathMatcherGrammar(new BufferedTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(error_listener);
final PathMatcherGrammar.ExprContext expr;
try {
expr = parser.expr();
} catch (Exception ex) {
LOG.log(Level.SEVERE, "parser yielded exceptional return", ex);
if (!error_listener.errors.isEmpty())
throw new ParseException(error_listener.errors, ex);
else
throw ex;
}
if (!error_listener.errors.isEmpty()) {
if (expr.exception != null)
throw new ParseException(error_listener.errors, expr.exception);
throw new ParseException(error_listener.errors);
} else if (expr.exception != null) {
throw new ParseException(expr.exception);
}
return expr.s;
} | [
"public",
"static",
"PathMatcher",
"valueOf",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
",",
"ParseException",
"{",
"class",
"DescriptiveErrorListener",
"extends",
"BaseErrorListener",
"{",
"public",
"List",
"<",
"String",
">",
"errors",
"=",
"new",
"... | Read path matcher from reader.
@param reader A reader supplying the input of a path expression.
@return A PathMatcher corresponding to the parsed input
from the reader.
@throws IOException on IO errors from the reader.
@throws
com.groupon.lex.metrics.PathMatcher.ParseException
on invalid path expression. | [
"Read",
"path",
"matcher",
"from",
"reader",
"."
] | eb68d72ba4c01fe018dc981097dbee033908f5c7 | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/PathMatcher.java#L405-L447 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.getChannelListeners | public List<ChannelListener> getChannelListeners() {
if (changes == null) {
return (List<ChannelListener>)Collections.EMPTY_LIST;
}
List<EventListener> listeners = changes.getListenerList(AMQP);
if ((listeners == null) || listeners.isEmpty()) {
return (List<ChannelListener>)Collections.EMPTY_LIST;
}
ArrayList<ChannelListener> list = new ArrayList<ChannelListener>();
for (EventListener listener : listeners) {
list.add((ChannelListener)listener);
}
return list;
} | java | public List<ChannelListener> getChannelListeners() {
if (changes == null) {
return (List<ChannelListener>)Collections.EMPTY_LIST;
}
List<EventListener> listeners = changes.getListenerList(AMQP);
if ((listeners == null) || listeners.isEmpty()) {
return (List<ChannelListener>)Collections.EMPTY_LIST;
}
ArrayList<ChannelListener> list = new ArrayList<ChannelListener>();
for (EventListener listener : listeners) {
list.add((ChannelListener)listener);
}
return list;
} | [
"public",
"List",
"<",
"ChannelListener",
">",
"getChannelListeners",
"(",
")",
"{",
"if",
"(",
"changes",
"==",
"null",
")",
"{",
"return",
"(",
"List",
"<",
"ChannelListener",
">",
")",
"Collections",
".",
"EMPTY_LIST",
";",
"}",
"List",
"<",
"EventListe... | Returns the list of ChannelListeners registered with this AmqpChannel instance.
@return List<ChannelListener> list of ChannelListeners | [
"Returns",
"the",
"list",
"of",
"ChannelListeners",
"registered",
"with",
"this",
"AmqpChannel",
"instance",
"."
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L144-L160 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.openChannel | AmqpChannel openChannel() {
if (readyState == ReadyState.OPEN) {
// If the channel is already open, just bail.
return this;
}
// try {
Object[] args = {""};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "openChannel";
String methodId = "20" + "10";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.getStateMachine().enterState("channelReady", "", null);
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
readyState = ReadyState.CONNECTING;
/*}
catch (Exception ex) {
if (errorHandler != null) {
AmqpEvent e = new ChannelEvent(this, Kind.ERROR, ex.getMessage());
errorHandler.error(e);
}
}
*/
return this;
} | java | AmqpChannel openChannel() {
if (readyState == ReadyState.OPEN) {
// If the channel is already open, just bail.
return this;
}
// try {
Object[] args = {""};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "openChannel";
String methodId = "20" + "10";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.getStateMachine().enterState("channelReady", "", null);
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
readyState = ReadyState.CONNECTING;
/*}
catch (Exception ex) {
if (errorHandler != null) {
AmqpEvent e = new ChannelEvent(this, Kind.ERROR, ex.getMessage());
errorHandler.error(e);
}
}
*/
return this;
} | [
"AmqpChannel",
"openChannel",
"(",
")",
"{",
"if",
"(",
"readyState",
"==",
"ReadyState",
".",
"OPEN",
")",
"{",
"// If the channel is already open, just bail.",
"return",
"this",
";",
"}",
"// try {",
"Object",
"[",
"]",
"args",
"=",
"{",
"\"\"",
"}",
";",
... | Creates a Channel to the AMQP server on the given clients connection
@return AmqpChannel | [
"Creates",
"a",
"Channel",
"to",
"the",
"AMQP",
"server",
"on",
"the",
"given",
"clients",
"connection"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L309-L338 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.flowChannel | public AmqpChannel flowChannel(boolean active) {
isFlowOn = active;
Object[] args = {active};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodId = "20" + "20";
String methodName = "flowChannel";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);;
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
if (client.getReadyState() == ReadyState.OPEN) {
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
}
return this;
} | java | public AmqpChannel flowChannel(boolean active) {
isFlowOn = active;
Object[] args = {active};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodId = "20" + "20";
String methodName = "flowChannel";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);;
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
if (client.getReadyState() == ReadyState.OPEN) {
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
}
return this;
} | [
"public",
"AmqpChannel",
"flowChannel",
"(",
"boolean",
"active",
")",
"{",
"isFlowOn",
"=",
"active",
";",
"Object",
"[",
"]",
"args",
"=",
"{",
"active",
"}",
";",
"WrappedByteBuffer",
"bodyArg",
"=",
"null",
";",
"HashMap",
"<",
"String",
",",
"Object",... | This method asks the peer to pause or restart the flow of content data sent by a consumer. This is a simple flow-control mechanism that a peer can use to
avoid overflowing its queues or otherwise finding itself receiving more messages than it can process.
@param enabled
If true, the peer starts sending content frames, else the peer stops sending content frames. | [
"This",
"method",
"asks",
"the",
"peer",
"to",
"pause",
"or",
"restart",
"the",
"flow",
"of",
"content",
"data",
"sent",
"by",
"a",
"consumer",
".",
"This",
"is",
"a",
"simple",
"flow",
"-",
"control",
"mechanism",
"that",
"a",
"peer",
"can",
"use",
"t... | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L348-L363 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.closeChannel | public AmqpChannel closeChannel(int replyCode, String replyText, int classId, int methodId1) {
if (readyState == ReadyState.CLOSED) {
return this;
}
Object[] args = {replyCode, replyText, classId, methodId1};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "closeChannel";
String methodId = "20" + "40";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | java | public AmqpChannel closeChannel(int replyCode, String replyText, int classId, int methodId1) {
if (readyState == ReadyState.CLOSED) {
return this;
}
Object[] args = {replyCode, replyText, classId, methodId1};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "closeChannel";
String methodId = "20" + "40";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | [
"public",
"AmqpChannel",
"closeChannel",
"(",
"int",
"replyCode",
",",
"String",
"replyText",
",",
"int",
"classId",
",",
"int",
"methodId1",
")",
"{",
"if",
"(",
"readyState",
"==",
"ReadyState",
".",
"CLOSED",
")",
"{",
"return",
"this",
";",
"}",
"Objec... | This method indicates that the sender wants to close the channel.
@param replyCode
@param replyText
@param classId
@param methodId1
@return AmqpChannel | [
"This",
"method",
"indicates",
"that",
"the",
"sender",
"wants",
"to",
"close",
"the",
"channel",
"."
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L395-L410 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.closeOkChannel | private AmqpChannel closeOkChannel() {
if (readyState == ReadyState.CLOSED) {
// If the channel has been closed, just bail.
return this;
}
Object[] args = {};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "closeOkChannel";
String methodId = "20" + "41";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);;
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | java | private AmqpChannel closeOkChannel() {
if (readyState == ReadyState.CLOSED) {
// If the channel has been closed, just bail.
return this;
}
Object[] args = {};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "closeOkChannel";
String methodId = "20" + "41";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);;
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | [
"private",
"AmqpChannel",
"closeOkChannel",
"(",
")",
"{",
"if",
"(",
"readyState",
"==",
"ReadyState",
".",
"CLOSED",
")",
"{",
"// If the channel has been closed, just bail.",
"return",
"this",
";",
"}",
"Object",
"[",
"]",
"args",
"=",
"{",
"}",
";",
"Wrapp... | Confirms to the peer that a flow command was received and processed.
@return AmqpChannel | [
"Confirms",
"to",
"the",
"peer",
"that",
"a",
"flow",
"command",
"was",
"received",
"and",
"processed",
"."
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L417-L433 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.deleteQueue | public AmqpChannel deleteQueue(String queue, boolean ifUnused, boolean ifEmpty, boolean noWait) {
Object[] args = {0, queue, ifUnused, ifEmpty, noWait};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "deleteQueue";
String methodId = "50" + "40";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
boolean hasnowait = false;
for (int i = 0; i < amqpMethod.allParameters.size(); i++) {
String argname = amqpMethod.allParameters.get(i).name;
if (argname == "noWait") {
hasnowait = true;
break;
}
}
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
if (hasnowait && noWait) {
asyncClient.enqueueAction("nowait", null, null, null, null);
}
return this;
} | java | public AmqpChannel deleteQueue(String queue, boolean ifUnused, boolean ifEmpty, boolean noWait) {
Object[] args = {0, queue, ifUnused, ifEmpty, noWait};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "deleteQueue";
String methodId = "50" + "40";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
boolean hasnowait = false;
for (int i = 0; i < amqpMethod.allParameters.size(); i++) {
String argname = amqpMethod.allParameters.get(i).name;
if (argname == "noWait") {
hasnowait = true;
break;
}
}
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
if (hasnowait && noWait) {
asyncClient.enqueueAction("nowait", null, null, null, null);
}
return this;
} | [
"public",
"AmqpChannel",
"deleteQueue",
"(",
"String",
"queue",
",",
"boolean",
"ifUnused",
",",
"boolean",
"ifEmpty",
",",
"boolean",
"noWait",
")",
"{",
"Object",
"[",
"]",
"args",
"=",
"{",
"0",
",",
"queue",
",",
"ifUnused",
",",
"ifEmpty",
",",
"noW... | This method deletes a queue. When a queue is deleted any pending messages are sent to a dead-letter queue if this is defined in the server configuration,
and all consumers on the queue are canceled.
@param queue
@param ifUnused
@param ifEmpty
@param noWait
@return AmqpChannel | [
"This",
"method",
"deletes",
"a",
"queue",
".",
"When",
"a",
"queue",
"is",
"deleted",
"any",
"pending",
"messages",
"are",
"sent",
"to",
"a",
"dead",
"-",
"letter",
"queue",
"if",
"this",
"is",
"defined",
"in",
"the",
"server",
"configuration",
"and",
"... | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L563-L589 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.unbindQueue | public AmqpChannel unbindQueue(String queue, String exchange, String routingKey, AmqpArguments arguments) {
Object[] args = {0, queue, exchange, routingKey, arguments};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "unbindQueue";
String methodId = "50" + "50";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] methodArguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", methodArguments, null, null);
return this;
} | java | public AmqpChannel unbindQueue(String queue, String exchange, String routingKey, AmqpArguments arguments) {
Object[] args = {0, queue, exchange, routingKey, arguments};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "unbindQueue";
String methodId = "50" + "50";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] methodArguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", methodArguments, null, null);
return this;
} | [
"public",
"AmqpChannel",
"unbindQueue",
"(",
"String",
"queue",
",",
"String",
"exchange",
",",
"String",
"routingKey",
",",
"AmqpArguments",
"arguments",
")",
"{",
"Object",
"[",
"]",
"args",
"=",
"{",
"0",
",",
"queue",
",",
"exchange",
",",
"routingKey",
... | This method unbinds a queue from an exchange.
@param queue
@param exchange
@param routingKey
@param arguments
@return AmqpChannel | [
"This",
"method",
"unbinds",
"a",
"queue",
"from",
"an",
"exchange",
"."
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L638-L649 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.qosBasic | public AmqpChannel qosBasic(int prefetchSize, int prefetchCount, boolean global) {
Object[] args = {prefetchSize, prefetchCount, global};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "qosBasic";
String methodId = "60" + "10";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | java | public AmqpChannel qosBasic(int prefetchSize, int prefetchCount, boolean global) {
Object[] args = {prefetchSize, prefetchCount, global};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "qosBasic";
String methodId = "60" + "10";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | [
"public",
"AmqpChannel",
"qosBasic",
"(",
"int",
"prefetchSize",
",",
"int",
"prefetchCount",
",",
"boolean",
"global",
")",
"{",
"Object",
"[",
"]",
"args",
"=",
"{",
"prefetchSize",
",",
"prefetchCount",
",",
"global",
"}",
";",
"WrappedByteBuffer",
"bodyArg... | This method requests a specific quality of service. The QoS can be specified for the current channel or for all channels on the connection. The
particular properties and semantics of a qos method always depend on the content class semantics. Though the qos method could in principle apply to both
peers, it is currently meaningful only for the server.
@param prefetchSize
@param prefetchCount
@param global | [
"This",
"method",
"requests",
"a",
"specific",
"quality",
"of",
"service",
".",
"The",
"QoS",
"can",
"be",
"specified",
"for",
"the",
"current",
"channel",
"or",
"for",
"all",
"channels",
"on",
"the",
"connection",
".",
"The",
"particular",
"properties",
"an... | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L699-L710 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.publishBasic | public AmqpChannel publishBasic(ByteBuffer body, AmqpProperties properties, String exchange, String routingKey, boolean mandatory, boolean immediate) {
@SuppressWarnings("unchecked")
Map<String, Object> amqpProps = (Map<String, Object>)Collections.EMPTY_MAP;
if (properties != null) {
amqpProps = properties.getProperties();
}
HashMap<String, Object> props = (HashMap<String, Object>)amqpProps;
return publishBasic(body, props, exchange, routingKey, mandatory, immediate);
} | java | public AmqpChannel publishBasic(ByteBuffer body, AmqpProperties properties, String exchange, String routingKey, boolean mandatory, boolean immediate) {
@SuppressWarnings("unchecked")
Map<String, Object> amqpProps = (Map<String, Object>)Collections.EMPTY_MAP;
if (properties != null) {
amqpProps = properties.getProperties();
}
HashMap<String, Object> props = (HashMap<String, Object>)amqpProps;
return publishBasic(body, props, exchange, routingKey, mandatory, immediate);
} | [
"public",
"AmqpChannel",
"publishBasic",
"(",
"ByteBuffer",
"body",
",",
"AmqpProperties",
"properties",
",",
"String",
"exchange",
",",
"String",
"routingKey",
",",
"boolean",
"mandatory",
",",
"boolean",
"immediate",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"un... | This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distributed to
any active consumers when the transaction, if any, is committed.
@param body
@param headers
@param exchange
@param routingKey
@param mandatory
@param immediate
@return AmqpChannel | [
"This",
"method",
"publishes",
"a",
"message",
"to",
"a",
"specific",
"exchange",
".",
"The",
"message",
"will",
"be",
"routed",
"to",
"queues",
"as",
"defined",
"by",
"the",
"exchange",
"configuration",
"and",
"distributed",
"to",
"any",
"active",
"consumers"... | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L834-L843 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.getBasic | public AmqpChannel getBasic(String queue, boolean noAck) {
Object[] args = {0, queue, noAck};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "getBasic";
String methodId = "60" + "70";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | java | public AmqpChannel getBasic(String queue, boolean noAck) {
Object[] args = {0, queue, noAck};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "getBasic";
String methodId = "60" + "70";
AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId);
Object[] arguments = {this, amqpMethod, this.id, args, bodyArg, headersArg};
asyncClient.enqueueAction(methodName, "channelWrite", arguments, null, null);
return this;
} | [
"public",
"AmqpChannel",
"getBasic",
"(",
"String",
"queue",
",",
"boolean",
"noAck",
")",
"{",
"Object",
"[",
"]",
"args",
"=",
"{",
"0",
",",
"queue",
",",
"noAck",
"}",
";",
"WrappedByteBuffer",
"bodyArg",
"=",
"null",
";",
"HashMap",
"<",
"String",
... | Gets messages from the queue and dispatches it to the listener
@param queue
@param noAck
@return AmqpChannel | [
"Gets",
"messages",
"from",
"the",
"queue",
"and",
"dispatches",
"it",
"to",
"the",
"listener"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L852-L863 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnOpen | private void fireOnOpen(ChannelEvent e) {
if (readyState == ReadyState.OPEN) {
// If the channel has already been opened, then we should not fire
// any events.
return;
}
readyState = ReadyState.OPEN;
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onOpen(e);
}
} | java | private void fireOnOpen(ChannelEvent e) {
if (readyState == ReadyState.OPEN) {
// If the channel has already been opened, then we should not fire
// any events.
return;
}
readyState = ReadyState.OPEN;
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onOpen(e);
}
} | [
"private",
"void",
"fireOnOpen",
"(",
"ChannelEvent",
"e",
")",
"{",
"if",
"(",
"readyState",
"==",
"ReadyState",
".",
"OPEN",
")",
"{",
"// If the channel has already been opened, then we should not fire",
"// any events.",
"return",
";",
"}",
"readyState",
"=",
"Rea... | Fired when channel is opened
@param e | [
"Fired",
"when",
"channel",
"is",
"opened"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1265-L1278 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnDeclareExchange | private void fireOnDeclareExchange(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareExchange(e);
}
} | java | private void fireOnDeclareExchange(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareExchange(e);
}
} | [
"private",
"void",
"fireOnDeclareExchange",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{",
... | Fired when exchange is declared
@param e | [
"Fired",
"when",
"exchange",
"is",
"declared"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1285-L1291 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnDeclareQueue | private void fireOnDeclareQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareQueue(e);
}
} | java | private void fireOnDeclareQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareQueue(e);
}
} | [
"private",
"void",
"fireOnDeclareQueue",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{",
"... | Fired when Queue is declared
@param e | [
"Fired",
"when",
"Queue",
"is",
"declared"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1298-L1304 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnBindQueue | private void fireOnBindQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onBindQueue(e);
}
} | java | private void fireOnBindQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onBindQueue(e);
}
} | [
"private",
"void",
"fireOnBindQueue",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{",
"Cha... | Fired when Queue is bound
@param e | [
"Fired",
"when",
"Queue",
"is",
"bound"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1311-L1317 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnConsumeBasic | private void fireOnConsumeBasic(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onConsumeBasic(e);
}
} | java | private void fireOnConsumeBasic(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onConsumeBasic(e);
}
} | [
"private",
"void",
"fireOnConsumeBasic",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{",
"... | Fired on consume basic
@param e | [
"Fired",
"on",
"consume",
"basic"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1324-L1330 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnCommitTransaction | private void fireOnCommitTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onCommit(e);
}
} | java | private void fireOnCommitTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onCommit(e);
}
} | [
"private",
"void",
"fireOnCommitTransaction",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{"... | Fired on transaction commit
@param e | [
"Fired",
"on",
"transaction",
"commit"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1337-L1343 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnRollbackTransaction | private void fireOnRollbackTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onRollback(e);
}
} | java | private void fireOnRollbackTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onRollback(e);
}
} | [
"private",
"void",
"fireOnRollbackTransaction",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"... | Fired on transaction rollbacked
@param e | [
"Fired",
"on",
"transaction",
"rollbacked"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1350-L1356 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnSelectTransaction | private void fireOnSelectTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onSelect(e);
}
} | java | private void fireOnSelectTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onSelect(e);
}
} | [
"private",
"void",
"fireOnSelectTransaction",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{"... | Fired on transaction select
@param e | [
"Fired",
"on",
"transaction",
"select"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1363-L1369 | train |
kaazing/java.client | amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java | AmqpChannel.fireOnMessage | private void fireOnMessage(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onMessage(e);
}
} | java | private void fireOnMessage(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onMessage(e);
}
} | [
"private",
"void",
"fireOnMessage",
"(",
"ChannelEvent",
"e",
")",
"{",
"List",
"<",
"EventListener",
">",
"listeners",
"=",
"changes",
".",
"getListenerList",
"(",
"AMQP",
")",
";",
"for",
"(",
"EventListener",
"listener",
":",
"listeners",
")",
"{",
"Chann... | Fired on message retreival
@param e | [
"Fired",
"on",
"message",
"retreival"
] | 25ad2ae5bb24aa9d6b79400fce649b518dcfbe26 | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpChannel.java#L1376-L1382 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.