id
int32 0
165k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
9,600
|
upwork/java-upwork
|
src/com/Upwork/api/Routers/Messages.java
|
Messages.sendMessageToRoom
|
public JSONObject sendMessageToRoom(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.post("/messages/v3/" + company + "/rooms/" + roomId + "/stories", params);
}
|
java
|
public JSONObject sendMessageToRoom(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.post("/messages/v3/" + company + "/rooms/" + roomId + "/stories", params);
}
|
[
"public",
"JSONObject",
"sendMessageToRoom",
"(",
"String",
"company",
",",
"String",
"roomId",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"post",
"(",
"\"/messages/v3/\"",
"+",
"company",
"+",
"\"/rooms/\"",
"+",
"roomId",
"+",
"\"/stories\"",
",",
"params",
")",
";",
"}"
] |
Send a message to a room
@param company Company ID
@param roomId Room ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
|
[
"Send",
"a",
"message",
"to",
"a",
"room"
] |
342297161503a74e9e0bddbd381ab5eebf4dc454
|
https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Messages.java#L126-L128
|
9,601
|
upwork/java-upwork
|
src/com/Upwork/api/Routers/Messages.java
|
Messages.updateRoomSettings
|
public JSONObject updateRoomSettings(String company, String roomId, String username, HashMap<String, String> params) throws JSONException {
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId + "/users/" + username, params);
}
|
java
|
public JSONObject updateRoomSettings(String company, String roomId, String username, HashMap<String, String> params) throws JSONException {
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId + "/users/" + username, params);
}
|
[
"public",
"JSONObject",
"updateRoomSettings",
"(",
"String",
"company",
",",
"String",
"roomId",
",",
"String",
"username",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"put",
"(",
"\"/messages/v3/\"",
"+",
"company",
"+",
"\"/rooms/\"",
"+",
"roomId",
"+",
"\"/users/\"",
"+",
"username",
",",
"params",
")",
";",
"}"
] |
Update a room settings
@param company Company ID
@param roomId Room ID
@param username User ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
|
[
"Update",
"a",
"room",
"settings"
] |
342297161503a74e9e0bddbd381ab5eebf4dc454
|
https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Messages.java#L140-L142
|
9,602
|
upwork/java-upwork
|
src/com/Upwork/api/Routers/Messages.java
|
Messages.updateRoomMetadata
|
public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId, params);
}
|
java
|
public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId, params);
}
|
[
"public",
"JSONObject",
"updateRoomMetadata",
"(",
"String",
"company",
",",
"String",
"roomId",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"put",
"(",
"\"/messages/v3/\"",
"+",
"company",
"+",
"\"/rooms/\"",
"+",
"roomId",
",",
"params",
")",
";",
"}"
] |
Update the metadata of a room
@param company Company ID
@param roomId Room ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
|
[
"Update",
"the",
"metadata",
"of",
"a",
"room"
] |
342297161503a74e9e0bddbd381ab5eebf4dc454
|
https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Messages.java#L153-L155
|
9,603
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java
|
EventBasedWebSocketListener.addOpenHandler
|
@Nonnull
public final HandlerRegistration addOpenHandler( @Nonnull final OpenEvent.Handler handler )
{
return _eventBus.addHandler( OpenEvent.getType(), handler );
}
|
java
|
@Nonnull
public final HandlerRegistration addOpenHandler( @Nonnull final OpenEvent.Handler handler )
{
return _eventBus.addHandler( OpenEvent.getType(), handler );
}
|
[
"@",
"Nonnull",
"public",
"final",
"HandlerRegistration",
"addOpenHandler",
"(",
"@",
"Nonnull",
"final",
"OpenEvent",
".",
"Handler",
"handler",
")",
"{",
"return",
"_eventBus",
".",
"addHandler",
"(",
"OpenEvent",
".",
"getType",
"(",
")",
",",
"handler",
")",
";",
"}"
] |
Add listener for open events.
@param handler the event handler.
@return the HandlerRegistration that manages the listener.
|
[
"Add",
"listener",
"for",
"open",
"events",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java#L45-L49
|
9,604
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java
|
EventBasedWebSocketListener.addCloseHandler
|
@Nonnull
public final HandlerRegistration addCloseHandler( @Nonnull final CloseEvent.Handler handler )
{
return _eventBus.addHandler( CloseEvent.getType(), handler );
}
|
java
|
@Nonnull
public final HandlerRegistration addCloseHandler( @Nonnull final CloseEvent.Handler handler )
{
return _eventBus.addHandler( CloseEvent.getType(), handler );
}
|
[
"@",
"Nonnull",
"public",
"final",
"HandlerRegistration",
"addCloseHandler",
"(",
"@",
"Nonnull",
"final",
"CloseEvent",
".",
"Handler",
"handler",
")",
"{",
"return",
"_eventBus",
".",
"addHandler",
"(",
"CloseEvent",
".",
"getType",
"(",
")",
",",
"handler",
")",
";",
"}"
] |
Add listener for close events.
@param handler the event handler.
@return the HandlerRegistration that manages the listener.
|
[
"Add",
"listener",
"for",
"close",
"events",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java#L57-L61
|
9,605
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java
|
EventBasedWebSocketListener.addMessageHandler
|
@Nonnull
public final HandlerRegistration addMessageHandler( @Nonnull final MessageEvent.Handler handler )
{
return _eventBus.addHandler( MessageEvent.getType(), handler );
}
|
java
|
@Nonnull
public final HandlerRegistration addMessageHandler( @Nonnull final MessageEvent.Handler handler )
{
return _eventBus.addHandler( MessageEvent.getType(), handler );
}
|
[
"@",
"Nonnull",
"public",
"final",
"HandlerRegistration",
"addMessageHandler",
"(",
"@",
"Nonnull",
"final",
"MessageEvent",
".",
"Handler",
"handler",
")",
"{",
"return",
"_eventBus",
".",
"addHandler",
"(",
"MessageEvent",
".",
"getType",
"(",
")",
",",
"handler",
")",
";",
"}"
] |
Add listener for message events.
@param handler the event handler.
@return the HandlerRegistration that manages the listener.
|
[
"Add",
"listener",
"for",
"message",
"events",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/event/EventBasedWebSocketListener.java#L69-L73
|
9,606
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.extractClassName
|
public static String extractClassName(Description description) {
final String displayName = description.getDisplayName();
final String regex = "^" + "[^\\(\\)]+" // non-parens
+ "\\((" // then an open-paren (start matching a group)
+ "[^\\\\(\\\\)]+" // non-parens
+ ")\\)" + "$";
// System.out.println(regex);
final Pattern parens = Pattern.compile(regex); // then a close-paren
// (end group match)
final Matcher m = parens.matcher(displayName);
if (!m.find()) {
return displayName;
}
return m.group(1);
}
|
java
|
public static String extractClassName(Description description) {
final String displayName = description.getDisplayName();
final String regex = "^" + "[^\\(\\)]+" // non-parens
+ "\\((" // then an open-paren (start matching a group)
+ "[^\\\\(\\\\)]+" // non-parens
+ ")\\)" + "$";
// System.out.println(regex);
final Pattern parens = Pattern.compile(regex); // then a close-paren
// (end group match)
final Matcher m = parens.matcher(displayName);
if (!m.find()) {
return displayName;
}
return m.group(1);
}
|
[
"public",
"static",
"String",
"extractClassName",
"(",
"Description",
"description",
")",
"{",
"final",
"String",
"displayName",
"=",
"description",
".",
"getDisplayName",
"(",
")",
";",
"final",
"String",
"regex",
"=",
"\"^\"",
"+",
"\"[^\\\\(\\\\)]+\"",
"// non-parens\r",
"+",
"\"\\\\((\"",
"// then an open-paren (start matching a group)\r",
"+",
"\"[^\\\\\\\\(\\\\\\\\)]+\"",
"// non-parens\r",
"+",
"\")\\\\)\"",
"+",
"\"$\"",
";",
"// System.out.println(regex);\r",
"final",
"Pattern",
"parens",
"=",
"Pattern",
".",
"compile",
"(",
"regex",
")",
";",
"// then a close-paren\r",
"// (end group match)\r",
"final",
"Matcher",
"m",
"=",
"parens",
".",
"matcher",
"(",
"displayName",
")",
";",
"if",
"(",
"!",
"m",
".",
"find",
"(",
")",
")",
"{",
"return",
"displayName",
";",
"}",
"return",
"m",
".",
"group",
"(",
"1",
")",
";",
"}"
] |
Extract the class name from a given junit test description
@param description
@return a class name
|
[
"Extract",
"the",
"class",
"name",
"from",
"a",
"given",
"junit",
"test",
"description"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L139-L154
|
9,607
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.extractSimpleClassName
|
public static String extractSimpleClassName(Description description) {
String simpleClassName = null;
final String className = extractClassName(description);
final String[] splitClassName = className.split("\\.");
if (splitClassName.length > 0) {
simpleClassName = splitClassName[splitClassName.length - 1];
}
return simpleClassName;
}
|
java
|
public static String extractSimpleClassName(Description description) {
String simpleClassName = null;
final String className = extractClassName(description);
final String[] splitClassName = className.split("\\.");
if (splitClassName.length > 0) {
simpleClassName = splitClassName[splitClassName.length - 1];
}
return simpleClassName;
}
|
[
"public",
"static",
"String",
"extractSimpleClassName",
"(",
"Description",
"description",
")",
"{",
"String",
"simpleClassName",
"=",
"null",
";",
"final",
"String",
"className",
"=",
"extractClassName",
"(",
"description",
")",
";",
"final",
"String",
"[",
"]",
"splitClassName",
"=",
"className",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"if",
"(",
"splitClassName",
".",
"length",
">",
"0",
")",
"{",
"simpleClassName",
"=",
"splitClassName",
"[",
"splitClassName",
".",
"length",
"-",
"1",
"]",
";",
"}",
"return",
"simpleClassName",
";",
"}"
] |
Extract the simple class name from a given junit test description
@param description
@return a simple class name
|
[
"Extract",
"the",
"simple",
"class",
"name",
"from",
"a",
"given",
"junit",
"test",
"description"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L162-L172
|
9,608
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.extractMethodName
|
public static String extractMethodName(Description description) {
String methodName = null;
final String[] splitDisplayName = description.getDisplayName().split("\\(");
if (splitDisplayName.length > 0) {
methodName = splitDisplayName[0];
}
return methodName;
}
|
java
|
public static String extractMethodName(Description description) {
String methodName = null;
final String[] splitDisplayName = description.getDisplayName().split("\\(");
if (splitDisplayName.length > 0) {
methodName = splitDisplayName[0];
}
return methodName;
}
|
[
"public",
"static",
"String",
"extractMethodName",
"(",
"Description",
"description",
")",
"{",
"String",
"methodName",
"=",
"null",
";",
"final",
"String",
"[",
"]",
"splitDisplayName",
"=",
"description",
".",
"getDisplayName",
"(",
")",
".",
"split",
"(",
"\"\\\\(\"",
")",
";",
"if",
"(",
"splitDisplayName",
".",
"length",
">",
"0",
")",
"{",
"methodName",
"=",
"splitDisplayName",
"[",
"0",
"]",
";",
"}",
"return",
"methodName",
";",
"}"
] |
Get the tested method name
@param description
@return tested methode name
|
[
"Get",
"the",
"tested",
"method",
"name"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L180-L189
|
9,609
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getLine
|
public static String getLine(JUnitTestData testMethod) {
String line = "~";
Throwable testException = testMethod.getFailException();
if (testException != null) {
StringBuilder lookFor = new StringBuilder();
lookFor.append(extractClassName(testMethod.getDescription()));
lookFor.append('.');
lookFor.append(extractMethodName(testMethod.getDescription()));
lookFor.append('(');
lookFor.append(extractSimpleClassName(testMethod.getDescription()));
lookFor.append(".java:");
StackTraceElement[] els = testException.getStackTrace();
for (int i = 0; i < els.length; i++) {
StackTraceElement el = els[i];
line = getLineNumberFromExceptionTraceLine(el.toString(),
lookFor.toString());
if (line.equals("") == Boolean.FALSE) {
break;
}
}
}
return line;
}
|
java
|
public static String getLine(JUnitTestData testMethod) {
String line = "~";
Throwable testException = testMethod.getFailException();
if (testException != null) {
StringBuilder lookFor = new StringBuilder();
lookFor.append(extractClassName(testMethod.getDescription()));
lookFor.append('.');
lookFor.append(extractMethodName(testMethod.getDescription()));
lookFor.append('(');
lookFor.append(extractSimpleClassName(testMethod.getDescription()));
lookFor.append(".java:");
StackTraceElement[] els = testException.getStackTrace();
for (int i = 0; i < els.length; i++) {
StackTraceElement el = els[i];
line = getLineNumberFromExceptionTraceLine(el.toString(),
lookFor.toString());
if (line.equals("") == Boolean.FALSE) {
break;
}
}
}
return line;
}
|
[
"public",
"static",
"String",
"getLine",
"(",
"JUnitTestData",
"testMethod",
")",
"{",
"String",
"line",
"=",
"\"~\"",
";",
"Throwable",
"testException",
"=",
"testMethod",
".",
"getFailException",
"(",
")",
";",
"if",
"(",
"testException",
"!=",
"null",
")",
"{",
"StringBuilder",
"lookFor",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"lookFor",
".",
"append",
"(",
"extractClassName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
")",
";",
"lookFor",
".",
"append",
"(",
"'",
"'",
")",
";",
"lookFor",
".",
"append",
"(",
"extractMethodName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
")",
";",
"lookFor",
".",
"append",
"(",
"'",
"'",
")",
";",
"lookFor",
".",
"append",
"(",
"extractSimpleClassName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
")",
";",
"lookFor",
".",
"append",
"(",
"\".java:\"",
")",
";",
"StackTraceElement",
"[",
"]",
"els",
"=",
"testException",
".",
"getStackTrace",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"els",
".",
"length",
";",
"i",
"++",
")",
"{",
"StackTraceElement",
"el",
"=",
"els",
"[",
"i",
"]",
";",
"line",
"=",
"getLineNumberFromExceptionTraceLine",
"(",
"el",
".",
"toString",
"(",
")",
",",
"lookFor",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"line",
".",
"equals",
"(",
"\"\"",
")",
"==",
"Boolean",
".",
"FALSE",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"line",
";",
"}"
] |
Get the line of the error in the exception info
@param testMethod
@return line of the error in the exception info
|
[
"Get",
"the",
"line",
"of",
"the",
"error",
"in",
"the",
"exception",
"info"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L217-L241
|
9,610
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getLineNumberFromExceptionTraceLine
|
public static String getLineNumberFromExceptionTraceLine(String exceptionTraceLine,
String substrToSearch) {
String lineNumber = "";
int index = exceptionTraceLine.indexOf(substrToSearch);
if (index >= 0) {
int length = substrToSearch.length() + index;
if (exceptionTraceLine.lastIndexOf(')') > length) {
lineNumber = exceptionTraceLine
.substring(length, exceptionTraceLine.lastIndexOf(')'));
}
}
return lineNumber;
}
|
java
|
public static String getLineNumberFromExceptionTraceLine(String exceptionTraceLine,
String substrToSearch) {
String lineNumber = "";
int index = exceptionTraceLine.indexOf(substrToSearch);
if (index >= 0) {
int length = substrToSearch.length() + index;
if (exceptionTraceLine.lastIndexOf(')') > length) {
lineNumber = exceptionTraceLine
.substring(length, exceptionTraceLine.lastIndexOf(')'));
}
}
return lineNumber;
}
|
[
"public",
"static",
"String",
"getLineNumberFromExceptionTraceLine",
"(",
"String",
"exceptionTraceLine",
",",
"String",
"substrToSearch",
")",
"{",
"String",
"lineNumber",
"=",
"\"\"",
";",
"int",
"index",
"=",
"exceptionTraceLine",
".",
"indexOf",
"(",
"substrToSearch",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"int",
"length",
"=",
"substrToSearch",
".",
"length",
"(",
")",
"+",
"index",
";",
"if",
"(",
"exceptionTraceLine",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
">",
"length",
")",
"{",
"lineNumber",
"=",
"exceptionTraceLine",
".",
"substring",
"(",
"length",
",",
"exceptionTraceLine",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"}",
"}",
"return",
"lineNumber",
";",
"}"
] |
Get the error line number from the exception stack trace
@param exceptionTraceLine
@param substrToSearch
@return error line number
|
[
"Get",
"the",
"error",
"line",
"number",
"from",
"the",
"exception",
"stack",
"trace"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L250-L262
|
9,611
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getError
|
public static String getError(JUnitTestData testMethod) {
String error = "~";
Throwable t = testMethod.getFailException();
if (t != null) {
error = t.getMessage();
}
return error;
}
|
java
|
public static String getError(JUnitTestData testMethod) {
String error = "~";
Throwable t = testMethod.getFailException();
if (t != null) {
error = t.getMessage();
}
return error;
}
|
[
"public",
"static",
"String",
"getError",
"(",
"JUnitTestData",
"testMethod",
")",
"{",
"String",
"error",
"=",
"\"~\"",
";",
"Throwable",
"t",
"=",
"testMethod",
".",
"getFailException",
"(",
")",
";",
"if",
"(",
"t",
"!=",
"null",
")",
"{",
"error",
"=",
"t",
".",
"getMessage",
"(",
")",
";",
"}",
"return",
"error",
";",
"}"
] |
Get the error message from a given failed JUnit test result
@param testMethod
@return error message from a given failed JUnit test result
|
[
"Get",
"the",
"error",
"message",
"from",
"a",
"given",
"failed",
"JUnit",
"test",
"result"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L270-L277
|
9,612
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getSeverity
|
public static String getSeverity(JUnitTestData testMethod) {
String severity = "~";
if (testMethod.getFailException() != null) {
severity = "High";
}
return severity;
}
|
java
|
public static String getSeverity(JUnitTestData testMethod) {
String severity = "~";
if (testMethod.getFailException() != null) {
severity = "High";
}
return severity;
}
|
[
"public",
"static",
"String",
"getSeverity",
"(",
"JUnitTestData",
"testMethod",
")",
"{",
"String",
"severity",
"=",
"\"~\"",
";",
"if",
"(",
"testMethod",
".",
"getFailException",
"(",
")",
"!=",
"null",
")",
"{",
"severity",
"=",
"\"High\"",
";",
"}",
"return",
"severity",
";",
"}"
] |
Get the severity of the test
@param testMethod
@return severity
|
[
"Get",
"the",
"severity",
"of",
"the",
"test"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L295-L301
|
9,613
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getDatetime
|
public static String getDatetime() {
long currentTimeMillis = System.currentTimeMillis();
final Date date = new Date(currentTimeMillis);
// ISO-8061 for YAMLish diagnostic
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(date);
}
|
java
|
public static String getDatetime() {
long currentTimeMillis = System.currentTimeMillis();
final Date date = new Date(currentTimeMillis);
// ISO-8061 for YAMLish diagnostic
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(date);
}
|
[
"public",
"static",
"String",
"getDatetime",
"(",
")",
"{",
"long",
"currentTimeMillis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"final",
"Date",
"date",
"=",
"new",
"Date",
"(",
"currentTimeMillis",
")",
";",
"// ISO-8061 for YAMLish diagnostic\r",
"return",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd'T'HH:mm:ss\"",
")",
".",
"format",
"(",
"date",
")",
";",
"}"
] |
Get a date time string
@return date time string
|
[
"Get",
"a",
"date",
"time",
"string"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L317-L322
|
9,614
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java
|
TapJUnitUtil.getBacktrace
|
public static String getBacktrace(JUnitTestData testMethod) {
StringBuilder stackTrace = new StringBuilder();
Throwable throwable = testMethod.getFailException();
if (throwable != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
String stackTraceString = sw.toString();
stackTraceString = stackTraceString.trim().replaceAll("\\r\\n",
"\n");
StringTokenizer st = new StringTokenizer(stackTraceString,
LINE_SEPARATOR);
while (st.hasMoreTokens()) {
String stackTraceLine = st.nextToken();
stackTrace.append(stackTraceLine);
stackTrace.append(LINE_SEPARATOR);
}
} else {
stackTrace.append('~');
}
return stackTrace.toString();
}
|
java
|
public static String getBacktrace(JUnitTestData testMethod) {
StringBuilder stackTrace = new StringBuilder();
Throwable throwable = testMethod.getFailException();
if (throwable != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
String stackTraceString = sw.toString();
stackTraceString = stackTraceString.trim().replaceAll("\\r\\n",
"\n");
StringTokenizer st = new StringTokenizer(stackTraceString,
LINE_SEPARATOR);
while (st.hasMoreTokens()) {
String stackTraceLine = st.nextToken();
stackTrace.append(stackTraceLine);
stackTrace.append(LINE_SEPARATOR);
}
} else {
stackTrace.append('~');
}
return stackTrace.toString();
}
|
[
"public",
"static",
"String",
"getBacktrace",
"(",
"JUnitTestData",
"testMethod",
")",
"{",
"StringBuilder",
"stackTrace",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Throwable",
"throwable",
"=",
"testMethod",
".",
"getFailException",
"(",
")",
";",
"if",
"(",
"throwable",
"!=",
"null",
")",
"{",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"sw",
")",
";",
"throwable",
".",
"printStackTrace",
"(",
"pw",
")",
";",
"String",
"stackTraceString",
"=",
"sw",
".",
"toString",
"(",
")",
";",
"stackTraceString",
"=",
"stackTraceString",
".",
"trim",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\\r\\\\n\"",
",",
"\"\\n\"",
")",
";",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"stackTraceString",
",",
"LINE_SEPARATOR",
")",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"stackTraceLine",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"stackTrace",
".",
"append",
"(",
"stackTraceLine",
")",
";",
"stackTrace",
".",
"append",
"(",
"LINE_SEPARATOR",
")",
";",
"}",
"}",
"else",
"{",
"stackTrace",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"return",
"stackTrace",
".",
"toString",
"(",
")",
";",
"}"
] |
Get the backtrace from a given failed JUnit test result
@param testMethod
@return Backtrace from a given failed JUnit test result
|
[
"Get",
"the",
"backtrace",
"from",
"a",
"given",
"failed",
"JUnit",
"test",
"result"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/util/TapJUnitUtil.java#L330-L357
|
9,615
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/parser/Tap13Parser.java
|
Tap13Parser.pushState
|
private void pushState(int indentation) {
states.push(state);
state = new StreamStatus();
state.setIndentationLevel(indentation);
}
|
java
|
private void pushState(int indentation) {
states.push(state);
state = new StreamStatus();
state.setIndentationLevel(indentation);
}
|
[
"private",
"void",
"pushState",
"(",
"int",
"indentation",
")",
"{",
"states",
".",
"push",
"(",
"state",
")",
";",
"state",
"=",
"new",
"StreamStatus",
"(",
")",
";",
"state",
".",
"setIndentationLevel",
"(",
"indentation",
")",
";",
"}"
] |
Saves the current state in the stack.
@param indentation state indentation
|
[
"Saves",
"the",
"current",
"state",
"in",
"the",
"stack",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/parser/Tap13Parser.java#L180-L184
|
9,616
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/parser/Tap13Parser.java
|
Tap13Parser.onFinish
|
private void onFinish() {
if (planRequired && state.getTestSet().getPlan() == null) {
throw new ParserException("Missing TAP Plan.");
}
parseDiagnostics();
while (!states.isEmpty() && state.getIndentationLevel() > baseIndentation) {
state = states.pop();
}
}
|
java
|
private void onFinish() {
if (planRequired && state.getTestSet().getPlan() == null) {
throw new ParserException("Missing TAP Plan.");
}
parseDiagnostics();
while (!states.isEmpty() && state.getIndentationLevel() > baseIndentation) {
state = states.pop();
}
}
|
[
"private",
"void",
"onFinish",
"(",
")",
"{",
"if",
"(",
"planRequired",
"&&",
"state",
".",
"getTestSet",
"(",
")",
".",
"getPlan",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"\"Missing TAP Plan.\"",
")",
";",
"}",
"parseDiagnostics",
"(",
")",
";",
"while",
"(",
"!",
"states",
".",
"isEmpty",
"(",
")",
"&&",
"state",
".",
"getIndentationLevel",
"(",
")",
">",
"baseIndentation",
")",
"{",
"state",
"=",
"states",
".",
"pop",
"(",
")",
";",
"}",
"}"
] |
Called after the rest of the stream has been processed.
|
[
"Called",
"after",
"the",
"rest",
"of",
"the",
"stream",
"has",
"been",
"processed",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/parser/Tap13Parser.java#L400-L409
|
9,617
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java
|
WebSocket.newWebSocketIfSupported
|
public static WebSocket newWebSocketIfSupported()
{
if ( null == g_factory && GWT.isClient() && getSupportDetector().isSupported() )
{
register( getSupportDetector().newFactory() );
return g_factory.newWebSocket();
}
return ( null != g_factory ) ? g_factory.newWebSocket() : null;
}
|
java
|
public static WebSocket newWebSocketIfSupported()
{
if ( null == g_factory && GWT.isClient() && getSupportDetector().isSupported() )
{
register( getSupportDetector().newFactory() );
return g_factory.newWebSocket();
}
return ( null != g_factory ) ? g_factory.newWebSocket() : null;
}
|
[
"public",
"static",
"WebSocket",
"newWebSocketIfSupported",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"g_factory",
"&&",
"GWT",
".",
"isClient",
"(",
")",
"&&",
"getSupportDetector",
"(",
")",
".",
"isSupported",
"(",
")",
")",
"{",
"register",
"(",
"getSupportDetector",
"(",
")",
".",
"newFactory",
"(",
")",
")",
";",
"return",
"g_factory",
".",
"newWebSocket",
"(",
")",
";",
"}",
"return",
"(",
"null",
"!=",
"g_factory",
")",
"?",
"g_factory",
".",
"newWebSocket",
"(",
")",
":",
"null",
";",
"}"
] |
Create a WebSocket if supported by the platform.
This method will use the registered factory to create the WebSocket instance.
@return a WebSocket instance, if supported by the platform, null otherwise.
|
[
"Create",
"a",
"WebSocket",
"if",
"supported",
"by",
"the",
"platform",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java#L50-L58
|
9,618
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java
|
WebSocket.deregister
|
public static boolean deregister( @Nonnull final Factory factory )
{
if ( g_factory != factory )
{
return false;
}
else
{
g_factory = null;
return true;
}
}
|
java
|
public static boolean deregister( @Nonnull final Factory factory )
{
if ( g_factory != factory )
{
return false;
}
else
{
g_factory = null;
return true;
}
}
|
[
"public",
"static",
"boolean",
"deregister",
"(",
"@",
"Nonnull",
"final",
"Factory",
"factory",
")",
"{",
"if",
"(",
"g_factory",
"!=",
"factory",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"g_factory",
"=",
"null",
";",
"return",
"true",
";",
"}",
"}"
] |
Deregister factory if the specified factory is the registered factory.
@param factory the factory to deregister.
@return true if able to deregister, false otherwise.
|
[
"Deregister",
"factory",
"if",
"the",
"specified",
"factory",
"is",
"the",
"registered",
"factory",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java#L87-L98
|
9,619
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java
|
WebSocket.setListener
|
public final void setListener( @Nullable final WebSocketListener listener )
{
_listener = null == listener ? NullWebSocketListener.LISTENER : listener;
}
|
java
|
public final void setListener( @Nullable final WebSocketListener listener )
{
_listener = null == listener ? NullWebSocketListener.LISTENER : listener;
}
|
[
"public",
"final",
"void",
"setListener",
"(",
"@",
"Nullable",
"final",
"WebSocketListener",
"listener",
")",
"{",
"_listener",
"=",
"null",
"==",
"listener",
"?",
"NullWebSocketListener",
".",
"LISTENER",
":",
"listener",
";",
"}"
] |
Set the listener to receive messages from the WebSocket.
@param listener the listener to receive messages from the WebSocket.
|
[
"Set",
"the",
"listener",
"to",
"receive",
"messages",
"from",
"the",
"WebSocket",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java#L246-L249
|
9,620
|
realityforge/gwt-websockets
|
src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java
|
WebSocket.onClose
|
protected final void onClose( final boolean wasClean,
final int code,
@Nullable final String reason )
{
getListener().onClose( this, wasClean, code, reason );
}
|
java
|
protected final void onClose( final boolean wasClean,
final int code,
@Nullable final String reason )
{
getListener().onClose( this, wasClean, code, reason );
}
|
[
"protected",
"final",
"void",
"onClose",
"(",
"final",
"boolean",
"wasClean",
",",
"final",
"int",
"code",
",",
"@",
"Nullable",
"final",
"String",
"reason",
")",
"{",
"getListener",
"(",
")",
".",
"onClose",
"(",
"this",
",",
"wasClean",
",",
"code",
",",
"reason",
")",
";",
"}"
] |
Fire a Close event.
|
[
"Fire",
"a",
"Close",
"event",
"."
] |
a3ec6873151b7c4b9667b9033fa986caed99b2f2
|
https://github.com/realityforge/gwt-websockets/blob/a3ec6873151b7c4b9667b9033fa986caed99b2f2/src/main/java/org/realityforge/gwt/websockets/client/WebSocket.java#L262-L267
|
9,621
|
tomasbjerre/violation-comments-to-gitlab-lib
|
src/main/java/se/bjurr/violations/comments/gitlab/lib/GitLabCommentsProvider.java
|
GitLabCommentsProvider.markMergeRequestAsWIP
|
private void markMergeRequestAsWIP() {
if (!this.api.getShouldSetWIP()) {
return;
}
final String currentTitle = mergeRequest.getTitle();
final String startTitle = "WIP: (VIOLATIONS) ";
if (currentTitle.startsWith(startTitle)) {
// To avoid setting WIP again on new comments
return;
}
final Integer projectId = this.project.getId();
final Integer mergeRequestIid = this.mergeRequest.getIid();
final String targetBranch = null;
final Integer assigneeId = null;
final String title = startTitle + currentTitle;
final String description = null;
final Constants.StateEvent stateEvent = null;
final String labels = null;
final Integer milestoneId = null;
final Boolean removeSourceBranch = null;
final Boolean squash = null;
final Boolean discussionLocked = null;
final Boolean allowCollaboration = null;
try {
mergeRequest.setTitle(title);
gitLabApi
.getMergeRequestApi()
.updateMergeRequest(
projectId,
mergeRequestIid,
targetBranch,
title,
assigneeId,
description,
stateEvent,
labels,
milestoneId,
removeSourceBranch,
squash,
discussionLocked,
allowCollaboration);
} catch (final Throwable e) {
violationsLogger.log(SEVERE, e.getMessage(), e);
}
}
|
java
|
private void markMergeRequestAsWIP() {
if (!this.api.getShouldSetWIP()) {
return;
}
final String currentTitle = mergeRequest.getTitle();
final String startTitle = "WIP: (VIOLATIONS) ";
if (currentTitle.startsWith(startTitle)) {
// To avoid setting WIP again on new comments
return;
}
final Integer projectId = this.project.getId();
final Integer mergeRequestIid = this.mergeRequest.getIid();
final String targetBranch = null;
final Integer assigneeId = null;
final String title = startTitle + currentTitle;
final String description = null;
final Constants.StateEvent stateEvent = null;
final String labels = null;
final Integer milestoneId = null;
final Boolean removeSourceBranch = null;
final Boolean squash = null;
final Boolean discussionLocked = null;
final Boolean allowCollaboration = null;
try {
mergeRequest.setTitle(title);
gitLabApi
.getMergeRequestApi()
.updateMergeRequest(
projectId,
mergeRequestIid,
targetBranch,
title,
assigneeId,
description,
stateEvent,
labels,
milestoneId,
removeSourceBranch,
squash,
discussionLocked,
allowCollaboration);
} catch (final Throwable e) {
violationsLogger.log(SEVERE, e.getMessage(), e);
}
}
|
[
"private",
"void",
"markMergeRequestAsWIP",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"api",
".",
"getShouldSetWIP",
"(",
")",
")",
"{",
"return",
";",
"}",
"final",
"String",
"currentTitle",
"=",
"mergeRequest",
".",
"getTitle",
"(",
")",
";",
"final",
"String",
"startTitle",
"=",
"\"WIP: (VIOLATIONS) \"",
";",
"if",
"(",
"currentTitle",
".",
"startsWith",
"(",
"startTitle",
")",
")",
"{",
"// To avoid setting WIP again on new comments",
"return",
";",
"}",
"final",
"Integer",
"projectId",
"=",
"this",
".",
"project",
".",
"getId",
"(",
")",
";",
"final",
"Integer",
"mergeRequestIid",
"=",
"this",
".",
"mergeRequest",
".",
"getIid",
"(",
")",
";",
"final",
"String",
"targetBranch",
"=",
"null",
";",
"final",
"Integer",
"assigneeId",
"=",
"null",
";",
"final",
"String",
"title",
"=",
"startTitle",
"+",
"currentTitle",
";",
"final",
"String",
"description",
"=",
"null",
";",
"final",
"Constants",
".",
"StateEvent",
"stateEvent",
"=",
"null",
";",
"final",
"String",
"labels",
"=",
"null",
";",
"final",
"Integer",
"milestoneId",
"=",
"null",
";",
"final",
"Boolean",
"removeSourceBranch",
"=",
"null",
";",
"final",
"Boolean",
"squash",
"=",
"null",
";",
"final",
"Boolean",
"discussionLocked",
"=",
"null",
";",
"final",
"Boolean",
"allowCollaboration",
"=",
"null",
";",
"try",
"{",
"mergeRequest",
".",
"setTitle",
"(",
"title",
")",
";",
"gitLabApi",
".",
"getMergeRequestApi",
"(",
")",
".",
"updateMergeRequest",
"(",
"projectId",
",",
"mergeRequestIid",
",",
"targetBranch",
",",
"title",
",",
"assigneeId",
",",
"description",
",",
"stateEvent",
",",
"labels",
",",
"milestoneId",
",",
"removeSourceBranch",
",",
"squash",
",",
"discussionLocked",
",",
"allowCollaboration",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"e",
")",
"{",
"violationsLogger",
".",
"log",
"(",
"SEVERE",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Set the merge request as "Work in Progress" if configured to do so by the shouldSetWIP flag.
|
[
"Set",
"the",
"merge",
"request",
"as",
"Work",
"in",
"Progress",
"if",
"configured",
"to",
"do",
"so",
"by",
"the",
"shouldSetWIP",
"flag",
"."
] |
44b7459f0fa7b51e88bd6320eb9159a83213019b
|
https://github.com/tomasbjerre/violation-comments-to-gitlab-lib/blob/44b7459f0fa7b51e88bd6320eb9159a83213019b/src/main/java/se/bjurr/violations/comments/gitlab/lib/GitLabCommentsProvider.java#L109-L154
|
9,622
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/producer/TapProducerFactory.java
|
TapProducerFactory.makeTap13YamlProducer
|
public static TapProducer makeTap13YamlProducer() {
DumperOptions options = new DumperOptions();
options.setPrintDiagnostics(true);
return new TapProducer(new Tap13Representer(options));
}
|
java
|
public static TapProducer makeTap13YamlProducer() {
DumperOptions options = new DumperOptions();
options.setPrintDiagnostics(true);
return new TapProducer(new Tap13Representer(options));
}
|
[
"public",
"static",
"TapProducer",
"makeTap13YamlProducer",
"(",
")",
"{",
"DumperOptions",
"options",
"=",
"new",
"DumperOptions",
"(",
")",
";",
"options",
".",
"setPrintDiagnostics",
"(",
"true",
")",
";",
"return",
"new",
"TapProducer",
"(",
"new",
"Tap13Representer",
"(",
"options",
")",
")",
";",
"}"
] |
Create a TAP 13 producer with YAMLish.
@return TapProducer
|
[
"Create",
"a",
"TAP",
"13",
"producer",
"with",
"YAMLish",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/producer/TapProducerFactory.java#L59-L63
|
9,623
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/model/TapElementFactory.java
|
TapElementFactory.createTextElement
|
public static Text createTextElement(String tapLine) {
Matcher m = Patterns.TEXT_PATTERN.matcher(tapLine);
if (m.matches()) {
Text result = new Text(tapLine);
result.setIndentationString(m.group(1));
result.indentation = m.group(1).length();
return result;
}
return null;
}
|
java
|
public static Text createTextElement(String tapLine) {
Matcher m = Patterns.TEXT_PATTERN.matcher(tapLine);
if (m.matches()) {
Text result = new Text(tapLine);
result.setIndentationString(m.group(1));
result.indentation = m.group(1).length();
return result;
}
return null;
}
|
[
"public",
"static",
"Text",
"createTextElement",
"(",
"String",
"tapLine",
")",
"{",
"Matcher",
"m",
"=",
"Patterns",
".",
"TEXT_PATTERN",
".",
"matcher",
"(",
"tapLine",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"{",
"Text",
"result",
"=",
"new",
"Text",
"(",
"tapLine",
")",
";",
"result",
".",
"setIndentationString",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
";",
"result",
".",
"indentation",
"=",
"m",
".",
"group",
"(",
"1",
")",
".",
"length",
"(",
")",
";",
"return",
"result",
";",
"}",
"return",
"null",
";",
"}"
] |
Create a text element. This element is created when none of the other elements have matched the TAP stream line.
@param tapLine TAP stream line
@return a {@link Text} TAP element
|
[
"Create",
"a",
"text",
"element",
".",
"This",
"element",
"is",
"created",
"when",
"none",
"of",
"the",
"other",
"elements",
"have",
"matched",
"the",
"TAP",
"stream",
"line",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/model/TapElementFactory.java#L48-L60
|
9,624
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/listener/TapListener.java
|
TapListener.generateTapPerMethod
|
protected void generateTapPerMethod(Result result) {
for (final JUnitTestData testMethod : testMethodsList) {
final TestResult tapTestResult = TapJUnitUtil
.generateTAPTestResult(testMethod, 1, isYaml());
final TestSet testSet = new TestSet();
testSet.setPlan(new Plan(1));
testSet.addTestResult(tapTestResult);
final String className = TapJUnitUtil.extractClassName(testMethod
.getDescription());
final String methodName = TapJUnitUtil.extractMethodName(testMethod
.getDescription());
final File output = new File(System.getProperty(
"tap.junit.results", "target/"), className + ":"
+ methodName + ".tap");
tapProducer.dump(testSet, output);
}
}
|
java
|
protected void generateTapPerMethod(Result result) {
for (final JUnitTestData testMethod : testMethodsList) {
final TestResult tapTestResult = TapJUnitUtil
.generateTAPTestResult(testMethod, 1, isYaml());
final TestSet testSet = new TestSet();
testSet.setPlan(new Plan(1));
testSet.addTestResult(tapTestResult);
final String className = TapJUnitUtil.extractClassName(testMethod
.getDescription());
final String methodName = TapJUnitUtil.extractMethodName(testMethod
.getDescription());
final File output = new File(System.getProperty(
"tap.junit.results", "target/"), className + ":"
+ methodName + ".tap");
tapProducer.dump(testSet, output);
}
}
|
[
"protected",
"void",
"generateTapPerMethod",
"(",
"Result",
"result",
")",
"{",
"for",
"(",
"final",
"JUnitTestData",
"testMethod",
":",
"testMethodsList",
")",
"{",
"final",
"TestResult",
"tapTestResult",
"=",
"TapJUnitUtil",
".",
"generateTAPTestResult",
"(",
"testMethod",
",",
"1",
",",
"isYaml",
"(",
")",
")",
";",
"final",
"TestSet",
"testSet",
"=",
"new",
"TestSet",
"(",
")",
";",
"testSet",
".",
"setPlan",
"(",
"new",
"Plan",
"(",
"1",
")",
")",
";",
"testSet",
".",
"addTestResult",
"(",
"tapTestResult",
")",
";",
"final",
"String",
"className",
"=",
"TapJUnitUtil",
".",
"extractClassName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
";",
"final",
"String",
"methodName",
"=",
"TapJUnitUtil",
".",
"extractMethodName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
";",
"final",
"File",
"output",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"tap.junit.results\"",
",",
"\"target/\"",
")",
",",
"className",
"+",
"\":\"",
"+",
"methodName",
"+",
"\".tap\"",
")",
";",
"tapProducer",
".",
"dump",
"(",
"testSet",
",",
"output",
")",
";",
"}",
"}"
] |
Generate tap file for each method
@param result
|
[
"Generate",
"tap",
"file",
"for",
"each",
"method"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/listener/TapListener.java#L180-L199
|
9,625
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/junit/listener/TapListener.java
|
TapListener.generateTapPerClass
|
protected void generateTapPerClass(Result result) {
Map<String, List<JUnitTestData>> testsByClass = new HashMap<>();
for (JUnitTestData testMethod : testMethodsList) {
String className = TapJUnitUtil.extractClassName(testMethod
.getDescription());
testsByClass.computeIfAbsent(className, k -> new ArrayList<>())
.add(testMethod);
}
testsByClass.forEach((className, testMethods) -> {
final TestSet testSet = new TestSet();
testSet.setPlan(new Plan(testMethods.size()));
testMethods.forEach(testMethod -> {
TestResult tapTestResult = TapJUnitUtil.generateTAPTestResult(
testMethod, 1, isYaml());
testSet.addTestResult(tapTestResult);
});
File output = new File(System.getProperty("tap.junit.results",
"target/"), className + ".tap");
tapProducer.dump(testSet, output);
});
}
|
java
|
protected void generateTapPerClass(Result result) {
Map<String, List<JUnitTestData>> testsByClass = new HashMap<>();
for (JUnitTestData testMethod : testMethodsList) {
String className = TapJUnitUtil.extractClassName(testMethod
.getDescription());
testsByClass.computeIfAbsent(className, k -> new ArrayList<>())
.add(testMethod);
}
testsByClass.forEach((className, testMethods) -> {
final TestSet testSet = new TestSet();
testSet.setPlan(new Plan(testMethods.size()));
testMethods.forEach(testMethod -> {
TestResult tapTestResult = TapJUnitUtil.generateTAPTestResult(
testMethod, 1, isYaml());
testSet.addTestResult(tapTestResult);
});
File output = new File(System.getProperty("tap.junit.results",
"target/"), className + ".tap");
tapProducer.dump(testSet, output);
});
}
|
[
"protected",
"void",
"generateTapPerClass",
"(",
"Result",
"result",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"JUnitTestData",
">",
">",
"testsByClass",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"JUnitTestData",
"testMethod",
":",
"testMethodsList",
")",
"{",
"String",
"className",
"=",
"TapJUnitUtil",
".",
"extractClassName",
"(",
"testMethod",
".",
"getDescription",
"(",
")",
")",
";",
"testsByClass",
".",
"computeIfAbsent",
"(",
"className",
",",
"k",
"->",
"new",
"ArrayList",
"<>",
"(",
")",
")",
".",
"add",
"(",
"testMethod",
")",
";",
"}",
"testsByClass",
".",
"forEach",
"(",
"(",
"className",
",",
"testMethods",
")",
"->",
"{",
"final",
"TestSet",
"testSet",
"=",
"new",
"TestSet",
"(",
")",
";",
"testSet",
".",
"setPlan",
"(",
"new",
"Plan",
"(",
"testMethods",
".",
"size",
"(",
")",
")",
")",
";",
"testMethods",
".",
"forEach",
"(",
"testMethod",
"->",
"{",
"TestResult",
"tapTestResult",
"=",
"TapJUnitUtil",
".",
"generateTAPTestResult",
"(",
"testMethod",
",",
"1",
",",
"isYaml",
"(",
")",
")",
";",
"testSet",
".",
"addTestResult",
"(",
"tapTestResult",
")",
";",
"}",
")",
";",
"File",
"output",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"tap.junit.results\"",
",",
"\"target/\"",
")",
",",
"className",
"+",
"\".tap\"",
")",
";",
"tapProducer",
".",
"dump",
"(",
"testSet",
",",
"output",
")",
";",
"}",
")",
";",
"}"
] |
Generate tap file for a class
@param result
|
[
"Generate",
"tap",
"file",
"for",
"a",
"class"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/junit/listener/TapListener.java#L206-L231
|
9,626
|
InkApplications/android-preferences
|
preferences/src/main/java/com/inkapplications/preferences/EnumPreference.java
|
EnumPreference.get
|
@SuppressWarnings("unchecked")
@Override public E get() {
if (getPreferences().contains(getKey())) {
return (E) enumValues[getPreferences().getInt(getKey(), 0)];
} else {
return getDefaultValue();
}
}
|
java
|
@SuppressWarnings("unchecked")
@Override public E get() {
if (getPreferences().contains(getKey())) {
return (E) enumValues[getPreferences().getInt(getKey(), 0)];
} else {
return getDefaultValue();
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"E",
"get",
"(",
")",
"{",
"if",
"(",
"getPreferences",
"(",
")",
".",
"contains",
"(",
"getKey",
"(",
")",
")",
")",
"{",
"return",
"(",
"E",
")",
"enumValues",
"[",
"getPreferences",
"(",
")",
".",
"getInt",
"(",
"getKey",
"(",
")",
",",
"0",
")",
"]",
";",
"}",
"else",
"{",
"return",
"getDefaultValue",
"(",
")",
";",
"}",
"}"
] |
Get the value the preference
|
[
"Get",
"the",
"value",
"the",
"preference"
] |
04e9eac6861ece36dfe15e3c91c89d4f64d6223c
|
https://github.com/InkApplications/android-preferences/blob/04e9eac6861ece36dfe15e3c91c89d4f64d6223c/preferences/src/main/java/com/inkapplications/preferences/EnumPreference.java#L49-L56
|
9,627
|
tupilabs/tap4j
|
tap4j-ext/src/main/java/org/tap4j/ext/jmeter/parser/JmeterResultParser.java
|
JmeterResultParser.parseFile
|
public TestSet parseFile(File file, boolean generateTapFile) {
TestSet testSet = new TestSet();
final Header header = new Header(TAP_VERSION);
testSet.setHeader(header);
List<AbstractSample> sampleResultList = getResultList(file);
Plan plan = new Plan(INITIAL_TEST_STEP, sampleResultList.size());
testSet.setPlan(plan);
for (AbstractSample httpSample : sampleResultList) {
List<AssertionResult> assetionResultList = httpSample.getAssertionResult();
boolean resultError = false;
String failitureMessage = "";
String severity = "";
// Searching an assertion failed
for (AssertionResult assertionResult : assetionResultList) {
resultError = (assertionResult.isFailure() || assertionResult.isError());
if (resultError) {
failitureMessage += FAILURE_MESSAGE + assertionResult.getFailureMessage();
// Log the type of fail
if (assertionResult.isFailure()) {
severity = FAIL_ASSERT;
}
if (assertionResult.isError()) {
severity += ERROR;
}
}
}
TestResult testResult = new TestResult();
testResult.setDescription(httpSample.getLb());
StatusValues status = StatusValues.OK;
if (resultError) {
final Map<String, Object> yamlish = testResult.getDiagnostic();
createYAMLishMessage(yamlish, httpSample, failitureMessage);
createYAMLishSeverity(yamlish, severity);
createYAMLishDump(yamlish, httpSample);
status = StatusValues.NOT_OK;
}
testResult.setStatus(status);
testSet.addTestResult(testResult);
}
if (generateTapFile) {
generateTapFile(file, testSet);
}
return testSet;
}
|
java
|
public TestSet parseFile(File file, boolean generateTapFile) {
TestSet testSet = new TestSet();
final Header header = new Header(TAP_VERSION);
testSet.setHeader(header);
List<AbstractSample> sampleResultList = getResultList(file);
Plan plan = new Plan(INITIAL_TEST_STEP, sampleResultList.size());
testSet.setPlan(plan);
for (AbstractSample httpSample : sampleResultList) {
List<AssertionResult> assetionResultList = httpSample.getAssertionResult();
boolean resultError = false;
String failitureMessage = "";
String severity = "";
// Searching an assertion failed
for (AssertionResult assertionResult : assetionResultList) {
resultError = (assertionResult.isFailure() || assertionResult.isError());
if (resultError) {
failitureMessage += FAILURE_MESSAGE + assertionResult.getFailureMessage();
// Log the type of fail
if (assertionResult.isFailure()) {
severity = FAIL_ASSERT;
}
if (assertionResult.isError()) {
severity += ERROR;
}
}
}
TestResult testResult = new TestResult();
testResult.setDescription(httpSample.getLb());
StatusValues status = StatusValues.OK;
if (resultError) {
final Map<String, Object> yamlish = testResult.getDiagnostic();
createYAMLishMessage(yamlish, httpSample, failitureMessage);
createYAMLishSeverity(yamlish, severity);
createYAMLishDump(yamlish, httpSample);
status = StatusValues.NOT_OK;
}
testResult.setStatus(status);
testSet.addTestResult(testResult);
}
if (generateTapFile) {
generateTapFile(file, testSet);
}
return testSet;
}
|
[
"public",
"TestSet",
"parseFile",
"(",
"File",
"file",
",",
"boolean",
"generateTapFile",
")",
"{",
"TestSet",
"testSet",
"=",
"new",
"TestSet",
"(",
")",
";",
"final",
"Header",
"header",
"=",
"new",
"Header",
"(",
"TAP_VERSION",
")",
";",
"testSet",
".",
"setHeader",
"(",
"header",
")",
";",
"List",
"<",
"AbstractSample",
">",
"sampleResultList",
"=",
"getResultList",
"(",
"file",
")",
";",
"Plan",
"plan",
"=",
"new",
"Plan",
"(",
"INITIAL_TEST_STEP",
",",
"sampleResultList",
".",
"size",
"(",
")",
")",
";",
"testSet",
".",
"setPlan",
"(",
"plan",
")",
";",
"for",
"(",
"AbstractSample",
"httpSample",
":",
"sampleResultList",
")",
"{",
"List",
"<",
"AssertionResult",
">",
"assetionResultList",
"=",
"httpSample",
".",
"getAssertionResult",
"(",
")",
";",
"boolean",
"resultError",
"=",
"false",
";",
"String",
"failitureMessage",
"=",
"\"\"",
";",
"String",
"severity",
"=",
"\"\"",
";",
"// Searching an assertion failed",
"for",
"(",
"AssertionResult",
"assertionResult",
":",
"assetionResultList",
")",
"{",
"resultError",
"=",
"(",
"assertionResult",
".",
"isFailure",
"(",
")",
"||",
"assertionResult",
".",
"isError",
"(",
")",
")",
";",
"if",
"(",
"resultError",
")",
"{",
"failitureMessage",
"+=",
"FAILURE_MESSAGE",
"+",
"assertionResult",
".",
"getFailureMessage",
"(",
")",
";",
"// Log the type of fail",
"if",
"(",
"assertionResult",
".",
"isFailure",
"(",
")",
")",
"{",
"severity",
"=",
"FAIL_ASSERT",
";",
"}",
"if",
"(",
"assertionResult",
".",
"isError",
"(",
")",
")",
"{",
"severity",
"+=",
"ERROR",
";",
"}",
"}",
"}",
"TestResult",
"testResult",
"=",
"new",
"TestResult",
"(",
")",
";",
"testResult",
".",
"setDescription",
"(",
"httpSample",
".",
"getLb",
"(",
")",
")",
";",
"StatusValues",
"status",
"=",
"StatusValues",
".",
"OK",
";",
"if",
"(",
"resultError",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"yamlish",
"=",
"testResult",
".",
"getDiagnostic",
"(",
")",
";",
"createYAMLishMessage",
"(",
"yamlish",
",",
"httpSample",
",",
"failitureMessage",
")",
";",
"createYAMLishSeverity",
"(",
"yamlish",
",",
"severity",
")",
";",
"createYAMLishDump",
"(",
"yamlish",
",",
"httpSample",
")",
";",
"status",
"=",
"StatusValues",
".",
"NOT_OK",
";",
"}",
"testResult",
".",
"setStatus",
"(",
"status",
")",
";",
"testSet",
".",
"addTestResult",
"(",
"testResult",
")",
";",
"}",
"if",
"(",
"generateTapFile",
")",
"{",
"generateTapFile",
"(",
"file",
",",
"testSet",
")",
";",
"}",
"return",
"testSet",
";",
"}"
] |
Parses jMeter result file into TestSet and optionally generates a Tap file with the same name of the parsed file
@param file the file
@param generateTapFile flag to generate a TAP file or not
@return a not nullable {@TestSet}
|
[
"Parses",
"jMeter",
"result",
"file",
"into",
"TestSet",
"and",
"optionally",
"generates",
"a",
"Tap",
"file",
"with",
"the",
"same",
"name",
"of",
"the",
"parsed",
"file"
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j-ext/src/main/java/org/tap4j/ext/jmeter/parser/JmeterResultParser.java#L72-L122
|
9,628
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/representer/Tap13Representer.java
|
Tap13Representer.printDiagnostic
|
protected void printDiagnostic(PrintWriter pw, TapElement tapElement) {
if (this.yaml != null) {
Map<String, Object> diagnostic = tapElement.getDiagnostic();
if (diagnostic != null && !diagnostic.isEmpty()) {
String diagnosticText = yaml.dump(diagnostic);
diagnosticText = diagnosticText.replaceAll("((?m)^)", " ");
pw.append(LINE_SEPARATOR);
printFiller(pw);
pw.append(diagnosticText);
}
}
}
|
java
|
protected void printDiagnostic(PrintWriter pw, TapElement tapElement) {
if (this.yaml != null) {
Map<String, Object> diagnostic = tapElement.getDiagnostic();
if (diagnostic != null && !diagnostic.isEmpty()) {
String diagnosticText = yaml.dump(diagnostic);
diagnosticText = diagnosticText.replaceAll("((?m)^)", " ");
pw.append(LINE_SEPARATOR);
printFiller(pw);
pw.append(diagnosticText);
}
}
}
|
[
"protected",
"void",
"printDiagnostic",
"(",
"PrintWriter",
"pw",
",",
"TapElement",
"tapElement",
")",
"{",
"if",
"(",
"this",
".",
"yaml",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"diagnostic",
"=",
"tapElement",
".",
"getDiagnostic",
"(",
")",
";",
"if",
"(",
"diagnostic",
"!=",
"null",
"&&",
"!",
"diagnostic",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"diagnosticText",
"=",
"yaml",
".",
"dump",
"(",
"diagnostic",
")",
";",
"diagnosticText",
"=",
"diagnosticText",
".",
"replaceAll",
"(",
"\"((?m)^)\"",
",",
"\" \"",
")",
";",
"pw",
".",
"append",
"(",
"LINE_SEPARATOR",
")",
";",
"printFiller",
"(",
"pw",
")",
";",
"pw",
".",
"append",
"(",
"diagnosticText",
")",
";",
"}",
"}",
"}"
] |
Prints diagnostic of the TAP Element into the Print Writer.
@param pw Print Writer
@param tapElement TAP element
|
[
"Prints",
"diagnostic",
"of",
"the",
"TAP",
"Element",
"into",
"the",
"Print",
"Writer",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/representer/Tap13Representer.java#L260-L271
|
9,629
|
tupilabs/tap4j
|
tap4j/src/main/java/org/tap4j/representer/Tap13Representer.java
|
Tap13Representer.printFiller
|
protected void printFiller(PrintWriter pw) {
if (this.options.getIndent() > 0) {
for (int i = 0; i < options.getIndent(); i++) {
pw.append(' ');
}
}
}
|
java
|
protected void printFiller(PrintWriter pw) {
if (this.options.getIndent() > 0) {
for (int i = 0; i < options.getIndent(); i++) {
pw.append(' ');
}
}
}
|
[
"protected",
"void",
"printFiller",
"(",
"PrintWriter",
"pw",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"getIndent",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"getIndent",
"(",
")",
";",
"i",
"++",
")",
"{",
"pw",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"}"
] |
Print filler.
@param pw Print Writer
|
[
"Print",
"filler",
"."
] |
1793b653ce7f3a06a7b5c9557cdf601e28dd1f55
|
https://github.com/tupilabs/tap4j/blob/1793b653ce7f3a06a7b5c9557cdf601e28dd1f55/tap4j/src/main/java/org/tap4j/representer/Tap13Representer.java#L278-L284
|
9,630
|
canoo/open-dolphin
|
subprojects/demo-javafx/server/src/main/java/org/opendolphin/demo/team/TeamMemberActions.java
|
TeamMemberActions.processEventsFromQueue
|
private void processEventsFromQueue(int timeoutValue, TimeUnit timeoutUnit) throws InterruptedException {
TeamEvent event = memberQueue.getVal(timeoutValue, timeoutUnit);
while (null != event) {
if (TeamEvent.Type.NEW == event.type) {
getServerDolphin().presentationModel(null, TYPE_TEAM_MEMBER, event.dto); // create on server side
}
if (TeamEvent.Type.CHANGE == event.type) {
silent = true; // do not issue additional posts on the bus from value changes that come from the bus
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
for (ServerAttribute attribute : attributes) {
PresentationModel pm = attribute.getPresentationModel();
if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
attribute.setValue(event.value);
}
}
silent = false;
}
if (TeamEvent.Type.REBASE == event.type) {
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
for (ServerAttribute attribute : attributes) {
attribute.rebase();
}
}
if (TeamEvent.Type.REMOVE == event.type) {
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
Set<ServerPresentationModel> toDelete = new HashSet<ServerPresentationModel>();
for (ServerAttribute attribute : attributes) {
ServerPresentationModel pm = attribute.getPresentationModel();
if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
toDelete.add(pm);
}
}
for (ServerPresentationModel pm : toDelete) {
getServerDolphin().remove(pm);
}
}
event = memberQueue.getVal(20, TimeUnit.MILLISECONDS);
}
}
|
java
|
private void processEventsFromQueue(int timeoutValue, TimeUnit timeoutUnit) throws InterruptedException {
TeamEvent event = memberQueue.getVal(timeoutValue, timeoutUnit);
while (null != event) {
if (TeamEvent.Type.NEW == event.type) {
getServerDolphin().presentationModel(null, TYPE_TEAM_MEMBER, event.dto); // create on server side
}
if (TeamEvent.Type.CHANGE == event.type) {
silent = true; // do not issue additional posts on the bus from value changes that come from the bus
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
for (ServerAttribute attribute : attributes) {
PresentationModel pm = attribute.getPresentationModel();
if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
attribute.setValue(event.value);
}
}
silent = false;
}
if (TeamEvent.Type.REBASE == event.type) {
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
for (ServerAttribute attribute : attributes) {
attribute.rebase();
}
}
if (TeamEvent.Type.REMOVE == event.type) {
List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
Set<ServerPresentationModel> toDelete = new HashSet<ServerPresentationModel>();
for (ServerAttribute attribute : attributes) {
ServerPresentationModel pm = attribute.getPresentationModel();
if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
toDelete.add(pm);
}
}
for (ServerPresentationModel pm : toDelete) {
getServerDolphin().remove(pm);
}
}
event = memberQueue.getVal(20, TimeUnit.MILLISECONDS);
}
}
|
[
"private",
"void",
"processEventsFromQueue",
"(",
"int",
"timeoutValue",
",",
"TimeUnit",
"timeoutUnit",
")",
"throws",
"InterruptedException",
"{",
"TeamEvent",
"event",
"=",
"memberQueue",
".",
"getVal",
"(",
"timeoutValue",
",",
"timeoutUnit",
")",
";",
"while",
"(",
"null",
"!=",
"event",
")",
"{",
"if",
"(",
"TeamEvent",
".",
"Type",
".",
"NEW",
"==",
"event",
".",
"type",
")",
"{",
"getServerDolphin",
"(",
")",
".",
"presentationModel",
"(",
"null",
",",
"TYPE_TEAM_MEMBER",
",",
"event",
".",
"dto",
")",
";",
"// create on server side",
"}",
"if",
"(",
"TeamEvent",
".",
"Type",
".",
"CHANGE",
"==",
"event",
".",
"type",
")",
"{",
"silent",
"=",
"true",
";",
"// do not issue additional posts on the bus from value changes that come from the bus",
"List",
"<",
"ServerAttribute",
">",
"attributes",
"=",
"getServerDolphin",
"(",
")",
".",
"findAllAttributesByQualifier",
"(",
"event",
".",
"qualifier",
")",
";",
"for",
"(",
"ServerAttribute",
"attribute",
":",
"attributes",
")",
"{",
"PresentationModel",
"pm",
"=",
"attribute",
".",
"getPresentationModel",
"(",
")",
";",
"if",
"(",
"TYPE_TEAM_MEMBER",
".",
"equals",
"(",
"pm",
".",
"getPresentationModelType",
"(",
")",
")",
")",
"{",
"attribute",
".",
"setValue",
"(",
"event",
".",
"value",
")",
";",
"}",
"}",
"silent",
"=",
"false",
";",
"}",
"if",
"(",
"TeamEvent",
".",
"Type",
".",
"REBASE",
"==",
"event",
".",
"type",
")",
"{",
"List",
"<",
"ServerAttribute",
">",
"attributes",
"=",
"getServerDolphin",
"(",
")",
".",
"findAllAttributesByQualifier",
"(",
"event",
".",
"qualifier",
")",
";",
"for",
"(",
"ServerAttribute",
"attribute",
":",
"attributes",
")",
"{",
"attribute",
".",
"rebase",
"(",
")",
";",
"}",
"}",
"if",
"(",
"TeamEvent",
".",
"Type",
".",
"REMOVE",
"==",
"event",
".",
"type",
")",
"{",
"List",
"<",
"ServerAttribute",
">",
"attributes",
"=",
"getServerDolphin",
"(",
")",
".",
"findAllAttributesByQualifier",
"(",
"event",
".",
"qualifier",
")",
";",
"Set",
"<",
"ServerPresentationModel",
">",
"toDelete",
"=",
"new",
"HashSet",
"<",
"ServerPresentationModel",
">",
"(",
")",
";",
"for",
"(",
"ServerAttribute",
"attribute",
":",
"attributes",
")",
"{",
"ServerPresentationModel",
"pm",
"=",
"attribute",
".",
"getPresentationModel",
"(",
")",
";",
"if",
"(",
"TYPE_TEAM_MEMBER",
".",
"equals",
"(",
"pm",
".",
"getPresentationModelType",
"(",
")",
")",
")",
"{",
"toDelete",
".",
"add",
"(",
"pm",
")",
";",
"}",
"}",
"for",
"(",
"ServerPresentationModel",
"pm",
":",
"toDelete",
")",
"{",
"getServerDolphin",
"(",
")",
".",
"remove",
"(",
"pm",
")",
";",
"}",
"}",
"event",
"=",
"memberQueue",
".",
"getVal",
"(",
"20",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}"
] |
with user interactions and is thus safe to process in a more efficient manner.
|
[
"with",
"user",
"interactions",
"and",
"is",
"thus",
"safe",
"to",
"process",
"in",
"a",
"more",
"efficient",
"manner",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/demo-javafx/server/src/main/java/org/opendolphin/demo/team/TeamMemberActions.java#L170-L208
|
9,631
|
netceteragroup/valdr-bean-validation
|
valdr-bean-validation/src/main/java/com/github/valdr/ClasspathScanner.java
|
ClasspathScanner.findClassesToParse
|
public Set<Class<?>> findClassesToParse() {
Reflections reflections = new Reflections(new ConfigurationBuilder().
setUrls(buildClassLoaderUrls()).setScanners(new SubTypesScanner(false)).filterInputsBy(buildPackagePredicates()));
return reflections.getSubTypesOf(Object.class);
}
|
java
|
public Set<Class<?>> findClassesToParse() {
Reflections reflections = new Reflections(new ConfigurationBuilder().
setUrls(buildClassLoaderUrls()).setScanners(new SubTypesScanner(false)).filterInputsBy(buildPackagePredicates()));
return reflections.getSubTypesOf(Object.class);
}
|
[
"public",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"findClassesToParse",
"(",
")",
"{",
"Reflections",
"reflections",
"=",
"new",
"Reflections",
"(",
"new",
"ConfigurationBuilder",
"(",
")",
".",
"setUrls",
"(",
"buildClassLoaderUrls",
"(",
")",
")",
".",
"setScanners",
"(",
"new",
"SubTypesScanner",
"(",
"false",
")",
")",
".",
"filterInputsBy",
"(",
"buildPackagePredicates",
"(",
")",
")",
")",
";",
"return",
"reflections",
".",
"getSubTypesOf",
"(",
"Object",
".",
"class",
")",
";",
"}"
] |
Scans the classpath to find all classes that are in the configured model packages. It ignores excluded classes.
@return classes to parse
@see Options
|
[
"Scans",
"the",
"classpath",
"to",
"find",
"all",
"classes",
"that",
"are",
"in",
"the",
"configured",
"model",
"packages",
".",
"It",
"ignores",
"excluded",
"classes",
"."
] |
3f49f1357c575a11331be2de867cf47809a83823
|
https://github.com/netceteragroup/valdr-bean-validation/blob/3f49f1357c575a11331be2de867cf47809a83823/valdr-bean-validation/src/main/java/com/github/valdr/ClasspathScanner.java#L39-L44
|
9,632
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/SecurityActions.java
|
SecurityActions.isExpression
|
static boolean isExpression(final String string) {
if (string == null) {
return false;
}
return string.startsWith("${") && string.endsWith("}");
}
|
java
|
static boolean isExpression(final String string) {
if (string == null) {
return false;
}
return string.startsWith("${") && string.endsWith("}");
}
|
[
"static",
"boolean",
"isExpression",
"(",
"final",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"string",
".",
"startsWith",
"(",
"\"${\"",
")",
"&&",
"string",
".",
"endsWith",
"(",
"\"}\"",
")",
";",
"}"
] |
Whether the string is a valid expression.
@param string
the string
@return true if the string starts with '${' and ends with '}', false
otherwise
|
[
"Whether",
"the",
"string",
"is",
"a",
"valid",
"expression",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/SecurityActions.java#L83-L88
|
9,633
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/SecurityActions.java
|
SecurityActions.getExpressValue
|
static String getExpressValue(final String key) {
if (isExpression(key)) {
String keyValue = getSystemProperty(key.substring(2, key.length() - 1));
return keyValue == null ? key : keyValue;
} else {
return key;
}
}
|
java
|
static String getExpressValue(final String key) {
if (isExpression(key)) {
String keyValue = getSystemProperty(key.substring(2, key.length() - 1));
return keyValue == null ? key : keyValue;
} else {
return key;
}
}
|
[
"static",
"String",
"getExpressValue",
"(",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"isExpression",
"(",
"key",
")",
")",
"{",
"String",
"keyValue",
"=",
"getSystemProperty",
"(",
"key",
".",
"substring",
"(",
"2",
",",
"key",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"return",
"keyValue",
"==",
"null",
"?",
"key",
":",
"keyValue",
";",
"}",
"else",
"{",
"return",
"key",
";",
"}",
"}"
] |
Gets the express value by the key.
@param key
the key where the system property is set.
@return the expression value or the key itself if the system property is
not set.
|
[
"Gets",
"the",
"express",
"value",
"by",
"the",
"key",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/SecurityActions.java#L98-L105
|
9,634
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxResourceAdapter.java
|
VertxResourceAdapter.endpointActivation
|
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
VertxActivation activation = new VertxActivation(this, endpointFactory,
(VertxActivationSpec) spec);
activations.put((VertxActivationSpec) spec, activation);
activation.start();
log.finest("endpointActivation()");
}
|
java
|
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
VertxActivation activation = new VertxActivation(this, endpointFactory,
(VertxActivationSpec) spec);
activations.put((VertxActivationSpec) spec, activation);
activation.start();
log.finest("endpointActivation()");
}
|
[
"public",
"void",
"endpointActivation",
"(",
"MessageEndpointFactory",
"endpointFactory",
",",
"ActivationSpec",
"spec",
")",
"throws",
"ResourceException",
"{",
"VertxActivation",
"activation",
"=",
"new",
"VertxActivation",
"(",
"this",
",",
"endpointFactory",
",",
"(",
"VertxActivationSpec",
")",
"spec",
")",
";",
"activations",
".",
"put",
"(",
"(",
"VertxActivationSpec",
")",
"spec",
",",
"activation",
")",
";",
"activation",
".",
"start",
"(",
")",
";",
"log",
".",
"finest",
"(",
"\"endpointActivation()\"",
")",
";",
"}"
] |
This is called during the activation of a message endpoint.
@param endpointFactory
A message endpoint factory instance.
@param spec
An activation spec JavaBean instance.
@throws ResourceException
generic exception
|
[
"This",
"is",
"called",
"during",
"the",
"activation",
"of",
"a",
"message",
"endpoint",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxResourceAdapter.java#L55-L64
|
9,635
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxResourceAdapter.java
|
VertxResourceAdapter.endpointDeactivation
|
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) {
VertxActivation activation = activations.remove(spec);
if (activation != null)
activation.stop();
log.finest("endpointDeactivation()");
}
|
java
|
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) {
VertxActivation activation = activations.remove(spec);
if (activation != null)
activation.stop();
log.finest("endpointDeactivation()");
}
|
[
"public",
"void",
"endpointDeactivation",
"(",
"MessageEndpointFactory",
"endpointFactory",
",",
"ActivationSpec",
"spec",
")",
"{",
"VertxActivation",
"activation",
"=",
"activations",
".",
"remove",
"(",
"spec",
")",
";",
"if",
"(",
"activation",
"!=",
"null",
")",
"activation",
".",
"stop",
"(",
")",
";",
"log",
".",
"finest",
"(",
"\"endpointDeactivation()\"",
")",
";",
"}"
] |
This is called when a message endpoint is deactivated.
@param endpointFactory
A message endpoint factory instance.
@param spec
An activation spec JavaBean instance.
|
[
"This",
"is",
"called",
"when",
"a",
"message",
"endpoint",
"is",
"deactivated",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxResourceAdapter.java#L74-L82
|
9,636
|
silb/dropwizard-shiro
|
src/main/java/org/secnod/dropwizard/shiro/ShiroBundle.java
|
ShiroBundle.createFilter
|
protected Filter createFilter(final T configuration) {
ShiroConfiguration shiroConfig = narrow(configuration);
final IniWebEnvironment shiroEnv = new IniWebEnvironment();
shiroEnv.setConfigLocations(shiroConfig.iniConfigs());
shiroEnv.init();
AbstractShiroFilter shiroFilter = new AbstractShiroFilter() {
@Override
public void init() throws Exception {
Collection<Realm> realms = createRealms(configuration);
WebSecurityManager securityManager = realms.isEmpty()
? shiroEnv.getWebSecurityManager()
: new DefaultWebSecurityManager(realms);
setSecurityManager(securityManager);
setFilterChainResolver(shiroEnv.getFilterChainResolver());
}
};
return shiroFilter;
}
|
java
|
protected Filter createFilter(final T configuration) {
ShiroConfiguration shiroConfig = narrow(configuration);
final IniWebEnvironment shiroEnv = new IniWebEnvironment();
shiroEnv.setConfigLocations(shiroConfig.iniConfigs());
shiroEnv.init();
AbstractShiroFilter shiroFilter = new AbstractShiroFilter() {
@Override
public void init() throws Exception {
Collection<Realm> realms = createRealms(configuration);
WebSecurityManager securityManager = realms.isEmpty()
? shiroEnv.getWebSecurityManager()
: new DefaultWebSecurityManager(realms);
setSecurityManager(securityManager);
setFilterChainResolver(shiroEnv.getFilterChainResolver());
}
};
return shiroFilter;
}
|
[
"protected",
"Filter",
"createFilter",
"(",
"final",
"T",
"configuration",
")",
"{",
"ShiroConfiguration",
"shiroConfig",
"=",
"narrow",
"(",
"configuration",
")",
";",
"final",
"IniWebEnvironment",
"shiroEnv",
"=",
"new",
"IniWebEnvironment",
"(",
")",
";",
"shiroEnv",
".",
"setConfigLocations",
"(",
"shiroConfig",
".",
"iniConfigs",
"(",
")",
")",
";",
"shiroEnv",
".",
"init",
"(",
")",
";",
"AbstractShiroFilter",
"shiroFilter",
"=",
"new",
"AbstractShiroFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"init",
"(",
")",
"throws",
"Exception",
"{",
"Collection",
"<",
"Realm",
">",
"realms",
"=",
"createRealms",
"(",
"configuration",
")",
";",
"WebSecurityManager",
"securityManager",
"=",
"realms",
".",
"isEmpty",
"(",
")",
"?",
"shiroEnv",
".",
"getWebSecurityManager",
"(",
")",
":",
"new",
"DefaultWebSecurityManager",
"(",
"realms",
")",
";",
"setSecurityManager",
"(",
"securityManager",
")",
";",
"setFilterChainResolver",
"(",
"shiroEnv",
".",
"getFilterChainResolver",
"(",
")",
")",
";",
"}",
"}",
";",
"return",
"shiroFilter",
";",
"}"
] |
Create the Shiro filter. Overriding this method allows for complete customization of how Shiro is initialized.
|
[
"Create",
"the",
"Shiro",
"filter",
".",
"Overriding",
"this",
"method",
"allows",
"for",
"complete",
"customization",
"of",
"how",
"Shiro",
"is",
"initialized",
"."
] |
4e05392a4820443c36522e9d3c5a4989a3953b42
|
https://github.com/silb/dropwizard-shiro/blob/4e05392a4820443c36522e9d3c5a4989a3953b42/src/main/java/org/secnod/dropwizard/shiro/ShiroBundle.java#L58-L76
|
9,637
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/DockerRule.java
|
DockerRule.getRegisteredContainers
|
public static List<Container> getRegisteredContainers() {
CONTAINERS_LOCK.lock();
try {
return ImmutableList.copyOf(CONTAINERS.values());
} finally {
CONTAINERS_LOCK.unlock();
}
}
|
java
|
public static List<Container> getRegisteredContainers() {
CONTAINERS_LOCK.lock();
try {
return ImmutableList.copyOf(CONTAINERS.values());
} finally {
CONTAINERS_LOCK.unlock();
}
}
|
[
"public",
"static",
"List",
"<",
"Container",
">",
"getRegisteredContainers",
"(",
")",
"{",
"CONTAINERS_LOCK",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"ImmutableList",
".",
"copyOf",
"(",
"CONTAINERS",
".",
"values",
"(",
")",
")",
";",
"}",
"finally",
"{",
"CONTAINERS_LOCK",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns a list of registered containers.
@return a list of registered containers.
|
[
"Returns",
"a",
"list",
"of",
"registered",
"containers",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/DockerRule.java#L107-L114
|
9,638
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/DockerRule.java
|
DockerRule.start
|
public static Container start(final DockerConfig config, final boolean stopOthers) throws Exception {
Preconditions.checkArgument(config != null, "config must be non-null");
if (stopOthers) {
getRegisteredContainers().stream() //
.filter(container -> {
return container.isStarted() //
&& container.getRefCount() == 0 //
&& !StringUtils.equals(config.getName(), container.getConfig().getName());
}) //
.forEach(container -> container.stop());
}
final Container container = register(config);
container.start();
return container;
}
|
java
|
public static Container start(final DockerConfig config, final boolean stopOthers) throws Exception {
Preconditions.checkArgument(config != null, "config must be non-null");
if (stopOthers) {
getRegisteredContainers().stream() //
.filter(container -> {
return container.isStarted() //
&& container.getRefCount() == 0 //
&& !StringUtils.equals(config.getName(), container.getConfig().getName());
}) //
.forEach(container -> container.stop());
}
final Container container = register(config);
container.start();
return container;
}
|
[
"public",
"static",
"Container",
"start",
"(",
"final",
"DockerConfig",
"config",
",",
"final",
"boolean",
"stopOthers",
")",
"throws",
"Exception",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"config",
"!=",
"null",
",",
"\"config must be non-null\"",
")",
";",
"if",
"(",
"stopOthers",
")",
"{",
"getRegisteredContainers",
"(",
")",
".",
"stream",
"(",
")",
"//",
".",
"filter",
"(",
"container",
"->",
"{",
"return",
"container",
".",
"isStarted",
"(",
")",
"//",
"&&",
"container",
".",
"getRefCount",
"(",
")",
"==",
"0",
"//",
"&&",
"!",
"StringUtils",
".",
"equals",
"(",
"config",
".",
"getName",
"(",
")",
",",
"container",
".",
"getConfig",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
")",
"//",
".",
"forEach",
"(",
"container",
"->",
"container",
".",
"stop",
"(",
")",
")",
";",
"}",
"final",
"Container",
"container",
"=",
"register",
"(",
"config",
")",
";",
"container",
".",
"start",
"(",
")",
";",
"return",
"container",
";",
"}"
] |
Starts a docker container with the given configuration.
This method is particularly useful when you want to start a container dynamically.
@param config
container configuration
@param stopOthers
true to stop other running containers; useful to limit the amount of memory that a
series of unit tests will consume.
@return a {@link Container} representing the started container.
@throws Exception
if the container cannot be started
|
[
"Starts",
"a",
"docker",
"container",
"with",
"the",
"given",
"configuration",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/DockerRule.java#L130-L146
|
9,639
|
netceteragroup/valdr-bean-validation
|
valdr-bean-validation/src/main/java/com/github/valdr/AnnotatedClass.java
|
AnnotatedClass.extractValidationRules
|
ClassConstraints extractValidationRules() {
final ClassConstraints classConstraints = new ClassConstraints();
Set<Field> allFields = ReflectionUtils.getAllFields(clazz, buildAnnotationsPredicate());
for (Field field : allFields) {
if (isNotExcluded(field)) {
FieldConstraints fieldValidationRules = new AnnotatedField(field,
relevantAnnotationClasses).extractValidationRules();
if (fieldValidationRules.size() > 0) {
classConstraints.put(field.getName(), fieldValidationRules);
}
}
}
return classConstraints;
}
|
java
|
ClassConstraints extractValidationRules() {
final ClassConstraints classConstraints = new ClassConstraints();
Set<Field> allFields = ReflectionUtils.getAllFields(clazz, buildAnnotationsPredicate());
for (Field field : allFields) {
if (isNotExcluded(field)) {
FieldConstraints fieldValidationRules = new AnnotatedField(field,
relevantAnnotationClasses).extractValidationRules();
if (fieldValidationRules.size() > 0) {
classConstraints.put(field.getName(), fieldValidationRules);
}
}
}
return classConstraints;
}
|
[
"ClassConstraints",
"extractValidationRules",
"(",
")",
"{",
"final",
"ClassConstraints",
"classConstraints",
"=",
"new",
"ClassConstraints",
"(",
")",
";",
"Set",
"<",
"Field",
">",
"allFields",
"=",
"ReflectionUtils",
".",
"getAllFields",
"(",
"clazz",
",",
"buildAnnotationsPredicate",
"(",
")",
")",
";",
"for",
"(",
"Field",
"field",
":",
"allFields",
")",
"{",
"if",
"(",
"isNotExcluded",
"(",
"field",
")",
")",
"{",
"FieldConstraints",
"fieldValidationRules",
"=",
"new",
"AnnotatedField",
"(",
"field",
",",
"relevantAnnotationClasses",
")",
".",
"extractValidationRules",
"(",
")",
";",
"if",
"(",
"fieldValidationRules",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"classConstraints",
".",
"put",
"(",
"field",
".",
"getName",
"(",
")",
",",
"fieldValidationRules",
")",
";",
"}",
"}",
"}",
"return",
"classConstraints",
";",
"}"
] |
Parses all fields and builds validation rules for those with relevant annotations.
@return validation rules for all fields that have at least one rule
@see AnnotatedClass(Class, Iterable)
|
[
"Parses",
"all",
"fields",
"and",
"builds",
"validation",
"rules",
"for",
"those",
"with",
"relevant",
"annotations",
"."
] |
3f49f1357c575a11331be2de867cf47809a83823
|
https://github.com/netceteragroup/valdr-bean-validation/blob/3f49f1357c575a11331be2de867cf47809a83823/valdr-bean-validation/src/main/java/com/github/valdr/AnnotatedClass.java#L42-L55
|
9,640
|
netceteragroup/valdr-bean-validation
|
valdr-bean-validation/src/main/java/com/github/valdr/AnnotatedField.java
|
AnnotatedField.extractValidationRules
|
FieldConstraints extractValidationRules() {
Annotation[] annotations = field.getAnnotations();
FieldConstraints fieldConstraints = new FieldConstraints();
for (Annotation annotation : annotations) {
if (Iterables.contains(relevantAnnotationClasses, annotation.annotationType())) {
ConstraintAttributes constraintAttributes = new ConstraintAttributes(annotation);
BuiltInConstraint supportedValidator = BuiltInConstraint.valueOfAnnotationClassOrNull(annotation
.annotationType());
if (supportedValidator == null) {
fieldConstraints.put(annotation.annotationType().getName(), constraintAttributes);
} else {
fieldConstraints.put(supportedValidator.toString(),
supportedValidator.createDecoratorFor(constraintAttributes));
}
}
}
return fieldConstraints;
}
|
java
|
FieldConstraints extractValidationRules() {
Annotation[] annotations = field.getAnnotations();
FieldConstraints fieldConstraints = new FieldConstraints();
for (Annotation annotation : annotations) {
if (Iterables.contains(relevantAnnotationClasses, annotation.annotationType())) {
ConstraintAttributes constraintAttributes = new ConstraintAttributes(annotation);
BuiltInConstraint supportedValidator = BuiltInConstraint.valueOfAnnotationClassOrNull(annotation
.annotationType());
if (supportedValidator == null) {
fieldConstraints.put(annotation.annotationType().getName(), constraintAttributes);
} else {
fieldConstraints.put(supportedValidator.toString(),
supportedValidator.createDecoratorFor(constraintAttributes));
}
}
}
return fieldConstraints;
}
|
[
"FieldConstraints",
"extractValidationRules",
"(",
")",
"{",
"Annotation",
"[",
"]",
"annotations",
"=",
"field",
".",
"getAnnotations",
"(",
")",
";",
"FieldConstraints",
"fieldConstraints",
"=",
"new",
"FieldConstraints",
"(",
")",
";",
"for",
"(",
"Annotation",
"annotation",
":",
"annotations",
")",
"{",
"if",
"(",
"Iterables",
".",
"contains",
"(",
"relevantAnnotationClasses",
",",
"annotation",
".",
"annotationType",
"(",
")",
")",
")",
"{",
"ConstraintAttributes",
"constraintAttributes",
"=",
"new",
"ConstraintAttributes",
"(",
"annotation",
")",
";",
"BuiltInConstraint",
"supportedValidator",
"=",
"BuiltInConstraint",
".",
"valueOfAnnotationClassOrNull",
"(",
"annotation",
".",
"annotationType",
"(",
")",
")",
";",
"if",
"(",
"supportedValidator",
"==",
"null",
")",
"{",
"fieldConstraints",
".",
"put",
"(",
"annotation",
".",
"annotationType",
"(",
")",
".",
"getName",
"(",
")",
",",
"constraintAttributes",
")",
";",
"}",
"else",
"{",
"fieldConstraints",
".",
"put",
"(",
"supportedValidator",
".",
"toString",
"(",
")",
",",
"supportedValidator",
".",
"createDecoratorFor",
"(",
"constraintAttributes",
")",
")",
";",
"}",
"}",
"}",
"return",
"fieldConstraints",
";",
"}"
] |
Parses all annotations and builds validation rules for the relevant ones.
@return validation rules (one per annotation)
@see AnnotatedField(Class, Iterable)
|
[
"Parses",
"all",
"annotations",
"and",
"builds",
"validation",
"rules",
"for",
"the",
"relevant",
"ones",
"."
] |
3f49f1357c575a11331be2de867cf47809a83823
|
https://github.com/netceteragroup/valdr-bean-validation/blob/3f49f1357c575a11331be2de867cf47809a83823/valdr-bean-validation/src/main/java/com/github/valdr/AnnotatedField.java#L32-L51
|
9,641
|
normanmaurer/niosmtp
|
src/main/java/me/normanmaurer/niosmtp/delivery/chain/ChainedSMTPClientFutureListener.java
|
ChainedSMTPClientFutureListener.initSession
|
@SuppressWarnings("unchecked")
private void initSession(SMTPClientSession session) {
Iterator<SMTPDeliveryEnvelope> transactionList = ((Iterator<SMTPDeliveryEnvelope>) session.getAttribute(SMTP_TRANSACTIONS_KEY));
SMTPDeliveryEnvelope transaction = transactionList.next();
session.setAttribute(CURRENT_SMTP_TRANSACTION_KEY,transaction);
session.setAttribute(RECIPIENTS_KEY, transaction.getRecipients().iterator());
session.setAttribute(DELIVERY_STATUS_KEY, new ArrayList<DeliveryRecipientStatus>());
// cleanup old attribute
session.setAttribute(CURRENT_RCPT_KEY, null);
}
|
java
|
@SuppressWarnings("unchecked")
private void initSession(SMTPClientSession session) {
Iterator<SMTPDeliveryEnvelope> transactionList = ((Iterator<SMTPDeliveryEnvelope>) session.getAttribute(SMTP_TRANSACTIONS_KEY));
SMTPDeliveryEnvelope transaction = transactionList.next();
session.setAttribute(CURRENT_SMTP_TRANSACTION_KEY,transaction);
session.setAttribute(RECIPIENTS_KEY, transaction.getRecipients().iterator());
session.setAttribute(DELIVERY_STATUS_KEY, new ArrayList<DeliveryRecipientStatus>());
// cleanup old attribute
session.setAttribute(CURRENT_RCPT_KEY, null);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"initSession",
"(",
"SMTPClientSession",
"session",
")",
"{",
"Iterator",
"<",
"SMTPDeliveryEnvelope",
">",
"transactionList",
"=",
"(",
"(",
"Iterator",
"<",
"SMTPDeliveryEnvelope",
">",
")",
"session",
".",
"getAttribute",
"(",
"SMTP_TRANSACTIONS_KEY",
")",
")",
";",
"SMTPDeliveryEnvelope",
"transaction",
"=",
"transactionList",
".",
"next",
"(",
")",
";",
"session",
".",
"setAttribute",
"(",
"CURRENT_SMTP_TRANSACTION_KEY",
",",
"transaction",
")",
";",
"session",
".",
"setAttribute",
"(",
"RECIPIENTS_KEY",
",",
"transaction",
".",
"getRecipients",
"(",
")",
".",
"iterator",
"(",
")",
")",
";",
"session",
".",
"setAttribute",
"(",
"DELIVERY_STATUS_KEY",
",",
"new",
"ArrayList",
"<",
"DeliveryRecipientStatus",
">",
"(",
")",
")",
";",
"// cleanup old attribute\r",
"session",
".",
"setAttribute",
"(",
"CURRENT_RCPT_KEY",
",",
"null",
")",
";",
"}"
] |
Init the SMTPClienSesion by adding all needed data to the attributes
@param session
|
[
"Init",
"the",
"SMTPClienSesion",
"by",
"adding",
"all",
"needed",
"data",
"to",
"the",
"attributes"
] |
817e775610fc74de3ea5a909d4b98d717d8aa4d4
|
https://github.com/normanmaurer/niosmtp/blob/817e775610fc74de3ea5a909d4b98d717d8aa4d4/src/main/java/me/normanmaurer/niosmtp/delivery/chain/ChainedSMTPClientFutureListener.java#L113-L125
|
9,642
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java
|
VertxPlatformFactory.getOrCreateVertx
|
public synchronized void getOrCreateVertx(
final VertxPlatformConfiguration config, final VertxListener listener) {
Vertx vertx = vertxPlatforms.get(config.getVertxPlatformIdentifier());
if (vertx != null) {
listener.whenReady(vertx);
return;
}
VertxOptions options = new VertxOptions();
options.setClustered(config.isClustered());
options.setClusterHost(config.getClusterHost());
options.setClusterPort(config.getClusterPort());
CountDownLatch latch = new CountDownLatch(1);
Vertx.clusteredVertx(options, ar -> {
try {
if (ar.succeeded()) {
log.log(Level.INFO, "Acquired Vert.x platform.");
listener.whenReady(ar.result());
vertxPlatforms.put(config.getVertxPlatformIdentifier(), ar.result());
} else {
throw new RuntimeException("Could not acquire Vert.x platform.",
ar.cause());
}
} finally {
latch.countDown();
}
});
try {
if (!latch.await(config.getTimeout(), TimeUnit.MILLISECONDS)) {
log.log(Level.SEVERE, "Could not acquire Vert.x platform in interval.");
throw new RuntimeException(
"Could not acquire Vert.x platform in interval");
}
} catch (Exception ignore) {
}
}
|
java
|
public synchronized void getOrCreateVertx(
final VertxPlatformConfiguration config, final VertxListener listener) {
Vertx vertx = vertxPlatforms.get(config.getVertxPlatformIdentifier());
if (vertx != null) {
listener.whenReady(vertx);
return;
}
VertxOptions options = new VertxOptions();
options.setClustered(config.isClustered());
options.setClusterHost(config.getClusterHost());
options.setClusterPort(config.getClusterPort());
CountDownLatch latch = new CountDownLatch(1);
Vertx.clusteredVertx(options, ar -> {
try {
if (ar.succeeded()) {
log.log(Level.INFO, "Acquired Vert.x platform.");
listener.whenReady(ar.result());
vertxPlatforms.put(config.getVertxPlatformIdentifier(), ar.result());
} else {
throw new RuntimeException("Could not acquire Vert.x platform.",
ar.cause());
}
} finally {
latch.countDown();
}
});
try {
if (!latch.await(config.getTimeout(), TimeUnit.MILLISECONDS)) {
log.log(Level.SEVERE, "Could not acquire Vert.x platform in interval.");
throw new RuntimeException(
"Could not acquire Vert.x platform in interval");
}
} catch (Exception ignore) {
}
}
|
[
"public",
"synchronized",
"void",
"getOrCreateVertx",
"(",
"final",
"VertxPlatformConfiguration",
"config",
",",
"final",
"VertxListener",
"listener",
")",
"{",
"Vertx",
"vertx",
"=",
"vertxPlatforms",
".",
"get",
"(",
"config",
".",
"getVertxPlatformIdentifier",
"(",
")",
")",
";",
"if",
"(",
"vertx",
"!=",
"null",
")",
"{",
"listener",
".",
"whenReady",
"(",
"vertx",
")",
";",
"return",
";",
"}",
"VertxOptions",
"options",
"=",
"new",
"VertxOptions",
"(",
")",
";",
"options",
".",
"setClustered",
"(",
"config",
".",
"isClustered",
"(",
")",
")",
";",
"options",
".",
"setClusterHost",
"(",
"config",
".",
"getClusterHost",
"(",
")",
")",
";",
"options",
".",
"setClusterPort",
"(",
"config",
".",
"getClusterPort",
"(",
")",
")",
";",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"Vertx",
".",
"clusteredVertx",
"(",
"options",
",",
"ar",
"->",
"{",
"try",
"{",
"if",
"(",
"ar",
".",
"succeeded",
"(",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Acquired Vert.x platform.\"",
")",
";",
"listener",
".",
"whenReady",
"(",
"ar",
".",
"result",
"(",
")",
")",
";",
"vertxPlatforms",
".",
"put",
"(",
"config",
".",
"getVertxPlatformIdentifier",
"(",
")",
",",
"ar",
".",
"result",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not acquire Vert.x platform.\"",
",",
"ar",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"}",
")",
";",
"try",
"{",
"if",
"(",
"!",
"latch",
".",
"await",
"(",
"config",
".",
"getTimeout",
"(",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Could not acquire Vert.x platform in interval.\"",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not acquire Vert.x platform in interval\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"}",
"}"
] |
Creates a Vertx if one is not started yet.
@param config
the configuration to start a vertx
@param lifecyleListener
the vertx lifecycle listener
|
[
"Creates",
"a",
"Vertx",
"if",
"one",
"is",
"not",
"started",
"yet",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java#L56-L95
|
9,643
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java
|
VertxPlatformFactory.addVertxHolder
|
public void addVertxHolder(VertxHolder holder) {
if (vertxPlatforms.containsValue(holder.getVertx())) {
if (!this.vertxHolders.contains(holder)) {
log.log(Level.INFO, "Adding Vertx Holder: " + holder);
this.vertxHolders.add(holder);
} else {
log.log(Level.WARNING, "Vertx Holder: " + holder
+ " has been added already.");
}
} else {
log.log(Level.SEVERE, "Vertx Holder: " + holder
+ " is out of management.");
}
}
|
java
|
public void addVertxHolder(VertxHolder holder) {
if (vertxPlatforms.containsValue(holder.getVertx())) {
if (!this.vertxHolders.contains(holder)) {
log.log(Level.INFO, "Adding Vertx Holder: " + holder);
this.vertxHolders.add(holder);
} else {
log.log(Level.WARNING, "Vertx Holder: " + holder
+ " has been added already.");
}
} else {
log.log(Level.SEVERE, "Vertx Holder: " + holder
+ " is out of management.");
}
}
|
[
"public",
"void",
"addVertxHolder",
"(",
"VertxHolder",
"holder",
")",
"{",
"if",
"(",
"vertxPlatforms",
".",
"containsValue",
"(",
"holder",
".",
"getVertx",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"vertxHolders",
".",
"contains",
"(",
"holder",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Adding Vertx Holder: \"",
"+",
"holder",
")",
";",
"this",
".",
"vertxHolders",
".",
"add",
"(",
"holder",
")",
";",
"}",
"else",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Vertx Holder: \"",
"+",
"holder",
"+",
"\" has been added already.\"",
")",
";",
"}",
"}",
"else",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Vertx Holder: \"",
"+",
"holder",
"+",
"\" is out of management.\"",
")",
";",
"}",
"}"
] |
Adds VertxHolder to be recorded.
@param holder
the VertxHolder
|
[
"Adds",
"VertxHolder",
"to",
"be",
"recorded",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java#L103-L117
|
9,644
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java
|
VertxPlatformFactory.removeVertxHolder
|
public void removeVertxHolder(VertxHolder holder) {
if (this.vertxHolders.contains(holder)) {
log.log(Level.INFO, "Removing Vertx Holder: " + holder);
this.vertxHolders.remove(holder);
} else {
log.log(Level.SEVERE, "Vertx Holder: " + holder
+ " is out of management.");
}
}
|
java
|
public void removeVertxHolder(VertxHolder holder) {
if (this.vertxHolders.contains(holder)) {
log.log(Level.INFO, "Removing Vertx Holder: " + holder);
this.vertxHolders.remove(holder);
} else {
log.log(Level.SEVERE, "Vertx Holder: " + holder
+ " is out of management.");
}
}
|
[
"public",
"void",
"removeVertxHolder",
"(",
"VertxHolder",
"holder",
")",
"{",
"if",
"(",
"this",
".",
"vertxHolders",
".",
"contains",
"(",
"holder",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Removing Vertx Holder: \"",
"+",
"holder",
")",
";",
"this",
".",
"vertxHolders",
".",
"remove",
"(",
"holder",
")",
";",
"}",
"else",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Vertx Holder: \"",
"+",
"holder",
"+",
"\" is out of management.\"",
")",
";",
"}",
"}"
] |
Removes the VertxHolder from recorded.
@param holder
the VertxHolder
|
[
"Removes",
"the",
"VertxHolder",
"from",
"recorded",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java#L125-L134
|
9,645
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java
|
VertxPlatformFactory.stopPlatformManager
|
public void stopPlatformManager(VertxPlatformConfiguration config) {
Vertx vertx = this.vertxPlatforms.get(config.getVertxPlatformIdentifier());
if (vertx != null && isVertxHolded(vertx)) {
log.log(Level.INFO,
"Stopping Vert.x: " + config.getVertxPlatformIdentifier());
vertxPlatforms.remove(config.getVertxPlatformIdentifier());
stopVertx(vertx);
}
}
|
java
|
public void stopPlatformManager(VertxPlatformConfiguration config) {
Vertx vertx = this.vertxPlatforms.get(config.getVertxPlatformIdentifier());
if (vertx != null && isVertxHolded(vertx)) {
log.log(Level.INFO,
"Stopping Vert.x: " + config.getVertxPlatformIdentifier());
vertxPlatforms.remove(config.getVertxPlatformIdentifier());
stopVertx(vertx);
}
}
|
[
"public",
"void",
"stopPlatformManager",
"(",
"VertxPlatformConfiguration",
"config",
")",
"{",
"Vertx",
"vertx",
"=",
"this",
".",
"vertxPlatforms",
".",
"get",
"(",
"config",
".",
"getVertxPlatformIdentifier",
"(",
")",
")",
";",
"if",
"(",
"vertx",
"!=",
"null",
"&&",
"isVertxHolded",
"(",
"vertx",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Stopping Vert.x: \"",
"+",
"config",
".",
"getVertxPlatformIdentifier",
"(",
")",
")",
";",
"vertxPlatforms",
".",
"remove",
"(",
"config",
".",
"getVertxPlatformIdentifier",
"(",
")",
")",
";",
"stopVertx",
"(",
"vertx",
")",
";",
"}",
"}"
] |
Stops the Vert.x Platform Manager and removes it from cache.
@param config
|
[
"Stops",
"the",
"Vert",
".",
"x",
"Platform",
"Manager",
"and",
"removes",
"it",
"from",
"cache",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java#L141-L150
|
9,646
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java
|
VertxPlatformFactory.closeAllPlatforms
|
public void closeAllPlatforms() {
log.log(Level.FINEST, "Closing all Vert.x instances");
try {
for (Map.Entry<String, Vertx> entry : this.vertxPlatforms.entrySet()) {
stopVertx(entry.getValue());
}
vertxPlatforms.clear();
vertxHolders.clear();
} catch (Exception e) {
log.log(Level.SEVERE, "Error closing Vert.x instance", e.getCause());
}
}
|
java
|
public void closeAllPlatforms() {
log.log(Level.FINEST, "Closing all Vert.x instances");
try {
for (Map.Entry<String, Vertx> entry : this.vertxPlatforms.entrySet()) {
stopVertx(entry.getValue());
}
vertxPlatforms.clear();
vertxHolders.clear();
} catch (Exception e) {
log.log(Level.SEVERE, "Error closing Vert.x instance", e.getCause());
}
}
|
[
"public",
"void",
"closeAllPlatforms",
"(",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"FINEST",
",",
"\"Closing all Vert.x instances\"",
")",
";",
"try",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Vertx",
">",
"entry",
":",
"this",
".",
"vertxPlatforms",
".",
"entrySet",
"(",
")",
")",
"{",
"stopVertx",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"vertxPlatforms",
".",
"clear",
"(",
")",
";",
"vertxHolders",
".",
"clear",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Error closing Vert.x instance\"",
",",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"}"
] |
Stops all started Vert.x platforms.
Clears all vertx holders.
|
[
"Stops",
"all",
"started",
"Vert",
".",
"x",
"platforms",
"."
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxPlatformFactory.java#L166-L180
|
9,647
|
netceteragroup/valdr-bean-validation
|
valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java
|
ConstraintParser.parse
|
public String parse() {
Map<String, ClassConstraints> classNameToValidationRulesMap = new HashMap<>();
for (Class clazz : classpathScanner.findClassesToParse()) {
if (clazz != null) {
ClassConstraints classValidationRules = new AnnotatedClass(clazz, options.getExcludedFields(),
allRelevantAnnotationClasses).extractValidationRules();
if (classValidationRules.size() > 0) {
String name = options.getOutputFullTypeName() ? clazz.getName() : clazz.getSimpleName();
classNameToValidationRulesMap.put(name, classValidationRules);
}
}
}
return toJson(classNameToValidationRulesMap);
}
|
java
|
public String parse() {
Map<String, ClassConstraints> classNameToValidationRulesMap = new HashMap<>();
for (Class clazz : classpathScanner.findClassesToParse()) {
if (clazz != null) {
ClassConstraints classValidationRules = new AnnotatedClass(clazz, options.getExcludedFields(),
allRelevantAnnotationClasses).extractValidationRules();
if (classValidationRules.size() > 0) {
String name = options.getOutputFullTypeName() ? clazz.getName() : clazz.getSimpleName();
classNameToValidationRulesMap.put(name, classValidationRules);
}
}
}
return toJson(classNameToValidationRulesMap);
}
|
[
"public",
"String",
"parse",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"ClassConstraints",
">",
"classNameToValidationRulesMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Class",
"clazz",
":",
"classpathScanner",
".",
"findClassesToParse",
"(",
")",
")",
"{",
"if",
"(",
"clazz",
"!=",
"null",
")",
"{",
"ClassConstraints",
"classValidationRules",
"=",
"new",
"AnnotatedClass",
"(",
"clazz",
",",
"options",
".",
"getExcludedFields",
"(",
")",
",",
"allRelevantAnnotationClasses",
")",
".",
"extractValidationRules",
"(",
")",
";",
"if",
"(",
"classValidationRules",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"String",
"name",
"=",
"options",
".",
"getOutputFullTypeName",
"(",
")",
"?",
"clazz",
".",
"getName",
"(",
")",
":",
"clazz",
".",
"getSimpleName",
"(",
")",
";",
"classNameToValidationRulesMap",
".",
"put",
"(",
"name",
",",
"classValidationRules",
")",
";",
"}",
"}",
"}",
"return",
"toJson",
"(",
"classNameToValidationRulesMap",
")",
";",
"}"
] |
Based on the configuration passed to the constructor model classes are parsed for constraints.
@return JSON string for <a href="https://github.com/netceteragroup/valdr">valdr</a>
|
[
"Based",
"on",
"the",
"configuration",
"passed",
"to",
"the",
"constructor",
"model",
"classes",
"are",
"parsed",
"for",
"constraints",
"."
] |
3f49f1357c575a11331be2de867cf47809a83823
|
https://github.com/netceteragroup/valdr-bean-validation/blob/3f49f1357c575a11331be2de867cf47809a83823/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java#L53-L68
|
9,648
|
canoo/open-dolphin
|
subprojects/client/src/main/groovy/org/opendolphin/core/client/ClientModelStore.java
|
ClientModelStore.add
|
@Override
public boolean add(ClientPresentationModel model) {
boolean success = super.add(model);
if (success) {
List<ClientAttribute> attributes = model.getAttributes();
for (ClientAttribute attribute : attributes) {
attribute.addPropertyChangeListener(attributeChangeListener);
}
if (!model.isClientSideOnly()) {
getClientConnector().send(CreatePresentationModelCommand.makeFrom(model));
}
}
return success;
}
|
java
|
@Override
public boolean add(ClientPresentationModel model) {
boolean success = super.add(model);
if (success) {
List<ClientAttribute> attributes = model.getAttributes();
for (ClientAttribute attribute : attributes) {
attribute.addPropertyChangeListener(attributeChangeListener);
}
if (!model.isClientSideOnly()) {
getClientConnector().send(CreatePresentationModelCommand.makeFrom(model));
}
}
return success;
}
|
[
"@",
"Override",
"public",
"boolean",
"add",
"(",
"ClientPresentationModel",
"model",
")",
"{",
"boolean",
"success",
"=",
"super",
".",
"add",
"(",
"model",
")",
";",
"if",
"(",
"success",
")",
"{",
"List",
"<",
"ClientAttribute",
">",
"attributes",
"=",
"model",
".",
"getAttributes",
"(",
")",
";",
"for",
"(",
"ClientAttribute",
"attribute",
":",
"attributes",
")",
"{",
"attribute",
".",
"addPropertyChangeListener",
"(",
"attributeChangeListener",
")",
";",
"}",
"if",
"(",
"!",
"model",
".",
"isClientSideOnly",
"(",
")",
")",
"{",
"getClientConnector",
"(",
")",
".",
"send",
"(",
"CreatePresentationModelCommand",
".",
"makeFrom",
"(",
"model",
")",
")",
";",
"}",
"}",
"return",
"success",
";",
"}"
] |
ModelStoreListener ADDED will be fired before server is notified.
|
[
"ModelStoreListener",
"ADDED",
"will",
"be",
"fired",
"before",
"server",
"is",
"notified",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/client/src/main/groovy/org/opendolphin/core/client/ClientModelStore.java#L67-L80
|
9,649
|
canoo/open-dolphin
|
subprojects/client/src/main/groovy/org/opendolphin/core/client/ClientModelStore.java
|
ClientModelStore.deleteAllPresentationModelsOfType
|
public void deleteAllPresentationModelsOfType(String presentationModelType) {
getClientConnector().send(new DeletedAllPresentationModelsOfTypeNotification(presentationModelType));
List<ClientPresentationModel> models = new LinkedList<ClientPresentationModel>(findAllPresentationModelsByType(presentationModelType));
for (ClientPresentationModel model: models) {
delete(model, false);
}
}
|
java
|
public void deleteAllPresentationModelsOfType(String presentationModelType) {
getClientConnector().send(new DeletedAllPresentationModelsOfTypeNotification(presentationModelType));
List<ClientPresentationModel> models = new LinkedList<ClientPresentationModel>(findAllPresentationModelsByType(presentationModelType));
for (ClientPresentationModel model: models) {
delete(model, false);
}
}
|
[
"public",
"void",
"deleteAllPresentationModelsOfType",
"(",
"String",
"presentationModelType",
")",
"{",
"getClientConnector",
"(",
")",
".",
"send",
"(",
"new",
"DeletedAllPresentationModelsOfTypeNotification",
"(",
"presentationModelType",
")",
")",
";",
"List",
"<",
"ClientPresentationModel",
">",
"models",
"=",
"new",
"LinkedList",
"<",
"ClientPresentationModel",
">",
"(",
"findAllPresentationModelsByType",
"(",
"presentationModelType",
")",
")",
";",
"for",
"(",
"ClientPresentationModel",
"model",
":",
"models",
")",
"{",
"delete",
"(",
"model",
",",
"false",
")",
";",
"}",
"}"
] |
ModelStoreListener REMOVE will be fired after the server is notified.
|
[
"ModelStoreListener",
"REMOVE",
"will",
"be",
"fired",
"after",
"the",
"server",
"is",
"notified",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/client/src/main/groovy/org/opendolphin/core/client/ClientModelStore.java#L136-L142
|
9,650
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/inflow/impl/VertxActivation.java
|
VertxActivation.start
|
public void start() throws ResourceException {
if (!deliveryActive.get()) {
VertxPlatformFactory.instance().getOrCreateVertx(config, this);
VertxPlatformFactory.instance().addVertxHolder(this);
}
setup();
}
|
java
|
public void start() throws ResourceException {
if (!deliveryActive.get()) {
VertxPlatformFactory.instance().getOrCreateVertx(config, this);
VertxPlatformFactory.instance().addVertxHolder(this);
}
setup();
}
|
[
"public",
"void",
"start",
"(",
")",
"throws",
"ResourceException",
"{",
"if",
"(",
"!",
"deliveryActive",
".",
"get",
"(",
")",
")",
"{",
"VertxPlatformFactory",
".",
"instance",
"(",
")",
".",
"getOrCreateVertx",
"(",
"config",
",",
"this",
")",
";",
"VertxPlatformFactory",
".",
"instance",
"(",
")",
".",
"addVertxHolder",
"(",
"this",
")",
";",
"}",
"setup",
"(",
")",
";",
"}"
] |
Start the activation
@throws ResourceException
Thrown if an error occurs
|
[
"Start",
"the",
"activation"
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/inflow/impl/VertxActivation.java#L83-L90
|
9,651
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/extensibility/OrtcClient.java
|
OrtcClient.send
|
public void send(String channel, String message) {
// CAUSE: Assignment to method parameter
Pair<Boolean, String> sendValidation = isSendValid(channel, message, null, null);
//String lMessage = message.replace("\n", "\\n");
if (sendValidation != null && sendValidation.first) {
try {
String messageId = Strings.randomString(8);
ArrayList<Pair<String, String>> messagesToSend = multiPartMessage(
message, messageId);
for (Pair<String, String> messageToSend : messagesToSend) {
send(channel, messageToSend.second, messageToSend.first,
sendValidation.second);
}
} catch (IOException e) {
raiseOrtcEvent(EventEnum.OnException, this, e);
}
}
}
|
java
|
public void send(String channel, String message) {
// CAUSE: Assignment to method parameter
Pair<Boolean, String> sendValidation = isSendValid(channel, message, null, null);
//String lMessage = message.replace("\n", "\\n");
if (sendValidation != null && sendValidation.first) {
try {
String messageId = Strings.randomString(8);
ArrayList<Pair<String, String>> messagesToSend = multiPartMessage(
message, messageId);
for (Pair<String, String> messageToSend : messagesToSend) {
send(channel, messageToSend.second, messageToSend.first,
sendValidation.second);
}
} catch (IOException e) {
raiseOrtcEvent(EventEnum.OnException, this, e);
}
}
}
|
[
"public",
"void",
"send",
"(",
"String",
"channel",
",",
"String",
"message",
")",
"{",
"// CAUSE: Assignment to method parameter",
"Pair",
"<",
"Boolean",
",",
"String",
">",
"sendValidation",
"=",
"isSendValid",
"(",
"channel",
",",
"message",
",",
"null",
",",
"null",
")",
";",
"//String lMessage = message.replace(\"\\n\", \"\\\\n\");",
"if",
"(",
"sendValidation",
"!=",
"null",
"&&",
"sendValidation",
".",
"first",
")",
"{",
"try",
"{",
"String",
"messageId",
"=",
"Strings",
".",
"randomString",
"(",
"8",
")",
";",
"ArrayList",
"<",
"Pair",
"<",
"String",
",",
"String",
">",
">",
"messagesToSend",
"=",
"multiPartMessage",
"(",
"message",
",",
"messageId",
")",
";",
"for",
"(",
"Pair",
"<",
"String",
",",
"String",
">",
"messageToSend",
":",
"messagesToSend",
")",
"{",
"send",
"(",
"channel",
",",
"messageToSend",
".",
"second",
",",
"messageToSend",
".",
"first",
",",
"sendValidation",
".",
"second",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"raiseOrtcEvent",
"(",
"EventEnum",
".",
"OnException",
",",
"this",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Sends a message to the specified channel.
@param channel
Channel to wich the message should be sent
@param message
The content of the message to be sent
|
[
"Sends",
"a",
"message",
"to",
"the",
"specified",
"channel",
"."
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L634-L653
|
9,652
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/extensibility/OrtcClient.java
|
OrtcClient.subscribeWithFilter
|
public void subscribeWithFilter(String channel, boolean subscribeOnReconnect, String filter,
OnMessageWithFilter onMessageWithFilter) {
ChannelSubscription subscribedChannel = subscribedChannels.get(channel);
Pair<Boolean, String> subscribeValidation = isSubscribeValid(channel,
subscribedChannel);
if (subscribeValidation != null && subscribeValidation.first) {
subscribedChannel = new ChannelSubscription(subscribeOnReconnect,
onMessageWithFilter);
subscribedChannel.setFilter(filter);
subscribedChannel.setWithFilter(true);
subscribedChannel.setSubscribing(true);
subscribedChannels.put(channel, subscribedChannel);
subscribe(channel, subscribeValidation.second, true, filter);
}
}
|
java
|
public void subscribeWithFilter(String channel, boolean subscribeOnReconnect, String filter,
OnMessageWithFilter onMessageWithFilter) {
ChannelSubscription subscribedChannel = subscribedChannels.get(channel);
Pair<Boolean, String> subscribeValidation = isSubscribeValid(channel,
subscribedChannel);
if (subscribeValidation != null && subscribeValidation.first) {
subscribedChannel = new ChannelSubscription(subscribeOnReconnect,
onMessageWithFilter);
subscribedChannel.setFilter(filter);
subscribedChannel.setWithFilter(true);
subscribedChannel.setSubscribing(true);
subscribedChannels.put(channel, subscribedChannel);
subscribe(channel, subscribeValidation.second, true, filter);
}
}
|
[
"public",
"void",
"subscribeWithFilter",
"(",
"String",
"channel",
",",
"boolean",
"subscribeOnReconnect",
",",
"String",
"filter",
",",
"OnMessageWithFilter",
"onMessageWithFilter",
")",
"{",
"ChannelSubscription",
"subscribedChannel",
"=",
"subscribedChannels",
".",
"get",
"(",
"channel",
")",
";",
"Pair",
"<",
"Boolean",
",",
"String",
">",
"subscribeValidation",
"=",
"isSubscribeValid",
"(",
"channel",
",",
"subscribedChannel",
")",
";",
"if",
"(",
"subscribeValidation",
"!=",
"null",
"&&",
"subscribeValidation",
".",
"first",
")",
"{",
"subscribedChannel",
"=",
"new",
"ChannelSubscription",
"(",
"subscribeOnReconnect",
",",
"onMessageWithFilter",
")",
";",
"subscribedChannel",
".",
"setFilter",
"(",
"filter",
")",
";",
"subscribedChannel",
".",
"setWithFilter",
"(",
"true",
")",
";",
"subscribedChannel",
".",
"setSubscribing",
"(",
"true",
")",
";",
"subscribedChannels",
".",
"put",
"(",
"channel",
",",
"subscribedChannel",
")",
";",
"subscribe",
"(",
"channel",
",",
"subscribeValidation",
".",
"second",
",",
"true",
",",
"filter",
")",
";",
"}",
"}"
] |
subscribeWithFilter the specified channel with a given filter in order to receive filtered messages in that
channel
@param channel
Channel to be subscribed
@param subscribeOnReconnect
Indicates if the channel should be subscribe if the event on
reconnected is fired
@param filter
The filter to apply to messages on the given channel
@param onMessageWithFilter
Event handler that will be called when a message will be
received on the subscribed channel
|
[
"subscribeWithFilter",
"the",
"specified",
"channel",
"with",
"a",
"given",
"filter",
"in",
"order",
"to",
"receive",
"filtered",
"messages",
"in",
"that",
"channel"
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L892-L908
|
9,653
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/extensibility/OrtcClient.java
|
OrtcClient.isSubscribed
|
public Boolean isSubscribed(String channel) {
Boolean result = null;
/*
* Sanity checks
*/
if (!isConnected) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcNotConnectedException());
} else if (Strings.isNullOrEmpty(channel)) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcEmptyFieldException("Channel"));
} else if (!Strings.ortcIsValidInput(channel)) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcInvalidCharactersException("Channel"));
} else {
ChannelSubscription subscribedChannel = subscribedChannels
.get(channel);
result = subscribedChannel != null
&& subscribedChannel.isSubscribed();
}
return result;
}
|
java
|
public Boolean isSubscribed(String channel) {
Boolean result = null;
/*
* Sanity checks
*/
if (!isConnected) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcNotConnectedException());
} else if (Strings.isNullOrEmpty(channel)) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcEmptyFieldException("Channel"));
} else if (!Strings.ortcIsValidInput(channel)) {
raiseOrtcEvent(EventEnum.OnException, this,
new OrtcInvalidCharactersException("Channel"));
} else {
ChannelSubscription subscribedChannel = subscribedChannels
.get(channel);
result = subscribedChannel != null
&& subscribedChannel.isSubscribed();
}
return result;
}
|
[
"public",
"Boolean",
"isSubscribed",
"(",
"String",
"channel",
")",
"{",
"Boolean",
"result",
"=",
"null",
";",
"/*\n\t\t * Sanity checks\n\t\t */",
"if",
"(",
"!",
"isConnected",
")",
"{",
"raiseOrtcEvent",
"(",
"EventEnum",
".",
"OnException",
",",
"this",
",",
"new",
"OrtcNotConnectedException",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"channel",
")",
")",
"{",
"raiseOrtcEvent",
"(",
"EventEnum",
".",
"OnException",
",",
"this",
",",
"new",
"OrtcEmptyFieldException",
"(",
"\"Channel\"",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"Strings",
".",
"ortcIsValidInput",
"(",
"channel",
")",
")",
"{",
"raiseOrtcEvent",
"(",
"EventEnum",
".",
"OnException",
",",
"this",
",",
"new",
"OrtcInvalidCharactersException",
"(",
"\"Channel\"",
")",
")",
";",
"}",
"else",
"{",
"ChannelSubscription",
"subscribedChannel",
"=",
"subscribedChannels",
".",
"get",
"(",
"channel",
")",
";",
"result",
"=",
"subscribedChannel",
"!=",
"null",
"&&",
"subscribedChannel",
".",
"isSubscribed",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Indicates if the channel is subscribed
@param channel
Channel to check
@return boolean True if the channel is subscribed otherwise false
|
[
"Indicates",
"if",
"the",
"channel",
"is",
"subscribed"
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L1159-L1182
|
9,654
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/extensibility/OrtcClient.java
|
OrtcClient.setProxy
|
public void setProxy(String host, int port, String user, String pwd) {
this.proxy = new Proxy(host, port, user, pwd);
}
|
java
|
public void setProxy(String host, int port, String user, String pwd) {
this.proxy = new Proxy(host, port, user, pwd);
}
|
[
"public",
"void",
"setProxy",
"(",
"String",
"host",
",",
"int",
"port",
",",
"String",
"user",
",",
"String",
"pwd",
")",
"{",
"this",
".",
"proxy",
"=",
"new",
"Proxy",
"(",
"host",
",",
"port",
",",
"user",
",",
"pwd",
")",
";",
"}"
] |
sets proxy, optionally using basic authentication
@param host proxy host
@param port proxy port
@param user proxy user or null when no authentication is needed
@param pwd proxy password or null when no authentication is needed
|
[
"sets",
"proxy",
"optionally",
"using",
"basic",
"authentication"
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L1329-L1331
|
9,655
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/api/Ortc.java
|
Ortc.loadOrtcFactory
|
public OrtcFactory loadOrtcFactory(String ortcType) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
OrtcFactory result = null;
// Gets the plugin class definition
Class<?> factoryClass = this.getClass().getClassLoader()
.loadClass(String.format("ibt.ortc.plugins.%s.%sFactory", ortcType, ortcType));
if (factoryClass != null) {
// Creates an instance of the plugin class
result = OrtcFactory.class.cast(factoryClass.newInstance());
}
return result;
}
|
java
|
public OrtcFactory loadOrtcFactory(String ortcType) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
OrtcFactory result = null;
// Gets the plugin class definition
Class<?> factoryClass = this.getClass().getClassLoader()
.loadClass(String.format("ibt.ortc.plugins.%s.%sFactory", ortcType, ortcType));
if (factoryClass != null) {
// Creates an instance of the plugin class
result = OrtcFactory.class.cast(factoryClass.newInstance());
}
return result;
}
|
[
"public",
"OrtcFactory",
"loadOrtcFactory",
"(",
"String",
"ortcType",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
",",
"ClassNotFoundException",
"{",
"OrtcFactory",
"result",
"=",
"null",
";",
"// Gets the plugin class definition",
"Class",
"<",
"?",
">",
"factoryClass",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"loadClass",
"(",
"String",
".",
"format",
"(",
"\"ibt.ortc.plugins.%s.%sFactory\"",
",",
"ortcType",
",",
"ortcType",
")",
")",
";",
"if",
"(",
"factoryClass",
"!=",
"null",
")",
"{",
"// Creates an instance of the plugin class",
"result",
"=",
"OrtcFactory",
".",
"class",
".",
"cast",
"(",
"factoryClass",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Creates an instance of a factory of the specified Ortc plugin type
@param ortcType
The Ortc plugin type
@return Instance of Ortc factory
@throws InstantiationException
@throws IllegalAccessException
@throws ClassNotFoundException
|
[
"Creates",
"an",
"instance",
"of",
"a",
"factory",
"of",
"the",
"specified",
"Ortc",
"plugin",
"type"
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/api/Ortc.java#L250-L263
|
9,656
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/util/Base64.java
|
Base64.encode
|
@SuppressWarnings("AssignmentToForLoopParameter")
public static String encode(final byte[] data) {
final int len = data.length;
final StringBuilder result = new StringBuilder((len / 3 + 1) * 4);
int bte;
int index;
for (int i = 0; i < len; i++) {
bte = data[i];
// First 6 bits
index = bte >> 2 & MASK_6;
result.append(CHAR_TABLE.charAt(index));
// Last 2 bits plus 4 from next byte
index = bte << 4 & MASK_6;
if (++i < len) {
bte = data[i];
index |= bte >> 4 & MASK_4;
}
result.append(CHAR_TABLE.charAt(index));
// 4 + 2 from next
if (i < len) {
index = bte << 2 & MASK_6;
if (++i < len) {
bte = data[i];
index |= bte >> 6 & MASK_2;
}
result.append(CHAR_TABLE.charAt(index));
} else {
i++;
result.append(CHAR_TABLE.charAt(64));
}
if (i < len) {
index = bte & MASK_6;
result.append(CHAR_TABLE.charAt(index));
} else {
result.append(CHAR_TABLE.charAt(64));
}
}
return result.toString();
}
|
java
|
@SuppressWarnings("AssignmentToForLoopParameter")
public static String encode(final byte[] data) {
final int len = data.length;
final StringBuilder result = new StringBuilder((len / 3 + 1) * 4);
int bte;
int index;
for (int i = 0; i < len; i++) {
bte = data[i];
// First 6 bits
index = bte >> 2 & MASK_6;
result.append(CHAR_TABLE.charAt(index));
// Last 2 bits plus 4 from next byte
index = bte << 4 & MASK_6;
if (++i < len) {
bte = data[i];
index |= bte >> 4 & MASK_4;
}
result.append(CHAR_TABLE.charAt(index));
// 4 + 2 from next
if (i < len) {
index = bte << 2 & MASK_6;
if (++i < len) {
bte = data[i];
index |= bte >> 6 & MASK_2;
}
result.append(CHAR_TABLE.charAt(index));
} else {
i++;
result.append(CHAR_TABLE.charAt(64));
}
if (i < len) {
index = bte & MASK_6;
result.append(CHAR_TABLE.charAt(index));
} else {
result.append(CHAR_TABLE.charAt(64));
}
}
return result.toString();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"AssignmentToForLoopParameter\"",
")",
"public",
"static",
"String",
"encode",
"(",
"final",
"byte",
"[",
"]",
"data",
")",
"{",
"final",
"int",
"len",
"=",
"data",
".",
"length",
";",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"(",
"len",
"/",
"3",
"+",
"1",
")",
"*",
"4",
")",
";",
"int",
"bte",
";",
"int",
"index",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"bte",
"=",
"data",
"[",
"i",
"]",
";",
"// First 6 bits",
"index",
"=",
"bte",
">>",
"2",
"&",
"MASK_6",
";",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"index",
")",
")",
";",
"// Last 2 bits plus 4 from next byte",
"index",
"=",
"bte",
"<<",
"4",
"&",
"MASK_6",
";",
"if",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"bte",
"=",
"data",
"[",
"i",
"]",
";",
"index",
"|=",
"bte",
">>",
"4",
"&",
"MASK_4",
";",
"}",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"index",
")",
")",
";",
"// 4 + 2 from next",
"if",
"(",
"i",
"<",
"len",
")",
"{",
"index",
"=",
"bte",
"<<",
"2",
"&",
"MASK_6",
";",
"if",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"bte",
"=",
"data",
"[",
"i",
"]",
";",
"index",
"|=",
"bte",
">>",
"6",
"&",
"MASK_2",
";",
"}",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"index",
")",
")",
";",
"}",
"else",
"{",
"i",
"++",
";",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"64",
")",
")",
";",
"}",
"if",
"(",
"i",
"<",
"len",
")",
"{",
"index",
"=",
"bte",
"&",
"MASK_6",
";",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"index",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"CHAR_TABLE",
".",
"charAt",
"(",
"64",
")",
")",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Encodes the given data to a base64 string.
@param data a valid byte[], must not be null.
@return a valid <code>String</code> instance representing the base64 encoding of the given data.
|
[
"Encodes",
"the",
"given",
"data",
"to",
"a",
"base64",
"string",
"."
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/util/Base64.java#L20-L65
|
9,657
|
canoo/open-dolphin
|
subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java
|
DolphinServlet.decodeInput
|
protected List<Command> decodeInput(Codec codec, String input) {
return codec.decode(input);
}
|
java
|
protected List<Command> decodeInput(Codec codec, String input) {
return codec.decode(input);
}
|
[
"protected",
"List",
"<",
"Command",
">",
"decodeInput",
"(",
"Codec",
"codec",
",",
"String",
"input",
")",
"{",
"return",
"codec",
".",
"decode",
"(",
"input",
")",
";",
"}"
] |
Decodes the given input.
@param codec - the {@code Codec} used to decode {@code input}
@param input - the incoming encoded commands
@return a collection of decoded commands
|
[
"Decodes",
"the",
"given",
"input",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java#L192-L194
|
9,658
|
canoo/open-dolphin
|
subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java
|
DolphinServlet.handleCommands
|
protected List<Command> handleCommands(ServerConnector serverConnector, List<Command> commands) {
List<Command> results = new ArrayList<Command>();
for (Command command : commands) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("processing " + command);
}
// TODO: add a catch-all exception handler here ?
results.addAll(serverConnector.receive(command));
}
return results;
}
|
java
|
protected List<Command> handleCommands(ServerConnector serverConnector, List<Command> commands) {
List<Command> results = new ArrayList<Command>();
for (Command command : commands) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("processing " + command);
}
// TODO: add a catch-all exception handler here ?
results.addAll(serverConnector.receive(command));
}
return results;
}
|
[
"protected",
"List",
"<",
"Command",
">",
"handleCommands",
"(",
"ServerConnector",
"serverConnector",
",",
"List",
"<",
"Command",
">",
"commands",
")",
"{",
"List",
"<",
"Command",
">",
"results",
"=",
"new",
"ArrayList",
"<",
"Command",
">",
"(",
")",
";",
"for",
"(",
"Command",
"command",
":",
"commands",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINEST",
")",
")",
"{",
"LOG",
".",
"finest",
"(",
"\"processing \"",
"+",
"command",
")",
";",
"}",
"// TODO: add a catch-all exception handler here ?",
"results",
".",
"addAll",
"(",
"serverConnector",
".",
"receive",
"(",
"command",
")",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Processes incoming commands and creates outgoing commands.
@param serverConnector - the {@code ServerConnector} required to han dle each command
@param commands - the collection of incoming commands to be handled
@return - a collection of outgoing commands
|
[
"Processes",
"incoming",
"commands",
"and",
"creates",
"outgoing",
"commands",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java#L204-L214
|
9,659
|
canoo/open-dolphin
|
subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java
|
DolphinServlet.encodeOutput
|
protected String encodeOutput(Codec codec, List<Command> results) {
return codec.encode(results);
}
|
java
|
protected String encodeOutput(Codec codec, List<Command> results) {
return codec.encode(results);
}
|
[
"protected",
"String",
"encodeOutput",
"(",
"Codec",
"codec",
",",
"List",
"<",
"Command",
">",
"results",
")",
"{",
"return",
"codec",
".",
"encode",
"(",
"results",
")",
";",
"}"
] |
Encodes the given output.
@param codec - the {@code Codec} used to endecode {@code output}
@param results - the outgoing collection of commands to be encoded.
@return a literal representation of the encoded commands
|
[
"Encodes",
"the",
"given",
"output",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/server/src/main/groovy/org/opendolphin/server/adapter/DolphinServlet.java#L224-L226
|
9,660
|
canoo/open-dolphin
|
subprojects/shared/src/main/groovy/org/opendolphin/core/BasePresentationModel.java
|
BasePresentationModel.getValue
|
public int getValue(String attributeName, int defaultValue) {
A attribute = getAt(attributeName);
Object attributeValue = (attribute == null) ? null : attribute.getValue();
return (attributeValue == null) ? defaultValue : Integer.parseInt(attributeValue.toString());
}
|
java
|
public int getValue(String attributeName, int defaultValue) {
A attribute = getAt(attributeName);
Object attributeValue = (attribute == null) ? null : attribute.getValue();
return (attributeValue == null) ? defaultValue : Integer.parseInt(attributeValue.toString());
}
|
[
"public",
"int",
"getValue",
"(",
"String",
"attributeName",
",",
"int",
"defaultValue",
")",
"{",
"A",
"attribute",
"=",
"getAt",
"(",
"attributeName",
")",
";",
"Object",
"attributeValue",
"=",
"(",
"attribute",
"==",
"null",
")",
"?",
"null",
":",
"attribute",
".",
"getValue",
"(",
")",
";",
"return",
"(",
"attributeValue",
"==",
"null",
")",
"?",
"defaultValue",
":",
"Integer",
".",
"parseInt",
"(",
"attributeValue",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Convenience method to get the value of an attribute if it exists or a default value otherwise.
|
[
"Convenience",
"method",
"to",
"get",
"the",
"value",
"of",
"an",
"attribute",
"if",
"it",
"exists",
"or",
"a",
"default",
"value",
"otherwise",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/shared/src/main/groovy/org/opendolphin/core/BasePresentationModel.java#L126-L130
|
9,661
|
canoo/open-dolphin
|
subprojects/shared/src/main/groovy/org/opendolphin/core/BasePresentationModel.java
|
BasePresentationModel.syncWith
|
public void syncWith(PresentationModel sourcePresentationModel) {
for (A targetAttribute : attributes) {
Attribute sourceAttribute = sourcePresentationModel.getAt(targetAttribute.getPropertyName(), targetAttribute.getTag());
if (sourceAttribute != null) targetAttribute.syncWith(sourceAttribute);
}
}
|
java
|
public void syncWith(PresentationModel sourcePresentationModel) {
for (A targetAttribute : attributes) {
Attribute sourceAttribute = sourcePresentationModel.getAt(targetAttribute.getPropertyName(), targetAttribute.getTag());
if (sourceAttribute != null) targetAttribute.syncWith(sourceAttribute);
}
}
|
[
"public",
"void",
"syncWith",
"(",
"PresentationModel",
"sourcePresentationModel",
")",
"{",
"for",
"(",
"A",
"targetAttribute",
":",
"attributes",
")",
"{",
"Attribute",
"sourceAttribute",
"=",
"sourcePresentationModel",
".",
"getAt",
"(",
"targetAttribute",
".",
"getPropertyName",
"(",
")",
",",
"targetAttribute",
".",
"getTag",
"(",
")",
")",
";",
"if",
"(",
"sourceAttribute",
"!=",
"null",
")",
"targetAttribute",
".",
"syncWith",
"(",
"sourceAttribute",
")",
";",
"}",
"}"
] |
Synchronizes all attributes of the source with all matching attributes of this presentation model
@param sourcePresentationModel may not be null since this most likely indicates an error
|
[
"Synchronizes",
"all",
"attributes",
"of",
"the",
"source",
"with",
"all",
"matching",
"attributes",
"of",
"this",
"presentation",
"model"
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/shared/src/main/groovy/org/opendolphin/core/BasePresentationModel.java#L196-L201
|
9,662
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.isSocketAlive
|
public static boolean isSocketAlive(final SocketAddress socketAddress, final int timeoutMsecs) {
final Socket socket = new Socket();
try {
socket.connect(socketAddress, timeoutMsecs);
socket.close();
return true;
} catch (final SocketTimeoutException exception) {
return false;
} catch (final IOException exception) {
return false;
}
}
|
java
|
public static boolean isSocketAlive(final SocketAddress socketAddress, final int timeoutMsecs) {
final Socket socket = new Socket();
try {
socket.connect(socketAddress, timeoutMsecs);
socket.close();
return true;
} catch (final SocketTimeoutException exception) {
return false;
} catch (final IOException exception) {
return false;
}
}
|
[
"public",
"static",
"boolean",
"isSocketAlive",
"(",
"final",
"SocketAddress",
"socketAddress",
",",
"final",
"int",
"timeoutMsecs",
")",
"{",
"final",
"Socket",
"socket",
"=",
"new",
"Socket",
"(",
")",
";",
"try",
"{",
"socket",
".",
"connect",
"(",
"socketAddress",
",",
"timeoutMsecs",
")",
";",
"socket",
".",
"close",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"SocketTimeoutException",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"final",
"IOException",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Returns true if a connection can be established to the given socket address within the
timeout provided.
@param socketAddress
socket address
@param timeoutMsecs
timeout
@return true if a connection can be established to the given socket address
|
[
"Returns",
"true",
"if",
"a",
"connection",
"can",
"be",
"established",
"to",
"the",
"given",
"socket",
"address",
"within",
"the",
"timeout",
"provided",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L87-L98
|
9,663
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.getPortBinding
|
public final Binding getPortBinding(final String portName)
throws IllegalStateException, IllegalArgumentException {
assertStarted();
final Map<String, List<PortBinding>> ports = info.networkSettings().ports();
final List<PortBinding> portBindings = ports.get(portName);
if (portBindings == null || portBindings.isEmpty()) {
throw new IllegalArgumentException("Unknown port binding: " + portName);
}
final PortBinding portBinding = portBindings.get(0);
return ImmutableBinding.builder() //
.host(portBinding.hostIp()) //
.port(Integer.parseInt(portBinding.hostPort())) //
.build();
}
|
java
|
public final Binding getPortBinding(final String portName)
throws IllegalStateException, IllegalArgumentException {
assertStarted();
final Map<String, List<PortBinding>> ports = info.networkSettings().ports();
final List<PortBinding> portBindings = ports.get(portName);
if (portBindings == null || portBindings.isEmpty()) {
throw new IllegalArgumentException("Unknown port binding: " + portName);
}
final PortBinding portBinding = portBindings.get(0);
return ImmutableBinding.builder() //
.host(portBinding.hostIp()) //
.port(Integer.parseInt(portBinding.hostPort())) //
.build();
}
|
[
"public",
"final",
"Binding",
"getPortBinding",
"(",
"final",
"String",
"portName",
")",
"throws",
"IllegalStateException",
",",
"IllegalArgumentException",
"{",
"assertStarted",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"PortBinding",
">",
">",
"ports",
"=",
"info",
".",
"networkSettings",
"(",
")",
".",
"ports",
"(",
")",
";",
"final",
"List",
"<",
"PortBinding",
">",
"portBindings",
"=",
"ports",
".",
"get",
"(",
"portName",
")",
";",
"if",
"(",
"portBindings",
"==",
"null",
"||",
"portBindings",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown port binding: \"",
"+",
"portName",
")",
";",
"}",
"final",
"PortBinding",
"portBinding",
"=",
"portBindings",
".",
"get",
"(",
"0",
")",
";",
"return",
"ImmutableBinding",
".",
"builder",
"(",
")",
"//",
".",
"host",
"(",
"portBinding",
".",
"hostIp",
"(",
")",
")",
"//",
".",
"port",
"(",
"Integer",
".",
"parseInt",
"(",
"portBinding",
".",
"hostPort",
"(",
")",
")",
")",
"//",
".",
"build",
"(",
")",
";",
"}"
] |
Returns the host and port information for the given Docker port name.
@param portName
Docker port name, e.g. '9200/tcp'
@return the host and port information
@throws IllegalStateException
if the container has not been started
@throws IllegalArgumentException
the given port name does not exist
|
[
"Returns",
"the",
"host",
"and",
"port",
"information",
"for",
"the",
"given",
"Docker",
"port",
"name",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L200-L215
|
9,664
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.stop
|
public void stop() {
synchronized (this.startStopMonitor) {
doStop();
// If we registered a JVM shutdown hook, we don't need it anymore now:
// We've already explicitly closed the context.
if (this.shutdownHook != null) {
try {
Runtime.getRuntime().removeShutdownHook(this.shutdownHook);
} catch (final IllegalStateException ex) {
// ignore - VM is already shutting down
}
}
}
}
|
java
|
public void stop() {
synchronized (this.startStopMonitor) {
doStop();
// If we registered a JVM shutdown hook, we don't need it anymore now:
// We've already explicitly closed the context.
if (this.shutdownHook != null) {
try {
Runtime.getRuntime().removeShutdownHook(this.shutdownHook);
} catch (final IllegalStateException ex) {
// ignore - VM is already shutting down
}
}
}
}
|
[
"public",
"void",
"stop",
"(",
")",
"{",
"synchronized",
"(",
"this",
".",
"startStopMonitor",
")",
"{",
"doStop",
"(",
")",
";",
"// If we registered a JVM shutdown hook, we don't need it anymore now:",
"// We've already explicitly closed the context.",
"if",
"(",
"this",
".",
"shutdownHook",
"!=",
"null",
")",
"{",
"try",
"{",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"removeShutdownHook",
"(",
"this",
".",
"shutdownHook",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalStateException",
"ex",
")",
"{",
"// ignore - VM is already shutting down",
"}",
"}",
"}",
"}"
] |
Instructs Docker to stop the container
|
[
"Instructs",
"Docker",
"to",
"stop",
"the",
"container"
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L305-L319
|
9,665
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.waitForLog
|
public final void waitForLog(final int timeout, final TimeUnit unit, final String... messages)
throws DockerException, InterruptedException {
final long startTime = System.currentTimeMillis();
final long timeoutTimeMillis = startTime + TimeUnit.MILLISECONDS.convert(timeout, unit);
int n = 0;
LOGGER.info("Tailing logs for \"{}\"", messages[n]);
final LogStream logs = client.logs(containerId, follow(), stdout(), stderr());
while (logs.hasNext()) {
if (Thread.interrupted()) {
// manual check for thread being terminated
throw new InterruptedException();
}
final String message = messages[n];
final String log = StandardCharsets.UTF_8.decode(logs.next().content()).toString();
if (log.contains(message)) {
LOGGER.info(
"Successfully received \"{}\" after {}ms",
message,
System.currentTimeMillis() - startTime);
if (++n >= messages.length) {
return;
}
}
if (startTime > timeoutTimeMillis) {
throw new IllegalStateException("Timeout waiting for log \"" + message + "\"");
}
}
}
|
java
|
public final void waitForLog(final int timeout, final TimeUnit unit, final String... messages)
throws DockerException, InterruptedException {
final long startTime = System.currentTimeMillis();
final long timeoutTimeMillis = startTime + TimeUnit.MILLISECONDS.convert(timeout, unit);
int n = 0;
LOGGER.info("Tailing logs for \"{}\"", messages[n]);
final LogStream logs = client.logs(containerId, follow(), stdout(), stderr());
while (logs.hasNext()) {
if (Thread.interrupted()) {
// manual check for thread being terminated
throw new InterruptedException();
}
final String message = messages[n];
final String log = StandardCharsets.UTF_8.decode(logs.next().content()).toString();
if (log.contains(message)) {
LOGGER.info(
"Successfully received \"{}\" after {}ms",
message,
System.currentTimeMillis() - startTime);
if (++n >= messages.length) {
return;
}
}
if (startTime > timeoutTimeMillis) {
throw new IllegalStateException("Timeout waiting for log \"" + message + "\"");
}
}
}
|
[
"public",
"final",
"void",
"waitForLog",
"(",
"final",
"int",
"timeout",
",",
"final",
"TimeUnit",
"unit",
",",
"final",
"String",
"...",
"messages",
")",
"throws",
"DockerException",
",",
"InterruptedException",
"{",
"final",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"final",
"long",
"timeoutTimeMillis",
"=",
"startTime",
"+",
"TimeUnit",
".",
"MILLISECONDS",
".",
"convert",
"(",
"timeout",
",",
"unit",
")",
";",
"int",
"n",
"=",
"0",
";",
"LOGGER",
".",
"info",
"(",
"\"Tailing logs for \\\"{}\\\"\"",
",",
"messages",
"[",
"n",
"]",
")",
";",
"final",
"LogStream",
"logs",
"=",
"client",
".",
"logs",
"(",
"containerId",
",",
"follow",
"(",
")",
",",
"stdout",
"(",
")",
",",
"stderr",
"(",
")",
")",
";",
"while",
"(",
"logs",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"{",
"// manual check for thread being terminated",
"throw",
"new",
"InterruptedException",
"(",
")",
";",
"}",
"final",
"String",
"message",
"=",
"messages",
"[",
"n",
"]",
";",
"final",
"String",
"log",
"=",
"StandardCharsets",
".",
"UTF_8",
".",
"decode",
"(",
"logs",
".",
"next",
"(",
")",
".",
"content",
"(",
")",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"log",
".",
"contains",
"(",
"message",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Successfully received \\\"{}\\\" after {}ms\"",
",",
"message",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
")",
";",
"if",
"(",
"++",
"n",
">=",
"messages",
".",
"length",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"startTime",
">",
"timeoutTimeMillis",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Timeout waiting for log \\\"\"",
"+",
"message",
"+",
"\"\\\"\"",
")",
";",
"}",
"}",
"}"
] |
Wait for nth occurrence of message to appear in docker logs within the specified timeframe.
@param timeout
timeout value
@param unit
timeout units
@param messages
The sequence of messages to wait for
@throws DockerException
if docker throws exception while tailing logs
@throws InterruptedException
if thread interrupted while waiting for timeout
|
[
"Wait",
"for",
"nth",
"occurrence",
"of",
"message",
"to",
"appear",
"in",
"docker",
"logs",
"within",
"the",
"specified",
"timeframe",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L335-L363
|
9,666
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.waitForPort
|
public final void waitForPort(final String portName) {
final Binding binding = getPortBinding(portName);
waitForPort(binding.getHost(), binding.getPort());
}
|
java
|
public final void waitForPort(final String portName) {
final Binding binding = getPortBinding(portName);
waitForPort(binding.getHost(), binding.getPort());
}
|
[
"public",
"final",
"void",
"waitForPort",
"(",
"final",
"String",
"portName",
")",
"{",
"final",
"Binding",
"binding",
"=",
"getPortBinding",
"(",
"portName",
")",
";",
"waitForPort",
"(",
"binding",
".",
"getHost",
"(",
")",
",",
"binding",
".",
"getPort",
"(",
")",
")",
";",
"}"
] |
Wait for the specified port to accept socket connection.
@param portName
Docker port name, e.g. '9200/tcp'
|
[
"Wait",
"for",
"the",
"specified",
"port",
"to",
"accept",
"socket",
"connection",
"."
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L385-L388
|
9,667
|
arakelian/docker-junit-rule
|
src/main/java/com/arakelian/docker/junit/Container.java
|
Container.startContainer
|
private void startContainer() throws DockerException {
final long startTime = System.currentTimeMillis();
try {
LOGGER.info("Starting container {} with id {}", containerConfig.image(), containerId);
client.startContainer(containerId);
} catch (DockerException | InterruptedException e) {
throw new DockerException(
"Unable to start container " + containerConfig.image() + " with id " + containerId, e);
} finally {
final long elapsedMillis = System.currentTimeMillis() - startTime;
LOGGER.info("Container {} started in {}ms", containerConfig.image(), elapsedMillis);
}
}
|
java
|
private void startContainer() throws DockerException {
final long startTime = System.currentTimeMillis();
try {
LOGGER.info("Starting container {} with id {}", containerConfig.image(), containerId);
client.startContainer(containerId);
} catch (DockerException | InterruptedException e) {
throw new DockerException(
"Unable to start container " + containerConfig.image() + " with id " + containerId, e);
} finally {
final long elapsedMillis = System.currentTimeMillis() - startTime;
LOGGER.info("Container {} started in {}ms", containerConfig.image(), elapsedMillis);
}
}
|
[
"private",
"void",
"startContainer",
"(",
")",
"throws",
"DockerException",
"{",
"final",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"LOGGER",
".",
"info",
"(",
"\"Starting container {} with id {}\"",
",",
"containerConfig",
".",
"image",
"(",
")",
",",
"containerId",
")",
";",
"client",
".",
"startContainer",
"(",
"containerId",
")",
";",
"}",
"catch",
"(",
"DockerException",
"|",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"DockerException",
"(",
"\"Unable to start container \"",
"+",
"containerConfig",
".",
"image",
"(",
")",
"+",
"\" with id \"",
"+",
"containerId",
",",
"e",
")",
";",
"}",
"finally",
"{",
"final",
"long",
"elapsedMillis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
";",
"LOGGER",
".",
"info",
"(",
"\"Container {} started in {}ms\"",
",",
"containerConfig",
".",
"image",
"(",
")",
",",
"elapsedMillis",
")",
";",
"}",
"}"
] |
Instructs Docker to start the container
@throws DockerException
if docker cannot start the container
|
[
"Instructs",
"Docker",
"to",
"start",
"the",
"container"
] |
cc99d63896a07df398b53fd5f0f6e4777e3b23cf
|
https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L591-L603
|
9,668
|
vert-x3/vertx-jca
|
rar/src/main/java/io/vertx/resourceadapter/impl/VertxConnectionImpl.java
|
VertxConnectionImpl.vertxEventBus
|
@Override
public VertxEventBus vertxEventBus() throws ResourceException {
log.finest("getConnection()");
if (this.mc != null) {
return this.mc.getVertxEventBus();
}
throw new ResourceException("Vertx Managed Connection has been closed.");
}
|
java
|
@Override
public VertxEventBus vertxEventBus() throws ResourceException {
log.finest("getConnection()");
if (this.mc != null) {
return this.mc.getVertxEventBus();
}
throw new ResourceException("Vertx Managed Connection has been closed.");
}
|
[
"@",
"Override",
"public",
"VertxEventBus",
"vertxEventBus",
"(",
")",
"throws",
"ResourceException",
"{",
"log",
".",
"finest",
"(",
"\"getConnection()\"",
")",
";",
"if",
"(",
"this",
".",
"mc",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"mc",
".",
"getVertxEventBus",
"(",
")",
";",
"}",
"throw",
"new",
"ResourceException",
"(",
"\"Vertx Managed Connection has been closed.\"",
")",
";",
"}"
] |
Get connection from factory
@return VertxConnection instance
@exception ResourceException
Thrown if a connection can't be obtained
|
[
"Get",
"connection",
"from",
"factory"
] |
605a5558a14941f5afa6e16e58337593f6ae0e8d
|
https://github.com/vert-x3/vertx-jca/blob/605a5558a14941f5afa6e16e58337593f6ae0e8d/rar/src/main/java/io/vertx/resourceadapter/impl/VertxConnectionImpl.java#L27-L34
|
9,669
|
realtime-framework/RealtimeMessaging-Java
|
library/src/main/java/ibt/ortc/api/Strings.java
|
Strings.randomString
|
public static String randomString(int length) {
// CAUSE: If-Else Statements Should Use Braces
if (length < 1) {
throw new IllegalArgumentException(String.format("length < 1: %s", length));
}
char[] buf = new char[length];
return nextString(buf);
}
|
java
|
public static String randomString(int length) {
// CAUSE: If-Else Statements Should Use Braces
if (length < 1) {
throw new IllegalArgumentException(String.format("length < 1: %s", length));
}
char[] buf = new char[length];
return nextString(buf);
}
|
[
"public",
"static",
"String",
"randomString",
"(",
"int",
"length",
")",
"{",
"// CAUSE: If-Else Statements Should Use Braces",
"if",
"(",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"length < 1: %s\"",
",",
"length",
")",
")",
";",
"}",
"char",
"[",
"]",
"buf",
"=",
"new",
"char",
"[",
"length",
"]",
";",
"return",
"nextString",
"(",
"buf",
")",
";",
"}"
] |
Generates a random alphanumeric string
@param length Number of characters the random string contains
@return String with the specified length
|
[
"Generates",
"a",
"random",
"alphanumeric",
"string"
] |
cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08
|
https://github.com/realtime-framework/RealtimeMessaging-Java/blob/cae0dfd01567a2d9e55a0849c0c9b09ad4b2cc08/library/src/main/java/ibt/ortc/api/Strings.java#L49-L58
|
9,670
|
canoo/open-dolphin
|
subprojects/shared/src/main/groovy/org/opendolphin/core/BaseAttribute.java
|
BaseAttribute.checkValue
|
public static Object checkValue(Object value) {
if (null == value) return null;
if (value instanceof Tag) return ((Tag)value).getName(); // name instead of ordinal to make decoding easier
Object result = value;
if (result instanceof GString) result = value.toString();
if (result instanceof BaseAttribute) {
if (log.isLoggable(Level.WARNING)) log.warning("An Attribute may not itself contain an attribute as a value. Assuming you forgot to call getValue().");
result = checkValue((((BaseAttribute) value).getValue()));
}
boolean ok = false;
for (Class type : SUPPORTED_VALUE_TYPES ) {
if (type.isAssignableFrom(result.getClass())) { ok = true; break; }
}
if (!ok) {
throw new IllegalArgumentException("Attribute values of this type are not allowed: " + result.getClass().getSimpleName());
}
return result;
}
|
java
|
public static Object checkValue(Object value) {
if (null == value) return null;
if (value instanceof Tag) return ((Tag)value).getName(); // name instead of ordinal to make decoding easier
Object result = value;
if (result instanceof GString) result = value.toString();
if (result instanceof BaseAttribute) {
if (log.isLoggable(Level.WARNING)) log.warning("An Attribute may not itself contain an attribute as a value. Assuming you forgot to call getValue().");
result = checkValue((((BaseAttribute) value).getValue()));
}
boolean ok = false;
for (Class type : SUPPORTED_VALUE_TYPES ) {
if (type.isAssignableFrom(result.getClass())) { ok = true; break; }
}
if (!ok) {
throw new IllegalArgumentException("Attribute values of this type are not allowed: " + result.getClass().getSimpleName());
}
return result;
}
|
[
"public",
"static",
"Object",
"checkValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"null",
"==",
"value",
")",
"return",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Tag",
")",
"return",
"(",
"(",
"Tag",
")",
"value",
")",
".",
"getName",
"(",
")",
";",
"// name instead of ordinal to make decoding easier",
"Object",
"result",
"=",
"value",
";",
"if",
"(",
"result",
"instanceof",
"GString",
")",
"result",
"=",
"value",
".",
"toString",
"(",
")",
";",
"if",
"(",
"result",
"instanceof",
"BaseAttribute",
")",
"{",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"WARNING",
")",
")",
"log",
".",
"warning",
"(",
"\"An Attribute may not itself contain an attribute as a value. Assuming you forgot to call getValue().\"",
")",
";",
"result",
"=",
"checkValue",
"(",
"(",
"(",
"(",
"BaseAttribute",
")",
"value",
")",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"boolean",
"ok",
"=",
"false",
";",
"for",
"(",
"Class",
"type",
":",
"SUPPORTED_VALUE_TYPES",
")",
"{",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"result",
".",
"getClass",
"(",
")",
")",
")",
"{",
"ok",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"ok",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute values of this type are not allowed: \"",
"+",
"result",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Check whether value is of allowed type and convert to an allowed type if possible.
|
[
"Check",
"whether",
"value",
"is",
"of",
"allowed",
"type",
"and",
"convert",
"to",
"an",
"allowed",
"type",
"if",
"possible",
"."
] |
50166defc3ef2de473d7a7246c32dc04304d80ef
|
https://github.com/canoo/open-dolphin/blob/50166defc3ef2de473d7a7246c32dc04304d80ef/subprojects/shared/src/main/groovy/org/opendolphin/core/BaseAttribute.java#L101-L118
|
9,671
|
RestComm/jain-slee.http
|
resources/http-servlet/ra/src/main/java/org/restcomm/slee/resource/http/HttpServletResourceAdaptor.java
|
HttpServletResourceAdaptor.releaseHttpRequest
|
private void releaseHttpRequest(HttpServletRequestEvent hreqEvent) {
if (tracer.isFinestEnabled()) {
tracer.finest("releaseHttpRequest() enter");
}
final Object lock = requestLock.removeLock(hreqEvent);
if (lock != null) {
synchronized (lock) {
lock.notify();
}
}
if (tracer.isFineEnabled()) {
tracer.fine("released lock for http request " + hreqEvent.getId());
}
}
|
java
|
private void releaseHttpRequest(HttpServletRequestEvent hreqEvent) {
if (tracer.isFinestEnabled()) {
tracer.finest("releaseHttpRequest() enter");
}
final Object lock = requestLock.removeLock(hreqEvent);
if (lock != null) {
synchronized (lock) {
lock.notify();
}
}
if (tracer.isFineEnabled()) {
tracer.fine("released lock for http request " + hreqEvent.getId());
}
}
|
[
"private",
"void",
"releaseHttpRequest",
"(",
"HttpServletRequestEvent",
"hreqEvent",
")",
"{",
"if",
"(",
"tracer",
".",
"isFinestEnabled",
"(",
")",
")",
"{",
"tracer",
".",
"finest",
"(",
"\"releaseHttpRequest() enter\"",
")",
";",
"}",
"final",
"Object",
"lock",
"=",
"requestLock",
".",
"removeLock",
"(",
"hreqEvent",
")",
";",
"if",
"(",
"lock",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"lock",
".",
"notify",
"(",
")",
";",
"}",
"}",
"if",
"(",
"tracer",
".",
"isFineEnabled",
"(",
")",
")",
"{",
"tracer",
".",
"fine",
"(",
"\"released lock for http request \"",
"+",
"hreqEvent",
".",
"getId",
"(",
")",
")",
";",
"}",
"}"
] |
Allows control to be returned back to the servlet conainer, which delivered the http request. The container will
mandatory close the response stream.
|
[
"Allows",
"control",
"to",
"be",
"returned",
"back",
"to",
"the",
"servlet",
"conainer",
"which",
"delivered",
"the",
"http",
"request",
".",
"The",
"container",
"will",
"mandatory",
"close",
"the",
"response",
"stream",
"."
] |
938e502a60355b988d6998d2539bbb16207674e8
|
https://github.com/RestComm/jain-slee.http/blob/938e502a60355b988d6998d2539bbb16207674e8/resources/http-servlet/ra/src/main/java/org/restcomm/slee/resource/http/HttpServletResourceAdaptor.java#L368-L383
|
9,672
|
RestComm/jain-slee.http
|
examples/http-client-nio-demo/sbb/src/main/java/org/restcomm/slee/ra/httpclient/nio/demo/HttpClientNIODemoSbb.java
|
HttpClientNIODemoSbb.onStartServiceEvent
|
public void onStartServiceEvent(
javax.slee.serviceactivity.ServiceStartedEvent event,
ActivityContextInterface aci) {
tracer.info("Retreiving www.telestax.com...");
try {
HttpClientNIORequestActivity activity = httpClientRA.execute(
new HttpGet("http://www.telestax.com"), null,
System.currentTimeMillis());
httpClientACIF.getActivityContextInterface(activity).attach(
sbbContext.getSbbLocalObject());
} catch (Exception e) {
tracer.severe("failed to retrieve webpage", e);
}
}
|
java
|
public void onStartServiceEvent(
javax.slee.serviceactivity.ServiceStartedEvent event,
ActivityContextInterface aci) {
tracer.info("Retreiving www.telestax.com...");
try {
HttpClientNIORequestActivity activity = httpClientRA.execute(
new HttpGet("http://www.telestax.com"), null,
System.currentTimeMillis());
httpClientACIF.getActivityContextInterface(activity).attach(
sbbContext.getSbbLocalObject());
} catch (Exception e) {
tracer.severe("failed to retrieve webpage", e);
}
}
|
[
"public",
"void",
"onStartServiceEvent",
"(",
"javax",
".",
"slee",
".",
"serviceactivity",
".",
"ServiceStartedEvent",
"event",
",",
"ActivityContextInterface",
"aci",
")",
"{",
"tracer",
".",
"info",
"(",
"\"Retreiving www.telestax.com...\"",
")",
";",
"try",
"{",
"HttpClientNIORequestActivity",
"activity",
"=",
"httpClientRA",
".",
"execute",
"(",
"new",
"HttpGet",
"(",
"\"http://www.telestax.com\"",
")",
",",
"null",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"httpClientACIF",
".",
"getActivityContextInterface",
"(",
"activity",
")",
".",
"attach",
"(",
"sbbContext",
".",
"getSbbLocalObject",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"tracer",
".",
"severe",
"(",
"\"failed to retrieve webpage\"",
",",
"e",
")",
";",
"}",
"}"
] |
Event handler methods
|
[
"Event",
"handler",
"methods"
] |
938e502a60355b988d6998d2539bbb16207674e8
|
https://github.com/RestComm/jain-slee.http/blob/938e502a60355b988d6998d2539bbb16207674e8/examples/http-client-nio-demo/sbb/src/main/java/org/restcomm/slee/ra/httpclient/nio/demo/HttpClientNIODemoSbb.java#L51-L64
|
9,673
|
tfredrich/DateAdapterJ
|
src/java/com/strategicgains/util/date/DateFormatProcessor.java
|
DateFormatProcessor.parse
|
public Date parse(String dateString)
throws ParseException
{
Date result = null;
ParseException lastException = null;
for (DateFormat format : inputFormats)
{
try
{
result = ((DateFormat) format.clone()).parse(dateString); // DateFormat is not thread safe.
lastException = null;
break;
}
catch (ParseException e)
{
// Keep the first exception that occurred.
if (lastException == null)
{
lastException = e;
}
// And just try the next input format.
}
}
if (lastException != null)
{
throw lastException;
}
return result;
}
|
java
|
public Date parse(String dateString)
throws ParseException
{
Date result = null;
ParseException lastException = null;
for (DateFormat format : inputFormats)
{
try
{
result = ((DateFormat) format.clone()).parse(dateString); // DateFormat is not thread safe.
lastException = null;
break;
}
catch (ParseException e)
{
// Keep the first exception that occurred.
if (lastException == null)
{
lastException = e;
}
// And just try the next input format.
}
}
if (lastException != null)
{
throw lastException;
}
return result;
}
|
[
"public",
"Date",
"parse",
"(",
"String",
"dateString",
")",
"throws",
"ParseException",
"{",
"Date",
"result",
"=",
"null",
";",
"ParseException",
"lastException",
"=",
"null",
";",
"for",
"(",
"DateFormat",
"format",
":",
"inputFormats",
")",
"{",
"try",
"{",
"result",
"=",
"(",
"(",
"DateFormat",
")",
"format",
".",
"clone",
"(",
")",
")",
".",
"parse",
"(",
"dateString",
")",
";",
"// DateFormat is not thread safe.",
"lastException",
"=",
"null",
";",
"break",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"// Keep the first exception that occurred.",
"if",
"(",
"lastException",
"==",
"null",
")",
"{",
"lastException",
"=",
"e",
";",
"}",
"// And just try the next input format.",
"}",
"}",
"if",
"(",
"lastException",
"!=",
"null",
")",
"{",
"throw",
"lastException",
";",
"}",
"return",
"result",
";",
"}"
] |
Attempts to parse the given string into a java.util.Date using the provided
input formats.
@param dateString a date string in one of the acceptable formats.
@throws ParseException if the date is not in one of the input formats.
|
[
"Attempts",
"to",
"parse",
"the",
"given",
"string",
"into",
"a",
"java",
".",
"util",
".",
"Date",
"using",
"the",
"provided",
"input",
"formats",
"."
] |
e3f6d385d7c47613ce931409d1c43a97f8d377c9
|
https://github.com/tfredrich/DateAdapterJ/blob/e3f6d385d7c47613ce931409d1c43a97f8d377c9/src/java/com/strategicgains/util/date/DateFormatProcessor.java#L98-L129
|
9,674
|
RestComm/jain-slee.http
|
resources/http-client-nio/ra/src/main/java/org/restcomm/slee/ra/httpclient/nio/ra/HttpClientNIOResourceAdaptor.java
|
HttpClientNIOResourceAdaptor.buildHttpAsyncClient
|
private HttpAsyncClient buildHttpAsyncClient() throws IOReactorException {
// Create I/O reactor configuration
IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setConnectTimeout(connectTimeout)
.setSoTimeout(socketTimeout)
.build();
// Create a custom I/O reactor
ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
// Create a connection manager with simple configuration.
PoolingNHttpClientConnectionManager connManager = new PoolingNHttpClientConnectionManager(ioReactor);
// Configure total max or per route limits for persistent connections
// that can be kept in the pool or leased by the connection manager.
connManager.setMaxTotal(maxTotal);
connManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
return httpAsyncClient = HttpAsyncClients.custom()
.useSystemProperties()
.setConnectionManager(connManager)
.build();
}
|
java
|
private HttpAsyncClient buildHttpAsyncClient() throws IOReactorException {
// Create I/O reactor configuration
IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setConnectTimeout(connectTimeout)
.setSoTimeout(socketTimeout)
.build();
// Create a custom I/O reactor
ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
// Create a connection manager with simple configuration.
PoolingNHttpClientConnectionManager connManager = new PoolingNHttpClientConnectionManager(ioReactor);
// Configure total max or per route limits for persistent connections
// that can be kept in the pool or leased by the connection manager.
connManager.setMaxTotal(maxTotal);
connManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
return httpAsyncClient = HttpAsyncClients.custom()
.useSystemProperties()
.setConnectionManager(connManager)
.build();
}
|
[
"private",
"HttpAsyncClient",
"buildHttpAsyncClient",
"(",
")",
"throws",
"IOReactorException",
"{",
"// Create I/O reactor configuration\r",
"IOReactorConfig",
"ioReactorConfig",
"=",
"IOReactorConfig",
".",
"custom",
"(",
")",
".",
"setConnectTimeout",
"(",
"connectTimeout",
")",
".",
"setSoTimeout",
"(",
"socketTimeout",
")",
".",
"build",
"(",
")",
";",
"// Create a custom I/O reactor\r",
"ConnectingIOReactor",
"ioReactor",
"=",
"new",
"DefaultConnectingIOReactor",
"(",
"ioReactorConfig",
")",
";",
"// Create a connection manager with simple configuration.\r",
"PoolingNHttpClientConnectionManager",
"connManager",
"=",
"new",
"PoolingNHttpClientConnectionManager",
"(",
"ioReactor",
")",
";",
"// Configure total max or per route limits for persistent connections\r",
"// that can be kept in the pool or leased by the connection manager.\r",
"connManager",
".",
"setMaxTotal",
"(",
"maxTotal",
")",
";",
"connManager",
".",
"setDefaultMaxPerRoute",
"(",
"defaultMaxPerRoute",
")",
";",
"return",
"httpAsyncClient",
"=",
"HttpAsyncClients",
".",
"custom",
"(",
")",
".",
"useSystemProperties",
"(",
")",
".",
"setConnectionManager",
"(",
"connManager",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Creates an instance of async http client.
|
[
"Creates",
"an",
"instance",
"of",
"async",
"http",
"client",
"."
] |
938e502a60355b988d6998d2539bbb16207674e8
|
https://github.com/RestComm/jain-slee.http/blob/938e502a60355b988d6998d2539bbb16207674e8/resources/http-client-nio/ra/src/main/java/org/restcomm/slee/ra/httpclient/nio/ra/HttpClientNIOResourceAdaptor.java#L506-L528
|
9,675
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/metrics/redis/RedisAggregateCounterRepository.java
|
RedisAggregateCounterRepository.doIncrementHash
|
private void doIncrementHash(String key, String hashKey, long amount, String bookkeepingKey) {
long newValue = hashOperations.increment(key, hashKey, amount);
// TODO: the following test does not necessarily mean that the hash
// is new, just that the key inside that hash is new. So we end up
// calling add more than needed
if (newValue == amount) {
setOperations.add(bookkeepingKey, key);
}
}
|
java
|
private void doIncrementHash(String key, String hashKey, long amount, String bookkeepingKey) {
long newValue = hashOperations.increment(key, hashKey, amount);
// TODO: the following test does not necessarily mean that the hash
// is new, just that the key inside that hash is new. So we end up
// calling add more than needed
if (newValue == amount) {
setOperations.add(bookkeepingKey, key);
}
}
|
[
"private",
"void",
"doIncrementHash",
"(",
"String",
"key",
",",
"String",
"hashKey",
",",
"long",
"amount",
",",
"String",
"bookkeepingKey",
")",
"{",
"long",
"newValue",
"=",
"hashOperations",
".",
"increment",
"(",
"key",
",",
"hashKey",
",",
"amount",
")",
";",
"// TODO: the following test does not necessarily mean that the hash",
"// is new, just that the key inside that hash is new. So we end up",
"// calling add more than needed",
"if",
"(",
"newValue",
"==",
"amount",
")",
"{",
"setOperations",
".",
"add",
"(",
"bookkeepingKey",
",",
"key",
")",
";",
"}",
"}"
] |
Internally increments the given hash key, keeping track of created hash for a given counter, so they can be
cleaned up when needed.
|
[
"Internally",
"increments",
"the",
"given",
"hash",
"key",
"keeping",
"track",
"of",
"created",
"hash",
"for",
"a",
"given",
"counter",
"so",
"they",
"can",
"be",
"cleaned",
"up",
"when",
"needed",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/metrics/redis/RedisAggregateCounterRepository.java#L122-L130
|
9,676
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java
|
AggregateCounterController.display
|
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
public AggregateCounterResource display(@PathVariable("name") String name) {
AggregateCounter counter = repository.findOne(name);
if (counter == null) {
throw new NoSuchMetricException(name);
}
return deepAssembler.toResource(counter);
}
|
java
|
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
public AggregateCounterResource display(@PathVariable("name") String name) {
AggregateCounter counter = repository.findOne(name);
if (counter == null) {
throw new NoSuchMetricException(name);
}
return deepAssembler.toResource(counter);
}
|
[
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/{name}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"public",
"AggregateCounterResource",
"display",
"(",
"@",
"PathVariable",
"(",
"\"name\"",
")",
"String",
"name",
")",
"{",
"AggregateCounter",
"counter",
"=",
"repository",
".",
"findOne",
"(",
"name",
")",
";",
"if",
"(",
"counter",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMetricException",
"(",
"name",
")",
";",
"}",
"return",
"deepAssembler",
".",
"toResource",
"(",
"counter",
")",
";",
"}"
] |
Retrieve information about a specific aggregate counter.
@param name counter name
@return {@link AggregateCounterResource}
|
[
"Retrieve",
"information",
"about",
"a",
"specific",
"aggregate",
"counter",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java#L80-L87
|
9,677
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java
|
AggregateCounterController.display
|
@ResponseBody
@RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public AggregateCounterResource display(
@PathVariable("name") String name,
@RequestParam(value = "from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime from,
@RequestParam(value = "to", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime to,
@RequestParam(value = "resolution", defaultValue = "hour") AggregateCounterResolution resolution) {
to = providedOrDefaultToValue(to);
from = providedOrDefaultFromValue(from, to, resolution);
AggregateCounter aggregate = repository.getCounts(name, new Interval(from, to), resolution);
return deepAssembler.toResource(aggregate);
}
|
java
|
@ResponseBody
@RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public AggregateCounterResource display(
@PathVariable("name") String name,
@RequestParam(value = "from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime from,
@RequestParam(value = "to", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime to,
@RequestParam(value = "resolution", defaultValue = "hour") AggregateCounterResolution resolution) {
to = providedOrDefaultToValue(to);
from = providedOrDefaultFromValue(from, to, resolution);
AggregateCounter aggregate = repository.getCounts(name, new Interval(from, to), resolution);
return deepAssembler.toResource(aggregate);
}
|
[
"@",
"ResponseBody",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/{name}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
",",
"produces",
"=",
"MediaType",
".",
"APPLICATION_JSON_VALUE",
")",
"public",
"AggregateCounterResource",
"display",
"(",
"@",
"PathVariable",
"(",
"\"name\"",
")",
"String",
"name",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"from\"",
",",
"required",
"=",
"false",
")",
"@",
"DateTimeFormat",
"(",
"iso",
"=",
"DateTimeFormat",
".",
"ISO",
".",
"DATE_TIME",
")",
"DateTime",
"from",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"to\"",
",",
"required",
"=",
"false",
")",
"@",
"DateTimeFormat",
"(",
"iso",
"=",
"DateTimeFormat",
".",
"ISO",
".",
"DATE_TIME",
")",
"DateTime",
"to",
",",
"@",
"RequestParam",
"(",
"value",
"=",
"\"resolution\"",
",",
"defaultValue",
"=",
"\"hour\"",
")",
"AggregateCounterResolution",
"resolution",
")",
"{",
"to",
"=",
"providedOrDefaultToValue",
"(",
"to",
")",
";",
"from",
"=",
"providedOrDefaultFromValue",
"(",
"from",
",",
"to",
",",
"resolution",
")",
";",
"AggregateCounter",
"aggregate",
"=",
"repository",
".",
"getCounts",
"(",
"name",
",",
"new",
"Interval",
"(",
"from",
",",
"to",
")",
",",
"resolution",
")",
";",
"return",
"deepAssembler",
".",
"toResource",
"(",
"aggregate",
")",
";",
"}"
] |
Retrieve counts for a given time interval, using some precision.
@param name the name of the aggregate counter we want to retrieve data from
@param from the start-time for the interval, default depends on the resolution (e.g. go back 1 day for hourly
buckets)
@param to the end-time for the interval, default "now"
@param resolution the size of buckets to aggregate, <i>e.g.</i> hourly, daily, <i>etc.</i> (default "hour")
@return counts
|
[
"Retrieve",
"counts",
"for",
"a",
"given",
"time",
"interval",
"using",
"some",
"precision",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java#L151-L162
|
9,678
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java
|
AggregateCounterController.providedOrDefaultFromValue
|
private DateTime providedOrDefaultFromValue(DateTime from, DateTime to,
AggregateCounterResolution resolution) {
if (from != null) {
return from;
}
switch (resolution) {
case minute:
return to.minusMinutes(59);
case hour:
return to.minusHours(23);
case day:
return to.minusDays(6);
case month:
return to.minusMonths(11);
case year:
return to.minusYears(4);
default:
throw new IllegalStateException(
"Shouldn't happen. Unhandled resolution: " + resolution);
}
}
|
java
|
private DateTime providedOrDefaultFromValue(DateTime from, DateTime to,
AggregateCounterResolution resolution) {
if (from != null) {
return from;
}
switch (resolution) {
case minute:
return to.minusMinutes(59);
case hour:
return to.minusHours(23);
case day:
return to.minusDays(6);
case month:
return to.minusMonths(11);
case year:
return to.minusYears(4);
default:
throw new IllegalStateException(
"Shouldn't happen. Unhandled resolution: " + resolution);
}
}
|
[
"private",
"DateTime",
"providedOrDefaultFromValue",
"(",
"DateTime",
"from",
",",
"DateTime",
"to",
",",
"AggregateCounterResolution",
"resolution",
")",
"{",
"if",
"(",
"from",
"!=",
"null",
")",
"{",
"return",
"from",
";",
"}",
"switch",
"(",
"resolution",
")",
"{",
"case",
"minute",
":",
"return",
"to",
".",
"minusMinutes",
"(",
"59",
")",
";",
"case",
"hour",
":",
"return",
"to",
".",
"minusHours",
"(",
"23",
")",
";",
"case",
"day",
":",
"return",
"to",
".",
"minusDays",
"(",
"6",
")",
";",
"case",
"month",
":",
"return",
"to",
".",
"minusMonths",
"(",
"11",
")",
";",
"case",
"year",
":",
"return",
"to",
".",
"minusYears",
"(",
"4",
")",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Shouldn't happen. Unhandled resolution: \"",
"+",
"resolution",
")",
";",
"}",
"}"
] |
Return a default value for the interval start if none has been provided.
|
[
"Return",
"a",
"default",
"value",
"for",
"the",
"interval",
"start",
"if",
"none",
"has",
"been",
"provided",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/AggregateCounterController.java#L177-L197
|
9,679
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.createXStream
|
protected XStream createXStream(HierarchicalStreamDriver driver, NaaccrPatientConverter patientConverter) {
XStream xstream = new XStream(driver) {
@Override
protected void setupConverters() {
registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
registerConverter(new IntConverter(), PRIORITY_NORMAL);
registerConverter(new FloatConverter(), PRIORITY_NORMAL);
registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
registerConverter(new LongConverter(), PRIORITY_NORMAL);
registerConverter(new ShortConverter(), PRIORITY_NORMAL);
registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
registerConverter(new ByteConverter(), PRIORITY_NORMAL);
registerConverter(new StringConverter(), PRIORITY_NORMAL);
registerConverter(new DateConverter(), PRIORITY_NORMAL);
registerConverter(new CollectionConverter(getMapper()), PRIORITY_NORMAL);
registerConverter(new ReflectionConverter(getMapper(), getReflectionProvider()), PRIORITY_VERY_LOW);
}
};
// setup proper security environment
xstream.addPermission(NoTypePermission.NONE);
xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));
// tell XStream how to read/write our main entities
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ROOT, NaaccrData.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ITEM, Item.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT, Patient.class);
// add some attributes
xstream.aliasAttribute(NaaccrData.class, "_baseDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_BASE_DICT);
xstream.aliasAttribute(NaaccrData.class, "_userDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_USER_DICT);
xstream.aliasAttribute(NaaccrData.class, "_recordType", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_REC_TYPE);
xstream.aliasAttribute(NaaccrData.class, "_timeGenerated", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_TIME_GENERATED);
xstream.aliasAttribute(NaaccrData.class, "_specificationVersion", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_SPEC_VERSION);
// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though
xstream.addImplicitCollection(NaaccrData.class, "_items", Item.class);
xstream.addImplicitCollection(NaaccrData.class, "_patients", Patient.class);
// handle patients
xstream.registerConverter(patientConverter);
return xstream;
}
|
java
|
protected XStream createXStream(HierarchicalStreamDriver driver, NaaccrPatientConverter patientConverter) {
XStream xstream = new XStream(driver) {
@Override
protected void setupConverters() {
registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
registerConverter(new IntConverter(), PRIORITY_NORMAL);
registerConverter(new FloatConverter(), PRIORITY_NORMAL);
registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
registerConverter(new LongConverter(), PRIORITY_NORMAL);
registerConverter(new ShortConverter(), PRIORITY_NORMAL);
registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
registerConverter(new ByteConverter(), PRIORITY_NORMAL);
registerConverter(new StringConverter(), PRIORITY_NORMAL);
registerConverter(new DateConverter(), PRIORITY_NORMAL);
registerConverter(new CollectionConverter(getMapper()), PRIORITY_NORMAL);
registerConverter(new ReflectionConverter(getMapper(), getReflectionProvider()), PRIORITY_VERY_LOW);
}
};
// setup proper security environment
xstream.addPermission(NoTypePermission.NONE);
xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));
// tell XStream how to read/write our main entities
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ROOT, NaaccrData.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ITEM, Item.class);
xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT, Patient.class);
// add some attributes
xstream.aliasAttribute(NaaccrData.class, "_baseDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_BASE_DICT);
xstream.aliasAttribute(NaaccrData.class, "_userDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_USER_DICT);
xstream.aliasAttribute(NaaccrData.class, "_recordType", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_REC_TYPE);
xstream.aliasAttribute(NaaccrData.class, "_timeGenerated", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_TIME_GENERATED);
xstream.aliasAttribute(NaaccrData.class, "_specificationVersion", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_SPEC_VERSION);
// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though
xstream.addImplicitCollection(NaaccrData.class, "_items", Item.class);
xstream.addImplicitCollection(NaaccrData.class, "_patients", Patient.class);
// handle patients
xstream.registerConverter(patientConverter);
return xstream;
}
|
[
"protected",
"XStream",
"createXStream",
"(",
"HierarchicalStreamDriver",
"driver",
",",
"NaaccrPatientConverter",
"patientConverter",
")",
"{",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"driver",
")",
"{",
"@",
"Override",
"protected",
"void",
"setupConverters",
"(",
")",
"{",
"registerConverter",
"(",
"new",
"NullConverter",
"(",
")",
",",
"PRIORITY_VERY_HIGH",
")",
";",
"registerConverter",
"(",
"new",
"IntConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"FloatConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"DoubleConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"LongConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ShortConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"BooleanConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ByteConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"StringConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"DateConverter",
"(",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"CollectionConverter",
"(",
"getMapper",
"(",
")",
")",
",",
"PRIORITY_NORMAL",
")",
";",
"registerConverter",
"(",
"new",
"ReflectionConverter",
"(",
"getMapper",
"(",
")",
",",
"getReflectionProvider",
"(",
")",
")",
",",
"PRIORITY_VERY_LOW",
")",
";",
"}",
"}",
";",
"// setup proper security environment",
"xstream",
".",
"addPermission",
"(",
"NoTypePermission",
".",
"NONE",
")",
";",
"xstream",
".",
"addPermission",
"(",
"new",
"WildcardTypePermission",
"(",
"new",
"String",
"[",
"]",
"{",
"\"com.imsweb.naaccrxml.**\"",
"}",
")",
")",
";",
"// tell XStream how to read/write our main entities",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_ROOT",
",",
"NaaccrData",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_ITEM",
",",
"Item",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"NaaccrXmlUtils",
".",
"NAACCR_XML_TAG_PATIENT",
",",
"Patient",
".",
"class",
")",
";",
"// add some attributes",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_baseDictionaryUri\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_BASE_DICT",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_userDictionaryUri\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_USER_DICT",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_recordType\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_REC_TYPE",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_timeGenerated\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_TIME_GENERATED",
")",
";",
"xstream",
".",
"aliasAttribute",
"(",
"NaaccrData",
".",
"class",
",",
"\"_specificationVersion\"",
",",
"NaaccrXmlUtils",
".",
"NAACCR_XML_ROOT_ATT_SPEC_VERSION",
")",
";",
"// all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though",
"xstream",
".",
"addImplicitCollection",
"(",
"NaaccrData",
".",
"class",
",",
"\"_items\"",
",",
"Item",
".",
"class",
")",
";",
"xstream",
".",
"addImplicitCollection",
"(",
"NaaccrData",
".",
"class",
",",
"\"_patients\"",
",",
"Patient",
".",
"class",
")",
";",
"// handle patients",
"xstream",
".",
"registerConverter",
"(",
"patientConverter",
")",
";",
"return",
"xstream",
";",
"}"
] |
Creates the instance of XStream to us for all reading and writing operations
@param driver an XStream driver (see createDriver())
@param patientConverter a patient converter (see createPatientConverter())
@return an instance of XStream, never null
|
[
"Creates",
"the",
"instance",
"of",
"XStream",
"to",
"us",
"for",
"all",
"reading",
"and",
"writing",
"operations"
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L134-L177
|
9,680
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.registerNamespace
|
public void registerNamespace(String namespacePrefix, String namespaceUri) {
if (_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has already been registered");
_namespaces.put(namespacePrefix, namespaceUri);
}
|
java
|
public void registerNamespace(String namespacePrefix, String namespaceUri) {
if (_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has already been registered");
_namespaces.put(namespacePrefix, namespaceUri);
}
|
[
"public",
"void",
"registerNamespace",
"(",
"String",
"namespacePrefix",
",",
"String",
"namespaceUri",
")",
"{",
"if",
"(",
"_namespaces",
".",
"containsKey",
"(",
"namespacePrefix",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Namespace prefix '\"",
"+",
"namespacePrefix",
"+",
"\"' has already been registered\"",
")",
";",
"_namespaces",
".",
"put",
"(",
"namespacePrefix",
",",
"namespaceUri",
")",
";",
"}"
] |
Registers a namespace for a given namespace prefix. This method must be called before registering any tags or attributes
for that namespace. Note that extensions require namespaces to work properly.
@param namespacePrefix the namespace prefix, cannot be null
@param namespaceUri the namespace URI, cannot be null
|
[
"Registers",
"a",
"namespace",
"for",
"a",
"given",
"namespace",
"prefix",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"registering",
"any",
"tags",
"or",
"attributes",
"for",
"that",
"namespace",
".",
"Note",
"that",
"extensions",
"require",
"namespaces",
"to",
"work",
"properly",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L236-L240
|
9,681
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.registerTag
|
public void registerTag(String namespacePrefix, String tagName, Class<?> clazz) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.alias(namespacePrefix + ":" + tagName, clazz);
_xstream.addPermission(new WildcardTypePermission(new String[] {clazz.getName()}));
_tags.computeIfAbsent(namespacePrefix, k -> new HashSet<>()).add(tagName);
}
|
java
|
public void registerTag(String namespacePrefix, String tagName, Class<?> clazz) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.alias(namespacePrefix + ":" + tagName, clazz);
_xstream.addPermission(new WildcardTypePermission(new String[] {clazz.getName()}));
_tags.computeIfAbsent(namespacePrefix, k -> new HashSet<>()).add(tagName);
}
|
[
"public",
"void",
"registerTag",
"(",
"String",
"namespacePrefix",
",",
"String",
"tagName",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"!",
"_namespaces",
".",
"containsKey",
"(",
"namespacePrefix",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Namespace prefix '\"",
"+",
"namespacePrefix",
"+",
"\"' has not been registered yet\"",
")",
";",
"_xstream",
".",
"alias",
"(",
"namespacePrefix",
"+",
"\":\"",
"+",
"tagName",
",",
"clazz",
")",
";",
"_xstream",
".",
"addPermission",
"(",
"new",
"WildcardTypePermission",
"(",
"new",
"String",
"[",
"]",
"{",
"clazz",
".",
"getName",
"(",
")",
"}",
")",
")",
";",
"_tags",
".",
"computeIfAbsent",
"(",
"namespacePrefix",
",",
"k",
"->",
"new",
"HashSet",
"<>",
"(",
")",
")",
".",
"add",
"(",
"tagName",
")",
";",
"}"
] |
Registers a tag corresponding to a specific class, in the given namespace.
@param namespacePrefix namespace prefix, required
@param tagName tag name, required
@param clazz class corresponding to the tag name, required
|
[
"Registers",
"a",
"tag",
"corresponding",
"to",
"a",
"specific",
"class",
"in",
"the",
"given",
"namespace",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L256-L262
|
9,682
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.registerTag
|
public void registerTag(String namespacePrefix, String tagName, Class<?> clazz, String fieldName, Class<?> fieldClass) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.alias(namespacePrefix + ":" + tagName, fieldClass);
_xstream.aliasField(namespacePrefix + ":" + tagName, clazz, fieldName);
_tags.computeIfAbsent(namespacePrefix, k -> new HashSet<>()).add(tagName);
}
|
java
|
public void registerTag(String namespacePrefix, String tagName, Class<?> clazz, String fieldName, Class<?> fieldClass) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.alias(namespacePrefix + ":" + tagName, fieldClass);
_xstream.aliasField(namespacePrefix + ":" + tagName, clazz, fieldName);
_tags.computeIfAbsent(namespacePrefix, k -> new HashSet<>()).add(tagName);
}
|
[
"public",
"void",
"registerTag",
"(",
"String",
"namespacePrefix",
",",
"String",
"tagName",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
",",
"Class",
"<",
"?",
">",
"fieldClass",
")",
"{",
"if",
"(",
"!",
"_namespaces",
".",
"containsKey",
"(",
"namespacePrefix",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Namespace prefix '\"",
"+",
"namespacePrefix",
"+",
"\"' has not been registered yet\"",
")",
";",
"_xstream",
".",
"alias",
"(",
"namespacePrefix",
"+",
"\":\"",
"+",
"tagName",
",",
"fieldClass",
")",
";",
"_xstream",
".",
"aliasField",
"(",
"namespacePrefix",
"+",
"\":\"",
"+",
"tagName",
",",
"clazz",
",",
"fieldName",
")",
";",
"_tags",
".",
"computeIfAbsent",
"(",
"namespacePrefix",
",",
"k",
"->",
"new",
"HashSet",
"<>",
"(",
")",
")",
".",
"add",
"(",
"tagName",
")",
";",
"}"
] |
Registers a tag corresponding to a specific field of a specific class, in a the given namespace.
@param namespacePrefix namespace prefix, required
@param tagName tag name, required
@param clazz class containing the field, required
@param fieldName field name, required
@param fieldClass field type, required
|
[
"Registers",
"a",
"tag",
"corresponding",
"to",
"a",
"specific",
"field",
"of",
"a",
"specific",
"class",
"in",
"a",
"the",
"given",
"namespace",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L272-L278
|
9,683
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java
|
NaaccrStreamConfiguration.registerAttribute
|
public void registerAttribute(String namespacePrefix, String attributeName, Class<?> clazz, String fieldName, Class<?> fieldClass) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.aliasAttribute(clazz, fieldName, namespacePrefix + ":" + attributeName);
_xstream.useAttributeFor(fieldName, fieldClass);
}
|
java
|
public void registerAttribute(String namespacePrefix, String attributeName, Class<?> clazz, String fieldName, Class<?> fieldClass) {
if (!_namespaces.containsKey(namespacePrefix))
throw new RuntimeException("Namespace prefix '" + namespacePrefix + "' has not been registered yet");
_xstream.aliasAttribute(clazz, fieldName, namespacePrefix + ":" + attributeName);
_xstream.useAttributeFor(fieldName, fieldClass);
}
|
[
"public",
"void",
"registerAttribute",
"(",
"String",
"namespacePrefix",
",",
"String",
"attributeName",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
",",
"Class",
"<",
"?",
">",
"fieldClass",
")",
"{",
"if",
"(",
"!",
"_namespaces",
".",
"containsKey",
"(",
"namespacePrefix",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Namespace prefix '\"",
"+",
"namespacePrefix",
"+",
"\"' has not been registered yet\"",
")",
";",
"_xstream",
".",
"aliasAttribute",
"(",
"clazz",
",",
"fieldName",
",",
"namespacePrefix",
"+",
"\":\"",
"+",
"attributeName",
")",
";",
"_xstream",
".",
"useAttributeFor",
"(",
"fieldName",
",",
"fieldClass",
")",
";",
"}"
] |
Registers an attribute corresponding to a specific field of a specific class, in a given namespace.
@param namespacePrefix namespace prefix, required
@param attributeName attribute name, required
@param clazz class containing the field, required
@param fieldName field name, required
@param fieldClass field type, required
|
[
"Registers",
"an",
"attribute",
"corresponding",
"to",
"a",
"specific",
"field",
"of",
"a",
"specific",
"class",
"in",
"a",
"given",
"namespace",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/NaaccrStreamConfiguration.java#L288-L293
|
9,684
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/NaaccrErrorUtils.java
|
NaaccrErrorUtils.getValidationError
|
public static String getValidationError(String code, Object... msgValues) {
if (!_MESSAGES.containsKey(code))
throw new RuntimeException("Unknown code: " + code);
return fillMessage(_MESSAGES.get(code), msgValues);
}
|
java
|
public static String getValidationError(String code, Object... msgValues) {
if (!_MESSAGES.containsKey(code))
throw new RuntimeException("Unknown code: " + code);
return fillMessage(_MESSAGES.get(code), msgValues);
}
|
[
"public",
"static",
"String",
"getValidationError",
"(",
"String",
"code",
",",
"Object",
"...",
"msgValues",
")",
"{",
"if",
"(",
"!",
"_MESSAGES",
".",
"containsKey",
"(",
"code",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Unknown code: \"",
"+",
"code",
")",
";",
"return",
"fillMessage",
"(",
"_MESSAGES",
".",
"get",
"(",
"code",
")",
",",
"msgValues",
")",
";",
"}"
] |
Returns the error message for the given error code
@param code error code
@param msgValues optional values to plug into the message
@return the corresponding error message, never null (will throw an runtime exception if unknown code)
|
[
"Returns",
"the",
"error",
"message",
"for",
"the",
"given",
"error",
"code"
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/NaaccrErrorUtils.java#L49-L53
|
9,685
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java
|
SasUtils.createReader
|
public static BufferedReader createReader(File file) throws IOException {
InputStream is = new FileInputStream(file);
if (file.getName().toLowerCase().endsWith(".gz"))
is = new GZIPInputStream(is);
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
}
|
java
|
public static BufferedReader createReader(File file) throws IOException {
InputStream is = new FileInputStream(file);
if (file.getName().toLowerCase().endsWith(".gz"))
is = new GZIPInputStream(is);
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
}
|
[
"public",
"static",
"BufferedReader",
"createReader",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".gz\"",
")",
")",
"is",
"=",
"new",
"GZIPInputStream",
"(",
"is",
")",
";",
"return",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"is",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}"
] |
Creates a reader from the given file. Support GZIP compressed files.
@param file file to read
@return reader
|
[
"Creates",
"a",
"reader",
"from",
"the",
"given",
"file",
".",
"Support",
"GZIP",
"compressed",
"files",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java#L38-L43
|
9,686
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java
|
SasUtils.createWriter
|
public static BufferedWriter createWriter(File file) throws IOException {
OutputStream os = new FileOutputStream(file);
if (file.getName().toLowerCase().endsWith(".gz"))
os = new GZIPOutputStream(os);
return new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
}
|
java
|
public static BufferedWriter createWriter(File file) throws IOException {
OutputStream os = new FileOutputStream(file);
if (file.getName().toLowerCase().endsWith(".gz"))
os = new GZIPOutputStream(os);
return new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
}
|
[
"public",
"static",
"BufferedWriter",
"createWriter",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"OutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".gz\"",
")",
")",
"os",
"=",
"new",
"GZIPOutputStream",
"(",
"os",
")",
";",
"return",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"os",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}"
] |
Creates a writer from the given file. Supports GZIP compressed files.
@param file file to write
@return writer
|
[
"Creates",
"a",
"writer",
"from",
"the",
"given",
"file",
".",
"Supports",
"GZIP",
"compressed",
"files",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java#L50-L55
|
9,687
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java
|
SasUtils.getFields
|
public static List<SasFieldInfo> getFields(String version, String recordType, File dictionary) {
return getFields(recordType, Thread.currentThread().getContextClassLoader().getResourceAsStream("naaccr-xml-items-" + version + ".csv"), dictionary);
}
|
java
|
public static List<SasFieldInfo> getFields(String version, String recordType, File dictionary) {
return getFields(recordType, Thread.currentThread().getContextClassLoader().getResourceAsStream("naaccr-xml-items-" + version + ".csv"), dictionary);
}
|
[
"public",
"static",
"List",
"<",
"SasFieldInfo",
">",
"getFields",
"(",
"String",
"version",
",",
"String",
"recordType",
",",
"File",
"dictionary",
")",
"{",
"return",
"getFields",
"(",
"recordType",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"naaccr-xml-items-\"",
"+",
"version",
"+",
"\".csv\"",
")",
",",
"dictionary",
")",
";",
"}"
] |
Returns the fields information for the given parameters.
@param version NAACCR version
@param recordType record type
@param dictionary user-defined dictionary in CSV format (see standard ones in docs folder)
@return fields information
|
[
"Returns",
"the",
"fields",
"information",
"for",
"the",
"given",
"parameters",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/sas/SasUtils.java#L64-L66
|
9,688
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/CounterController.java
|
CounterController.display
|
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
public CounterResource display(@PathVariable("name") String name) {
Metric<Double> c = findCounter(name);
return counterResourceAssembler.toResource(c);
}
|
java
|
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
public CounterResource display(@PathVariable("name") String name) {
Metric<Double> c = findCounter(name);
return counterResourceAssembler.toResource(c);
}
|
[
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/{name}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"public",
"CounterResource",
"display",
"(",
"@",
"PathVariable",
"(",
"\"name\"",
")",
"String",
"name",
")",
"{",
"Metric",
"<",
"Double",
">",
"c",
"=",
"findCounter",
"(",
"name",
")",
";",
"return",
"counterResourceAssembler",
".",
"toResource",
"(",
"c",
")",
";",
"}"
] |
Retrieve information about a specific counter.
@param name name
@return counter information
|
[
"Retrieve",
"information",
"about",
"a",
"specific",
"counter",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/CounterController.java#L102-L106
|
9,689
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/CounterController.java
|
CounterController.findCounter
|
private Metric<Double> findCounter(@PathVariable("name") String name) {
@SuppressWarnings("unchecked")
Metric<Double> c = (Metric<Double>) metricRepository.findOne(COUNTER_PREFIX + name);
if (c == null) {
throw new NoSuchMetricException(name);
}
return c;
}
|
java
|
private Metric<Double> findCounter(@PathVariable("name") String name) {
@SuppressWarnings("unchecked")
Metric<Double> c = (Metric<Double>) metricRepository.findOne(COUNTER_PREFIX + name);
if (c == null) {
throw new NoSuchMetricException(name);
}
return c;
}
|
[
"private",
"Metric",
"<",
"Double",
">",
"findCounter",
"(",
"@",
"PathVariable",
"(",
"\"name\"",
")",
"String",
"name",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Metric",
"<",
"Double",
">",
"c",
"=",
"(",
"Metric",
"<",
"Double",
">",
")",
"metricRepository",
".",
"findOne",
"(",
"COUNTER_PREFIX",
"+",
"name",
")",
";",
"if",
"(",
"c",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMetricException",
"(",
"name",
")",
";",
"}",
"return",
"c",
";",
"}"
] |
Find a given counter, taking care of name conversion between the Spring Boot domain and our domain.
@param name name
@return counter
@throws NoSuchMetricException if the counter does not exist
|
[
"Find",
"a",
"given",
"counter",
"taking",
"care",
"of",
"name",
"conversion",
"between",
"the",
"Spring",
"Boot",
"domain",
"and",
"our",
"domain",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/CounterController.java#L127-L134
|
9,690
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/rest/controller/CounterController.java
|
CounterController.filterCounters
|
@SuppressWarnings("unchecked")
private <T extends Number> List<Metric<T>> filterCounters(Iterable<Metric<?>> input) {
List<Metric<T>> result = new ArrayList<>();
for (Metric<?> metric : input) {
if (metric.getName().startsWith(COUNTER_PREFIX)) {
result.add((Metric<T>) metric);
}
}
return result;
}
|
java
|
@SuppressWarnings("unchecked")
private <T extends Number> List<Metric<T>> filterCounters(Iterable<Metric<?>> input) {
List<Metric<T>> result = new ArrayList<>();
for (Metric<?> metric : input) {
if (metric.getName().startsWith(COUNTER_PREFIX)) {
result.add((Metric<T>) metric);
}
}
return result;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
"extends",
"Number",
">",
"List",
"<",
"Metric",
"<",
"T",
">",
">",
"filterCounters",
"(",
"Iterable",
"<",
"Metric",
"<",
"?",
">",
">",
"input",
")",
"{",
"List",
"<",
"Metric",
"<",
"T",
">>",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Metric",
"<",
"?",
">",
"metric",
":",
"input",
")",
"{",
"if",
"(",
"metric",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"COUNTER_PREFIX",
")",
")",
"{",
"result",
".",
"add",
"(",
"(",
"Metric",
"<",
"T",
">",
")",
"metric",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Filter the list of Boot metrics to only return those that are counters.
|
[
"Filter",
"the",
"list",
"of",
"Boot",
"metrics",
"to",
"only",
"return",
"those",
"that",
"are",
"counters",
"."
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/rest/controller/CounterController.java#L140-L149
|
9,691
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/gui/components/SeerClickableLabel.java
|
SeerClickableLabel.createBrowseToUrlAction
|
public static SeerClickableLabelAction createBrowseToUrlAction(final String url) {
return () -> {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
}
catch (IOException | RuntimeException e) {
// ignored
}
}
};
}
|
java
|
public static SeerClickableLabelAction createBrowseToUrlAction(final String url) {
return () -> {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
}
catch (IOException | RuntimeException e) {
// ignored
}
}
};
}
|
[
"public",
"static",
"SeerClickableLabelAction",
"createBrowseToUrlAction",
"(",
"final",
"String",
"url",
")",
"{",
"return",
"(",
")",
"->",
"{",
"Desktop",
"desktop",
"=",
"Desktop",
".",
"isDesktopSupported",
"(",
")",
"?",
"Desktop",
".",
"getDesktop",
"(",
")",
":",
"null",
";",
"if",
"(",
"desktop",
"!=",
"null",
"&&",
"desktop",
".",
"isSupported",
"(",
"Desktop",
".",
"Action",
".",
"BROWSE",
")",
")",
"{",
"try",
"{",
"desktop",
".",
"browse",
"(",
"URI",
".",
"create",
"(",
"url",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"RuntimeException",
"e",
")",
"{",
"// ignored",
"}",
"}",
"}",
";",
"}"
] |
Utility method to create an action that browse to a given internet address.
@param url internet address
@return corresponding action
|
[
"Utility",
"method",
"to",
"create",
"an",
"action",
"that",
"browse",
"to",
"a",
"given",
"internet",
"address",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/gui/components/SeerClickableLabel.java#L124-L136
|
9,692
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/SpecificationVersion.java
|
SpecificationVersion.isSpecificationSupported
|
public static boolean isSpecificationSupported(String spec) {
return SPEC_1_0.equals(spec) || SPEC_1_1.equals(spec) || SPEC_1_2.equals(spec) || SPEC_1_3.equals(spec);
}
|
java
|
public static boolean isSpecificationSupported(String spec) {
return SPEC_1_0.equals(spec) || SPEC_1_1.equals(spec) || SPEC_1_2.equals(spec) || SPEC_1_3.equals(spec);
}
|
[
"public",
"static",
"boolean",
"isSpecificationSupported",
"(",
"String",
"spec",
")",
"{",
"return",
"SPEC_1_0",
".",
"equals",
"(",
"spec",
")",
"||",
"SPEC_1_1",
".",
"equals",
"(",
"spec",
")",
"||",
"SPEC_1_2",
".",
"equals",
"(",
"spec",
")",
"||",
"SPEC_1_3",
".",
"equals",
"(",
"spec",
")",
";",
"}"
] |
Returns true if the provided spec is supported by this library, false otherwise.
|
[
"Returns",
"true",
"if",
"the",
"provided",
"spec",
"is",
"supported",
"by",
"this",
"library",
"false",
"otherwise",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/SpecificationVersion.java#L33-L35
|
9,693
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/SpecificationVersion.java
|
SpecificationVersion.compareSpecifications
|
public static int compareSpecifications(String spec1, String spec2) {
String[] parts1 = StringUtils.split(spec1, '.');
Integer major1 = Integer.valueOf(parts1[0]);
Integer minor1 = Integer.valueOf(parts1[1]);
String[] parts2 = StringUtils.split(spec2, '.');
Integer major2 = Integer.valueOf(parts2[0]);
Integer minor2 = Integer.valueOf(parts2[1]);
if (major1.equals(major2))
return minor1.compareTo(minor2);
return major1.compareTo(major2);
}
|
java
|
public static int compareSpecifications(String spec1, String spec2) {
String[] parts1 = StringUtils.split(spec1, '.');
Integer major1 = Integer.valueOf(parts1[0]);
Integer minor1 = Integer.valueOf(parts1[1]);
String[] parts2 = StringUtils.split(spec2, '.');
Integer major2 = Integer.valueOf(parts2[0]);
Integer minor2 = Integer.valueOf(parts2[1]);
if (major1.equals(major2))
return minor1.compareTo(minor2);
return major1.compareTo(major2);
}
|
[
"public",
"static",
"int",
"compareSpecifications",
"(",
"String",
"spec1",
",",
"String",
"spec2",
")",
"{",
"String",
"[",
"]",
"parts1",
"=",
"StringUtils",
".",
"split",
"(",
"spec1",
",",
"'",
"'",
")",
";",
"Integer",
"major1",
"=",
"Integer",
".",
"valueOf",
"(",
"parts1",
"[",
"0",
"]",
")",
";",
"Integer",
"minor1",
"=",
"Integer",
".",
"valueOf",
"(",
"parts1",
"[",
"1",
"]",
")",
";",
"String",
"[",
"]",
"parts2",
"=",
"StringUtils",
".",
"split",
"(",
"spec2",
",",
"'",
"'",
")",
";",
"Integer",
"major2",
"=",
"Integer",
".",
"valueOf",
"(",
"parts2",
"[",
"0",
"]",
")",
";",
"Integer",
"minor2",
"=",
"Integer",
".",
"valueOf",
"(",
"parts2",
"[",
"1",
"]",
")",
";",
"if",
"(",
"major1",
".",
"equals",
"(",
"major2",
")",
")",
"return",
"minor1",
".",
"compareTo",
"(",
"minor2",
")",
";",
"return",
"major1",
".",
"compareTo",
"(",
"major2",
")",
";",
"}"
] |
Compare the two provided specifications. Result is undefined if any of them is not supported.
@param spec1 first version to compare
@param spec2 second version to compare
@return negative integer if first version is smaller, 0 if they are the same, positive integer otherwise
|
[
"Compare",
"the",
"two",
"provided",
"specifications",
".",
"Result",
"is",
"undefined",
"if",
"any",
"of",
"them",
"is",
"not",
"supported",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/SpecificationVersion.java#L43-L55
|
9,694
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/entity/dictionary/NaaccrDictionaryGroupedItem.java
|
NaaccrDictionaryGroupedItem.getContainedItemId
|
public List<String> getContainedItemId() {
if (StringUtils.isBlank(_contains))
return Collections.emptyList();
return Arrays.asList(StringUtils.split(_contains, ','));
}
|
java
|
public List<String> getContainedItemId() {
if (StringUtils.isBlank(_contains))
return Collections.emptyList();
return Arrays.asList(StringUtils.split(_contains, ','));
}
|
[
"public",
"List",
"<",
"String",
">",
"getContainedItemId",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"_contains",
")",
")",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"return",
"Arrays",
".",
"asList",
"(",
"StringUtils",
".",
"split",
"(",
"_contains",
",",
"'",
"'",
")",
")",
";",
"}"
] |
Returns the NAACCR ID of the items contained in this grouped item.
@return the NAACCR ID of the items contained in this grouped item
|
[
"Returns",
"the",
"NAACCR",
"ID",
"of",
"the",
"items",
"contained",
"in",
"this",
"grouped",
"item",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/entity/dictionary/NaaccrDictionaryGroupedItem.java#L31-L35
|
9,695
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/entity/Patient.java
|
Patient.getAllValidationErrors
|
public List<NaaccrValidationError> getAllValidationErrors() {
List<NaaccrValidationError> results = new ArrayList<>(getValidationErrors());
results.addAll(getItems().stream().filter(item -> item.getValidationError() != null).map(Item::getValidationError).collect(Collectors.toList()));
for (Tumor tumor : getTumors())
results.addAll(tumor.getAllValidationErrors());
return results;
}
|
java
|
public List<NaaccrValidationError> getAllValidationErrors() {
List<NaaccrValidationError> results = new ArrayList<>(getValidationErrors());
results.addAll(getItems().stream().filter(item -> item.getValidationError() != null).map(Item::getValidationError).collect(Collectors.toList()));
for (Tumor tumor : getTumors())
results.addAll(tumor.getAllValidationErrors());
return results;
}
|
[
"public",
"List",
"<",
"NaaccrValidationError",
">",
"getAllValidationErrors",
"(",
")",
"{",
"List",
"<",
"NaaccrValidationError",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
"getValidationErrors",
"(",
")",
")",
";",
"results",
".",
"addAll",
"(",
"getItems",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"item",
"->",
"item",
".",
"getValidationError",
"(",
")",
"!=",
"null",
")",
".",
"map",
"(",
"Item",
"::",
"getValidationError",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"for",
"(",
"Tumor",
"tumor",
":",
"getTumors",
"(",
")",
")",
"results",
".",
"addAll",
"(",
"tumor",
".",
"getAllValidationErrors",
"(",
")",
")",
";",
"return",
"results",
";",
"}"
] |
This methods returns all the validation errors on the patient, any of its items and any of its tumors.
@return collection of validation errors, maybe empty but never null
|
[
"This",
"methods",
"returns",
"all",
"the",
"validation",
"errors",
"on",
"the",
"patient",
"any",
"of",
"its",
"items",
"and",
"any",
"of",
"its",
"tumors",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/entity/Patient.java#L33-L39
|
9,696
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/runtime/RuntimeNaaccrDictionary.java
|
RuntimeNaaccrDictionary.computeId
|
public static String computeId(String recordType, NaaccrDictionary baseDictionary, Collection<NaaccrDictionary> userDictionaries) {
if (baseDictionary == null)
return recordType;
StringBuilder buf = new StringBuilder(recordType);
buf.append(";").append(baseDictionary.getDictionaryUri());
if (userDictionaries != null)
for (NaaccrDictionary userDictionary : userDictionaries)
if (userDictionary != null)
buf.append(";").append(userDictionary.getDictionaryUri());
return buf.toString();
}
|
java
|
public static String computeId(String recordType, NaaccrDictionary baseDictionary, Collection<NaaccrDictionary> userDictionaries) {
if (baseDictionary == null)
return recordType;
StringBuilder buf = new StringBuilder(recordType);
buf.append(";").append(baseDictionary.getDictionaryUri());
if (userDictionaries != null)
for (NaaccrDictionary userDictionary : userDictionaries)
if (userDictionary != null)
buf.append(";").append(userDictionary.getDictionaryUri());
return buf.toString();
}
|
[
"public",
"static",
"String",
"computeId",
"(",
"String",
"recordType",
",",
"NaaccrDictionary",
"baseDictionary",
",",
"Collection",
"<",
"NaaccrDictionary",
">",
"userDictionaries",
")",
"{",
"if",
"(",
"baseDictionary",
"==",
"null",
")",
"return",
"recordType",
";",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"recordType",
")",
";",
"buf",
".",
"append",
"(",
"\";\"",
")",
".",
"append",
"(",
"baseDictionary",
".",
"getDictionaryUri",
"(",
")",
")",
";",
"if",
"(",
"userDictionaries",
"!=",
"null",
")",
"for",
"(",
"NaaccrDictionary",
"userDictionary",
":",
"userDictionaries",
")",
"if",
"(",
"userDictionary",
"!=",
"null",
")",
"buf",
".",
"append",
"(",
"\";\"",
")",
".",
"append",
"(",
"userDictionary",
".",
"getDictionaryUri",
"(",
")",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] |
Helper method to compute an ID for a runtime dictionary based on the URI of its base and user dictionaries.
@param baseDictionary base dictionary (required)
@param userDictionaries user-defined dictionaries (optional, can be null or empty)
@return computed runtime dictionary ID, never null
|
[
"Helper",
"method",
"to",
"compute",
"an",
"ID",
"for",
"a",
"runtime",
"dictionary",
"based",
"on",
"the",
"URI",
"of",
"its",
"base",
"and",
"user",
"dictionaries",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/runtime/RuntimeNaaccrDictionary.java#L124-L135
|
9,697
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/entity/AbstractEntity.java
|
AbstractEntity.getItemValue
|
public String getItemValue(String id) {
Item item = getItem(id);
if (item != null)
return item.getValue();
return null;
}
|
java
|
public String getItemValue(String id) {
Item item = getItem(id);
if (item != null)
return item.getValue();
return null;
}
|
[
"public",
"String",
"getItemValue",
"(",
"String",
"id",
")",
"{",
"Item",
"item",
"=",
"getItem",
"(",
"id",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"return",
"item",
".",
"getValue",
"(",
")",
";",
"return",
"null",
";",
"}"
] |
Returns the value of the item with the requested ID.
@param id requested item ID
@return the value of the corresponding item, sometimes null
|
[
"Returns",
"the",
"value",
"of",
"the",
"item",
"with",
"the",
"requested",
"ID",
"."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/entity/AbstractEntity.java#L94-L99
|
9,698
|
spring-projects/spring-analytics
|
src/main/java/org/springframework/analytics/metrics/MetricUtils.java
|
MetricUtils.sum
|
public static long sum(long[] array) {
if (array == null) {
return 0L;
}
long sum = 0;
for (int i = 0; i < array.length; i++) {
sum += array[i];
}
return sum;
}
|
java
|
public static long sum(long[] array) {
if (array == null) {
return 0L;
}
long sum = 0;
for (int i = 0; i < array.length; i++) {
sum += array[i];
}
return sum;
}
|
[
"public",
"static",
"long",
"sum",
"(",
"long",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"return",
"0L",
";",
"}",
"long",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"sum",
"+=",
"array",
"[",
"i",
"]",
";",
"}",
"return",
"sum",
";",
"}"
] |
Return the sum of values in the array
@param array the array to sum
@return the sum
|
[
"Return",
"the",
"sum",
"of",
"values",
"in",
"the",
"array"
] |
e3ef19d2b794d6dc10265c171bba46cd757b1abd
|
https://github.com/spring-projects/spring-analytics/blob/e3ef19d2b794d6dc10265c171bba46cd757b1abd/src/main/java/org/springframework/analytics/metrics/MetricUtils.java#L75-L84
|
9,699
|
imsweb/naaccr-xml
|
src/main/java/com/imsweb/naaccrxml/PatientXmlWriter.java
|
PatientXmlWriter.convertSyntaxException
|
protected NaaccrIOException convertSyntaxException(ConversionException ex) {
String msg = ex.get("message");
if (msg == null)
msg = ex.getMessage();
NaaccrIOException e = new NaaccrIOException(msg, ex);
if (ex.get("line number") != null)
e.setLineNumber(Integer.valueOf(ex.get("line number")));
e.setPath(ex.get("path"));
return e;
}
|
java
|
protected NaaccrIOException convertSyntaxException(ConversionException ex) {
String msg = ex.get("message");
if (msg == null)
msg = ex.getMessage();
NaaccrIOException e = new NaaccrIOException(msg, ex);
if (ex.get("line number") != null)
e.setLineNumber(Integer.valueOf(ex.get("line number")));
e.setPath(ex.get("path"));
return e;
}
|
[
"protected",
"NaaccrIOException",
"convertSyntaxException",
"(",
"ConversionException",
"ex",
")",
"{",
"String",
"msg",
"=",
"ex",
".",
"get",
"(",
"\"message\"",
")",
";",
"if",
"(",
"msg",
"==",
"null",
")",
"msg",
"=",
"ex",
".",
"getMessage",
"(",
")",
";",
"NaaccrIOException",
"e",
"=",
"new",
"NaaccrIOException",
"(",
"msg",
",",
"ex",
")",
";",
"if",
"(",
"ex",
".",
"get",
"(",
"\"line number\"",
")",
"!=",
"null",
")",
"e",
".",
"setLineNumber",
"(",
"Integer",
".",
"valueOf",
"(",
"ex",
".",
"get",
"(",
"\"line number\"",
")",
")",
")",
";",
"e",
".",
"setPath",
"(",
"ex",
".",
"get",
"(",
"\"path\"",
")",
")",
";",
"return",
"e",
";",
"}"
] |
We don't want to expose the conversion exceptions, so let's translate them into our own exceptions...
|
[
"We",
"don",
"t",
"want",
"to",
"expose",
"the",
"conversion",
"exceptions",
"so",
"let",
"s",
"translate",
"them",
"into",
"our",
"own",
"exceptions",
"..."
] |
a3a501faa2a0c3411dd5248b2c1379f279131696
|
https://github.com/imsweb/naaccr-xml/blob/a3a501faa2a0c3411dd5248b2c1379f279131696/src/main/java/com/imsweb/naaccrxml/PatientXmlWriter.java#L268-L277
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.