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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
actframework/actframework | src/main/java/act/util/ClassNode.java | ClassNode.addInterface | public ClassNode addInterface(String name) {
ClassNode intf = infoBase.node(name);
addInterface(intf);
return this;
} | java | public ClassNode addInterface(String name) {
ClassNode intf = infoBase.node(name);
addInterface(intf);
return this;
} | [
"public",
"ClassNode",
"addInterface",
"(",
"String",
"name",
")",
"{",
"ClassNode",
"intf",
"=",
"infoBase",
".",
"node",
"(",
"name",
")",
";",
"addInterface",
"(",
"intf",
")",
";",
"return",
"this",
";",
"}"
] | Specify the class represented by this `ClassNode` implements
an interface specified by the given name
@param name the name of the interface class
@return this `ClassNode` instance | [
"Specify",
"the",
"class",
"represented",
"by",
"this",
"ClassNode",
"implements",
"an",
"interface",
"specified",
"by",
"the",
"given",
"name"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/ClassNode.java#L125-L129 | train |
actframework/actframework | src/main/java/act/util/ClassNode.java | ClassNode.annotatedWith | public ClassNode annotatedWith(String name) {
ClassNode anno = infoBase.node(name);
this.annotations.add(anno);
anno.annotated.add(this);
return this;
} | java | public ClassNode annotatedWith(String name) {
ClassNode anno = infoBase.node(name);
this.annotations.add(anno);
anno.annotated.add(this);
return this;
} | [
"public",
"ClassNode",
"annotatedWith",
"(",
"String",
"name",
")",
"{",
"ClassNode",
"anno",
"=",
"infoBase",
".",
"node",
"(",
"name",
")",
";",
"this",
".",
"annotations",
".",
"add",
"(",
"anno",
")",
";",
"anno",
".",
"annotated",
".",
"add",
"(",... | Specify the class represented by this `ClassNode` is annotated
by an annotation class specified by the name
@param name the name of the annotation class
@return this `ClassNode` instance | [
"Specify",
"the",
"class",
"represented",
"by",
"this",
"ClassNode",
"is",
"annotated",
"by",
"an",
"annotation",
"class",
"specified",
"by",
"the",
"name"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/ClassNode.java#L153-L158 | train |
actframework/actframework | src/main/java/act/i18n/TimeZoneResolver.java | TimeZoneResolver.timezoneOffset | public static int timezoneOffset(H.Session session) {
String s = null != session ? session.get(SESSION_KEY) : null;
return S.notBlank(s) ? Integer.parseInt(s) : serverTimezoneOffset();
} | java | public static int timezoneOffset(H.Session session) {
String s = null != session ? session.get(SESSION_KEY) : null;
return S.notBlank(s) ? Integer.parseInt(s) : serverTimezoneOffset();
} | [
"public",
"static",
"int",
"timezoneOffset",
"(",
"H",
".",
"Session",
"session",
")",
"{",
"String",
"s",
"=",
"null",
"!=",
"session",
"?",
"session",
".",
"get",
"(",
"SESSION_KEY",
")",
":",
"null",
";",
"return",
"S",
".",
"notBlank",
"(",
"s",
... | Returns timezone offset from a session instance. The offset is
in minutes to UTC time
@param session
the session instance
@return the offset to UTC time in minutes | [
"Returns",
"timezone",
"offset",
"from",
"a",
"session",
"instance",
".",
"The",
"offset",
"is",
"in",
"minutes",
"to",
"UTC",
"time"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/i18n/TimeZoneResolver.java#L62-L65 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionManager.java | WebSocketConnectionManager.sendJsonToUrl | public void sendJsonToUrl(Object data, String url) {
sendToUrl(JSON.toJSONString(data), url);
} | java | public void sendJsonToUrl(Object data, String url) {
sendToUrl(JSON.toJSONString(data), url);
} | [
"public",
"void",
"sendJsonToUrl",
"(",
"Object",
"data",
",",
"String",
"url",
")",
"{",
"sendToUrl",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"url",
")",
";",
"}"
] | Send JSON representation of given data object to all connections
connected to given URL
@param data the data object
@param url the url | [
"Send",
"JSON",
"representation",
"of",
"given",
"data",
"object",
"to",
"all",
"connections",
"connected",
"to",
"given",
"URL"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionManager.java#L129-L131 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionManager.java | WebSocketConnectionManager.sendToTagged | public void sendToTagged(String message, String ... labels) {
for (String label : labels) {
sendToTagged(message, label);
}
} | java | public void sendToTagged(String message, String ... labels) {
for (String label : labels) {
sendToTagged(message, label);
}
} | [
"public",
"void",
"sendToTagged",
"(",
"String",
"message",
",",
"String",
"...",
"labels",
")",
"{",
"for",
"(",
"String",
"label",
":",
"labels",
")",
"{",
"sendToTagged",
"(",
"message",
",",
"label",
")",
";",
"}",
"}"
] | Send message to all connections tagged with all given tags
@param message the message
@param labels the tag labels | [
"Send",
"message",
"to",
"all",
"connections",
"tagged",
"with",
"all",
"given",
"tags"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionManager.java#L147-L151 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionManager.java | WebSocketConnectionManager.sendJsonToTagged | public void sendJsonToTagged(Object data, String label) {
sendToTagged(JSON.toJSONString(data), label);
} | java | public void sendJsonToTagged(Object data, String label) {
sendToTagged(JSON.toJSONString(data), label);
} | [
"public",
"void",
"sendJsonToTagged",
"(",
"Object",
"data",
",",
"String",
"label",
")",
"{",
"sendToTagged",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"label",
")",
";",
"}"
] | Send JSON representation of given data object to all connections tagged with
given label
@param data the data object
@param label the tag label | [
"Send",
"JSON",
"representation",
"of",
"given",
"data",
"object",
"to",
"all",
"connections",
"tagged",
"with",
"given",
"label"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionManager.java#L170-L172 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionManager.java | WebSocketConnectionManager.sendJsonToTagged | public void sendJsonToTagged(Object data, String ... labels) {
for (String label : labels) {
sendJsonToTagged(data, label);
}
} | java | public void sendJsonToTagged(Object data, String ... labels) {
for (String label : labels) {
sendJsonToTagged(data, label);
}
} | [
"public",
"void",
"sendJsonToTagged",
"(",
"Object",
"data",
",",
"String",
"...",
"labels",
")",
"{",
"for",
"(",
"String",
"label",
":",
"labels",
")",
"{",
"sendJsonToTagged",
"(",
"data",
",",
"label",
")",
";",
"}",
"}"
] | Send JSON representation of given data object to all connections tagged with all give tag labels
@param data the data object
@param labels the tag labels | [
"Send",
"JSON",
"representation",
"of",
"given",
"data",
"object",
"to",
"all",
"connections",
"tagged",
"with",
"all",
"give",
"tag",
"labels"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionManager.java#L179-L183 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionManager.java | WebSocketConnectionManager.sendJsonToUser | public void sendJsonToUser(Object data, String username) {
sendToUser(JSON.toJSONString(data), username);
} | java | public void sendJsonToUser(Object data, String username) {
sendToUser(JSON.toJSONString(data), username);
} | [
"public",
"void",
"sendJsonToUser",
"(",
"Object",
"data",
",",
"String",
"username",
")",
"{",
"sendToUser",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"username",
")",
";",
"}"
] | Send JSON representation of given data object to all connections of a user
@param data the data object
@param username the username | [
"Send",
"JSON",
"representation",
"of",
"given",
"data",
"object",
"to",
"all",
"connections",
"of",
"a",
"user"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionManager.java#L210-L212 | train |
actframework/actframework | src/main/java/act/SysUtilAdmin.java | SysUtilAdmin.isBinary | private static boolean isBinary(InputStream in) {
try {
int size = in.available();
if (size > 1024) size = 1024;
byte[] data = new byte[size];
in.read(data);
in.close();
int ascii = 0;
int other = 0;
for (int i = 0; i < data.length; i++) {
byte b = data[i];
if (b < 0x09) return true;
if (b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D) ascii++;
else if (b >= 0x20 && b <= 0x7E) ascii++;
else other++;
}
return other != 0 && 100 * other / (ascii + other) > 95;
} catch (IOException e) {
throw E.ioException(e);
}
} | java | private static boolean isBinary(InputStream in) {
try {
int size = in.available();
if (size > 1024) size = 1024;
byte[] data = new byte[size];
in.read(data);
in.close();
int ascii = 0;
int other = 0;
for (int i = 0; i < data.length; i++) {
byte b = data[i];
if (b < 0x09) return true;
if (b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D) ascii++;
else if (b >= 0x20 && b <= 0x7E) ascii++;
else other++;
}
return other != 0 && 100 * other / (ascii + other) > 95;
} catch (IOException e) {
throw E.ioException(e);
}
} | [
"private",
"static",
"boolean",
"isBinary",
"(",
"InputStream",
"in",
")",
"{",
"try",
"{",
"int",
"size",
"=",
"in",
".",
"available",
"(",
")",
";",
"if",
"(",
"size",
">",
"1024",
")",
"size",
"=",
"1024",
";",
"byte",
"[",
"]",
"data",
"=",
"... | Guess whether given file is binary. Just checks for anything under 0x09. | [
"Guess",
"whether",
"given",
"file",
"is",
"binary",
".",
"Just",
"checks",
"for",
"anything",
"under",
"0x09",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/SysUtilAdmin.java#L359-L384 | train |
actframework/actframework | src/main/java/act/apidoc/javadoc/Javadoc.java | Javadoc.toText | public String toText() {
StringBuilder sb = new StringBuilder();
if (!description.isEmpty()) {
sb.append(description.toText());
sb.append(EOL);
}
if (!blockTags.isEmpty()) {
sb.append(EOL);
}
for (JavadocBlockTag tag : blockTags) {
sb.append(tag.toText()).append(EOL);
}
return sb.toString();
} | java | public String toText() {
StringBuilder sb = new StringBuilder();
if (!description.isEmpty()) {
sb.append(description.toText());
sb.append(EOL);
}
if (!blockTags.isEmpty()) {
sb.append(EOL);
}
for (JavadocBlockTag tag : blockTags) {
sb.append(tag.toText()).append(EOL);
}
return sb.toString();
} | [
"public",
"String",
"toText",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"description",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"description",
".",
"toText",
"(",
")",
")",
... | Return the text content of the document. It does not containing trailing spaces and asterisks
at the start of the line. | [
"Return",
"the",
"text",
"content",
"of",
"the",
"document",
".",
"It",
"does",
"not",
"containing",
"trailing",
"spaces",
"and",
"asterisks",
"at",
"the",
"start",
"of",
"the",
"line",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/apidoc/javadoc/Javadoc.java#L82-L95 | train |
actframework/actframework | src/main/java/act/apidoc/javadoc/Javadoc.java | Javadoc.toComment | public JavadocComment toComment(String indentation) {
for (char c : indentation.toCharArray()) {
if (!Character.isWhitespace(c)) {
throw new IllegalArgumentException("The indentation string should be composed only by whitespace characters");
}
}
StringBuilder sb = new StringBuilder();
sb.append(EOL);
final String text = toText();
if (!text.isEmpty()) {
for (String line : text.split(EOL)) {
sb.append(indentation);
sb.append(" * ");
sb.append(line);
sb.append(EOL);
}
}
sb.append(indentation);
sb.append(" ");
return new JavadocComment(sb.toString());
} | java | public JavadocComment toComment(String indentation) {
for (char c : indentation.toCharArray()) {
if (!Character.isWhitespace(c)) {
throw new IllegalArgumentException("The indentation string should be composed only by whitespace characters");
}
}
StringBuilder sb = new StringBuilder();
sb.append(EOL);
final String text = toText();
if (!text.isEmpty()) {
for (String line : text.split(EOL)) {
sb.append(indentation);
sb.append(" * ");
sb.append(line);
sb.append(EOL);
}
}
sb.append(indentation);
sb.append(" ");
return new JavadocComment(sb.toString());
} | [
"public",
"JavadocComment",
"toComment",
"(",
"String",
"indentation",
")",
"{",
"for",
"(",
"char",
"c",
":",
"indentation",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isWhitespace",
"(",
"c",
")",
")",
"{",
"throw",
"n... | Create a JavadocComment, by formatting the text of the Javadoc using the given indentation. | [
"Create",
"a",
"JavadocComment",
"by",
"formatting",
"the",
"text",
"of",
"the",
"Javadoc",
"using",
"the",
"given",
"indentation",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/apidoc/javadoc/Javadoc.java#L107-L127 | train |
actframework/actframework | src/main/java/act/view/ViewManager.java | ViewManager.isTemplatePath | public static boolean isTemplatePath(String string) {
int sz = string.length();
if (sz == 0) {
return true;
}
for (int i = 0; i < sz; ++i) {
char c = string.charAt(i);
switch (c) {
case ' ':
case '\t':
case '\b':
case '<':
case '>':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
case '!':
case '@':
case '#':
case '*':
case '?':
case '%':
case '|':
case ',':
case ':':
case ';':
case '^':
case '&':
return false;
}
}
return true;
} | java | public static boolean isTemplatePath(String string) {
int sz = string.length();
if (sz == 0) {
return true;
}
for (int i = 0; i < sz; ++i) {
char c = string.charAt(i);
switch (c) {
case ' ':
case '\t':
case '\b':
case '<':
case '>':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
case '!':
case '@':
case '#':
case '*':
case '?':
case '%':
case '|':
case ',':
case ':':
case ';':
case '^':
case '&':
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isTemplatePath",
"(",
"String",
"string",
")",
"{",
"int",
"sz",
"=",
"string",
".",
"length",
"(",
")",
";",
"if",
"(",
"sz",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",... | Check if a given string is a template path or template content
If the string contains anyone the following characters then we assume it
is content, otherwise it is path:
* space characters
* non numeric-alphabetic characters except:
** dot "."
** dollar: "$"
@param string
the string to be tested
@return `true` if the string literal is template content or `false` otherwise | [
"Check",
"if",
"a",
"given",
"string",
"is",
"a",
"template",
"path",
"or",
"template",
"content"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/view/ViewManager.java#L350-L385 | train |
actframework/actframework | src/main/java/act/validation/PasswordSpec.java | PasswordSpec.parse | public static PasswordSpec parse(String spec) {
char[] ca = spec.toCharArray();
int len = ca.length;
illegalIf(0 == len, spec);
Builder builder = new Builder();
StringBuilder minBuf = new StringBuilder();
StringBuilder maxBuf = new StringBuilder();
boolean lenSpecStart = false;
boolean minPart = false;
for (int i = 0; i < len; ++i) {
char c = ca[i];
switch (c) {
case SPEC_LOWERCASE:
illegalIf(lenSpecStart, spec);
builder.requireLowercase();
break;
case SPEC_UPPERCASE:
illegalIf(lenSpecStart, spec);
builder.requireUppercase();
break;
case SPEC_SPECIAL_CHAR:
illegalIf(lenSpecStart, spec);
builder.requireSpecialChar();
break;
case SPEC_LENSPEC_START:
lenSpecStart = true;
minPart = true;
break;
case SPEC_LENSPEC_CLOSE:
illegalIf(minPart, spec);
lenSpecStart = false;
break;
case SPEC_LENSPEC_SEP:
minPart = false;
break;
case SPEC_DIGIT:
if (!lenSpecStart) {
builder.requireDigit();
} else {
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
break;
default:
illegalIf(!lenSpecStart || !isDigit(c), spec);
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
}
illegalIf(lenSpecStart, spec);
if (minBuf.length() != 0) {
builder.minLength(Integer.parseInt(minBuf.toString()));
}
if (maxBuf.length() != 0) {
builder.maxLength(Integer.parseInt(maxBuf.toString()));
}
return builder;
} | java | public static PasswordSpec parse(String spec) {
char[] ca = spec.toCharArray();
int len = ca.length;
illegalIf(0 == len, spec);
Builder builder = new Builder();
StringBuilder minBuf = new StringBuilder();
StringBuilder maxBuf = new StringBuilder();
boolean lenSpecStart = false;
boolean minPart = false;
for (int i = 0; i < len; ++i) {
char c = ca[i];
switch (c) {
case SPEC_LOWERCASE:
illegalIf(lenSpecStart, spec);
builder.requireLowercase();
break;
case SPEC_UPPERCASE:
illegalIf(lenSpecStart, spec);
builder.requireUppercase();
break;
case SPEC_SPECIAL_CHAR:
illegalIf(lenSpecStart, spec);
builder.requireSpecialChar();
break;
case SPEC_LENSPEC_START:
lenSpecStart = true;
minPart = true;
break;
case SPEC_LENSPEC_CLOSE:
illegalIf(minPart, spec);
lenSpecStart = false;
break;
case SPEC_LENSPEC_SEP:
minPart = false;
break;
case SPEC_DIGIT:
if (!lenSpecStart) {
builder.requireDigit();
} else {
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
break;
default:
illegalIf(!lenSpecStart || !isDigit(c), spec);
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
}
illegalIf(lenSpecStart, spec);
if (minBuf.length() != 0) {
builder.minLength(Integer.parseInt(minBuf.toString()));
}
if (maxBuf.length() != 0) {
builder.maxLength(Integer.parseInt(maxBuf.toString()));
}
return builder;
} | [
"public",
"static",
"PasswordSpec",
"parse",
"(",
"String",
"spec",
")",
"{",
"char",
"[",
"]",
"ca",
"=",
"spec",
".",
"toCharArray",
"(",
")",
";",
"int",
"len",
"=",
"ca",
".",
"length",
";",
"illegalIf",
"(",
"0",
"==",
"len",
",",
"spec",
")",... | Parse a string representation of password spec.
A password spec string should be `<trait spec><length spec>`.
Where "trait spec" should be a composition of
* `a` - indicate lowercase letter required
* `A` - indicate uppercase letter required
* `0` - indicate digit letter required
* `#` - indicate special character required
"length spec" should be `[min,max]` where `max` can be omitted.
Here are examples of valid "length spec":
* `[6,20]` // min length: 6, max length: 20
* `[8,]` // min length: 8, max length: unlimited
And examples of invalid "length spec":
* `[8]` // "," required after min part
* `[a,f]` // min and max part needs to be decimal digit(s)
* `[3,9)` // length spec must be started with `[` and end with `]`
@param spec a string representation of password spec
@return a {@link PasswordSpec} instance | [
"Parse",
"a",
"string",
"representation",
"of",
"password",
"spec",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/validation/PasswordSpec.java#L285-L348 | train |
actframework/actframework | src/main/java/act/xio/WebSocketConnectionHandler.java | WebSocketConnectionHandler._onConnect | protected final void _onConnect(WebSocketContext context) {
if (null != connectionListener) {
connectionListener.onConnect(context);
}
connectionListenerManager.notifyFreeListeners(context, false);
Act.eventBus().emit(new WebSocketConnectEvent(context));
} | java | protected final void _onConnect(WebSocketContext context) {
if (null != connectionListener) {
connectionListener.onConnect(context);
}
connectionListenerManager.notifyFreeListeners(context, false);
Act.eventBus().emit(new WebSocketConnectEvent(context));
} | [
"protected",
"final",
"void",
"_onConnect",
"(",
"WebSocketContext",
"context",
")",
"{",
"if",
"(",
"null",
"!=",
"connectionListener",
")",
"{",
"connectionListener",
".",
"onConnect",
"(",
"context",
")",
";",
"}",
"connectionListenerManager",
".",
"notifyFreeL... | Called by implementation class once websocket connection established
at networking layer.
@param context the websocket context | [
"Called",
"by",
"implementation",
"class",
"once",
"websocket",
"connection",
"established",
"at",
"networking",
"layer",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/xio/WebSocketConnectionHandler.java#L186-L192 | train |
actframework/actframework | src/main/java/act/util/IdGenerator.java | IdGenerator.genId | public String genId() {
S.Buffer sb = S.newBuffer();
sb.a(longEncoder.longToStr(nodeIdProvider.nodeId()))
.a(longEncoder.longToStr(startIdProvider.startId()))
.a(longEncoder.longToStr(sequenceProvider.seqId()));
return sb.toString();
} | java | public String genId() {
S.Buffer sb = S.newBuffer();
sb.a(longEncoder.longToStr(nodeIdProvider.nodeId()))
.a(longEncoder.longToStr(startIdProvider.startId()))
.a(longEncoder.longToStr(sequenceProvider.seqId()));
return sb.toString();
} | [
"public",
"String",
"genId",
"(",
")",
"{",
"S",
".",
"Buffer",
"sb",
"=",
"S",
".",
"newBuffer",
"(",
")",
";",
"sb",
".",
"a",
"(",
"longEncoder",
".",
"longToStr",
"(",
"nodeIdProvider",
".",
"nodeId",
"(",
")",
")",
")",
".",
"a",
"(",
"longE... | Generate a unique ID across the cluster
@return generated ID | [
"Generate",
"a",
"unique",
"ID",
"across",
"the",
"cluster"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/IdGenerator.java#L388-L394 | train |
actframework/actframework | src/main/java/act/app/AppServiceRegistry.java | AppServiceRegistry.bulkRegisterSingleton | synchronized void bulkRegisterSingleton() {
for (Map.Entry<Class<? extends AppService>, AppService> entry : registry.entrySet()) {
if (isSingletonService(entry.getKey())) {
app.registerSingleton(entry.getKey(), entry.getValue());
}
}
} | java | synchronized void bulkRegisterSingleton() {
for (Map.Entry<Class<? extends AppService>, AppService> entry : registry.entrySet()) {
if (isSingletonService(entry.getKey())) {
app.registerSingleton(entry.getKey(), entry.getValue());
}
}
} | [
"synchronized",
"void",
"bulkRegisterSingleton",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Class",
"<",
"?",
"extends",
"AppService",
">",
",",
"AppService",
">",
"entry",
":",
"registry",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"is... | Called when app's singleton registry has been initialized | [
"Called",
"when",
"app",
"s",
"singleton",
"registry",
"has",
"been",
"initialized"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/AppServiceRegistry.java#L74-L80 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.paramKeys | @Override
public Set<String> paramKeys() {
Set<String> set = new HashSet<String>();
set.addAll(C.<String>list(request.paramNames()));
set.addAll(extraParams.keySet());
set.addAll(bodyParams().keySet());
set.remove("_method");
set.remove("_body");
return set;
} | java | @Override
public Set<String> paramKeys() {
Set<String> set = new HashSet<String>();
set.addAll(C.<String>list(request.paramNames()));
set.addAll(extraParams.keySet());
set.addAll(bodyParams().keySet());
set.remove("_method");
set.remove("_body");
return set;
} | [
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"paramKeys",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"set",
".",
"addAll",
"(",
"C",
".",
"<",
"String",
">",
"list",
"(",
... | Get all parameter keys.
@return a set of parameter keys | [
"Get",
"all",
"parameter",
"keys",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L739-L748 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.applyContentType | public ActionContext applyContentType(Result result) {
if (!result.status().isError()) {
return applyContentType();
}
return applyContentType(contentTypeForErrorResult(req()));
} | java | public ActionContext applyContentType(Result result) {
if (!result.status().isError()) {
return applyContentType();
}
return applyContentType(contentTypeForErrorResult(req()));
} | [
"public",
"ActionContext",
"applyContentType",
"(",
"Result",
"result",
")",
"{",
"if",
"(",
"!",
"result",
".",
"status",
"(",
")",
".",
"isError",
"(",
")",
")",
"{",
"return",
"applyContentType",
"(",
")",
";",
"}",
"return",
"applyContentType",
"(",
... | Apply content type to response with result provided.
If `result` is an error then it might not apply content type as requested:
* If request is not ajax request, then use `text/html`
* If request is ajax request then apply requested content type only when `json` or `xml` is requested
* otherwise use `text/html`
@param result
the result used to check if it is error result
@return this `ActionContext`. | [
"Apply",
"content",
"type",
"to",
"response",
"with",
"result",
"provided",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L935-L940 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.cached | public <T> T cached(String key) {
H.Session sess = session();
if (null != sess) {
return sess.cached(key);
} else {
return app().cache().get(key);
}
} | java | public <T> T cached(String key) {
H.Session sess = session();
if (null != sess) {
return sess.cached(key);
} else {
return app().cache().get(key);
}
} | [
"public",
"<",
"T",
">",
"T",
"cached",
"(",
"String",
"key",
")",
"{",
"H",
".",
"Session",
"sess",
"=",
"session",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"sess",
")",
"{",
"return",
"sess",
".",
"cached",
"(",
"key",
")",
";",
"}",
"else",
... | Return cached object by key. The key will be concatenated with
current session id when fetching the cached object
@param key
@param <T>
the object type
@return the cached object | [
"Return",
"cached",
"object",
"by",
"key",
".",
"The",
"key",
"will",
"be",
"concatenated",
"with",
"current",
"session",
"id",
"when",
"fetching",
"the",
"cached",
"object"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1089-L1096 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.cache | public void cache(String key, Object obj) {
H.Session sess = session();
if (null != sess) {
sess.cache(key, obj);
} else {
app().cache().put(key, obj);
}
} | java | public void cache(String key, Object obj) {
H.Session sess = session();
if (null != sess) {
sess.cache(key, obj);
} else {
app().cache().put(key, obj);
}
} | [
"public",
"void",
"cache",
"(",
"String",
"key",
",",
"Object",
"obj",
")",
"{",
"H",
".",
"Session",
"sess",
"=",
"session",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"sess",
")",
"{",
"sess",
".",
"cache",
"(",
"key",
",",
"obj",
")",
";",
"}",... | Add an object into cache by key. The key will be used in conjunction with session id if
there is a session instance
@param key
the key to index the object within the cache
@param obj
the object to be cached | [
"Add",
"an",
"object",
"into",
"cache",
"by",
"key",
".",
"The",
"key",
"will",
"be",
"used",
"in",
"conjunction",
"with",
"session",
"id",
"if",
"there",
"is",
"a",
"session",
"instance"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1107-L1114 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.cache | public void cache(String key, Object obj, int expiration) {
H.Session session = this.session;
if (null != session) {
session.cache(key, obj, expiration);
} else {
app().cache().put(key, obj, expiration);
}
} | java | public void cache(String key, Object obj, int expiration) {
H.Session session = this.session;
if (null != session) {
session.cache(key, obj, expiration);
} else {
app().cache().put(key, obj, expiration);
}
} | [
"public",
"void",
"cache",
"(",
"String",
"key",
",",
"Object",
"obj",
",",
"int",
"expiration",
")",
"{",
"H",
".",
"Session",
"session",
"=",
"this",
".",
"session",
";",
"if",
"(",
"null",
"!=",
"session",
")",
"{",
"session",
".",
"cache",
"(",
... | Add an object into cache by key with expiration time specified
@param key
the key to index the object within the cache
@param obj
the object to be cached
@param expiration
the seconds after which the object will be evicted from the cache | [
"Add",
"an",
"object",
"into",
"cache",
"by",
"key",
"with",
"expiration",
"time",
"specified"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1126-L1133 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.evictCache | public void evictCache(String key) {
H.Session sess = session();
if (null != sess) {
sess.evict(key);
} else {
app().cache().evict(key);
}
} | java | public void evictCache(String key) {
H.Session sess = session();
if (null != sess) {
sess.evict(key);
} else {
app().cache().evict(key);
}
} | [
"public",
"void",
"evictCache",
"(",
"String",
"key",
")",
"{",
"H",
".",
"Session",
"sess",
"=",
"session",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"sess",
")",
"{",
"sess",
".",
"evict",
"(",
"key",
")",
";",
"}",
"else",
"{",
"app",
"(",
")"... | Evict cached object
@param key
the key indexed the cached object to be evicted | [
"Evict",
"cached",
"object"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1189-L1196 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.login | public void login(Object userIdentifier) {
session().put(config().sessionKeyUsername(), userIdentifier);
app().eventBus().trigger(new LoginEvent(userIdentifier.toString()));
} | java | public void login(Object userIdentifier) {
session().put(config().sessionKeyUsername(), userIdentifier);
app().eventBus().trigger(new LoginEvent(userIdentifier.toString()));
} | [
"public",
"void",
"login",
"(",
"Object",
"userIdentifier",
")",
"{",
"session",
"(",
")",
".",
"put",
"(",
"config",
"(",
")",
".",
"sessionKeyUsername",
"(",
")",
",",
"userIdentifier",
")",
";",
"app",
"(",
")",
".",
"eventBus",
"(",
")",
".",
"tr... | Update the context session to mark a user logged in
@param userIdentifier
the user identifier, could be either userId or username | [
"Update",
"the",
"context",
"session",
"to",
"mark",
"a",
"user",
"logged",
"in"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1268-L1271 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.loginAndRedirectBack | public void loginAndRedirectBack(Object userIdentifier, String defaultLandingUrl) {
login(userIdentifier);
RedirectToLoginUrl.redirectToOriginalUrl(this, defaultLandingUrl);
} | java | public void loginAndRedirectBack(Object userIdentifier, String defaultLandingUrl) {
login(userIdentifier);
RedirectToLoginUrl.redirectToOriginalUrl(this, defaultLandingUrl);
} | [
"public",
"void",
"loginAndRedirectBack",
"(",
"Object",
"userIdentifier",
",",
"String",
"defaultLandingUrl",
")",
"{",
"login",
"(",
"userIdentifier",
")",
";",
"RedirectToLoginUrl",
".",
"redirectToOriginalUrl",
"(",
"this",
",",
"defaultLandingUrl",
")",
";",
"}... | Login the user and redirect back to original URL. If no
original URL found then redirect to `defaultLandingUrl`.
@param userIdentifier
the user identifier, could be either userId or username
@param defaultLandingUrl
the URL to be redirected if original URL not found | [
"Login",
"the",
"user",
"and",
"redirect",
"back",
"to",
"original",
"URL",
".",
"If",
"no",
"original",
"URL",
"found",
"then",
"redirect",
"to",
"defaultLandingUrl",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1293-L1296 | train |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.logout | public void logout() {
String userIdentifier = session.get(config().sessionKeyUsername());
SessionManager sessionManager = app().sessionManager();
sessionManager.logout(session);
if (S.notBlank(userIdentifier)) {
app().eventBus().trigger(new LogoutEvent(userIdentifier));
}
} | java | public void logout() {
String userIdentifier = session.get(config().sessionKeyUsername());
SessionManager sessionManager = app().sessionManager();
sessionManager.logout(session);
if (S.notBlank(userIdentifier)) {
app().eventBus().trigger(new LogoutEvent(userIdentifier));
}
} | [
"public",
"void",
"logout",
"(",
")",
"{",
"String",
"userIdentifier",
"=",
"session",
".",
"get",
"(",
"config",
"(",
")",
".",
"sessionKeyUsername",
"(",
")",
")",
";",
"SessionManager",
"sessionManager",
"=",
"app",
"(",
")",
".",
"sessionManager",
"(",... | Logout the current session. After calling this method,
the session will be cleared | [
"Logout",
"the",
"current",
"session",
".",
"After",
"calling",
"this",
"method",
"the",
"session",
"will",
"be",
"cleared"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1315-L1322 | train |
actframework/actframework | src/main/java/act/job/JobContext.java | JobContext.init | public static void init(String jobId) {
JobContext parent = current_.get();
JobContext ctx = new JobContext(parent);
current_.set(ctx);
// don't call setJobId(String)
// as it will trigger listeners -- TODO fix me
ctx.jobId = jobId;
if (null == parent) {
Act.eventBus().trigger(new JobContextInitialized(ctx));
}
} | java | public static void init(String jobId) {
JobContext parent = current_.get();
JobContext ctx = new JobContext(parent);
current_.set(ctx);
// don't call setJobId(String)
// as it will trigger listeners -- TODO fix me
ctx.jobId = jobId;
if (null == parent) {
Act.eventBus().trigger(new JobContextInitialized(ctx));
}
} | [
"public",
"static",
"void",
"init",
"(",
"String",
"jobId",
")",
"{",
"JobContext",
"parent",
"=",
"current_",
".",
"get",
"(",
")",
";",
"JobContext",
"ctx",
"=",
"new",
"JobContext",
"(",
"parent",
")",
";",
"current_",
".",
"set",
"(",
"ctx",
")",
... | make it public for CLI interaction to reuse JobContext | [
"make",
"it",
"public",
"for",
"CLI",
"interaction",
"to",
"reuse",
"JobContext"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/job/JobContext.java#L120-L130 | train |
actframework/actframework | src/main/java/act/job/JobContext.java | JobContext.clear | public static void clear() {
JobContext ctx = current_.get();
if (null != ctx) {
ctx.bag_.clear();
JobContext parent = ctx.parent;
if (null != parent) {
current_.set(parent);
ctx.parent = null;
} else {
current_.remove();
Act.eventBus().trigger(new JobContextDestroyed(ctx));
}
}
} | java | public static void clear() {
JobContext ctx = current_.get();
if (null != ctx) {
ctx.bag_.clear();
JobContext parent = ctx.parent;
if (null != parent) {
current_.set(parent);
ctx.parent = null;
} else {
current_.remove();
Act.eventBus().trigger(new JobContextDestroyed(ctx));
}
}
} | [
"public",
"static",
"void",
"clear",
"(",
")",
"{",
"JobContext",
"ctx",
"=",
"current_",
".",
"get",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"ctx",
")",
"{",
"ctx",
".",
"bag_",
".",
"clear",
"(",
")",
";",
"JobContext",
"parent",
"=",
"ctx",
".... | Clear JobContext of current thread | [
"Clear",
"JobContext",
"of",
"current",
"thread"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/job/JobContext.java#L135-L148 | train |
actframework/actframework | src/main/java/act/job/JobContext.java | JobContext.get | public static <T> T get(String key, Class<T> clz) {
return (T)m().get(key);
} | java | public static <T> T get(String key, Class<T> clz) {
return (T)m().get(key);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"String",
"key",
",",
"Class",
"<",
"T",
">",
"clz",
")",
"{",
"return",
"(",
"T",
")",
"m",
"(",
")",
".",
"get",
"(",
"key",
")",
";",
"}"
] | Generic version of getting value by key from the JobContext of current thread
@param key the key
@param clz the val class
@param <T> the val type
@return the value | [
"Generic",
"version",
"of",
"getting",
"value",
"by",
"key",
"from",
"the",
"JobContext",
"of",
"current",
"thread"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/job/JobContext.java#L167-L169 | train |
actframework/actframework | src/main/java/act/job/JobContext.java | JobContext.copy | static JobContext copy() {
JobContext current = current_.get();
//JobContext ctxt = new JobContext(keepParent ? current : null);
JobContext ctxt = new JobContext(null);
if (null != current) {
ctxt.bag_.putAll(current.bag_);
}
return ctxt;
} | java | static JobContext copy() {
JobContext current = current_.get();
//JobContext ctxt = new JobContext(keepParent ? current : null);
JobContext ctxt = new JobContext(null);
if (null != current) {
ctxt.bag_.putAll(current.bag_);
}
return ctxt;
} | [
"static",
"JobContext",
"copy",
"(",
")",
"{",
"JobContext",
"current",
"=",
"current_",
".",
"get",
"(",
")",
";",
"//JobContext ctxt = new JobContext(keepParent ? current : null);",
"JobContext",
"ctxt",
"=",
"new",
"JobContext",
"(",
"null",
")",
";",
"if",
"("... | Make a copy of JobContext of current thread
@return the copy of current job context or an empty job context | [
"Make",
"a",
"copy",
"of",
"JobContext",
"of",
"current",
"thread"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/job/JobContext.java#L192-L200 | train |
actframework/actframework | src/main/java/act/job/JobContext.java | JobContext.loadFromOrigin | static void loadFromOrigin(JobContext origin) {
if (origin.bag_.isEmpty()) {
return;
}
ActContext<?> actContext = ActContext.Base.currentContext();
if (null != actContext) {
Locale locale = (Locale) origin.bag_.get("locale");
if (null != locale) {
actContext.locale(locale);
}
H.Session session = (H.Session) origin.bag_.get("session");
if (null != session) {
actContext.attribute("__session", session);
}
}
} | java | static void loadFromOrigin(JobContext origin) {
if (origin.bag_.isEmpty()) {
return;
}
ActContext<?> actContext = ActContext.Base.currentContext();
if (null != actContext) {
Locale locale = (Locale) origin.bag_.get("locale");
if (null != locale) {
actContext.locale(locale);
}
H.Session session = (H.Session) origin.bag_.get("session");
if (null != session) {
actContext.attribute("__session", session);
}
}
} | [
"static",
"void",
"loadFromOrigin",
"(",
"JobContext",
"origin",
")",
"{",
"if",
"(",
"origin",
".",
"bag_",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"ActContext",
"<",
"?",
">",
"actContext",
"=",
"ActContext",
".",
"Base",
".",
"curren... | Initialize current thread's JobContext using specified copy
@param origin the original job context | [
"Initialize",
"current",
"thread",
"s",
"JobContext",
"using",
"specified",
"copy"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/job/JobContext.java#L206-L221 | train |
actframework/actframework | src/main/java/act/controller/captcha/CaptchaSession.java | CaptchaSession.getToken | public String getToken() {
String id = null == answer ? text : answer;
return Act.app().crypto().generateToken(id);
} | java | public String getToken() {
String id = null == answer ? text : answer;
return Act.app().crypto().generateToken(id);
} | [
"public",
"String",
"getToken",
"(",
")",
"{",
"String",
"id",
"=",
"null",
"==",
"answer",
"?",
"text",
":",
"answer",
";",
"return",
"Act",
".",
"app",
"(",
")",
".",
"crypto",
"(",
")",
".",
"generateToken",
"(",
"id",
")",
";",
"}"
] | Returns an encrypted token combined with answer. | [
"Returns",
"an",
"encrypted",
"token",
"combined",
"with",
"answer",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/controller/captcha/CaptchaSession.java#L77-L80 | train |
actframework/actframework | src/main/java/act/app/RouterRegexMacroLookup.java | RouterRegexMacroLookup.expand | public String expand(String macro) {
if (!isMacro(macro)) {
return macro;
}
String definition = macros.get(Config.canonical(macro));
if (null == definition) {
warn("possible missing definition of macro[%s]", macro);
}
return null == definition ? macro : definition;
} | java | public String expand(String macro) {
if (!isMacro(macro)) {
return macro;
}
String definition = macros.get(Config.canonical(macro));
if (null == definition) {
warn("possible missing definition of macro[%s]", macro);
}
return null == definition ? macro : definition;
} | [
"public",
"String",
"expand",
"(",
"String",
"macro",
")",
"{",
"if",
"(",
"!",
"isMacro",
"(",
"macro",
")",
")",
"{",
"return",
"macro",
";",
"}",
"String",
"definition",
"=",
"macros",
".",
"get",
"(",
"Config",
".",
"canonical",
"(",
"macro",
")"... | Expand a macro.
This will look up the macro definition from {@link #macros} map.
If not found then return passed in `macro` itself, otherwise return
the macro definition found.
**note** if macro definition is not found and the string
{@link #isMacro(String) comply to macro name convention}, then a
warn level message will be logged.
@param macro the macro name
@return macro definition or macro itself if no definition found. | [
"Expand",
"a",
"macro",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/RouterRegexMacroLookup.java#L106-L115 | train |
actframework/actframework | src/main/java/act/internal/util/JavaNames.java | JavaNames.isPackageOrClassName | public static boolean isPackageOrClassName(String s) {
if (S.blank(s)) {
return false;
}
S.List parts = S.fastSplit(s, ".");
if (parts.size() < 2) {
return false;
}
for (String part: parts) {
if (!Character.isJavaIdentifierStart(part.charAt(0))) {
return false;
}
for (int i = 1, len = part.length(); i < len; ++i) {
if (!Character.isJavaIdentifierPart(part.charAt(i))) {
return false;
}
}
}
return true;
} | java | public static boolean isPackageOrClassName(String s) {
if (S.blank(s)) {
return false;
}
S.List parts = S.fastSplit(s, ".");
if (parts.size() < 2) {
return false;
}
for (String part: parts) {
if (!Character.isJavaIdentifierStart(part.charAt(0))) {
return false;
}
for (int i = 1, len = part.length(); i < len; ++i) {
if (!Character.isJavaIdentifierPart(part.charAt(i))) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"isPackageOrClassName",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"S",
".",
"blank",
"(",
"s",
")",
")",
"{",
"return",
"false",
";",
"}",
"S",
".",
"List",
"parts",
"=",
"S",
".",
"fastSplit",
"(",
"s",
",",
"\".\"",
... | Check if a given string is a valid java package or class name.
This method use the technique documented in
[this SO question](https://stackoverflow.com/questions/13557195/how-to-check-if-string-is-a-valid-class-identifier)
with the following extensions:
* if the string does not contain `.` then assume it is not a valid package or class name
@param s
the string to be checked
@return
`true` if `s` is a valid java package or class name | [
"Check",
"if",
"a",
"given",
"string",
"is",
"a",
"valid",
"java",
"package",
"or",
"class",
"name",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/internal/util/JavaNames.java#L45-L64 | train |
actframework/actframework | src/main/java/act/internal/util/JavaNames.java | JavaNames.packageNameOf | public static String packageNameOf(Class<?> clazz) {
String name = clazz.getName();
int pos = name.lastIndexOf('.');
E.unexpectedIf(pos < 0, "Class does not have package: " + name);
return name.substring(0, pos);
} | java | public static String packageNameOf(Class<?> clazz) {
String name = clazz.getName();
int pos = name.lastIndexOf('.');
E.unexpectedIf(pos < 0, "Class does not have package: " + name);
return name.substring(0, pos);
} | [
"public",
"static",
"String",
"packageNameOf",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"String",
"name",
"=",
"clazz",
".",
"getName",
"(",
")",
";",
"int",
"pos",
"=",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"E",
".",
"unexpec... | Returns package name of a class
@param clazz
the class
@return
the package name of the class | [
"Returns",
"package",
"name",
"of",
"a",
"class"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/internal/util/JavaNames.java#L74-L79 | train |
actframework/actframework | src/main/java/act/route/RouteInfo.java | RouteInfo.of | public static RouteInfo of(ActionContext context) {
H.Method m = context.req().method();
String path = context.req().url();
RequestHandler handler = context.handler();
if (null == handler) {
handler = UNKNOWN_HANDLER;
}
return new RouteInfo(m, path, handler);
} | java | public static RouteInfo of(ActionContext context) {
H.Method m = context.req().method();
String path = context.req().url();
RequestHandler handler = context.handler();
if (null == handler) {
handler = UNKNOWN_HANDLER;
}
return new RouteInfo(m, path, handler);
} | [
"public",
"static",
"RouteInfo",
"of",
"(",
"ActionContext",
"context",
")",
"{",
"H",
".",
"Method",
"m",
"=",
"context",
".",
"req",
"(",
")",
".",
"method",
"(",
")",
";",
"String",
"path",
"=",
"context",
".",
"req",
"(",
")",
".",
"url",
"(",
... | used by Error template | [
"used",
"by",
"Error",
"template"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/route/RouteInfo.java#L90-L98 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.get | public List<WebSocketConnection> get(String key) {
final List<WebSocketConnection> retList = new ArrayList<>();
accept(key, C.F.addTo(retList));
return retList;
} | java | public List<WebSocketConnection> get(String key) {
final List<WebSocketConnection> retList = new ArrayList<>();
accept(key, C.F.addTo(retList));
return retList;
} | [
"public",
"List",
"<",
"WebSocketConnection",
">",
"get",
"(",
"String",
"key",
")",
"{",
"final",
"List",
"<",
"WebSocketConnection",
">",
"retList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"accept",
"(",
"key",
",",
"C",
".",
"F",
".",
"addTo",... | Return a list of websocket connection by key
@param key
the key to find the websocket connection list
@return a list of websocket connection or an empty list if no websocket connection found by key | [
"Return",
"a",
"list",
"of",
"websocket",
"connection",
"by",
"key"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L50-L54 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.signIn | public void signIn(String key, WebSocketConnection connection) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.put(connection, connection);
} | java | public void signIn(String key, WebSocketConnection connection) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.put(connection, connection);
} | [
"public",
"void",
"signIn",
"(",
"String",
"key",
",",
"WebSocketConnection",
"connection",
")",
"{",
"ConcurrentMap",
"<",
"WebSocketConnection",
",",
"WebSocketConnection",
">",
"bag",
"=",
"ensureConnectionList",
"(",
"key",
")",
";",
"bag",
".",
"put",
"(",
... | Sign in a connection to the registry by key.
Note multiple connections can be attached to the same key
@param key
the key
@param connection
the websocket connection
@see #register(String, WebSocketConnection) | [
"Sign",
"in",
"a",
"connection",
"to",
"the",
"registry",
"by",
"key",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L131-L134 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.signIn | public void signIn(String key, Collection<WebSocketConnection> connections) {
if (connections.isEmpty()) {
return;
}
Map<WebSocketConnection, WebSocketConnection> newMap = new HashMap<>();
for (WebSocketConnection conn : connections) {
newMap.put(conn, conn);
}
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.putAll(newMap);
} | java | public void signIn(String key, Collection<WebSocketConnection> connections) {
if (connections.isEmpty()) {
return;
}
Map<WebSocketConnection, WebSocketConnection> newMap = new HashMap<>();
for (WebSocketConnection conn : connections) {
newMap.put(conn, conn);
}
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.putAll(newMap);
} | [
"public",
"void",
"signIn",
"(",
"String",
"key",
",",
"Collection",
"<",
"WebSocketConnection",
">",
"connections",
")",
"{",
"if",
"(",
"connections",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"Map",
"<",
"WebSocketConnection",
",",
"WebSoc... | Sign in a group of connections to the registry by key
@param key
the key
@param connections
a collection of websocket connections | [
"Sign",
"in",
"a",
"group",
"of",
"connections",
"to",
"the",
"registry",
"by",
"key"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L156-L166 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.signOff | public void signOff(String key, WebSocketConnection connection) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> connections = registry.get(key);
if (null == connections) {
return;
}
connections.remove(connection);
} | java | public void signOff(String key, WebSocketConnection connection) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> connections = registry.get(key);
if (null == connections) {
return;
}
connections.remove(connection);
} | [
"public",
"void",
"signOff",
"(",
"String",
"key",
",",
"WebSocketConnection",
"connection",
")",
"{",
"ConcurrentMap",
"<",
"WebSocketConnection",
",",
"WebSocketConnection",
">",
"connections",
"=",
"registry",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"n... | Detach a connection from a key.
@param key
the key
@param connection
the connection | [
"Detach",
"a",
"connection",
"from",
"a",
"key",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L203-L209 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.signOff | public void signOff(WebSocketConnection connection) {
for (ConcurrentMap<WebSocketConnection, WebSocketConnection> connections : registry.values()) {
connections.remove(connection);
}
} | java | public void signOff(WebSocketConnection connection) {
for (ConcurrentMap<WebSocketConnection, WebSocketConnection> connections : registry.values()) {
connections.remove(connection);
}
} | [
"public",
"void",
"signOff",
"(",
"WebSocketConnection",
"connection",
")",
"{",
"for",
"(",
"ConcurrentMap",
"<",
"WebSocketConnection",
",",
"WebSocketConnection",
">",
"connections",
":",
"registry",
".",
"values",
"(",
")",
")",
"{",
"connections",
".",
"rem... | Remove a connection from all keys.
@param connection
the connection | [
"Remove",
"a",
"connection",
"from",
"all",
"keys",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L229-L233 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.signOff | public void signOff(String key, Collection<WebSocketConnection> connections) {
if (connections.isEmpty()) {
return;
}
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.keySet().removeAll(connections);
} | java | public void signOff(String key, Collection<WebSocketConnection> connections) {
if (connections.isEmpty()) {
return;
}
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.keySet().removeAll(connections);
} | [
"public",
"void",
"signOff",
"(",
"String",
"key",
",",
"Collection",
"<",
"WebSocketConnection",
">",
"connections",
")",
"{",
"if",
"(",
"connections",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"ConcurrentMap",
"<",
"WebSocketConnection",
","... | Sign off a group of connections from the registry by key
@param key
the key
@param connections
a collection of websocket connections | [
"Sign",
"off",
"a",
"group",
"of",
"connections",
"from",
"the",
"registry",
"by",
"key"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L243-L249 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.count | public int count() {
int n = 0;
for (ConcurrentMap<?, ?> bag : registry.values()) {
n += bag.size();
}
return n;
} | java | public int count() {
int n = 0;
for (ConcurrentMap<?, ?> bag : registry.values()) {
n += bag.size();
}
return n;
} | [
"public",
"int",
"count",
"(",
")",
"{",
"int",
"n",
"=",
"0",
";",
"for",
"(",
"ConcurrentMap",
"<",
"?",
",",
"?",
">",
"bag",
":",
"registry",
".",
"values",
"(",
")",
")",
"{",
"n",
"+=",
"bag",
".",
"size",
"(",
")",
";",
"}",
"return",
... | Returns the connection count in this registry.
Note it might count connections that are closed but not removed from registry yet
@return the connection count | [
"Returns",
"the",
"connection",
"count",
"in",
"this",
"registry",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L259-L265 | train |
actframework/actframework | src/main/java/act/ws/WebSocketConnectionRegistry.java | WebSocketConnectionRegistry.count | public int count(String key) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = registry.get(key);
return null == bag ? 0 : bag.size();
} | java | public int count(String key) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = registry.get(key);
return null == bag ? 0 : bag.size();
} | [
"public",
"int",
"count",
"(",
"String",
"key",
")",
"{",
"ConcurrentMap",
"<",
"WebSocketConnection",
",",
"WebSocketConnection",
">",
"bag",
"=",
"registry",
".",
"get",
"(",
"key",
")",
";",
"return",
"null",
"==",
"bag",
"?",
"0",
":",
"bag",
".",
... | Returns the connection count by key specified in this registry
Note it might count connections that are closed but not removed from registry yet
@param key
the key
@return connection count by key | [
"Returns",
"the",
"connection",
"count",
"by",
"key",
"specified",
"in",
"this",
"registry"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L276-L279 | train |
actframework/actframework | src/main/java/act/util/ReflectedInvokerHelper.java | ReflectedInvokerHelper.tryGetSingleton | public static Object tryGetSingleton(Class<?> invokerClass, App app) {
Object singleton = app.singleton(invokerClass);
if (null == singleton) {
if (isGlobalOrStateless(invokerClass, new HashSet<Class>())) {
singleton = app.getInstance(invokerClass);
}
}
if (null != singleton) {
app.registerSingleton(singleton);
}
return singleton;
} | java | public static Object tryGetSingleton(Class<?> invokerClass, App app) {
Object singleton = app.singleton(invokerClass);
if (null == singleton) {
if (isGlobalOrStateless(invokerClass, new HashSet<Class>())) {
singleton = app.getInstance(invokerClass);
}
}
if (null != singleton) {
app.registerSingleton(singleton);
}
return singleton;
} | [
"public",
"static",
"Object",
"tryGetSingleton",
"(",
"Class",
"<",
"?",
">",
"invokerClass",
",",
"App",
"app",
")",
"{",
"Object",
"singleton",
"=",
"app",
".",
"singleton",
"(",
"invokerClass",
")",
";",
"if",
"(",
"null",
"==",
"singleton",
")",
"{",... | If the `invokerClass` specified is singleton, or without field or all fields are
stateless, then return an instance of the invoker class. Otherwise, return null
@param invokerClass the invoker class
@param app the app
@return an instance of the invokerClass or `null` if invoker class is stateful class | [
"If",
"the",
"invokerClass",
"specified",
"is",
"singleton",
"or",
"without",
"field",
"or",
"all",
"fields",
"are",
"stateless",
"then",
"return",
"an",
"instance",
"of",
"the",
"invoker",
"class",
".",
"Otherwise",
"return",
"null"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/ReflectedInvokerHelper.java#L56-L67 | train |
actframework/actframework | src/main/java/act/util/JsonUtilConfig.java | JsonUtilConfig.writeJson | private static final void writeJson(Writer os, //
Object object, //
SerializeConfig config, //
SerializeFilter[] filters, //
DateFormat dateFormat, //
int defaultFeatures, //
SerializerFeature... features) {
SerializeWriter writer = new SerializeWriter(os, defaultFeatures, features);
try {
JSONSerializer serializer = new JSONSerializer(writer, config);
if (dateFormat != null) {
serializer.setDateFormat(dateFormat);
serializer.config(SerializerFeature.WriteDateUseDateFormat, true);
}
if (filters != null) {
for (SerializeFilter filter : filters) {
serializer.addFilter(filter);
}
}
serializer.write(object);
} finally {
writer.close();
}
} | java | private static final void writeJson(Writer os, //
Object object, //
SerializeConfig config, //
SerializeFilter[] filters, //
DateFormat dateFormat, //
int defaultFeatures, //
SerializerFeature... features) {
SerializeWriter writer = new SerializeWriter(os, defaultFeatures, features);
try {
JSONSerializer serializer = new JSONSerializer(writer, config);
if (dateFormat != null) {
serializer.setDateFormat(dateFormat);
serializer.config(SerializerFeature.WriteDateUseDateFormat, true);
}
if (filters != null) {
for (SerializeFilter filter : filters) {
serializer.addFilter(filter);
}
}
serializer.write(object);
} finally {
writer.close();
}
} | [
"private",
"static",
"final",
"void",
"writeJson",
"(",
"Writer",
"os",
",",
"//",
"Object",
"object",
",",
"//",
"SerializeConfig",
"config",
",",
"//",
"SerializeFilter",
"[",
"]",
"filters",
",",
"//",
"DateFormat",
"dateFormat",
",",
"//",
"int",
"defaul... | FastJSON does not provide the API so we have to create our own | [
"FastJSON",
"does",
"not",
"provide",
"the",
"API",
"so",
"we",
"have",
"to",
"create",
"our",
"own"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/JsonUtilConfig.java#L235-L261 | train |
actframework/actframework | src/main/java/act/db/DbService.java | DbService.entityClasses | public Set<Class> entityClasses() {
EntityMetaInfoRepo repo = app().entityMetaInfoRepo().forDb(id);
return null == repo ? C.<Class>set() : repo.entityClasses();
} | java | public Set<Class> entityClasses() {
EntityMetaInfoRepo repo = app().entityMetaInfoRepo().forDb(id);
return null == repo ? C.<Class>set() : repo.entityClasses();
} | [
"public",
"Set",
"<",
"Class",
">",
"entityClasses",
"(",
")",
"{",
"EntityMetaInfoRepo",
"repo",
"=",
"app",
"(",
")",
".",
"entityMetaInfoRepo",
"(",
")",
".",
"forDb",
"(",
"id",
")",
";",
"return",
"null",
"==",
"repo",
"?",
"C",
".",
"<",
"Class... | Returns all model classes registered on this datasource
@return model classes talk to this datasource | [
"Returns",
"all",
"model",
"classes",
"registered",
"on",
"this",
"datasource"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/db/DbService.java#L71-L74 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.messageReceived | public WebSocketContext messageReceived(String receivedMessage) {
this.stringMessage = S.string(receivedMessage).trim();
isJson = stringMessage.startsWith("{") || stringMessage.startsWith("]");
tryParseQueryParams();
return this;
} | java | public WebSocketContext messageReceived(String receivedMessage) {
this.stringMessage = S.string(receivedMessage).trim();
isJson = stringMessage.startsWith("{") || stringMessage.startsWith("]");
tryParseQueryParams();
return this;
} | [
"public",
"WebSocketContext",
"messageReceived",
"(",
"String",
"receivedMessage",
")",
"{",
"this",
".",
"stringMessage",
"=",
"S",
".",
"string",
"(",
"receivedMessage",
")",
".",
"trim",
"(",
")",
";",
"isJson",
"=",
"stringMessage",
".",
"startsWith",
"(",... | Called when remote end send a message to this connection
@param receivedMessage the message received
@return this context | [
"Called",
"when",
"remote",
"end",
"send",
"a",
"message",
"to",
"this",
"connection"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L98-L103 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.reTag | public WebSocketContext reTag(String label) {
WebSocketConnectionRegistry registry = manager.tagRegistry();
registry.signOff(connection);
registry.signIn(label, connection);
return this;
} | java | public WebSocketContext reTag(String label) {
WebSocketConnectionRegistry registry = manager.tagRegistry();
registry.signOff(connection);
registry.signIn(label, connection);
return this;
} | [
"public",
"WebSocketContext",
"reTag",
"(",
"String",
"label",
")",
"{",
"WebSocketConnectionRegistry",
"registry",
"=",
"manager",
".",
"tagRegistry",
"(",
")",
";",
"registry",
".",
"signOff",
"(",
"connection",
")",
";",
"registry",
".",
"signIn",
"(",
"lab... | Re-Tag the websocket connection hold by this context with label specified.
This method will remove all previous tags on the websocket connection and then
tag it with the new label.
@param label the label.
@return this websocket conext. | [
"Re",
"-",
"Tag",
"the",
"websocket",
"connection",
"hold",
"by",
"this",
"context",
"with",
"label",
"specified",
".",
"This",
"method",
"will",
"remove",
"all",
"previous",
"tags",
"on",
"the",
"websocket",
"connection",
"and",
"then",
"tag",
"it",
"with",... | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L122-L127 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToPeers | public WebSocketContext sendToPeers(String message, boolean excludeSelf) {
return sendToConnections(message, url, manager.urlRegistry(), excludeSelf);
} | java | public WebSocketContext sendToPeers(String message, boolean excludeSelf) {
return sendToConnections(message, url, manager.urlRegistry(), excludeSelf);
} | [
"public",
"WebSocketContext",
"sendToPeers",
"(",
"String",
"message",
",",
"boolean",
"excludeSelf",
")",
"{",
"return",
"sendToConnections",
"(",
"message",
",",
"url",
",",
"manager",
".",
"urlRegistry",
"(",
")",
",",
"excludeSelf",
")",
";",
"}"
] | Send message to all connections connected to the same URL of this context
@param message the message to be sent
@param excludeSelf whether the connection of this context should be sent to
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"connected",
"to",
"the",
"same",
"URL",
"of",
"this",
"context"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L185-L187 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToTagged | public WebSocketContext sendToTagged(String message, String tag) {
return sendToTagged(message, tag, false);
} | java | public WebSocketContext sendToTagged(String message, String tag) {
return sendToTagged(message, tag, false);
} | [
"public",
"WebSocketContext",
"sendToTagged",
"(",
"String",
"message",
",",
"String",
"tag",
")",
"{",
"return",
"sendToTagged",
"(",
"message",
",",
"tag",
",",
"false",
")",
";",
"}"
] | Send message to all connections labeled with tag specified
with self connection excluded
@param message the message to be sent
@param tag the string that tag the connections to be sent
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"labeled",
"with",
"tag",
"specified",
"with",
"self",
"connection",
"excluded"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L220-L222 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToTagged | public WebSocketContext sendToTagged(String message, String tag, boolean excludeSelf) {
return sendToConnections(message, tag, manager.tagRegistry(), excludeSelf);
} | java | public WebSocketContext sendToTagged(String message, String tag, boolean excludeSelf) {
return sendToConnections(message, tag, manager.tagRegistry(), excludeSelf);
} | [
"public",
"WebSocketContext",
"sendToTagged",
"(",
"String",
"message",
",",
"String",
"tag",
",",
"boolean",
"excludeSelf",
")",
"{",
"return",
"sendToConnections",
"(",
"message",
",",
"tag",
",",
"manager",
".",
"tagRegistry",
"(",
")",
",",
"excludeSelf",
... | Send message to all connections labeled with tag specified.
@param message the message to be sent
@param tag the string that tag the connections to be sent
@param excludeSelf specify whether the connection of this context should be send
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"labeled",
"with",
"tag",
"specified",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L232-L234 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToUser | public WebSocketContext sendToUser(String message, String username) {
return sendToConnections(message, username, manager.usernameRegistry(), true);
} | java | public WebSocketContext sendToUser(String message, String username) {
return sendToConnections(message, username, manager.usernameRegistry(), true);
} | [
"public",
"WebSocketContext",
"sendToUser",
"(",
"String",
"message",
",",
"String",
"username",
")",
"{",
"return",
"sendToConnections",
"(",
"message",
",",
"username",
",",
"manager",
".",
"usernameRegistry",
"(",
")",
",",
"true",
")",
";",
"}"
] | Send message to all connections of a certain user
@param message the message to be sent
@param username the username
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"of",
"a",
"certain",
"user"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L269-L271 | train |
actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendJsonToUser | public WebSocketContext sendJsonToUser(Object data, String username) {
return sendToTagged(JSON.toJSONString(data), username);
} | java | public WebSocketContext sendJsonToUser(Object data, String username) {
return sendToTagged(JSON.toJSONString(data), username);
} | [
"public",
"WebSocketContext",
"sendJsonToUser",
"(",
"Object",
"data",
",",
"String",
"username",
")",
"{",
"return",
"sendToTagged",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"username",
")",
";",
"}"
] | Send JSON representation of a data object to all connections of a certain user
@param data the data to be sent
@param username the username
@return this context | [
"Send",
"JSON",
"representation",
"of",
"a",
"data",
"object",
"to",
"all",
"connections",
"of",
"a",
"certain",
"user"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L280-L282 | train |
noboomu/proteus | core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java | ApplicationModule.bindMappers | public void bindMappers()
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(xmlModule);
xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
this.bind(XmlMapper.class).toInstance(xmlMapper);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
objectMapper.registerModule(new AfterburnerModule());
objectMapper.registerModule(new Jdk8Module());
this.bind(ObjectMapper.class).toInstance(objectMapper);
this.requestStaticInjection(Extractors.class);
this.requestStaticInjection(ServerResponse.class);
} | java | public void bindMappers()
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(xmlModule);
xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
this.bind(XmlMapper.class).toInstance(xmlMapper);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
objectMapper.registerModule(new AfterburnerModule());
objectMapper.registerModule(new Jdk8Module());
this.bind(ObjectMapper.class).toInstance(objectMapper);
this.requestStaticInjection(Extractors.class);
this.requestStaticInjection(ServerResponse.class);
} | [
"public",
"void",
"bindMappers",
"(",
")",
"{",
"JacksonXmlModule",
"xmlModule",
"=",
"new",
"JacksonXmlModule",
"(",
")",
";",
"xmlModule",
".",
"setDefaultUseWrapper",
"(",
"false",
")",
";",
"XmlMapper",
"xmlMapper",
"=",
"new",
"XmlMapper",
"(",
"xmlModule",... | Override for customizing XmlMapper and ObjectMapper | [
"Override",
"for",
"customizing",
"XmlMapper",
"and",
"ObjectMapper"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java#L50-L76 | train |
noboomu/proteus | swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java | Reader.read | public Swagger read(Set<Class<?>> classes) {
Set<Class<?>> sortedClasses = new TreeSet<>((class1, class2) -> {
if (class1.equals(class2)) {
return 0;
} else if (class1.isAssignableFrom(class2)) {
return -1;
} else if (class2.isAssignableFrom(class1)) {
return 1;
}
return class1.getName().compareTo(class2.getName());
});
sortedClasses.addAll(classes);
Map<Class<?>, ReaderListener> listeners = new HashMap<Class<?>, ReaderListener>();
for (Class<?> cls : sortedClasses) {
if (ReaderListener.class.isAssignableFrom(cls) && !listeners.containsKey(cls)) {
try {
listeners.put(cls, (ReaderListener) cls.newInstance());
} catch (Exception e) {
LOGGER.error("Failed to create ReaderListener", e);
}
}
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.beforeScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking beforeScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
// process SwaggerDefinitions first - so we get tags in desired order
for (Class<?> cls : sortedClasses) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
}
for (Class<?> cls : sortedClasses) {
read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.afterScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking afterScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
return swagger;
} | java | public Swagger read(Set<Class<?>> classes) {
Set<Class<?>> sortedClasses = new TreeSet<>((class1, class2) -> {
if (class1.equals(class2)) {
return 0;
} else if (class1.isAssignableFrom(class2)) {
return -1;
} else if (class2.isAssignableFrom(class1)) {
return 1;
}
return class1.getName().compareTo(class2.getName());
});
sortedClasses.addAll(classes);
Map<Class<?>, ReaderListener> listeners = new HashMap<Class<?>, ReaderListener>();
for (Class<?> cls : sortedClasses) {
if (ReaderListener.class.isAssignableFrom(cls) && !listeners.containsKey(cls)) {
try {
listeners.put(cls, (ReaderListener) cls.newInstance());
} catch (Exception e) {
LOGGER.error("Failed to create ReaderListener", e);
}
}
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.beforeScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking beforeScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
// process SwaggerDefinitions first - so we get tags in desired order
for (Class<?> cls : sortedClasses) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
}
for (Class<?> cls : sortedClasses) {
read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.afterScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking afterScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
return swagger;
} | [
"public",
"Swagger",
"read",
"(",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
")",
"{",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"sortedClasses",
"=",
"new",
"TreeSet",
"<>",
"(",
"(",
"class1",
",",
"class2",
")",
"->",
"{",
"if",
"(",
... | Scans a set of classes for both ReaderListeners and Swagger annotations. All found listeners will
be instantiated before any of the classes are scanned for Swagger annotations - so they can be invoked
accordingly.
@param classes a set of classes to scan
@return the generated Swagger definition | [
"Scans",
"a",
"set",
"of",
"classes",
"for",
"both",
"ReaderListeners",
"and",
"Swagger",
"annotations",
".",
"All",
"found",
"listeners",
"will",
"be",
"instantiated",
"before",
"any",
"of",
"the",
"classes",
"are",
"scanned",
"for",
"Swagger",
"annotations",
... | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java#L97-L151 | train |
noboomu/proteus | swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java | Reader.read | public Swagger read(Class<?> cls) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
return read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
} | java | public Swagger read(Class<?> cls) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
return read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
} | [
"public",
"Swagger",
"read",
"(",
"Class",
"<",
"?",
">",
"cls",
")",
"{",
"SwaggerDefinition",
"swaggerDefinition",
"=",
"cls",
".",
"getAnnotation",
"(",
"SwaggerDefinition",
".",
"class",
")",
";",
"if",
"(",
"swaggerDefinition",
"!=",
"null",
")",
"{",
... | Scans a single class for Swagger annotations - does not invoke ReaderListeners | [
"Scans",
"a",
"single",
"class",
"for",
"Swagger",
"annotations",
"-",
"does",
"not",
"invoke",
"ReaderListeners"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java#L156-L163 | train |
noboomu/proteus | core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java | HandlerGenerator.generateRoutes | protected void generateRoutes()
{
try {
// Optional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// typeLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = typeLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// for(Method m : this.controllerClass.getDeclaredMethods())
// {
//
// Optional<io.sinistral.proteus.annotations.Chain> methodLevelWrapAnnotation = Optional.ofNullable(m.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// methodLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = methodLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// }
//
// log.info("handlerWrapperMap: " + handlerWrapperMap);
TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC)
.addSuperinterface(ParameterizedTypeName.get(Supplier.class, RoutingHandler.class));
ClassName extractorClass = ClassName.get("io.sinistral.proteus.server", "Extractors");
ClassName injectClass = ClassName.get("com.google.inject", "Inject");
MethodSpec.Builder constructor = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addAnnotation(injectClass);
String className = this.controllerClass.getSimpleName().toLowerCase() + "Controller";
typeBuilder.addField(this.controllerClass, className, Modifier.PROTECTED, Modifier.FINAL);
ClassName wrapperClass = ClassName.get("io.undertow.server", "HandlerWrapper");
ClassName stringClass = ClassName.get("java.lang", "String");
ClassName mapClass = ClassName.get("java.util", "Map");
TypeName mapOfWrappers = ParameterizedTypeName.get(mapClass, stringClass, wrapperClass);
TypeName annotatedMapOfWrappers = mapOfWrappers
.annotated(AnnotationSpec.builder(com.google.inject.name.Named.class).addMember("value", "$S", "registeredHandlerWrappers").build());
typeBuilder.addField(mapOfWrappers, "registeredHandlerWrappers", Modifier.PROTECTED, Modifier.FINAL);
constructor.addParameter(this.controllerClass, className);
constructor.addParameter(annotatedMapOfWrappers, "registeredHandlerWrappers");
constructor.addStatement("this.$N = $N", className, className);
constructor.addStatement("this.$N = $N", "registeredHandlerWrappers", "registeredHandlerWrappers");
addClassMethodHandlers(typeBuilder, this.controllerClass);
typeBuilder.addMethod(constructor.build());
JavaFile javaFile = JavaFile.builder(packageName, typeBuilder.build()).addStaticImport(extractorClass, "*").build();
StringBuilder sb = new StringBuilder();
javaFile.writeTo(sb);
this.sourceString = sb.toString();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} | java | protected void generateRoutes()
{
try {
// Optional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// typeLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = typeLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// for(Method m : this.controllerClass.getDeclaredMethods())
// {
//
// Optional<io.sinistral.proteus.annotations.Chain> methodLevelWrapAnnotation = Optional.ofNullable(m.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// methodLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = methodLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// }
//
// log.info("handlerWrapperMap: " + handlerWrapperMap);
TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC)
.addSuperinterface(ParameterizedTypeName.get(Supplier.class, RoutingHandler.class));
ClassName extractorClass = ClassName.get("io.sinistral.proteus.server", "Extractors");
ClassName injectClass = ClassName.get("com.google.inject", "Inject");
MethodSpec.Builder constructor = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addAnnotation(injectClass);
String className = this.controllerClass.getSimpleName().toLowerCase() + "Controller";
typeBuilder.addField(this.controllerClass, className, Modifier.PROTECTED, Modifier.FINAL);
ClassName wrapperClass = ClassName.get("io.undertow.server", "HandlerWrapper");
ClassName stringClass = ClassName.get("java.lang", "String");
ClassName mapClass = ClassName.get("java.util", "Map");
TypeName mapOfWrappers = ParameterizedTypeName.get(mapClass, stringClass, wrapperClass);
TypeName annotatedMapOfWrappers = mapOfWrappers
.annotated(AnnotationSpec.builder(com.google.inject.name.Named.class).addMember("value", "$S", "registeredHandlerWrappers").build());
typeBuilder.addField(mapOfWrappers, "registeredHandlerWrappers", Modifier.PROTECTED, Modifier.FINAL);
constructor.addParameter(this.controllerClass, className);
constructor.addParameter(annotatedMapOfWrappers, "registeredHandlerWrappers");
constructor.addStatement("this.$N = $N", className, className);
constructor.addStatement("this.$N = $N", "registeredHandlerWrappers", "registeredHandlerWrappers");
addClassMethodHandlers(typeBuilder, this.controllerClass);
typeBuilder.addMethod(constructor.build());
JavaFile javaFile = JavaFile.builder(packageName, typeBuilder.build()).addStaticImport(extractorClass, "*").build();
StringBuilder sb = new StringBuilder();
javaFile.writeTo(sb);
this.sourceString = sb.toString();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} | [
"protected",
"void",
"generateRoutes",
"(",
")",
"{",
"try",
"{",
"//\t\t\tOptional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));",
"//\t\t\t",
"//\t\t\ttypeLevelWrapAnnotation.i... | Generates the routing Java source code | [
"Generates",
"the",
"routing",
"Java",
"source",
"code"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java#L128-L224 | train |
noboomu/proteus | core/src/main/java/io/sinistral/proteus/ProteusApplication.java | ProteusApplication.addDefaultRoutes | public ProteusApplication addDefaultRoutes(RoutingHandler router)
{
if (config.hasPath("health.statusPath")) {
try {
final String statusPath = config.getString("health.statusPath");
router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
exchange.getResponseSender().send("OK");
});
this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());
} catch (Exception e) {
log.error("Error adding health status route.", e.getMessage());
}
}
if (config.hasPath("application.favicon")) {
try {
final ByteBuffer faviconImageBuffer;
final File faviconFile = new File(config.getString("application.favicon"));
if (!faviconFile.exists()) {
try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
} else {
try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
}
router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString());
exchange.getResponseSender().send(faviconImageBuffer);
});
} catch (Exception e) {
log.error("Error adding favicon route.", e.getMessage());
}
}
return this;
} | java | public ProteusApplication addDefaultRoutes(RoutingHandler router)
{
if (config.hasPath("health.statusPath")) {
try {
final String statusPath = config.getString("health.statusPath");
router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
exchange.getResponseSender().send("OK");
});
this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());
} catch (Exception e) {
log.error("Error adding health status route.", e.getMessage());
}
}
if (config.hasPath("application.favicon")) {
try {
final ByteBuffer faviconImageBuffer;
final File faviconFile = new File(config.getString("application.favicon"));
if (!faviconFile.exists()) {
try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
} else {
try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
}
router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString());
exchange.getResponseSender().send(faviconImageBuffer);
});
} catch (Exception e) {
log.error("Error adding favicon route.", e.getMessage());
}
}
return this;
} | [
"public",
"ProteusApplication",
"addDefaultRoutes",
"(",
"RoutingHandler",
"router",
")",
"{",
"if",
"(",
"config",
".",
"hasPath",
"(",
"\"health.statusPath\"",
")",
")",
"{",
"try",
"{",
"final",
"String",
"statusPath",
"=",
"config",
".",
"getString",
"(",
... | Add utility routes the router
@param router | [
"Add",
"utility",
"routes",
"the",
"router"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/ProteusApplication.java#L362-L434 | train |
noboomu/proteus | core/src/main/java/io/sinistral/proteus/ProteusApplication.java | ProteusApplication.setServerConfigurationFunction | public ProteusApplication setServerConfigurationFunction(Function<Undertow.Builder, Undertow.Builder> serverConfigurationFunction)
{
this.serverConfigurationFunction = serverConfigurationFunction;
return this;
} | java | public ProteusApplication setServerConfigurationFunction(Function<Undertow.Builder, Undertow.Builder> serverConfigurationFunction)
{
this.serverConfigurationFunction = serverConfigurationFunction;
return this;
} | [
"public",
"ProteusApplication",
"setServerConfigurationFunction",
"(",
"Function",
"<",
"Undertow",
".",
"Builder",
",",
"Undertow",
".",
"Builder",
">",
"serverConfigurationFunction",
")",
"{",
"this",
".",
"serverConfigurationFunction",
"=",
"serverConfigurationFunction",... | Allows direct access to the Undertow.Builder for custom configuration
@param serverConfigurationFunction the serverConfigurationFunction | [
"Allows",
"direct",
"access",
"to",
"the",
"Undertow",
".",
"Builder",
"for",
"custom",
"configuration"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/ProteusApplication.java#L465-L469 | train |
felipecsl/AsymmetricGridView | library/src/main/java/com/felipecsl/asymmetricgridview/Utils.java | Utils.getDisplayMetrics | static DisplayMetrics getDisplayMetrics(final Context context) {
final WindowManager
windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics;
} | java | static DisplayMetrics getDisplayMetrics(final Context context) {
final WindowManager
windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics;
} | [
"static",
"DisplayMetrics",
"getDisplayMetrics",
"(",
"final",
"Context",
"context",
")",
"{",
"final",
"WindowManager",
"windowManager",
"=",
"(",
"WindowManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"WINDOW_SERVICE",
")",
";",
"final",
... | Returns a valid DisplayMetrics object
@param context valid context
@return DisplayMetrics object | [
"Returns",
"a",
"valid",
"DisplayMetrics",
"object"
] | f8c3d6da518a85218c3627b93ec62415befe7a6a | https://github.com/felipecsl/AsymmetricGridView/blob/f8c3d6da518a85218c3627b93ec62415befe7a6a/library/src/main/java/com/felipecsl/asymmetricgridview/Utils.java#L27-L34 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/live/LiveBlurWorker.java | LiveBlurWorker.crop | private static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
float scale = 1f / downsampling;
return Bitmap.createBitmap(
srcBmp,
(int) Math.floor((ViewCompat.getX(canvasView)) * scale),
(int) Math.floor((ViewCompat.getY(canvasView)) * scale),
(int) Math.floor((canvasView.getWidth()) * scale),
(int) Math.floor((canvasView.getHeight()) * scale)
);
} | java | private static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
float scale = 1f / downsampling;
return Bitmap.createBitmap(
srcBmp,
(int) Math.floor((ViewCompat.getX(canvasView)) * scale),
(int) Math.floor((ViewCompat.getY(canvasView)) * scale),
(int) Math.floor((canvasView.getWidth()) * scale),
(int) Math.floor((canvasView.getHeight()) * scale)
);
} | [
"private",
"static",
"Bitmap",
"crop",
"(",
"Bitmap",
"srcBmp",
",",
"View",
"canvasView",
",",
"int",
"downsampling",
")",
"{",
"float",
"scale",
"=",
"1f",
"/",
"downsampling",
";",
"return",
"Bitmap",
".",
"createBitmap",
"(",
"srcBmp",
",",
"(",
"int",... | crops the srcBmp with the canvasView bounds and returns the cropped bitmap | [
"crops",
"the",
"srcBmp",
"with",
"the",
"canvasView",
"bounds",
"and",
"returns",
"the",
"cropped",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/live/LiveBlurWorker.java#L102-L111 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java | PerformanceProfiler.startTask | public void startTask(int id, String taskName) {
if (isActivated) {
durations.add(new Duration(id, taskName, BenchmarkUtil.elapsedRealTimeNanos()));
}
} | java | public void startTask(int id, String taskName) {
if (isActivated) {
durations.add(new Duration(id, taskName, BenchmarkUtil.elapsedRealTimeNanos()));
}
} | [
"public",
"void",
"startTask",
"(",
"int",
"id",
",",
"String",
"taskName",
")",
"{",
"if",
"(",
"isActivated",
")",
"{",
"durations",
".",
"add",
"(",
"new",
"Duration",
"(",
"id",
",",
"taskName",
",",
"BenchmarkUtil",
".",
"elapsedRealTimeNanos",
"(",
... | Start a task. The id is needed to end the task
@param id
@param taskName | [
"Start",
"a",
"task",
".",
"The",
"id",
"is",
"needed",
"to",
"end",
"the",
"task"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java#L43-L47 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java | PerformanceProfiler.getDurationMs | public double getDurationMs() {
double durationMs = 0;
for (Duration duration : durations) {
if (duration.taskFinished()) {
durationMs += duration.getDurationMS();
}
}
return durationMs;
} | java | public double getDurationMs() {
double durationMs = 0;
for (Duration duration : durations) {
if (duration.taskFinished()) {
durationMs += duration.getDurationMS();
}
}
return durationMs;
} | [
"public",
"double",
"getDurationMs",
"(",
")",
"{",
"double",
"durationMs",
"=",
"0",
";",
"for",
"(",
"Duration",
"duration",
":",
"durations",
")",
"{",
"if",
"(",
"duration",
".",
"taskFinished",
"(",
")",
")",
"{",
"durationMs",
"+=",
"duration",
"."... | Returns the duration of the measured tasks in ms | [
"Returns",
"the",
"duration",
"of",
"the",
"measured",
"tasks",
"in",
"ms"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java#L71-L79 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.setViewBackground | public static void setViewBackground(View v, Drawable d) {
if (Build.VERSION.SDK_INT >= 16) {
v.setBackground(d);
} else {
v.setBackgroundDrawable(d);
}
} | java | public static void setViewBackground(View v, Drawable d) {
if (Build.VERSION.SDK_INT >= 16) {
v.setBackground(d);
} else {
v.setBackgroundDrawable(d);
}
} | [
"public",
"static",
"void",
"setViewBackground",
"(",
"View",
"v",
",",
"Drawable",
"d",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"16",
")",
"{",
"v",
".",
"setBackground",
"(",
"d",
")",
";",
"}",
"else",
"{",
"v",
".",
... | legacy helper for setting background | [
"legacy",
"helper",
"for",
"setting",
"background"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L36-L42 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.byteSizeOf | public static int byteSizeOf(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return bitmap.getAllocationByteCount();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
} | java | public static int byteSizeOf(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return bitmap.getAllocationByteCount();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
} | [
"public",
"static",
"int",
"byteSizeOf",
"(",
"Bitmap",
"bitmap",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"KITKAT",
")",
"{",
"return",
"bitmap",
".",
"getAllocationByteCount",
"(",
")",
";",
... | returns the bytesize of the give bitmap | [
"returns",
"the",
"bytesize",
"of",
"the",
"give",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L47-L55 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.getCacheDir | public static String getCacheDir(Context ctx) {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || (!Environment.isExternalStorageRemovable() && ctx.getExternalCacheDir() != null) ?
ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath();
} | java | public static String getCacheDir(Context ctx) {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || (!Environment.isExternalStorageRemovable() && ctx.getExternalCacheDir() != null) ?
ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath();
} | [
"public",
"static",
"String",
"getCacheDir",
"(",
"Context",
"ctx",
")",
"{",
"return",
"Environment",
".",
"MEDIA_MOUNTED",
".",
"equals",
"(",
"Environment",
".",
"getExternalStorageState",
"(",
")",
")",
"||",
"(",
"!",
"Environment",
".",
"isExternalStorageR... | Gets the appropriate cache dir
@param ctx
@return | [
"Gets",
"the",
"appropriate",
"cache",
"dir"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L72-L75 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ImageReference.java | ImageReference.measureImage | public Point measureImage(Resources resources) {
BitmapFactory.Options justBoundsOptions = new BitmapFactory.Options();
justBoundsOptions.inJustDecodeBounds = true;
if (bitmap != null) {
return new Point(bitmap.getWidth(), bitmap.getHeight());
} else if (resId != null) {
BitmapFactory.decodeResource(resources, resId, justBoundsOptions);
float scale = (float) justBoundsOptions.inTargetDensity / justBoundsOptions.inDensity;
return new Point((int) (justBoundsOptions.outWidth * scale + 0.5f), (int) (justBoundsOptions.outHeight * scale + 0.5f));
} else if (fileToBitmap != null) {
BitmapFactory.decodeFile(fileToBitmap.getAbsolutePath(), justBoundsOptions);
} else if (inputStream != null) {
BitmapFactory.decodeStream(inputStream, null, justBoundsOptions);
try {
inputStream.reset();
} catch (IOException ignored) {
}
} else if (view != null) {
return new Point(view.getWidth(), view.getHeight());
}
return new Point(justBoundsOptions.outWidth, justBoundsOptions.outHeight);
} | java | public Point measureImage(Resources resources) {
BitmapFactory.Options justBoundsOptions = new BitmapFactory.Options();
justBoundsOptions.inJustDecodeBounds = true;
if (bitmap != null) {
return new Point(bitmap.getWidth(), bitmap.getHeight());
} else if (resId != null) {
BitmapFactory.decodeResource(resources, resId, justBoundsOptions);
float scale = (float) justBoundsOptions.inTargetDensity / justBoundsOptions.inDensity;
return new Point((int) (justBoundsOptions.outWidth * scale + 0.5f), (int) (justBoundsOptions.outHeight * scale + 0.5f));
} else if (fileToBitmap != null) {
BitmapFactory.decodeFile(fileToBitmap.getAbsolutePath(), justBoundsOptions);
} else if (inputStream != null) {
BitmapFactory.decodeStream(inputStream, null, justBoundsOptions);
try {
inputStream.reset();
} catch (IOException ignored) {
}
} else if (view != null) {
return new Point(view.getWidth(), view.getHeight());
}
return new Point(justBoundsOptions.outWidth, justBoundsOptions.outHeight);
} | [
"public",
"Point",
"measureImage",
"(",
"Resources",
"resources",
")",
"{",
"BitmapFactory",
".",
"Options",
"justBoundsOptions",
"=",
"new",
"BitmapFactory",
".",
"Options",
"(",
")",
";",
"justBoundsOptions",
".",
"inJustDecodeBounds",
"=",
"true",
";",
"if",
... | If the not a bitmap itself, this will read the file's meta data.
@param resources {@link android.content.Context#getResources()}
@return Point where x = width and y = height | [
"If",
"the",
"not",
"a",
"bitmap",
"itself",
"this",
"will",
"read",
"the",
"file",
"s",
"meta",
"data",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ImageReference.java#L153-L175 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ExecutorManager.java | ExecutorManager.cancelByTag | public synchronized int cancelByTag(String tagToCancel) {
int i = 0;
if (taskList.containsKey(tagToCancel)) {
removeDoneTasks();
for (Future<BlurWorker.Result> future : taskList.get(tagToCancel)) {
BuilderUtil.logVerbose(Dali.getConfig().logTag, "Canceling task with tag " + tagToCancel, Dali.getConfig().debugMode);
future.cancel(true);
i++;
}
//remove all canceled tasks
Iterator<Future<BlurWorker.Result>> iter = taskList.get(tagToCancel).iterator();
while (iter.hasNext()) {
if (iter.next().isCancelled()) {
iter.remove();
}
}
}
return i;
} | java | public synchronized int cancelByTag(String tagToCancel) {
int i = 0;
if (taskList.containsKey(tagToCancel)) {
removeDoneTasks();
for (Future<BlurWorker.Result> future : taskList.get(tagToCancel)) {
BuilderUtil.logVerbose(Dali.getConfig().logTag, "Canceling task with tag " + tagToCancel, Dali.getConfig().debugMode);
future.cancel(true);
i++;
}
//remove all canceled tasks
Iterator<Future<BlurWorker.Result>> iter = taskList.get(tagToCancel).iterator();
while (iter.hasNext()) {
if (iter.next().isCancelled()) {
iter.remove();
}
}
}
return i;
} | [
"public",
"synchronized",
"int",
"cancelByTag",
"(",
"String",
"tagToCancel",
")",
"{",
"int",
"i",
"=",
"0",
";",
"if",
"(",
"taskList",
".",
"containsKey",
"(",
"tagToCancel",
")",
")",
"{",
"removeDoneTasks",
"(",
")",
";",
"for",
"(",
"Future",
"<",
... | Cancel all task with this tag and returns the canceled task count
@param tagToCancel
@return | [
"Cancel",
"all",
"task",
"with",
"this",
"tag",
"and",
"returns",
"the",
"canceled",
"task",
"count"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ExecutorManager.java#L69-L89 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/BitmapUtil.java | BitmapUtil.flip | public static Bitmap flip(Bitmap src) {
Matrix m = new Matrix();
m.preScale(-1, 1);
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
} | java | public static Bitmap flip(Bitmap src) {
Matrix m = new Matrix();
m.preScale(-1, 1);
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
} | [
"public",
"static",
"Bitmap",
"flip",
"(",
"Bitmap",
"src",
")",
"{",
"Matrix",
"m",
"=",
"new",
"Matrix",
"(",
")",
";",
"m",
".",
"preScale",
"(",
"-",
"1",
",",
"1",
")",
";",
"return",
"Bitmap",
".",
"createBitmap",
"(",
"src",
",",
"0",
",",... | Mirrors the given bitmap | [
"Mirrors",
"the",
"given",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/BitmapUtil.java#L83-L87 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/TwoLevelCache.java | TwoLevelCache.purge | public void purge(String cacheKey) {
try {
if (useMemoryCache) {
if (memoryCache != null) {
memoryCache.remove(cacheKey);
}
}
if (useDiskCache) {
if (diskLruCache != null) {
diskLruCache.remove(cacheKey);
}
}
} catch (Exception e) {
Log.w(TAG, "Could not remove entry in cache purge", e);
}
} | java | public void purge(String cacheKey) {
try {
if (useMemoryCache) {
if (memoryCache != null) {
memoryCache.remove(cacheKey);
}
}
if (useDiskCache) {
if (diskLruCache != null) {
diskLruCache.remove(cacheKey);
}
}
} catch (Exception e) {
Log.w(TAG, "Could not remove entry in cache purge", e);
}
} | [
"public",
"void",
"purge",
"(",
"String",
"cacheKey",
")",
"{",
"try",
"{",
"if",
"(",
"useMemoryCache",
")",
"{",
"if",
"(",
"memoryCache",
"!=",
"null",
")",
"{",
"memoryCache",
".",
"remove",
"(",
"cacheKey",
")",
";",
"}",
"}",
"if",
"(",
"useDis... | Removes the value connected to the given key
from all levels of the cache. Will not throw an
exception on fail.
@param cacheKey | [
"Removes",
"the",
"value",
"connected",
"to",
"the",
"given",
"key",
"from",
"all",
"levels",
"of",
"the",
"cache",
".",
"Will",
"not",
"throw",
"an",
"exception",
"on",
"fail",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/TwoLevelCache.java#L223-L239 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ContextWrapper.java | ContextWrapper.getRenderScript | public RenderScript getRenderScript() {
if (renderScript == null) {
renderScript = RenderScript.create(context, renderScriptContextType);
}
return renderScript;
} | java | public RenderScript getRenderScript() {
if (renderScript == null) {
renderScript = RenderScript.create(context, renderScriptContextType);
}
return renderScript;
} | [
"public",
"RenderScript",
"getRenderScript",
"(",
")",
"{",
"if",
"(",
"renderScript",
"==",
"null",
")",
"{",
"renderScript",
"=",
"RenderScript",
".",
"create",
"(",
"context",
",",
"renderScriptContextType",
")",
";",
"}",
"return",
"renderScript",
";",
"}"... | Syncronously creates a Renderscript context if none exists.
Creating a Renderscript context takes about 20 ms in Nexus 5
@return | [
"Syncronously",
"creates",
"a",
"Renderscript",
"context",
"if",
"none",
"exists",
".",
"Creating",
"a",
"Renderscript",
"context",
"takes",
"about",
"20",
"ms",
"in",
"Nexus",
"5"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ContextWrapper.java#L34-L39 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java | DaliBlurDrawerToggle.renderBlurLayer | private void renderBlurLayer(float slideOffset) {
if (enableBlur) {
if (slideOffset == 0 || forceRedraw) {
clearBlurView();
}
if (slideOffset > 0f && blurView == null) {
if (drawerLayout.getChildCount() == 2) {
blurView = new ImageView(drawerLayout.getContext());
blurView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
blurView.setScaleType(ImageView.ScaleType.FIT_CENTER);
drawerLayout.addView(blurView, 1);
}
if (BuilderUtil.isOnUiThread()) {
if (cacheMode.equals(CacheMode.AUTO) || forceRedraw) {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().skipCache().into(blurView);
forceRedraw = false;
} else {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().into(blurView);
}
}
}
if (slideOffset > 0f && slideOffset < 1f) {
int alpha = (int) Math.ceil((double) slideOffset * 255d);
LegacySDKUtil.setImageAlpha(blurView, alpha);
}
}
} | java | private void renderBlurLayer(float slideOffset) {
if (enableBlur) {
if (slideOffset == 0 || forceRedraw) {
clearBlurView();
}
if (slideOffset > 0f && blurView == null) {
if (drawerLayout.getChildCount() == 2) {
blurView = new ImageView(drawerLayout.getContext());
blurView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
blurView.setScaleType(ImageView.ScaleType.FIT_CENTER);
drawerLayout.addView(blurView, 1);
}
if (BuilderUtil.isOnUiThread()) {
if (cacheMode.equals(CacheMode.AUTO) || forceRedraw) {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().skipCache().into(blurView);
forceRedraw = false;
} else {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().into(blurView);
}
}
}
if (slideOffset > 0f && slideOffset < 1f) {
int alpha = (int) Math.ceil((double) slideOffset * 255d);
LegacySDKUtil.setImageAlpha(blurView, alpha);
}
}
} | [
"private",
"void",
"renderBlurLayer",
"(",
"float",
"slideOffset",
")",
"{",
"if",
"(",
"enableBlur",
")",
"{",
"if",
"(",
"slideOffset",
"==",
"0",
"||",
"forceRedraw",
")",
"{",
"clearBlurView",
"(",
")",
";",
"}",
"if",
"(",
"slideOffset",
">",
"0f",
... | This will blur the view behind it and set it in
a imageview over the content with a alpha value
that corresponds to slideOffset. | [
"This",
"will",
"blur",
"the",
"view",
"behind",
"it",
"and",
"set",
"it",
"in",
"a",
"imageview",
"over",
"the",
"content",
"with",
"a",
"alpha",
"value",
"that",
"corresponds",
"to",
"slideOffset",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java#L70-L99 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java | DaliBlurDrawerToggle.onDrawerOpened | public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (listener != null) listener.onDrawerClosed(drawerView);
} | java | public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (listener != null) listener.onDrawerClosed(drawerView);
} | [
"public",
"void",
"onDrawerOpened",
"(",
"View",
"drawerView",
")",
"{",
"super",
".",
"onDrawerOpened",
"(",
"drawerView",
")",
";",
"if",
"(",
"listener",
"!=",
"null",
")",
"listener",
".",
"onDrawerClosed",
"(",
"drawerView",
")",
";",
"}"
] | Called when a drawer has settled in a completely open state. | [
"Called",
"when",
"a",
"drawer",
"has",
"settled",
"in",
"a",
"completely",
"open",
"state",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java#L149-L152 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/BuilderUtil.java | BuilderUtil.getIBlurAlgorithm | public static IBlur getIBlurAlgorithm(EBlurAlgorithm algorithm, ContextWrapper contextWrapper) {
RenderScript rs = contextWrapper.getRenderScript();
Context ctx = contextWrapper.getContext();
switch (algorithm) {
case RS_GAUSS_FAST:
return new RenderScriptGaussianBlur(rs);
case RS_BOX_5x5:
return new RenderScriptBox5x5Blur(rs);
case RS_GAUSS_5x5:
return new RenderScriptGaussian5x5Blur(rs);
case RS_STACKBLUR:
return new RenderScriptStackBlur(rs, ctx);
case STACKBLUR:
return new StackBlur();
case GAUSS_FAST:
return new GaussianFastBlur();
case BOX_BLUR:
return new BoxBlur();
default:
return new IgnoreBlur();
}
} | java | public static IBlur getIBlurAlgorithm(EBlurAlgorithm algorithm, ContextWrapper contextWrapper) {
RenderScript rs = contextWrapper.getRenderScript();
Context ctx = contextWrapper.getContext();
switch (algorithm) {
case RS_GAUSS_FAST:
return new RenderScriptGaussianBlur(rs);
case RS_BOX_5x5:
return new RenderScriptBox5x5Blur(rs);
case RS_GAUSS_5x5:
return new RenderScriptGaussian5x5Blur(rs);
case RS_STACKBLUR:
return new RenderScriptStackBlur(rs, ctx);
case STACKBLUR:
return new StackBlur();
case GAUSS_FAST:
return new GaussianFastBlur();
case BOX_BLUR:
return new BoxBlur();
default:
return new IgnoreBlur();
}
} | [
"public",
"static",
"IBlur",
"getIBlurAlgorithm",
"(",
"EBlurAlgorithm",
"algorithm",
",",
"ContextWrapper",
"contextWrapper",
")",
"{",
"RenderScript",
"rs",
"=",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
";",
"Context",
"ctx",
"=",
"contextWrapper",
".",... | Creates an IBlur instance for the given algorithm enum
@param algorithm
@param contextWrapper
@return | [
"Creates",
"an",
"IBlur",
"instance",
"for",
"the",
"given",
"algorithm",
"enum"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/BuilderUtil.java#L40-L62 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.downScale | public BlurBuilder downScale(int scaleInSample) {
data.options.inSampleSize = Math.min(Math.max(1, scaleInSample), 16384);
return this;
} | java | public BlurBuilder downScale(int scaleInSample) {
data.options.inSampleSize = Math.min(Math.max(1, scaleInSample), 16384);
return this;
} | [
"public",
"BlurBuilder",
"downScale",
"(",
"int",
"scaleInSample",
")",
"{",
"data",
".",
"options",
".",
"inSampleSize",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"1",
",",
"scaleInSample",
")",
",",
"16384",
")",
";",
"return",
"this",
"... | Will scale the image down before processing for
performance enhancement and less memory usage
sacrificing image quality.
@param scaleInSample value greater than 1 will scale the image width/height, so 2 will getFromDiskCache you 1/4
of the original size and 4 will getFromDiskCache you 1/16 of the original size - this just sets
the inSample size in {@link android.graphics.BitmapFactory.Options#inSampleSize } and
behaves exactly the same, so keep the value 2^n for least scaling artifacts | [
"Will",
"scale",
"the",
"image",
"down",
"before",
"processing",
"for",
"performance",
"enhancement",
"and",
"less",
"memory",
"usage",
"sacrificing",
"image",
"quality",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L110-L113 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.brightness | public BlurBuilder brightness(float brightness) {
data.preProcessors.add(new RenderscriptBrightnessProcessor(data.contextWrapper.getRenderScript(), brightness, data.contextWrapper.getResources()));
return this;
} | java | public BlurBuilder brightness(float brightness) {
data.preProcessors.add(new RenderscriptBrightnessProcessor(data.contextWrapper.getRenderScript(), brightness, data.contextWrapper.getResources()));
return this;
} | [
"public",
"BlurBuilder",
"brightness",
"(",
"float",
"brightness",
")",
"{",
"data",
".",
"preProcessors",
".",
"add",
"(",
"new",
"RenderscriptBrightnessProcessor",
"(",
"data",
".",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
",",
"brightness",
",",
"d... | Set brightness to eg. darken the resulting image for use as background
@param brightness default is 0, pos values increase brightness, neg. values decrease brightness
.-100 is black, positive goes up to 1000+ | [
"Set",
"brightness",
"to",
"eg",
".",
"darken",
"the",
"resulting",
"image",
"for",
"use",
"as",
"background"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L155-L158 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.contrast | public BlurBuilder contrast(float contrast) {
data.preProcessors.add(new ContrastProcessor(data.contextWrapper.getRenderScript(), Math.max(Math.min(1500.f, contrast), -1500.f)));
return this;
} | java | public BlurBuilder contrast(float contrast) {
data.preProcessors.add(new ContrastProcessor(data.contextWrapper.getRenderScript(), Math.max(Math.min(1500.f, contrast), -1500.f)));
return this;
} | [
"public",
"BlurBuilder",
"contrast",
"(",
"float",
"contrast",
")",
"{",
"data",
".",
"preProcessors",
".",
"add",
"(",
"new",
"ContrastProcessor",
"(",
"data",
".",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
",",
"Math",
".",
"max",
"(",
"Math",
... | Change contrast of the image
@param contrast default is 0, pos values increase contrast, neg. values decrease contrast | [
"Change",
"contrast",
"of",
"the",
"image"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L165-L168 | train |
patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/Dali.java | Dali.resetAndSetNewConfig | public static synchronized void resetAndSetNewConfig(Context ctx, Config config) {
GLOBAL_CONFIG = config;
if (DISK_CACHE_MANAGER != null) {
DISK_CACHE_MANAGER.clear();
DISK_CACHE_MANAGER = null;
createCache(ctx);
}
if (EXECUTOR_MANAGER != null) {
EXECUTOR_MANAGER.shutDown();
EXECUTOR_MANAGER = null;
}
Log.i(TAG, "New config set");
} | java | public static synchronized void resetAndSetNewConfig(Context ctx, Config config) {
GLOBAL_CONFIG = config;
if (DISK_CACHE_MANAGER != null) {
DISK_CACHE_MANAGER.clear();
DISK_CACHE_MANAGER = null;
createCache(ctx);
}
if (EXECUTOR_MANAGER != null) {
EXECUTOR_MANAGER.shutDown();
EXECUTOR_MANAGER = null;
}
Log.i(TAG, "New config set");
} | [
"public",
"static",
"synchronized",
"void",
"resetAndSetNewConfig",
"(",
"Context",
"ctx",
",",
"Config",
"config",
")",
"{",
"GLOBAL_CONFIG",
"=",
"config",
";",
"if",
"(",
"DISK_CACHE_MANAGER",
"!=",
"null",
")",
"{",
"DISK_CACHE_MANAGER",
".",
"clear",
"(",
... | Sets a new config and clears the previous cache | [
"Sets",
"a",
"new",
"config",
"and",
"clears",
"the",
"previous",
"cache"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/Dali.java#L49-L63 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.getIbanLength | public static int getIbanLength(final CountryCode countryCode) {
final BbanStructure structure = getBbanStructure(countryCode);
return COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH + structure.getBbanLength();
} | java | public static int getIbanLength(final CountryCode countryCode) {
final BbanStructure structure = getBbanStructure(countryCode);
return COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH + structure.getBbanLength();
} | [
"public",
"static",
"int",
"getIbanLength",
"(",
"final",
"CountryCode",
"countryCode",
")",
"{",
"final",
"BbanStructure",
"structure",
"=",
"getBbanStructure",
"(",
"countryCode",
")",
";",
"return",
"COUNTRY_CODE_LENGTH",
"+",
"CHECK_DIGIT_LENGTH",
"+",
"structure"... | Returns iban length for the specified country.
@param countryCode {@link org.iban4j.CountryCode}
@return the length of the iban for the specified country. | [
"Returns",
"iban",
"length",
"for",
"the",
"specified",
"country",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L133-L136 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.getCountryCodeAndCheckDigit | public static String getCountryCodeAndCheckDigit(final String iban) {
return iban.substring(COUNTRY_CODE_INDEX,
COUNTRY_CODE_INDEX + COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH);
} | java | public static String getCountryCodeAndCheckDigit(final String iban) {
return iban.substring(COUNTRY_CODE_INDEX,
COUNTRY_CODE_INDEX + COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH);
} | [
"public",
"static",
"String",
"getCountryCodeAndCheckDigit",
"(",
"final",
"String",
"iban",
")",
"{",
"return",
"iban",
".",
"substring",
"(",
"COUNTRY_CODE_INDEX",
",",
"COUNTRY_CODE_INDEX",
"+",
"COUNTRY_CODE_LENGTH",
"+",
"CHECK_DIGIT_LENGTH",
")",
";",
"}"
] | Returns iban's country code and check digit.
@param iban String
@return countryCodeAndCheckDigit String | [
"Returns",
"iban",
"s",
"country",
"code",
"and",
"check",
"digit",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L166-L169 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.replaceCheckDigit | static String replaceCheckDigit(final String iban, final String checkDigit) {
return getCountryCode(iban) + checkDigit + getBban(iban);
} | java | static String replaceCheckDigit(final String iban, final String checkDigit) {
return getCountryCode(iban) + checkDigit + getBban(iban);
} | [
"static",
"String",
"replaceCheckDigit",
"(",
"final",
"String",
"iban",
",",
"final",
"String",
"checkDigit",
")",
"{",
"return",
"getCountryCode",
"(",
"iban",
")",
"+",
"checkDigit",
"+",
"getBban",
"(",
"iban",
")",
";",
"}"
] | Returns an iban with replaced check digit.
@param iban The iban
@return The iban without the check digit | [
"Returns",
"an",
"iban",
"with",
"replaced",
"check",
"digit",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L261-L263 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.toFormattedString | static String toFormattedString(final String iban) {
final StringBuilder ibanBuffer = new StringBuilder(iban);
final int length = ibanBuffer.length();
for (int i = 0; i < length / 4; i++) {
ibanBuffer.insert((i + 1) * 4 + i, ' ');
}
return ibanBuffer.toString().trim();
} | java | static String toFormattedString(final String iban) {
final StringBuilder ibanBuffer = new StringBuilder(iban);
final int length = ibanBuffer.length();
for (int i = 0; i < length / 4; i++) {
ibanBuffer.insert((i + 1) * 4 + i, ' ');
}
return ibanBuffer.toString().trim();
} | [
"static",
"String",
"toFormattedString",
"(",
"final",
"String",
"iban",
")",
"{",
"final",
"StringBuilder",
"ibanBuffer",
"=",
"new",
"StringBuilder",
"(",
"iban",
")",
";",
"final",
"int",
"length",
"=",
"ibanBuffer",
".",
"length",
"(",
")",
";",
"for",
... | Returns formatted version of Iban.
@return A string representing formatted Iban for printing. | [
"Returns",
"formatted",
"version",
"of",
"Iban",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L270-L279 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/Bic.java | Bic.valueOf | public static Bic valueOf(final String bic) throws BicFormatException,
UnsupportedCountryException {
BicUtil.validate(bic);
return new Bic(bic);
} | java | public static Bic valueOf(final String bic) throws BicFormatException,
UnsupportedCountryException {
BicUtil.validate(bic);
return new Bic(bic);
} | [
"public",
"static",
"Bic",
"valueOf",
"(",
"final",
"String",
"bic",
")",
"throws",
"BicFormatException",
",",
"UnsupportedCountryException",
"{",
"BicUtil",
".",
"validate",
"(",
"bic",
")",
";",
"return",
"new",
"Bic",
"(",
"bic",
")",
";",
"}"
] | Returns a Bic object holding the value of the specified String.
@param bic the String to be parsed.
@return a Bic object holding the value represented by the string argument.
@throws BicFormatException if the String doesn't contain parsable Bic.
UnsupportedCountryException if bic's country is not supported. | [
"Returns",
"a",
"Bic",
"object",
"holding",
"the",
"value",
"of",
"the",
"specified",
"String",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/Bic.java#L40-L44 | train |
arturmkrtchyan/iban4j | src/main/java/org/iban4j/BicUtil.java | BicUtil.validate | public static void validate(final String bic) throws BicFormatException,
UnsupportedCountryException {
try {
validateEmpty(bic);
validateLength(bic);
validateCase(bic);
validateBankCode(bic);
validateCountryCode(bic);
validateLocationCode(bic);
if(hasBranchCode(bic)) {
validateBranchCode(bic);
}
} catch (UnsupportedCountryException e) {
throw e;
} catch (RuntimeException e) {
throw new BicFormatException(UNKNOWN, e.getMessage());
}
} | java | public static void validate(final String bic) throws BicFormatException,
UnsupportedCountryException {
try {
validateEmpty(bic);
validateLength(bic);
validateCase(bic);
validateBankCode(bic);
validateCountryCode(bic);
validateLocationCode(bic);
if(hasBranchCode(bic)) {
validateBranchCode(bic);
}
} catch (UnsupportedCountryException e) {
throw e;
} catch (RuntimeException e) {
throw new BicFormatException(UNKNOWN, e.getMessage());
}
} | [
"public",
"static",
"void",
"validate",
"(",
"final",
"String",
"bic",
")",
"throws",
"BicFormatException",
",",
"UnsupportedCountryException",
"{",
"try",
"{",
"validateEmpty",
"(",
"bic",
")",
";",
"validateLength",
"(",
"bic",
")",
";",
"validateCase",
"(",
... | Validates bic.
@param bic to be validated.
@throws BicFormatException if bic is invalid.
UnsupportedCountryException if bic's country is not supported. | [
"Validates",
"bic",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/BicUtil.java#L44-L62 | train |
detro/ghostdriver | binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriver.java | PhantomJSDriver.getScreenshotAs | @Override
public <X> X getScreenshotAs(OutputType<X> target) {
// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)
String base64 = (String) execute(DriverCommand.SCREENSHOT).getValue();
return target.convertFromBase64Png(base64);
} | java | @Override
public <X> X getScreenshotAs(OutputType<X> target) {
// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)
String base64 = (String) execute(DriverCommand.SCREENSHOT).getValue();
return target.convertFromBase64Png(base64);
} | [
"@",
"Override",
"public",
"<",
"X",
">",
"X",
"getScreenshotAs",
"(",
"OutputType",
"<",
"X",
">",
"target",
")",
"{",
"// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)",
"String",
"base64",
"=",
"(",
"String",
")",
"execute",
... | Take screenshot of the current window.
@param target The target type/format of the Screenshot
@return Screenshot of current window, in the requested format | [
"Take",
"screenshot",
"of",
"the",
"current",
"window",
"."
] | fe3063d52f47ec2781d43970452595c42f729ebf | https://github.com/detro/ghostdriver/blob/fe3063d52f47ec2781d43970452595c42f729ebf/binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriver.java#L134-L139 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.sound | public PayloadBuilder sound(final String sound) {
if (sound != null) {
aps.put("sound", sound);
} else {
aps.remove("sound");
}
return this;
} | java | public PayloadBuilder sound(final String sound) {
if (sound != null) {
aps.put("sound", sound);
} else {
aps.remove("sound");
}
return this;
} | [
"public",
"PayloadBuilder",
"sound",
"(",
"final",
"String",
"sound",
")",
"{",
"if",
"(",
"sound",
"!=",
"null",
")",
"{",
"aps",
".",
"put",
"(",
"\"sound\"",
",",
"sound",
")",
";",
"}",
"else",
"{",
"aps",
".",
"remove",
"(",
"\"sound\"",
")",
... | Sets the alert sound to be played.
Passing {@code null} disables the notification sound.
@param sound the file name or song name to be played
when receiving the notification
@return this | [
"Sets",
"the",
"alert",
"sound",
"to",
"be",
"played",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L153-L160 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.category | public PayloadBuilder category(final String category) {
if (category != null) {
aps.put("category", category);
} else {
aps.remove("category");
}
return this;
} | java | public PayloadBuilder category(final String category) {
if (category != null) {
aps.put("category", category);
} else {
aps.remove("category");
}
return this;
} | [
"public",
"PayloadBuilder",
"category",
"(",
"final",
"String",
"category",
")",
"{",
"if",
"(",
"category",
"!=",
"null",
")",
"{",
"aps",
".",
"put",
"(",
"\"category\"",
",",
"category",
")",
";",
"}",
"else",
"{",
"aps",
".",
"remove",
"(",
"\"cate... | Sets the category of the notification for iOS8 notification
actions. See 13 minutes into "What's new in iOS Notifications"
Passing {@code null} removes the category.
@param category the name of the category supplied to the app
when receiving the notification
@return this | [
"Sets",
"the",
"category",
"of",
"the",
"notification",
"for",
"iOS8",
"notification",
"actions",
".",
"See",
"13",
"minutes",
"into",
"What",
"s",
"new",
"in",
"iOS",
"Notifications"
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L172-L179 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.customField | public PayloadBuilder customField(final String key, final Object value) {
root.put(key, value);
return this;
} | java | public PayloadBuilder customField(final String key, final Object value) {
root.put(key, value);
return this;
} | [
"public",
"PayloadBuilder",
"customField",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"value",
")",
"{",
"root",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets any application-specific custom fields. The values
are presented to the application and the iPhone doesn't
display them automatically.
This can be used to pass specific values (urls, ids, etc) to
the application in addition to the notification message
itself.
@param key the custom field name
@param value the custom field value
@return this | [
"Sets",
"any",
"application",
"-",
"specific",
"custom",
"fields",
".",
"The",
"values",
"are",
"presented",
"to",
"the",
"application",
"and",
"the",
"iPhone",
"doesn",
"t",
"display",
"them",
"automatically",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L327-L330 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.resizeAlertBody | public PayloadBuilder resizeAlertBody(final int payloadLength, final String postfix) {
int currLength = length();
if (currLength <= payloadLength) {
return this;
}
// now we are sure that truncation is required
String body = (String)customAlert.get("body");
final int acceptableSize = Utilities.toUTF8Bytes(body).length
- (currLength - payloadLength
+ Utilities.toUTF8Bytes(postfix).length);
body = Utilities.truncateWhenUTF8(body, acceptableSize) + postfix;
// set it back
customAlert.put("body", body);
// calculate the length again
currLength = length();
if(currLength > payloadLength) {
// string is still too long, just remove the body as the body is
// anyway not the cause OR the postfix might be too long
customAlert.remove("body");
}
return this;
} | java | public PayloadBuilder resizeAlertBody(final int payloadLength, final String postfix) {
int currLength = length();
if (currLength <= payloadLength) {
return this;
}
// now we are sure that truncation is required
String body = (String)customAlert.get("body");
final int acceptableSize = Utilities.toUTF8Bytes(body).length
- (currLength - payloadLength
+ Utilities.toUTF8Bytes(postfix).length);
body = Utilities.truncateWhenUTF8(body, acceptableSize) + postfix;
// set it back
customAlert.put("body", body);
// calculate the length again
currLength = length();
if(currLength > payloadLength) {
// string is still too long, just remove the body as the body is
// anyway not the cause OR the postfix might be too long
customAlert.remove("body");
}
return this;
} | [
"public",
"PayloadBuilder",
"resizeAlertBody",
"(",
"final",
"int",
"payloadLength",
",",
"final",
"String",
"postfix",
")",
"{",
"int",
"currLength",
"=",
"length",
"(",
")",
";",
"if",
"(",
"currLength",
"<=",
"payloadLength",
")",
"{",
"return",
"this",
"... | Shrinks the alert message body so that the resulting payload
message fits within the passed expected payload length.
This method performs best-effort approach, and its behavior
is unspecified when handling alerts where the payload
without body is already longer than the permitted size, or
if the break occurs within word.
@param payloadLength the expected max size of the payload
@param postfix for the truncated body, e.g. "..."
@return this | [
"Shrinks",
"the",
"alert",
"message",
"body",
"so",
"that",
"the",
"resulting",
"payload",
"message",
"fits",
"within",
"the",
"passed",
"expected",
"payload",
"length",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L401-L428 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.build | public String build() {
if (!root.containsKey("mdm")) {
insertCustomAlert();
root.put("aps", aps);
}
try {
return mapper.writeValueAsString(root);
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | java | public String build() {
if (!root.containsKey("mdm")) {
insertCustomAlert();
root.put("aps", aps);
}
try {
return mapper.writeValueAsString(root);
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"String",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"root",
".",
"containsKey",
"(",
"\"mdm\"",
")",
")",
"{",
"insertCustomAlert",
"(",
")",
";",
"root",
".",
"put",
"(",
"\"aps\"",
",",
"aps",
")",
";",
"}",
"try",
"{",
"return",
"mapper"... | Returns the JSON String representation of the payload
according to Apple APNS specification
@return the String representation as expected by Apple | [
"Returns",
"the",
"JSON",
"String",
"representation",
"of",
"the",
"payload",
"according",
"to",
"Apple",
"APNS",
"specification"
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L468-L478 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withSocksProxy | public ApnsServiceBuilder withSocksProxy(String host, int port) {
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
new InetSocketAddress(host, port));
return withProxy(proxy);
} | java | public ApnsServiceBuilder withSocksProxy(String host, int port) {
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
new InetSocketAddress(host, port));
return withProxy(proxy);
} | [
"public",
"ApnsServiceBuilder",
"withSocksProxy",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"Proxy",
"proxy",
"=",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"SOCKS",
",",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
")",
";... | Specify the address of the SOCKS proxy the connection should
use.
<p>Read the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html">
Java Networking and Proxies</a> guide to understand the
proxies complexity.
<p>Be aware that this method only handles SOCKS proxies, not
HTTPS proxies. Use {@link #withProxy(Proxy)} instead.
@param host the hostname of the SOCKS proxy
@param port the port of the SOCKS proxy server
@return this | [
"Specify",
"the",
"address",
"of",
"the",
"SOCKS",
"proxy",
"the",
"connection",
"should",
"use",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L469-L473 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withAuthProxy | public ApnsServiceBuilder withAuthProxy(Proxy proxy, String proxyUsername, String proxyPassword) {
this.proxy = proxy;
this.proxyUsername = proxyUsername;
this.proxyPassword = proxyPassword;
return this;
} | java | public ApnsServiceBuilder withAuthProxy(Proxy proxy, String proxyUsername, String proxyPassword) {
this.proxy = proxy;
this.proxyUsername = proxyUsername;
this.proxyPassword = proxyPassword;
return this;
} | [
"public",
"ApnsServiceBuilder",
"withAuthProxy",
"(",
"Proxy",
"proxy",
",",
"String",
"proxyUsername",
",",
"String",
"proxyPassword",
")",
"{",
"this",
".",
"proxy",
"=",
"proxy",
";",
"this",
".",
"proxyUsername",
"=",
"proxyUsername",
";",
"this",
".",
"pr... | Specify the proxy and the authentication parameters to be used
to establish the connections to Apple Servers.
<p>Read the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html">
Java Networking and Proxies</a> guide to understand the
proxies complexity.
@param proxy the proxy object to be used to create connections
@param proxyUsername a String object representing the username of the proxy server
@param proxyPassword a String object representing the password of the proxy server
@return this | [
"Specify",
"the",
"proxy",
"and",
"the",
"authentication",
"parameters",
"to",
"be",
"used",
"to",
"establish",
"the",
"connections",
"to",
"Apple",
"Servers",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L488-L493 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withProxySocket | @Deprecated
public ApnsServiceBuilder withProxySocket(Socket proxySocket) {
return this.withProxy(new Proxy(Proxy.Type.SOCKS,
proxySocket.getRemoteSocketAddress()));
} | java | @Deprecated
public ApnsServiceBuilder withProxySocket(Socket proxySocket) {
return this.withProxy(new Proxy(Proxy.Type.SOCKS,
proxySocket.getRemoteSocketAddress()));
} | [
"@",
"Deprecated",
"public",
"ApnsServiceBuilder",
"withProxySocket",
"(",
"Socket",
"proxySocket",
")",
"{",
"return",
"this",
".",
"withProxy",
"(",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"SOCKS",
",",
"proxySocket",
".",
"getRemoteSocketAddress",
"("... | Specify the socket to be used as underlying socket to connect
to the APN service.
This assumes that the socket connects to a SOCKS proxy.
@deprecated use {@link ApnsServiceBuilder#withProxy(Proxy)} instead
@param proxySocket the underlying socket for connections
@return this | [
"Specify",
"the",
"socket",
"to",
"be",
"used",
"as",
"underlying",
"socket",
"to",
"connect",
"to",
"the",
"APN",
"service",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L533-L537 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withDelegate | public ApnsServiceBuilder withDelegate(ApnsDelegate delegate) {
this.delegate = delegate == null ? ApnsDelegate.EMPTY : delegate;
return this;
} | java | public ApnsServiceBuilder withDelegate(ApnsDelegate delegate) {
this.delegate = delegate == null ? ApnsDelegate.EMPTY : delegate;
return this;
} | [
"public",
"ApnsServiceBuilder",
"withDelegate",
"(",
"ApnsDelegate",
"delegate",
")",
"{",
"this",
".",
"delegate",
"=",
"delegate",
"==",
"null",
"?",
"ApnsDelegate",
".",
"EMPTY",
":",
"delegate",
";",
"return",
"this",
";",
"}"
] | Sets the delegate of the service, that gets notified of the
status of message delivery.
Note: This option has no effect when using non-blocking
connections. | [
"Sets",
"the",
"delegate",
"of",
"the",
"service",
"that",
"gets",
"notified",
"of",
"the",
"status",
"of",
"message",
"delivery",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L679-L682 | train |
notnoop/java-apns | src/main/java/com/notnoop/apns/SimpleApnsNotification.java | SimpleApnsNotification.length | public int length() {
int length = 1 + 2 + deviceToken.length + 2 + payload.length;
final int marshalledLength = marshall().length;
assert marshalledLength == length;
return length;
} | java | public int length() {
int length = 1 + 2 + deviceToken.length + 2 + payload.length;
final int marshalledLength = marshall().length;
assert marshalledLength == length;
return length;
} | [
"public",
"int",
"length",
"(",
")",
"{",
"int",
"length",
"=",
"1",
"+",
"2",
"+",
"deviceToken",
".",
"length",
"+",
"2",
"+",
"payload",
".",
"length",
";",
"final",
"int",
"marshalledLength",
"=",
"marshall",
"(",
")",
".",
"length",
";",
"assert... | Returns the length of the message in bytes as it is encoded on the wire.
Apple require the message to be of length 255 bytes or less.
@return length of encoded message in bytes | [
"Returns",
"the",
"length",
"of",
"the",
"message",
"in",
"bytes",
"as",
"it",
"is",
"encoded",
"on",
"the",
"wire",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/SimpleApnsNotification.java#L124-L129 | train |
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java | MultiPageStack.setPadding | public void setPadding(float padding, Layout.Axis axis) {
OrientedLayout layout = null;
switch(axis) {
case X:
layout = mShiftLayout;
break;
case Y:
layout = mShiftLayout;
break;
case Z:
layout = mStackLayout;
break;
}
if (layout != null) {
if (!equal(layout.getDividerPadding(axis), padding)) {
layout.setDividerPadding(padding, axis);
if (layout.getOrientationAxis() == axis) {
requestLayout();
}
}
}
} | java | public void setPadding(float padding, Layout.Axis axis) {
OrientedLayout layout = null;
switch(axis) {
case X:
layout = mShiftLayout;
break;
case Y:
layout = mShiftLayout;
break;
case Z:
layout = mStackLayout;
break;
}
if (layout != null) {
if (!equal(layout.getDividerPadding(axis), padding)) {
layout.setDividerPadding(padding, axis);
if (layout.getOrientationAxis() == axis) {
requestLayout();
}
}
}
} | [
"public",
"void",
"setPadding",
"(",
"float",
"padding",
",",
"Layout",
".",
"Axis",
"axis",
")",
"{",
"OrientedLayout",
"layout",
"=",
"null",
";",
"switch",
"(",
"axis",
")",
"{",
"case",
"X",
":",
"layout",
"=",
"mShiftLayout",
";",
"break",
";",
"c... | Sets padding between the pages
@param padding
@param axis | [
"Sets",
"padding",
"between",
"the",
"pages"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java#L80-L103 | train |
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java | MultiPageStack.setShiftOrientation | public void setShiftOrientation(OrientedLayout.Orientation orientation) {
if (mShiftLayout.getOrientation() != orientation &&
orientation != OrientedLayout.Orientation.STACK) {
mShiftLayout.setOrientation(orientation);
requestLayout();
}
} | java | public void setShiftOrientation(OrientedLayout.Orientation orientation) {
if (mShiftLayout.getOrientation() != orientation &&
orientation != OrientedLayout.Orientation.STACK) {
mShiftLayout.setOrientation(orientation);
requestLayout();
}
} | [
"public",
"void",
"setShiftOrientation",
"(",
"OrientedLayout",
".",
"Orientation",
"orientation",
")",
"{",
"if",
"(",
"mShiftLayout",
".",
"getOrientation",
"(",
")",
"!=",
"orientation",
"&&",
"orientation",
"!=",
"OrientedLayout",
".",
"Orientation",
".",
"STA... | Sets page shift orientation. The pages might be shifted horizontally or vertically relative
to each other to make the content of each page on the screen at least partially visible
@param orientation | [
"Sets",
"page",
"shift",
"orientation",
".",
"The",
"pages",
"might",
"be",
"shifted",
"horizontally",
"or",
"vertically",
"relative",
"to",
"each",
"other",
"to",
"make",
"the",
"content",
"of",
"each",
"page",
"on",
"the",
"screen",
"at",
"least",
"partial... | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java#L110-L116 | train |
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java | TouchManager.removeHandlerFor | public boolean removeHandlerFor(final GVRSceneObject sceneObject) {
sceneObject.detachComponent(GVRCollider.getComponentType());
return null != touchHandlers.remove(sceneObject);
} | java | public boolean removeHandlerFor(final GVRSceneObject sceneObject) {
sceneObject.detachComponent(GVRCollider.getComponentType());
return null != touchHandlers.remove(sceneObject);
} | [
"public",
"boolean",
"removeHandlerFor",
"(",
"final",
"GVRSceneObject",
"sceneObject",
")",
"{",
"sceneObject",
".",
"detachComponent",
"(",
"GVRCollider",
".",
"getComponentType",
"(",
")",
")",
";",
"return",
"null",
"!=",
"touchHandlers",
".",
"remove",
"(",
... | Makes the object unpickable and removes the touch handler for it
@param sceneObject
@return true if the handler has been successfully removed | [
"Makes",
"the",
"object",
"unpickable",
"and",
"removes",
"the",
"touch",
"handler",
"for",
"it"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java#L93-L96 | train |
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java | TouchManager.makePickable | public void makePickable(GVRSceneObject sceneObject) {
try {
GVRMeshCollider collider = new GVRMeshCollider(sceneObject.getGVRContext(), false);
sceneObject.attachComponent(collider);
} catch (Exception e) {
// Possible that some objects (X3D panel nodes) are without mesh
Log.e(Log.SUBSYSTEM.INPUT, TAG, "makePickable(): possible that some objects (X3D panel nodes) are without mesh!");
}
} | java | public void makePickable(GVRSceneObject sceneObject) {
try {
GVRMeshCollider collider = new GVRMeshCollider(sceneObject.getGVRContext(), false);
sceneObject.attachComponent(collider);
} catch (Exception e) {
// Possible that some objects (X3D panel nodes) are without mesh
Log.e(Log.SUBSYSTEM.INPUT, TAG, "makePickable(): possible that some objects (X3D panel nodes) are without mesh!");
}
} | [
"public",
"void",
"makePickable",
"(",
"GVRSceneObject",
"sceneObject",
")",
"{",
"try",
"{",
"GVRMeshCollider",
"collider",
"=",
"new",
"GVRMeshCollider",
"(",
"sceneObject",
".",
"getGVRContext",
"(",
")",
",",
"false",
")",
";",
"sceneObject",
".",
"attachCom... | Makes the scene object pickable by eyes. However, the object has to be touchable to process
the touch events.
@param sceneObject | [
"Makes",
"the",
"scene",
"object",
"pickable",
"by",
"eyes",
".",
"However",
"the",
"object",
"has",
"to",
"be",
"touchable",
"to",
"process",
"the",
"touch",
"events",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java#L104-L112 | train |
Samsung/GearVRf | GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableUtility.java | GearWearableUtility.isInCircle | static boolean isInCircle(float x, float y, float centerX, float centerY, float
radius) {
return Math.abs(x - centerX) < radius && Math.abs(y - centerY) < radius;
} | java | static boolean isInCircle(float x, float y, float centerX, float centerY, float
radius) {
return Math.abs(x - centerX) < radius && Math.abs(y - centerY) < radius;
} | [
"static",
"boolean",
"isInCircle",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"centerX",
",",
"float",
"centerY",
",",
"float",
"radius",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"x",
"-",
"centerX",
")",
"<",
"radius",
"&&",
"Math",
"."... | Check if a position is within a circle
@param x x position
@param y y position
@param centerX center x of circle
@param centerY center y of circle
@return true if within circle, false otherwise | [
"Check",
"if",
"a",
"position",
"is",
"within",
"a",
"circle"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableUtility.java#L13-L16 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.