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
145,600
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.unregisterFromPushServices
public void unregisterFromPushServices(final Respoke.TaskCompletionListener completionListener) { if (isConnected()) { SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); if (null != prefs) { String lastKnownPushTokenID = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN_ID, "notAvailable"); if ((null != lastKnownPushTokenID) && !lastKnownPushTokenID.equals("notAvailable")) { // A push token has previously been registered successfully String httpURI = String.format("/v1/connections/%s/push-token/%s", localConnectionID, lastKnownPushTokenID); signalingChannel.sendRESTMessage("delete", httpURI, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { // Remove the push token ID from shared memory so that push may be registered again in the future SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.remove(PROPERTY_LAST_VALID_PUSH_TOKEN_ID); editor.apply(); Respoke.postTaskSuccess(completionListener); } @Override public void onError(String errorMessage) { Respoke.postTaskError(completionListener, "Error unregistering push service token: " + errorMessage); } }); } else { Respoke.postTaskSuccess(completionListener); } } else { Respoke.postTaskError(completionListener, "Unable to access shared preferences to look for push token"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
java
public void unregisterFromPushServices(final Respoke.TaskCompletionListener completionListener) { if (isConnected()) { SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); if (null != prefs) { String lastKnownPushTokenID = prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN_ID, "notAvailable"); if ((null != lastKnownPushTokenID) && !lastKnownPushTokenID.equals("notAvailable")) { // A push token has previously been registered successfully String httpURI = String.format("/v1/connections/%s/push-token/%s", localConnectionID, lastKnownPushTokenID); signalingChannel.sendRESTMessage("delete", httpURI, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { // Remove the push token ID from shared memory so that push may be registered again in the future SharedPreferences prefs = appContext.getSharedPreferences(appContext.getPackageName(), Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.remove(PROPERTY_LAST_VALID_PUSH_TOKEN_ID); editor.apply(); Respoke.postTaskSuccess(completionListener); } @Override public void onError(String errorMessage) { Respoke.postTaskError(completionListener, "Error unregistering push service token: " + errorMessage); } }); } else { Respoke.postTaskSuccess(completionListener); } } else { Respoke.postTaskError(completionListener, "Unable to access shared preferences to look for push token"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
[ "public", "void", "unregisterFromPushServices", "(", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "isConnected", "(", ")", ")", "{", "SharedPreferences", "prefs", "=", "appContext", ".", "getSharedPreferences", "(", "appContext", ".", "getPackageName", "(", ")", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "if", "(", "null", "!=", "prefs", ")", "{", "String", "lastKnownPushTokenID", "=", "prefs", ".", "getString", "(", "PROPERTY_LAST_VALID_PUSH_TOKEN_ID", ",", "\"notAvailable\"", ")", ";", "if", "(", "(", "null", "!=", "lastKnownPushTokenID", ")", "&&", "!", "lastKnownPushTokenID", ".", "equals", "(", "\"notAvailable\"", ")", ")", "{", "// A push token has previously been registered successfully", "String", "httpURI", "=", "String", ".", "format", "(", "\"/v1/connections/%s/push-token/%s\"", ",", "localConnectionID", ",", "lastKnownPushTokenID", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"delete\"", ",", "httpURI", ",", "null", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "// Remove the push token ID from shared memory so that push may be registered again in the future", "SharedPreferences", "prefs", "=", "appContext", ".", "getSharedPreferences", "(", "appContext", ".", "getPackageName", "(", ")", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "SharedPreferences", ".", "Editor", "editor", "=", "prefs", ".", "edit", "(", ")", ";", "editor", ".", "remove", "(", "PROPERTY_LAST_VALID_PUSH_TOKEN_ID", ")", ";", "editor", ".", "apply", "(", ")", ";", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error unregistering push service token: \"", "+", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "else", "{", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Unable to access shared preferences to look for push token\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Can't complete request when not connected. Please reconnect!\"", ")", ";", "}", "}" ]
Unregister this client from the push service so that no more notifications will be received for this endpoint ID @param completionListener A listener to receive the notification on the success or failure of the asynchronous operation
[ "Unregister", "this", "client", "from", "the", "push", "service", "so", "that", "no", "more", "notifications", "will", "be", "received", "for", "this", "endpoint", "ID" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L998-L1034
145,601
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.postConnectError
private void postConnectError(final ConnectCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
java
private void postConnectError(final ConnectCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
[ "private", "void", "postConnectError", "(", "final", "ConnectCompletionListener", "completionListener", ",", "final", "String", "errorMessage", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onError", "(", "errorMessage", ")", ";", "}", "}", "}", ")", ";", "}" ]
A convenience method for posting errors to a ConnectCompletionListener @param completionListener The listener to notify @param errorMessage The human-readable error message that occurred
[ "A", "convenience", "method", "for", "posting", "errors", "to", "a", "ConnectCompletionListener" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1072-L1081
145,602
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.postJoinGroupMembersError
private void postJoinGroupMembersError(final JoinGroupCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
java
private void postJoinGroupMembersError(final JoinGroupCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
[ "private", "void", "postJoinGroupMembersError", "(", "final", "JoinGroupCompletionListener", "completionListener", ",", "final", "String", "errorMessage", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onError", "(", "errorMessage", ")", ";", "}", "}", "}", ")", ";", "}" ]
A convenience method for posting errors to a JoinGroupCompletionListener @param completionListener The listener to notify @param errorMessage The human-readable error message that occurred
[ "A", "convenience", "method", "for", "posting", "errors", "to", "a", "JoinGroupCompletionListener" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1089-L1098
145,603
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.performReconnect
private void performReconnect() { if (null != applicationID) { reconnectCount++; new java.util.Timer().schedule( new java.util.TimerTask() { @Override public void run() { actuallyReconnect(); } }, RECONNECT_INTERVAL * (reconnectCount - 1) ); } }
java
private void performReconnect() { if (null != applicationID) { reconnectCount++; new java.util.Timer().schedule( new java.util.TimerTask() { @Override public void run() { actuallyReconnect(); } }, RECONNECT_INTERVAL * (reconnectCount - 1) ); } }
[ "private", "void", "performReconnect", "(", ")", "{", "if", "(", "null", "!=", "applicationID", ")", "{", "reconnectCount", "++", ";", "new", "java", ".", "util", ".", "Timer", "(", ")", ".", "schedule", "(", "new", "java", ".", "util", ".", "TimerTask", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "actuallyReconnect", "(", ")", ";", "}", "}", ",", "RECONNECT_INTERVAL", "*", "(", "reconnectCount", "-", "1", ")", ")", ";", "}", "}" ]
Attempt to reconnect the client after a small delay
[ "Attempt", "to", "reconnect", "the", "client", "after", "a", "small", "delay" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1139-L1153
145,604
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.actuallyReconnect
private void actuallyReconnect() { if (((null == signalingChannel) || !signalingChannel.connected) && reconnect) { if (connectionInProgress) { // The client app must have initiated a connection manually during the timeout period. Try again later performReconnect(); } else { Log.d(TAG, "Trying to reconnect..."); connect(localEndpointID, applicationID, reconnect, presence, appContext, new ConnectCompletionListener() { @Override public void onError(final String errorMessage) { // A REST API call failed. Socket errors are handled in the onError callback new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onError(RespokeClient.this, errorMessage); } } }); // Try again later performReconnect(); } }); } } }
java
private void actuallyReconnect() { if (((null == signalingChannel) || !signalingChannel.connected) && reconnect) { if (connectionInProgress) { // The client app must have initiated a connection manually during the timeout period. Try again later performReconnect(); } else { Log.d(TAG, "Trying to reconnect..."); connect(localEndpointID, applicationID, reconnect, presence, appContext, new ConnectCompletionListener() { @Override public void onError(final String errorMessage) { // A REST API call failed. Socket errors are handled in the onError callback new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onError(RespokeClient.this, errorMessage); } } }); // Try again later performReconnect(); } }); } } }
[ "private", "void", "actuallyReconnect", "(", ")", "{", "if", "(", "(", "(", "null", "==", "signalingChannel", ")", "||", "!", "signalingChannel", ".", "connected", ")", "&&", "reconnect", ")", "{", "if", "(", "connectionInProgress", ")", "{", "// The client app must have initiated a connection manually during the timeout period. Try again later", "performReconnect", "(", ")", ";", "}", "else", "{", "Log", ".", "d", "(", "TAG", ",", "\"Trying to reconnect...\"", ")", ";", "connect", "(", "localEndpointID", ",", "applicationID", ",", "reconnect", ",", "presence", ",", "appContext", ",", "new", "ConnectCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "// A REST API call failed. Socket errors are handled in the onError callback", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onError", "(", "RespokeClient", ".", "this", ",", "errorMessage", ")", ";", "}", "}", "}", ")", ";", "// Try again later", "performReconnect", "(", ")", ";", "}", "}", ")", ";", "}", "}", "}" ]
Attempt to reconnect the client if it is not already trying in another thread
[ "Attempt", "to", "reconnect", "the", "client", "if", "it", "is", "not", "already", "trying", "in", "another", "thread" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1158-L1185
145,605
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java
RespokeClient.buildGroupMessage
private RespokeGroupMessage buildGroupMessage(JSONObject source) throws JSONException { if (source == null) { throw new IllegalArgumentException("source cannot be null"); } final JSONObject header = source.getJSONObject("header"); final String endpointID = header.getString("from"); final RespokeEndpoint endpoint = getEndpoint(endpointID, false); final String groupID = header.getString("channel"); RespokeGroup group = getGroup(groupID); if (group == null) { group = new RespokeGroup(groupID, signalingChannel, this, false); groups.put(groupID, group); } final String message = source.getString("message"); final Date timestamp; if (!header.isNull("timestamp")) { timestamp = new Date(header.getLong("timestamp")); } else { // Just use the current time if no date is specified in the header data timestamp = new Date(); } return new RespokeGroupMessage(message, group, endpoint, timestamp); }
java
private RespokeGroupMessage buildGroupMessage(JSONObject source) throws JSONException { if (source == null) { throw new IllegalArgumentException("source cannot be null"); } final JSONObject header = source.getJSONObject("header"); final String endpointID = header.getString("from"); final RespokeEndpoint endpoint = getEndpoint(endpointID, false); final String groupID = header.getString("channel"); RespokeGroup group = getGroup(groupID); if (group == null) { group = new RespokeGroup(groupID, signalingChannel, this, false); groups.put(groupID, group); } final String message = source.getString("message"); final Date timestamp; if (!header.isNull("timestamp")) { timestamp = new Date(header.getLong("timestamp")); } else { // Just use the current time if no date is specified in the header data timestamp = new Date(); } return new RespokeGroupMessage(message, group, endpoint, timestamp); }
[ "private", "RespokeGroupMessage", "buildGroupMessage", "(", "JSONObject", "source", ")", "throws", "JSONException", "{", "if", "(", "source", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"source cannot be null\"", ")", ";", "}", "final", "JSONObject", "header", "=", "source", ".", "getJSONObject", "(", "\"header\"", ")", ";", "final", "String", "endpointID", "=", "header", ".", "getString", "(", "\"from\"", ")", ";", "final", "RespokeEndpoint", "endpoint", "=", "getEndpoint", "(", "endpointID", ",", "false", ")", ";", "final", "String", "groupID", "=", "header", ".", "getString", "(", "\"channel\"", ")", ";", "RespokeGroup", "group", "=", "getGroup", "(", "groupID", ")", ";", "if", "(", "group", "==", "null", ")", "{", "group", "=", "new", "RespokeGroup", "(", "groupID", ",", "signalingChannel", ",", "this", ",", "false", ")", ";", "groups", ".", "put", "(", "groupID", ",", "group", ")", ";", "}", "final", "String", "message", "=", "source", ".", "getString", "(", "\"message\"", ")", ";", "final", "Date", "timestamp", ";", "if", "(", "!", "header", ".", "isNull", "(", "\"timestamp\"", ")", ")", "{", "timestamp", "=", "new", "Date", "(", "header", ".", "getLong", "(", "\"timestamp\"", ")", ")", ";", "}", "else", "{", "// Just use the current time if no date is specified in the header data", "timestamp", "=", "new", "Date", "(", ")", ";", "}", "return", "new", "RespokeGroupMessage", "(", "message", ",", "group", ",", "endpoint", ",", "timestamp", ")", ";", "}" ]
Build a group message from a JSON object. The format of the JSON object would be the format that comes over the wire from Respoke when receiving a pubsub message. This same format is used when retrieving message history. @param source The source JSON object to build the RespokeGroupMessage from @return The built RespokeGroupMessage @throws JSONException
[ "Build", "a", "group", "message", "from", "a", "JSON", "object", ".", "The", "format", "of", "the", "JSON", "object", "would", "be", "the", "format", "that", "comes", "over", "the", "wire", "from", "Respoke", "when", "receiving", "a", "pubsub", "message", ".", "This", "same", "format", "is", "used", "when", "retrieving", "message", "history", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeClient.java#L1576-L1604
145,606
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.setListener
public void setListener(Listener listener) { if (null != listener) { listenerReference = new WeakReference<Listener>(listener); } else { listenerReference = null; } }
java
public void setListener(Listener listener) { if (null != listener) { listenerReference = new WeakReference<Listener>(listener); } else { listenerReference = null; } }
[ "public", "void", "setListener", "(", "Listener", "listener", ")", "{", "if", "(", "null", "!=", "listener", ")", "{", "listenerReference", "=", "new", "WeakReference", "<", "Listener", ">", "(", "listener", ")", ";", "}", "else", "{", "listenerReference", "=", "null", ";", "}", "}" ]
Set a receiver for the Listener interface @param listener The new receiver for events from the Listener interface for this instance
[ "Set", "a", "receiver", "for", "the", "Listener", "interface" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L92-L98
145,607
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.accept
public void accept(Context context) { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidAccept(context); } } }
java
public void accept(Context context) { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidAccept(context); } } }
[ "public", "void", "accept", "(", "Context", "context", ")", "{", "if", "(", "null", "!=", "callReference", ")", "{", "RespokeCall", "call", "=", "callReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "call", ")", "{", "call", ".", "directConnectionDidAccept", "(", "context", ")", ";", "}", "}", "}" ]
Accept the direct connection and start the process of obtaining media. @param context An application context with which to access system resources
[ "Accept", "the", "direct", "connection", "and", "start", "the", "process", "of", "obtaining", "media", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L106-L113
145,608
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.sendMessage
public void sendMessage(String message, final Respoke.TaskCompletionListener completionListener) { if (isActive()) { JSONObject jsonMessage = new JSONObject(); try { jsonMessage.put("message", message); byte[] rawMessage = jsonMessage.toString().getBytes(Charset.forName("UTF-8")); ByteBuffer directData = ByteBuffer.allocateDirect(rawMessage.length); directData.put(rawMessage); directData.flip(); DataChannel.Buffer data = new DataChannel.Buffer(directData, false); if (dataChannel.send(data)) { Respoke.postTaskSuccess(completionListener); } else { Respoke.postTaskError(completionListener, "Error sending message"); } } catch (JSONException e) { Respoke.postTaskError(completionListener, "Unable to encode message to JSON"); } } else { Respoke.postTaskError(completionListener, "DataChannel not in an open state"); } }
java
public void sendMessage(String message, final Respoke.TaskCompletionListener completionListener) { if (isActive()) { JSONObject jsonMessage = new JSONObject(); try { jsonMessage.put("message", message); byte[] rawMessage = jsonMessage.toString().getBytes(Charset.forName("UTF-8")); ByteBuffer directData = ByteBuffer.allocateDirect(rawMessage.length); directData.put(rawMessage); directData.flip(); DataChannel.Buffer data = new DataChannel.Buffer(directData, false); if (dataChannel.send(data)) { Respoke.postTaskSuccess(completionListener); } else { Respoke.postTaskError(completionListener, "Error sending message"); } } catch (JSONException e) { Respoke.postTaskError(completionListener, "Unable to encode message to JSON"); } } else { Respoke.postTaskError(completionListener, "DataChannel not in an open state"); } }
[ "public", "void", "sendMessage", "(", "String", "message", ",", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "JSONObject", "jsonMessage", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "jsonMessage", ".", "put", "(", "\"message\"", ",", "message", ")", ";", "byte", "[", "]", "rawMessage", "=", "jsonMessage", ".", "toString", "(", ")", ".", "getBytes", "(", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ";", "ByteBuffer", "directData", "=", "ByteBuffer", ".", "allocateDirect", "(", "rawMessage", ".", "length", ")", ";", "directData", ".", "put", "(", "rawMessage", ")", ";", "directData", ".", "flip", "(", ")", ";", "DataChannel", ".", "Buffer", "data", "=", "new", "DataChannel", ".", "Buffer", "(", "directData", ",", "false", ")", ";", "if", "(", "dataChannel", ".", "send", "(", "data", ")", ")", "{", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error sending message\"", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Unable to encode message to JSON\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"DataChannel not in an open state\"", ")", ";", "}", "}" ]
Send a message to the remote client through the direct connection. @param message The message to send @param completionListener A listener to receive a notification on the success of the asynchronous operation
[ "Send", "a", "message", "to", "the", "remote", "client", "through", "the", "direct", "connection", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L146-L168
145,609
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.createDataChannel
public void createDataChannel() { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { PeerConnection peerConnection = call.getPeerConnection(); dataChannel = peerConnection.createDataChannel("respokeDataChannel", new DataChannel.Init()); dataChannel.registerObserver(this); } } }
java
public void createDataChannel() { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { PeerConnection peerConnection = call.getPeerConnection(); dataChannel = peerConnection.createDataChannel("respokeDataChannel", new DataChannel.Init()); dataChannel.registerObserver(this); } } }
[ "public", "void", "createDataChannel", "(", ")", "{", "if", "(", "null", "!=", "callReference", ")", "{", "RespokeCall", "call", "=", "callReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "call", ")", "{", "PeerConnection", "peerConnection", "=", "call", ".", "getPeerConnection", "(", ")", ";", "dataChannel", "=", "peerConnection", ".", "createDataChannel", "(", "\"respokeDataChannel\"", ",", "new", "DataChannel", ".", "Init", "(", ")", ")", ";", "dataChannel", ".", "registerObserver", "(", "this", ")", ";", "}", "}", "}" ]
Establish a new direct connection instance with the peer connection for the call. This is used internally to the SDK and should not be called directly by your client application.
[ "Establish", "a", "new", "direct", "connection", "instance", "with", "the", "peer", "connection", "for", "the", "call", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L174-L183
145,610
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.peerConnectionDidOpenDataChannel
public void peerConnectionDidOpenDataChannel(DataChannel newDataChannel) { if (null != dataChannel) { // Replacing the previous connection, so disable observer messages from the old instance dataChannel.unregisterObserver(); } else { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onStart(RespokeDirectConnection.this); } } } }); } dataChannel = newDataChannel; newDataChannel.registerObserver(this); }
java
public void peerConnectionDidOpenDataChannel(DataChannel newDataChannel) { if (null != dataChannel) { // Replacing the previous connection, so disable observer messages from the old instance dataChannel.unregisterObserver(); } else { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onStart(RespokeDirectConnection.this); } } } }); } dataChannel = newDataChannel; newDataChannel.registerObserver(this); }
[ "public", "void", "peerConnectionDidOpenDataChannel", "(", "DataChannel", "newDataChannel", ")", "{", "if", "(", "null", "!=", "dataChannel", ")", "{", "// Replacing the previous connection, so disable observer messages from the old instance", "dataChannel", ".", "unregisterObserver", "(", ")", ";", "}", "else", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "listenerReference", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onStart", "(", "RespokeDirectConnection", ".", "this", ")", ";", "}", "}", "}", "}", ")", ";", "}", "dataChannel", "=", "newDataChannel", ";", "newDataChannel", ".", "registerObserver", "(", "this", ")", ";", "}" ]
Notify the direct connection instance that the peer connection has opened the specified data channel @param newDataChannel The DataChannel that has opened
[ "Notify", "the", "direct", "connection", "instance", "that", "the", "peer", "connection", "has", "opened", "the", "specified", "data", "channel" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L191-L210
145,611
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java
RespokeDirectConnection.onStateChange
public void onStateChange() { switch (dataChannel.state()) { case CONNECTING: break; case OPEN: { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidOpen(this); } } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onOpen(RespokeDirectConnection.this); } } } }); } break; case CLOSING: break; case CLOSED: { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidClose(this); } } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onClose(RespokeDirectConnection.this); } } } }); } break; } }
java
public void onStateChange() { switch (dataChannel.state()) { case CONNECTING: break; case OPEN: { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidOpen(this); } } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onOpen(RespokeDirectConnection.this); } } } }); } break; case CLOSING: break; case CLOSED: { if (null != callReference) { RespokeCall call = callReference.get(); if (null != call) { call.directConnectionDidClose(this); } } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onClose(RespokeDirectConnection.this); } } } }); } break; } }
[ "public", "void", "onStateChange", "(", ")", "{", "switch", "(", "dataChannel", ".", "state", "(", ")", ")", "{", "case", "CONNECTING", ":", "break", ";", "case", "OPEN", ":", "{", "if", "(", "null", "!=", "callReference", ")", "{", "RespokeCall", "call", "=", "callReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "call", ")", "{", "call", ".", "directConnectionDidOpen", "(", "this", ")", ";", "}", "}", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "listenerReference", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onOpen", "(", "RespokeDirectConnection", ".", "this", ")", ";", "}", "}", "}", "}", ")", ";", "}", "break", ";", "case", "CLOSING", ":", "break", ";", "case", "CLOSED", ":", "{", "if", "(", "null", "!=", "callReference", ")", "{", "RespokeCall", "call", "=", "callReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "call", ")", "{", "call", ".", "directConnectionDidClose", "(", "this", ")", ";", "}", "}", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "listenerReference", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onClose", "(", "RespokeDirectConnection", ".", "this", ")", ";", "}", "}", "}", "}", ")", ";", "}", "break", ";", "}", "}" ]
org.webrtc.DataChannel.Observer methods
[ "org", ".", "webrtc", ".", "DataChannel", ".", "Observer", "methods" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeDirectConnection.java#L216-L266
145,612
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java
AtomicShortIntArray.set
public void set(int[] initial) { resizeLock.lock(); try { if (initial.length != length) { throw new IllegalArgumentException("Array length mismatch, expected " + length + ", got " + initial.length); } int unique = AtomicShortIntArray.getUnique(initial); int allowedPalette = AtomicShortIntPaletteBackingArray.getAllowedPalette(length); if (unique == 1) { store.set(new AtomicShortIntUniformBackingArray(length, initial[0])); } else if (unique > allowedPalette) { store.set(new AtomicShortIntDirectBackingArray(length, initial)); } else { store.set(new AtomicShortIntPaletteBackingArray(length, unique, initial)); } } finally { resizeLock.unlock(); } }
java
public void set(int[] initial) { resizeLock.lock(); try { if (initial.length != length) { throw new IllegalArgumentException("Array length mismatch, expected " + length + ", got " + initial.length); } int unique = AtomicShortIntArray.getUnique(initial); int allowedPalette = AtomicShortIntPaletteBackingArray.getAllowedPalette(length); if (unique == 1) { store.set(new AtomicShortIntUniformBackingArray(length, initial[0])); } else if (unique > allowedPalette) { store.set(new AtomicShortIntDirectBackingArray(length, initial)); } else { store.set(new AtomicShortIntPaletteBackingArray(length, unique, initial)); } } finally { resizeLock.unlock(); } }
[ "public", "void", "set", "(", "int", "[", "]", "initial", ")", "{", "resizeLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "initial", ".", "length", "!=", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Array length mismatch, expected \"", "+", "length", "+", "\", got \"", "+", "initial", ".", "length", ")", ";", "}", "int", "unique", "=", "AtomicShortIntArray", ".", "getUnique", "(", "initial", ")", ";", "int", "allowedPalette", "=", "AtomicShortIntPaletteBackingArray", ".", "getAllowedPalette", "(", "length", ")", ";", "if", "(", "unique", "==", "1", ")", "{", "store", ".", "set", "(", "new", "AtomicShortIntUniformBackingArray", "(", "length", ",", "initial", "[", "0", "]", ")", ")", ";", "}", "else", "if", "(", "unique", ">", "allowedPalette", ")", "{", "store", ".", "set", "(", "new", "AtomicShortIntDirectBackingArray", "(", "length", ",", "initial", ")", ")", ";", "}", "else", "{", "store", ".", "set", "(", "new", "AtomicShortIntPaletteBackingArray", "(", "length", ",", "unique", ",", "initial", ")", ")", ";", "}", "}", "finally", "{", "resizeLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Sets the array equal to the given array. The array should be the same length as this array @param initial the array containing the new values
[ "Sets", "the", "array", "equal", "to", "the", "given", "array", ".", "The", "array", "should", "be", "the", "same", "length", "as", "this", "array" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java#L144-L162
145,613
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java
AtomicShortIntArray.uncompressedSet
public void uncompressedSet(int[] initial) { resizeLock.lock(); try { if (initial.length != length) { throw new IllegalArgumentException("Array length mismatch, expected " + length + ", got " + initial.length); } store.set(new AtomicShortIntDirectBackingArray(length, initial)); } finally { resizeLock.unlock(); } }
java
public void uncompressedSet(int[] initial) { resizeLock.lock(); try { if (initial.length != length) { throw new IllegalArgumentException("Array length mismatch, expected " + length + ", got " + initial.length); } store.set(new AtomicShortIntDirectBackingArray(length, initial)); } finally { resizeLock.unlock(); } }
[ "public", "void", "uncompressedSet", "(", "int", "[", "]", "initial", ")", "{", "resizeLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "initial", ".", "length", "!=", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Array length mismatch, expected \"", "+", "length", "+", "\", got \"", "+", "initial", ".", "length", ")", ";", "}", "store", ".", "set", "(", "new", "AtomicShortIntDirectBackingArray", "(", "length", ",", "initial", ")", ")", ";", "}", "finally", "{", "resizeLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Sets the array equal to the given array without automatically compressing the data. The array should be the same length as this array @param initial the array containing the new values
[ "Sets", "the", "array", "equal", "to", "the", "given", "array", "without", "automatically", "compressing", "the", "data", ".", "The", "array", "should", "be", "the", "same", "length", "as", "this", "array" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java#L169-L179
145,614
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java
AtomicShortIntArray.set
public void set(int[] palette, int blockArrayWidth, int[] variableWidthBlockArray) { resizeLock.lock(); try { if (palette.length == 0) { store.set(new AtomicShortIntDirectBackingArray(length, variableWidthBlockArray)); } else if (palette.length == 1) { store.set(new AtomicShortIntUniformBackingArray(length, palette[0])); } else { store.set(new AtomicShortIntPaletteBackingArray(length, palette, blockArrayWidth, variableWidthBlockArray)); } } finally { resizeLock.unlock(); } }
java
public void set(int[] palette, int blockArrayWidth, int[] variableWidthBlockArray) { resizeLock.lock(); try { if (palette.length == 0) { store.set(new AtomicShortIntDirectBackingArray(length, variableWidthBlockArray)); } else if (palette.length == 1) { store.set(new AtomicShortIntUniformBackingArray(length, palette[0])); } else { store.set(new AtomicShortIntPaletteBackingArray(length, palette, blockArrayWidth, variableWidthBlockArray)); } } finally { resizeLock.unlock(); } }
[ "public", "void", "set", "(", "int", "[", "]", "palette", ",", "int", "blockArrayWidth", ",", "int", "[", "]", "variableWidthBlockArray", ")", "{", "resizeLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "palette", ".", "length", "==", "0", ")", "{", "store", ".", "set", "(", "new", "AtomicShortIntDirectBackingArray", "(", "length", ",", "variableWidthBlockArray", ")", ")", ";", "}", "else", "if", "(", "palette", ".", "length", "==", "1", ")", "{", "store", ".", "set", "(", "new", "AtomicShortIntUniformBackingArray", "(", "length", ",", "palette", "[", "0", "]", ")", ")", ";", "}", "else", "{", "store", ".", "set", "(", "new", "AtomicShortIntPaletteBackingArray", "(", "length", ",", "palette", ",", "blockArrayWidth", ",", "variableWidthBlockArray", ")", ")", ";", "}", "}", "finally", "{", "resizeLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Sets the array equal to the given palette based array. The main array should be the same length as this array @param palette the palette, if the palette is of length 0, variableWidthBlockArray contains the data, in flat format @param blockArrayWidth the with of each entry in the main array @param variableWidthBlockArray the array containing the new values, packed into ints
[ "Sets", "the", "array", "equal", "to", "the", "given", "palette", "based", "array", ".", "The", "main", "array", "should", "be", "the", "same", "length", "as", "this", "array" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java#L188-L201
145,615
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java
AtomicShortIntArray.compress
public void compress() { resizeLock.lock(); try { AtomicShortIntBackingArray s = store.get(); if (s instanceof AtomicShortIntUniformBackingArray) { return; } int unique = s.getUnique(); if (AtomicShortIntPaletteBackingArray.roundUpWidth(unique - 1) >= s.width()) { return; } if (unique > AtomicShortIntPaletteBackingArray.getAllowedPalette(s.length())) { return; } if (unique == 1) { store.set(new AtomicShortIntUniformBackingArray(s)); } else { store.set(new AtomicShortIntPaletteBackingArray(s, length, true, false, unique)); } } finally { resizeLock.unlock(); } }
java
public void compress() { resizeLock.lock(); try { AtomicShortIntBackingArray s = store.get(); if (s instanceof AtomicShortIntUniformBackingArray) { return; } int unique = s.getUnique(); if (AtomicShortIntPaletteBackingArray.roundUpWidth(unique - 1) >= s.width()) { return; } if (unique > AtomicShortIntPaletteBackingArray.getAllowedPalette(s.length())) { return; } if (unique == 1) { store.set(new AtomicShortIntUniformBackingArray(s)); } else { store.set(new AtomicShortIntPaletteBackingArray(s, length, true, false, unique)); } } finally { resizeLock.unlock(); } }
[ "public", "void", "compress", "(", ")", "{", "resizeLock", ".", "lock", "(", ")", ";", "try", "{", "AtomicShortIntBackingArray", "s", "=", "store", ".", "get", "(", ")", ";", "if", "(", "s", "instanceof", "AtomicShortIntUniformBackingArray", ")", "{", "return", ";", "}", "int", "unique", "=", "s", ".", "getUnique", "(", ")", ";", "if", "(", "AtomicShortIntPaletteBackingArray", ".", "roundUpWidth", "(", "unique", "-", "1", ")", ">=", "s", ".", "width", "(", ")", ")", "{", "return", ";", "}", "if", "(", "unique", ">", "AtomicShortIntPaletteBackingArray", ".", "getAllowedPalette", "(", "s", ".", "length", "(", ")", ")", ")", "{", "return", ";", "}", "if", "(", "unique", "==", "1", ")", "{", "store", ".", "set", "(", "new", "AtomicShortIntUniformBackingArray", "(", "s", ")", ")", ";", "}", "else", "{", "store", ".", "set", "(", "new", "AtomicShortIntPaletteBackingArray", "(", "s", ",", "length", ",", "true", ",", "false", ",", "unique", ")", ")", ";", "}", "}", "finally", "{", "resizeLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Attempts to compress the array
[ "Attempts", "to", "compress", "the", "array" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntArray.java#L238-L260
145,616
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.getMembers
public void getMembers(final GetGroupMembersCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { String urlEndpoint = "/v1/channels/" + groupID + "/subscribers/"; signalingChannel.sendRESTMessage("get", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { JSONArray responseArray = null; if (response != null) { if (response instanceof JSONArray) { responseArray = (JSONArray) response; } else if (response instanceof String) { try { responseArray = new JSONArray((String) response); } catch (JSONException e) { // An exception will trigger the error handler } } } if (null != responseArray) { final ArrayList<RespokeConnection> nameList = new ArrayList<RespokeConnection>(); RespokeClient client = clientReference.get(); if (null != client) { for (int ii = 0; ii < responseArray.length(); ii++) { try { JSONObject eachEntry = (JSONObject) responseArray.get(ii); String newEndpointID = eachEntry.getString("endpointId"); String newConnectionID = eachEntry.getString("connectionId"); // Do not include ourselves in this list if (!newEndpointID.equals(client.getEndpointID())) { // Get the existing instance for this connection, or create a new one if necessary RespokeConnection connection = client.getConnection(newConnectionID, newEndpointID, false); if (null != connection) { nameList.add(connection); } } } catch (JSONException e) { // Skip unintelligible records } } } // If certain connections present in the members array prior to this method are somehow no longer in the list received from the server, it's assumed a pending onLeave message will handle flushing it out of the client cache after this method completes members.clear(); members.addAll(nameList); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(nameList); } } }); } else { postGetGroupMembersError(completionListener, "Invalid response from server"); } } @Override public void onError(final String errorMessage) { postGetGroupMembersError(completionListener, errorMessage); } }); } else { postGetGroupMembersError(completionListener, "Group name must be specified"); } } else { postGetGroupMembersError(completionListener, "Not a member of this group anymore."); } }
java
public void getMembers(final GetGroupMembersCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { String urlEndpoint = "/v1/channels/" + groupID + "/subscribers/"; signalingChannel.sendRESTMessage("get", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { JSONArray responseArray = null; if (response != null) { if (response instanceof JSONArray) { responseArray = (JSONArray) response; } else if (response instanceof String) { try { responseArray = new JSONArray((String) response); } catch (JSONException e) { // An exception will trigger the error handler } } } if (null != responseArray) { final ArrayList<RespokeConnection> nameList = new ArrayList<RespokeConnection>(); RespokeClient client = clientReference.get(); if (null != client) { for (int ii = 0; ii < responseArray.length(); ii++) { try { JSONObject eachEntry = (JSONObject) responseArray.get(ii); String newEndpointID = eachEntry.getString("endpointId"); String newConnectionID = eachEntry.getString("connectionId"); // Do not include ourselves in this list if (!newEndpointID.equals(client.getEndpointID())) { // Get the existing instance for this connection, or create a new one if necessary RespokeConnection connection = client.getConnection(newConnectionID, newEndpointID, false); if (null != connection) { nameList.add(connection); } } } catch (JSONException e) { // Skip unintelligible records } } } // If certain connections present in the members array prior to this method are somehow no longer in the list received from the server, it's assumed a pending onLeave message will handle flushing it out of the client cache after this method completes members.clear(); members.addAll(nameList); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onSuccess(nameList); } } }); } else { postGetGroupMembersError(completionListener, "Invalid response from server"); } } @Override public void onError(final String errorMessage) { postGetGroupMembersError(completionListener, errorMessage); } }); } else { postGetGroupMembersError(completionListener, "Group name must be specified"); } } else { postGetGroupMembersError(completionListener, "Not a member of this group anymore."); } }
[ "public", "void", "getMembers", "(", "final", "GetGroupMembersCompletionListener", "completionListener", ")", "{", "if", "(", "isJoined", "(", ")", ")", "{", "if", "(", "(", "null", "!=", "groupID", ")", "&&", "(", "groupID", ".", "length", "(", ")", ">", "0", ")", ")", "{", "String", "urlEndpoint", "=", "\"/v1/channels/\"", "+", "groupID", "+", "\"/subscribers/\"", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"get\"", ",", "urlEndpoint", ",", "null", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "JSONArray", "responseArray", "=", "null", ";", "if", "(", "response", "!=", "null", ")", "{", "if", "(", "response", "instanceof", "JSONArray", ")", "{", "responseArray", "=", "(", "JSONArray", ")", "response", ";", "}", "else", "if", "(", "response", "instanceof", "String", ")", "{", "try", "{", "responseArray", "=", "new", "JSONArray", "(", "(", "String", ")", "response", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "// An exception will trigger the error handler", "}", "}", "}", "if", "(", "null", "!=", "responseArray", ")", "{", "final", "ArrayList", "<", "RespokeConnection", ">", "nameList", "=", "new", "ArrayList", "<", "RespokeConnection", ">", "(", ")", ";", "RespokeClient", "client", "=", "clientReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "client", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "responseArray", ".", "length", "(", ")", ";", "ii", "++", ")", "{", "try", "{", "JSONObject", "eachEntry", "=", "(", "JSONObject", ")", "responseArray", ".", "get", "(", "ii", ")", ";", "String", "newEndpointID", "=", "eachEntry", ".", "getString", "(", "\"endpointId\"", ")", ";", "String", "newConnectionID", "=", "eachEntry", ".", "getString", "(", "\"connectionId\"", ")", ";", "// Do not include ourselves in this list", "if", "(", "!", "newEndpointID", ".", "equals", "(", "client", ".", "getEndpointID", "(", ")", ")", ")", "{", "// Get the existing instance for this connection, or create a new one if necessary", "RespokeConnection", "connection", "=", "client", ".", "getConnection", "(", "newConnectionID", ",", "newEndpointID", ",", "false", ")", ";", "if", "(", "null", "!=", "connection", ")", "{", "nameList", ".", "add", "(", "connection", ")", ";", "}", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "// Skip unintelligible records", "}", "}", "}", "// If certain connections present in the members array prior to this method are somehow no longer in the list received from the server, it's assumed a pending onLeave message will handle flushing it out of the client cache after this method completes", "members", ".", "clear", "(", ")", ";", "members", ".", "addAll", "(", "nameList", ")", ";", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onSuccess", "(", "nameList", ")", ";", "}", "}", "}", ")", ";", "}", "else", "{", "postGetGroupMembersError", "(", "completionListener", ",", "\"Invalid response from server\"", ")", ";", "}", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "postGetGroupMembersError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "else", "{", "postGetGroupMembersError", "(", "completionListener", ",", "\"Group name must be specified\"", ")", ";", "}", "}", "else", "{", "postGetGroupMembersError", "(", "completionListener", ",", "\"Not a member of this group anymore.\"", ")", ";", "}", "}" ]
Get an array containing the members of the group. @param completionListener A listener to receive a notification on the success of the asynchronous operation
[ "Get", "an", "array", "containing", "the", "members", "of", "the", "group", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L133-L208
145,617
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.join
public void join(final Respoke.TaskCompletionListener completionListener) { if (!isConnected()) { Respoke.postTaskError(completionListener, "Can't complete request when not connected. " + "Please reconnect!"); return; } if ((groupID == null) || (groupID.length() == 0)) { Respoke.postTaskError(completionListener, "Group name must be specified"); return; } String urlEndpoint = String.format("/v1/groups/%s", groupID); signalingChannel.sendRESTMessage("post", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { joined = true; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); }
java
public void join(final Respoke.TaskCompletionListener completionListener) { if (!isConnected()) { Respoke.postTaskError(completionListener, "Can't complete request when not connected. " + "Please reconnect!"); return; } if ((groupID == null) || (groupID.length() == 0)) { Respoke.postTaskError(completionListener, "Group name must be specified"); return; } String urlEndpoint = String.format("/v1/groups/%s", groupID); signalingChannel.sendRESTMessage("post", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { joined = true; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); }
[ "public", "void", "join", "(", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "!", "isConnected", "(", ")", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Can't complete request when not connected. \"", "+", "\"Please reconnect!\"", ")", ";", "return", ";", "}", "if", "(", "(", "groupID", "==", "null", ")", "||", "(", "groupID", ".", "length", "(", ")", "==", "0", ")", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Group name must be specified\"", ")", ";", "return", ";", "}", "String", "urlEndpoint", "=", "String", ".", "format", "(", "\"/v1/groups/%s\"", ",", "groupID", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "urlEndpoint", ",", "null", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "joined", "=", "true", ";", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}" ]
Join this group @param completionListener A listener to receive a notification upon completion of this async operation
[ "Join", "this", "group" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L217-L242
145,618
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.leave
public void leave(final Respoke.TaskCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { String urlEndpoint = "/v1/groups"; JSONArray groupList = new JSONArray(); groupList.put(groupID); JSONObject data = new JSONObject(); try { data.put("groups", groupList); signalingChannel.sendRESTMessage("delete", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { joined = false; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding group list to json"); } } else { Respoke.postTaskError(completionListener, "Group name must be specified"); } } else { Respoke.postTaskError(completionListener, "Not a member of this group anymore."); } }
java
public void leave(final Respoke.TaskCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { String urlEndpoint = "/v1/groups"; JSONArray groupList = new JSONArray(); groupList.put(groupID); JSONObject data = new JSONObject(); try { data.put("groups", groupList); signalingChannel.sendRESTMessage("delete", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { joined = false; Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding group list to json"); } } else { Respoke.postTaskError(completionListener, "Group name must be specified"); } } else { Respoke.postTaskError(completionListener, "Not a member of this group anymore."); } }
[ "public", "void", "leave", "(", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "isJoined", "(", ")", ")", "{", "if", "(", "(", "null", "!=", "groupID", ")", "&&", "(", "groupID", ".", "length", "(", ")", ">", "0", ")", ")", "{", "String", "urlEndpoint", "=", "\"/v1/groups\"", ";", "JSONArray", "groupList", "=", "new", "JSONArray", "(", ")", ";", "groupList", ".", "put", "(", "groupID", ")", ";", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "data", ".", "put", "(", "\"groups\"", ",", "groupList", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"delete\"", ",", "urlEndpoint", ",", "data", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "joined", "=", "false", ";", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error encoding group list to json\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Group name must be specified\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Not a member of this group anymore.\"", ")", ";", "}", "}" ]
Leave this group @param completionListener A listener to receive a notification on the success of the asynchronous operation
[ "Leave", "this", "group" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L250-L284
145,619
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.sendMessage
public void sendMessage(String message, boolean push, boolean persist, final Respoke.TaskCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { RespokeClient client = clientReference.get(); if (null != client) { JSONObject data = new JSONObject(); try { data.put("endpointId", client.getEndpointID()); data.put("message", message); data.put("push", push); data.put("persist", persist); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Unable to encode message"); return; } String urlEndpoint = "/v1/channels/" + groupID + "/publish/"; signalingChannel.sendRESTMessage("post", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } else { Respoke.postTaskError(completionListener, "There was an internal error processing this request."); } } else { Respoke.postTaskError(completionListener, "Group name must be specified"); } } else { Respoke.postTaskError(completionListener, "Not a member of this group anymore."); } }
java
public void sendMessage(String message, boolean push, boolean persist, final Respoke.TaskCompletionListener completionListener) { if (isJoined()) { if ((null != groupID) && (groupID.length() > 0)) { RespokeClient client = clientReference.get(); if (null != client) { JSONObject data = new JSONObject(); try { data.put("endpointId", client.getEndpointID()); data.put("message", message); data.put("push", push); data.put("persist", persist); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Unable to encode message"); return; } String urlEndpoint = "/v1/channels/" + groupID + "/publish/"; signalingChannel.sendRESTMessage("post", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } else { Respoke.postTaskError(completionListener, "There was an internal error processing this request."); } } else { Respoke.postTaskError(completionListener, "Group name must be specified"); } } else { Respoke.postTaskError(completionListener, "Not a member of this group anymore."); } }
[ "public", "void", "sendMessage", "(", "String", "message", ",", "boolean", "push", ",", "boolean", "persist", ",", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "isJoined", "(", ")", ")", "{", "if", "(", "(", "null", "!=", "groupID", ")", "&&", "(", "groupID", ".", "length", "(", ")", ">", "0", ")", ")", "{", "RespokeClient", "client", "=", "clientReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "client", ")", "{", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "data", ".", "put", "(", "\"endpointId\"", ",", "client", ".", "getEndpointID", "(", ")", ")", ";", "data", ".", "put", "(", "\"message\"", ",", "message", ")", ";", "data", ".", "put", "(", "\"push\"", ",", "push", ")", ";", "data", ".", "put", "(", "\"persist\"", ",", "persist", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Unable to encode message\"", ")", ";", "return", ";", "}", "String", "urlEndpoint", "=", "\"/v1/channels/\"", "+", "groupID", "+", "\"/publish/\"", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "urlEndpoint", ",", "data", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"There was an internal error processing this request.\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Group name must be specified\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Not a member of this group anymore.\"", ")", ";", "}", "}" ]
Send a message to the entire group. @param message The message to send @param push A flag indicating if a push notification should be sent for this message @param persist A flag indicating if history should be maintained for this message. @param completionListener A listener to receive a notification on the success of the asynchronous operation
[ "Send", "a", "message", "to", "the", "entire", "group", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L318-L358
145,620
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.connectionDidJoin
public void connectionDidJoin(final RespokeConnection connection) { members.add(connection); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onJoin(connection, RespokeGroup.this); } } }); }
java
public void connectionDidJoin(final RespokeConnection connection) { members.add(connection); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onJoin(connection, RespokeGroup.this); } } }); }
[ "public", "void", "connectionDidJoin", "(", "final", "RespokeConnection", "connection", ")", "{", "members", ".", "add", "(", "connection", ")", ";", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onJoin", "(", "connection", ",", "RespokeGroup", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}" ]
Notify the group that a connection has joined. This is used internally to the SDK and should not be called directly by your client application. @param connection The connection that has joined the group
[ "Notify", "the", "group", "that", "a", "connection", "has", "joined", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L370-L382
145,621
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.connectionDidLeave
public void connectionDidLeave(final RespokeConnection connection) { members.remove(connection); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onLeave(connection, RespokeGroup.this); } } }); }
java
public void connectionDidLeave(final RespokeConnection connection) { members.remove(connection); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Listener listener = listenerReference.get(); if (null != listener) { listener.onLeave(connection, RespokeGroup.this); } } }); }
[ "public", "void", "connectionDidLeave", "(", "final", "RespokeConnection", "connection", ")", "{", "members", ".", "remove", "(", "connection", ")", ";", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onLeave", "(", "connection", ",", "RespokeGroup", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}" ]
Notify the group that a connection has left. This is used internally to the SDK and should not be called directly by your client application. @param connection The connection that has left the group
[ "Notify", "the", "group", "that", "a", "connection", "has", "left", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L390-L402
145,622
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java
RespokeGroup.postGetGroupMembersError
private void postGetGroupMembersError(final GetGroupMembersCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
java
private void postGetGroupMembersError(final GetGroupMembersCompletionListener completionListener, final String errorMessage) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != completionListener) { completionListener.onError(errorMessage); } } }); }
[ "private", "void", "postGetGroupMembersError", "(", "final", "GetGroupMembersCompletionListener", "completionListener", ",", "final", "String", "errorMessage", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "completionListener", ")", "{", "completionListener", ".", "onError", "(", "errorMessage", ")", ";", "}", "}", "}", ")", ";", "}" ]
A convenience method for posting errors to a GetGroupMembersCompletionListener @param completionListener The listener to notify @param errorMessage The human-readable error message that occurred
[ "A", "convenience", "method", "for", "posting", "errors", "to", "a", "GetGroupMembersCompletionListener" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeGroup.java#L434-L443
145,623
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/metadata/controller/AbstractMetadataPublishingController.java
AbstractMetadataPublishingController.getMetadata
public HttpEntity<byte[]> getMetadata(HttpServletRequest request, @RequestHeader(name = "Accept", required = false) String acceptHeader) { logger.debug("Request to download metadata from {}", request.getRemoteAddr()); try { // Check if the metadata is up-to-date according to how the container was configured. // if (this.metadataContainer.updateRequired(true)) { logger.debug("Metadata needs to be updated ..."); this.metadataContainer.update(true); logger.debug("Metadata was updated and signed"); } else { logger.debug("Metadata is up-to-date, using cached metadata"); } // Get the DOM for the metadata and serialize it. // Element dom = this.metadataContainer.marshall(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); SerializeSupport.writeNode(dom, stream); // Assign the HTTP headers. // HttpHeaders header = new HttpHeaders(); if (acceptHeader != null && !acceptHeader.contains(APPLICATION_SAML_METADATA)) { header.setContentType(MediaType.APPLICATION_XML); } else { header.setContentType(MediaType.valueOf(APPLICATION_SAML_METADATA)); } // TODO: turn off caching byte[] documentBody = stream.toByteArray(); header.setContentLength(documentBody.length); return new HttpEntity<byte[]>(documentBody, header); } catch (SignatureException | MarshallingException e) { logger.error("Failed to return valid metadata", e); return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR); } }
java
public HttpEntity<byte[]> getMetadata(HttpServletRequest request, @RequestHeader(name = "Accept", required = false) String acceptHeader) { logger.debug("Request to download metadata from {}", request.getRemoteAddr()); try { // Check if the metadata is up-to-date according to how the container was configured. // if (this.metadataContainer.updateRequired(true)) { logger.debug("Metadata needs to be updated ..."); this.metadataContainer.update(true); logger.debug("Metadata was updated and signed"); } else { logger.debug("Metadata is up-to-date, using cached metadata"); } // Get the DOM for the metadata and serialize it. // Element dom = this.metadataContainer.marshall(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); SerializeSupport.writeNode(dom, stream); // Assign the HTTP headers. // HttpHeaders header = new HttpHeaders(); if (acceptHeader != null && !acceptHeader.contains(APPLICATION_SAML_METADATA)) { header.setContentType(MediaType.APPLICATION_XML); } else { header.setContentType(MediaType.valueOf(APPLICATION_SAML_METADATA)); } // TODO: turn off caching byte[] documentBody = stream.toByteArray(); header.setContentLength(documentBody.length); return new HttpEntity<byte[]>(documentBody, header); } catch (SignatureException | MarshallingException e) { logger.error("Failed to return valid metadata", e); return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR); } }
[ "public", "HttpEntity", "<", "byte", "[", "]", ">", "getMetadata", "(", "HttpServletRequest", "request", ",", "@", "RequestHeader", "(", "name", "=", "\"Accept\"", ",", "required", "=", "false", ")", "String", "acceptHeader", ")", "{", "logger", ".", "debug", "(", "\"Request to download metadata from {}\"", ",", "request", ".", "getRemoteAddr", "(", ")", ")", ";", "try", "{", "// Check if the metadata is up-to-date according to how the container was configured.", "//", "if", "(", "this", ".", "metadataContainer", ".", "updateRequired", "(", "true", ")", ")", "{", "logger", ".", "debug", "(", "\"Metadata needs to be updated ...\"", ")", ";", "this", ".", "metadataContainer", ".", "update", "(", "true", ")", ";", "logger", ".", "debug", "(", "\"Metadata was updated and signed\"", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "\"Metadata is up-to-date, using cached metadata\"", ")", ";", "}", "// Get the DOM for the metadata and serialize it.", "//", "Element", "dom", "=", "this", ".", "metadataContainer", ".", "marshall", "(", ")", ";", "ByteArrayOutputStream", "stream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "SerializeSupport", ".", "writeNode", "(", "dom", ",", "stream", ")", ";", "// Assign the HTTP headers.", "//", "HttpHeaders", "header", "=", "new", "HttpHeaders", "(", ")", ";", "if", "(", "acceptHeader", "!=", "null", "&&", "!", "acceptHeader", ".", "contains", "(", "APPLICATION_SAML_METADATA", ")", ")", "{", "header", ".", "setContentType", "(", "MediaType", ".", "APPLICATION_XML", ")", ";", "}", "else", "{", "header", ".", "setContentType", "(", "MediaType", ".", "valueOf", "(", "APPLICATION_SAML_METADATA", ")", ")", ";", "}", "// TODO: turn off caching", "byte", "[", "]", "documentBody", "=", "stream", ".", "toByteArray", "(", ")", ";", "header", ".", "setContentLength", "(", "documentBody", ".", "length", ")", ";", "return", "new", "HttpEntity", "<", "byte", "[", "]", ">", "(", "documentBody", ",", "header", ")", ";", "}", "catch", "(", "SignatureException", "|", "MarshallingException", "e", ")", "{", "logger", ".", "error", "(", "\"Failed to return valid metadata\"", ",", "e", ")", ";", "return", "new", "ResponseEntity", "<", "byte", "[", "]", ">", "(", "HttpStatus", ".", "INTERNAL_SERVER_ERROR", ")", ";", "}", "}" ]
Returns the metadata for the entity. @param request the HTTP request @param acceptHeader the Accept header value @return an HttpEntity holding the SAML metadata
[ "Returns", "the", "metadata", "for", "the", "entity", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/metadata/controller/AbstractMetadataPublishingController.java#L77-L120
145,624
politie/cinch
src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchJob.java
StreamingCinchJob.execute
@Override public void execute(StreamingCinchContext cinchContext, SparkConf sparkConf) { JavaStreamingContext streamingContext = new JavaStreamingContext(sparkConf, new Duration(durationInMillis)); defineJob(streamingContext, cinchContext); streamingContext.start(); streamingContext.awaitTermination(); }
java
@Override public void execute(StreamingCinchContext cinchContext, SparkConf sparkConf) { JavaStreamingContext streamingContext = new JavaStreamingContext(sparkConf, new Duration(durationInMillis)); defineJob(streamingContext, cinchContext); streamingContext.start(); streamingContext.awaitTermination(); }
[ "@", "Override", "public", "void", "execute", "(", "StreamingCinchContext", "cinchContext", ",", "SparkConf", "sparkConf", ")", "{", "JavaStreamingContext", "streamingContext", "=", "new", "JavaStreamingContext", "(", "sparkConf", ",", "new", "Duration", "(", "durationInMillis", ")", ")", ";", "defineJob", "(", "streamingContext", ",", "cinchContext", ")", ";", "streamingContext", ".", "start", "(", ")", ";", "streamingContext", ".", "awaitTermination", "(", ")", ";", "}" ]
Execute cinch job with context and spark conf.
[ "Execute", "cinch", "job", "with", "context", "and", "spark", "conf", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/streaming/StreamingCinchJob.java#L22-L30
145,625
febit/wit
wit-core/src/main/java/org/febit/wit/Template.java
Template.merge
public Context merge(final Map<String, Object> vars) { return merge(Vars.of(vars)); }
java
public Context merge(final Map<String, Object> vars) { return merge(Vars.of(vars)); }
[ "public", "Context", "merge", "(", "final", "Map", "<", "String", ",", "Object", ">", "vars", ")", "{", "return", "merge", "(", "Vars", ".", "of", "(", "vars", ")", ")", ";", "}" ]
Merge this template, and discard outputs. @param vars @return Context @throws ScriptRuntimeException @throws ParseException @since 2.4.0
[ "Merge", "this", "template", "and", "discard", "outputs", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Template.java#L223-L225
145,626
febit/wit
wit-core/src/main/java/org/febit/wit/Template.java
Template.debug
public Context debug(final Vars vars, final Out out, final BreakpointListener listener) { try { return Parser.parse(this, listener) .execute(this, out, vars); } catch (Exception e) { throw completeException(e); } }
java
public Context debug(final Vars vars, final Out out, final BreakpointListener listener) { try { return Parser.parse(this, listener) .execute(this, out, vars); } catch (Exception e) { throw completeException(e); } }
[ "public", "Context", "debug", "(", "final", "Vars", "vars", ",", "final", "Out", "out", ",", "final", "BreakpointListener", "listener", ")", "{", "try", "{", "return", "Parser", ".", "parse", "(", "this", ",", "listener", ")", ".", "execute", "(", "this", ",", "out", ",", "vars", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "completeException", "(", "e", ")", ";", "}", "}" ]
Debug this template. @param vars @param out @param listener @return Context @throws ScriptRuntimeException @throws ParseException
[ "Debug", "this", "template", "." ]
89ee29efbc5633b79c30c3c7b953c9f4130575af
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/Template.java#L277-L284
145,627
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/actions/UpdateAssertionForProxyIdpAction.java
UpdateAssertionForProxyIdpAction.setAuthenticatingAuthority
protected void setAuthenticatingAuthority(Assertion assertion, Assertion proxiedAssertion) { if (proxiedAssertion.getIssuer() == null || proxiedAssertion.getIssuer().getValue() == null) { log.warn("No issuer element found in proxied assertion"); return; } if (assertion.getAuthnStatements().isEmpty()) { log.warn("No AuthnStatement available is assertion to update - will not process"); return; } AuthnStatement authnStatement = assertion.getAuthnStatements().get(0); if (authnStatement.getAuthnContext() == null) { log.warn("No AuthnContext found in assertion to update - will not process"); } final XMLObjectBuilderFactory bf = XMLObjectProviderRegistrySupport.getBuilderFactory(); SAMLObjectBuilder<AuthenticatingAuthority> aaBuilder = (SAMLObjectBuilder<AuthenticatingAuthority>) bf .<AuthenticatingAuthority> getBuilderOrThrow(AuthenticatingAuthority.DEFAULT_ELEMENT_NAME); AuthenticatingAuthority aa = aaBuilder.buildObject(); aa.setURI(proxiedAssertion.getIssuer().getValue()); authnStatement.getAuthnContext().getAuthenticatingAuthorities().add(aa); log.info("Updated Assertion with AuthenticatingAuthority ({})", aa.getURI()); }
java
protected void setAuthenticatingAuthority(Assertion assertion, Assertion proxiedAssertion) { if (proxiedAssertion.getIssuer() == null || proxiedAssertion.getIssuer().getValue() == null) { log.warn("No issuer element found in proxied assertion"); return; } if (assertion.getAuthnStatements().isEmpty()) { log.warn("No AuthnStatement available is assertion to update - will not process"); return; } AuthnStatement authnStatement = assertion.getAuthnStatements().get(0); if (authnStatement.getAuthnContext() == null) { log.warn("No AuthnContext found in assertion to update - will not process"); } final XMLObjectBuilderFactory bf = XMLObjectProviderRegistrySupport.getBuilderFactory(); SAMLObjectBuilder<AuthenticatingAuthority> aaBuilder = (SAMLObjectBuilder<AuthenticatingAuthority>) bf .<AuthenticatingAuthority> getBuilderOrThrow(AuthenticatingAuthority.DEFAULT_ELEMENT_NAME); AuthenticatingAuthority aa = aaBuilder.buildObject(); aa.setURI(proxiedAssertion.getIssuer().getValue()); authnStatement.getAuthnContext().getAuthenticatingAuthorities().add(aa); log.info("Updated Assertion with AuthenticatingAuthority ({})", aa.getURI()); }
[ "protected", "void", "setAuthenticatingAuthority", "(", "Assertion", "assertion", ",", "Assertion", "proxiedAssertion", ")", "{", "if", "(", "proxiedAssertion", ".", "getIssuer", "(", ")", "==", "null", "||", "proxiedAssertion", ".", "getIssuer", "(", ")", ".", "getValue", "(", ")", "==", "null", ")", "{", "log", ".", "warn", "(", "\"No issuer element found in proxied assertion\"", ")", ";", "return", ";", "}", "if", "(", "assertion", ".", "getAuthnStatements", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "log", ".", "warn", "(", "\"No AuthnStatement available is assertion to update - will not process\"", ")", ";", "return", ";", "}", "AuthnStatement", "authnStatement", "=", "assertion", ".", "getAuthnStatements", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "authnStatement", ".", "getAuthnContext", "(", ")", "==", "null", ")", "{", "log", ".", "warn", "(", "\"No AuthnContext found in assertion to update - will not process\"", ")", ";", "}", "final", "XMLObjectBuilderFactory", "bf", "=", "XMLObjectProviderRegistrySupport", ".", "getBuilderFactory", "(", ")", ";", "SAMLObjectBuilder", "<", "AuthenticatingAuthority", ">", "aaBuilder", "=", "(", "SAMLObjectBuilder", "<", "AuthenticatingAuthority", ">", ")", "bf", ".", "<", "AuthenticatingAuthority", ">", "getBuilderOrThrow", "(", "AuthenticatingAuthority", ".", "DEFAULT_ELEMENT_NAME", ")", ";", "AuthenticatingAuthority", "aa", "=", "aaBuilder", ".", "buildObject", "(", ")", ";", "aa", ".", "setURI", "(", "proxiedAssertion", ".", "getIssuer", "(", ")", ".", "getValue", "(", ")", ")", ";", "authnStatement", ".", "getAuthnContext", "(", ")", ".", "getAuthenticatingAuthorities", "(", ")", ".", "add", "(", "aa", ")", ";", "log", ".", "info", "(", "\"Updated Assertion with AuthenticatingAuthority ({})\"", ",", "aa", ".", "getURI", "(", ")", ")", ";", "}" ]
Assigns the AuthenticatingAuthority element holding the issuer of the proxied assertion. @param assertion the assertion to update @param proxiedAssertion the proxied assertion
[ "Assigns", "the", "AuthenticatingAuthority", "element", "holding", "the", "issuer", "of", "the", "proxied", "assertion", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/actions/UpdateAssertionForProxyIdpAction.java#L100-L124
145,628
flow/commons
src/main/java/com/flowpowered/commons/ViewFrustum.java
ViewFrustum.update
public void update(Matrix4f projection, Matrix4f view) { // http://www.crownandcutlass.com/features/technicaldetails/frustum.html final float[] clip = projection.mul(view).toArray(true); // Extract the numbers for the RIGHT plane frustum[0][0] = clip[3] - clip[0]; frustum[0][1] = clip[7] - clip[4]; frustum[0][2] = clip[11] - clip[8]; frustum[0][3] = clip[15] - clip[12]; // Extract the numbers for the LEFT plane frustum[1][0] = clip[3] + clip[0]; frustum[1][1] = clip[7] + clip[4]; frustum[1][2] = clip[11] + clip[8]; frustum[1][3] = clip[15] + clip[12]; // Extract the BOTTOM plane frustum[2][0] = clip[3] + clip[1]; frustum[2][1] = clip[7] + clip[5]; frustum[2][2] = clip[11] + clip[9]; frustum[2][3] = clip[15] + clip[13]; // Extract the TOP plane frustum[3][0] = clip[3] - clip[1]; frustum[3][1] = clip[7] - clip[5]; frustum[3][2] = clip[11] - clip[9]; frustum[3][3] = clip[15] - clip[13]; // Extract the FAR plane frustum[4][0] = clip[3] - clip[2]; frustum[4][1] = clip[7] - clip[6]; frustum[4][2] = clip[11] - clip[10]; frustum[4][3] = clip[15] - clip[14]; // Extract the NEAR plane frustum[5][0] = clip[3] + clip[2]; frustum[5][1] = clip[7] + clip[6]; frustum[5][2] = clip[11] + clip[10]; frustum[5][3] = clip[15] + clip[14]; // Compute the position // http://www.opengl.org/discussion_boards/showthread.php/178484-Extracting-camera-position-from-a-ModelView-Matrix final Vector4f nPos = view.invert().getColumn(3); position = nPos.div(nPos.getW()).toVector3(); // Invalidate the caches vertices = null; farPlane = -1; nearPlane = -1; }
java
public void update(Matrix4f projection, Matrix4f view) { // http://www.crownandcutlass.com/features/technicaldetails/frustum.html final float[] clip = projection.mul(view).toArray(true); // Extract the numbers for the RIGHT plane frustum[0][0] = clip[3] - clip[0]; frustum[0][1] = clip[7] - clip[4]; frustum[0][2] = clip[11] - clip[8]; frustum[0][3] = clip[15] - clip[12]; // Extract the numbers for the LEFT plane frustum[1][0] = clip[3] + clip[0]; frustum[1][1] = clip[7] + clip[4]; frustum[1][2] = clip[11] + clip[8]; frustum[1][3] = clip[15] + clip[12]; // Extract the BOTTOM plane frustum[2][0] = clip[3] + clip[1]; frustum[2][1] = clip[7] + clip[5]; frustum[2][2] = clip[11] + clip[9]; frustum[2][3] = clip[15] + clip[13]; // Extract the TOP plane frustum[3][0] = clip[3] - clip[1]; frustum[3][1] = clip[7] - clip[5]; frustum[3][2] = clip[11] - clip[9]; frustum[3][3] = clip[15] - clip[13]; // Extract the FAR plane frustum[4][0] = clip[3] - clip[2]; frustum[4][1] = clip[7] - clip[6]; frustum[4][2] = clip[11] - clip[10]; frustum[4][3] = clip[15] - clip[14]; // Extract the NEAR plane frustum[5][0] = clip[3] + clip[2]; frustum[5][1] = clip[7] + clip[6]; frustum[5][2] = clip[11] + clip[10]; frustum[5][3] = clip[15] + clip[14]; // Compute the position // http://www.opengl.org/discussion_boards/showthread.php/178484-Extracting-camera-position-from-a-ModelView-Matrix final Vector4f nPos = view.invert().getColumn(3); position = nPos.div(nPos.getW()).toVector3(); // Invalidate the caches vertices = null; farPlane = -1; nearPlane = -1; }
[ "public", "void", "update", "(", "Matrix4f", "projection", ",", "Matrix4f", "view", ")", "{", "// http://www.crownandcutlass.com/features/technicaldetails/frustum.html", "final", "float", "[", "]", "clip", "=", "projection", ".", "mul", "(", "view", ")", ".", "toArray", "(", "true", ")", ";", "// Extract the numbers for the RIGHT plane", "frustum", "[", "0", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "-", "clip", "[", "0", "]", ";", "frustum", "[", "0", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "-", "clip", "[", "4", "]", ";", "frustum", "[", "0", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "-", "clip", "[", "8", "]", ";", "frustum", "[", "0", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "-", "clip", "[", "12", "]", ";", "// Extract the numbers for the LEFT plane", "frustum", "[", "1", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "+", "clip", "[", "0", "]", ";", "frustum", "[", "1", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "+", "clip", "[", "4", "]", ";", "frustum", "[", "1", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "+", "clip", "[", "8", "]", ";", "frustum", "[", "1", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "+", "clip", "[", "12", "]", ";", "// Extract the BOTTOM plane", "frustum", "[", "2", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "+", "clip", "[", "1", "]", ";", "frustum", "[", "2", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "+", "clip", "[", "5", "]", ";", "frustum", "[", "2", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "+", "clip", "[", "9", "]", ";", "frustum", "[", "2", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "+", "clip", "[", "13", "]", ";", "// Extract the TOP plane", "frustum", "[", "3", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "-", "clip", "[", "1", "]", ";", "frustum", "[", "3", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "-", "clip", "[", "5", "]", ";", "frustum", "[", "3", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "-", "clip", "[", "9", "]", ";", "frustum", "[", "3", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "-", "clip", "[", "13", "]", ";", "// Extract the FAR plane", "frustum", "[", "4", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "-", "clip", "[", "2", "]", ";", "frustum", "[", "4", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "-", "clip", "[", "6", "]", ";", "frustum", "[", "4", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "-", "clip", "[", "10", "]", ";", "frustum", "[", "4", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "-", "clip", "[", "14", "]", ";", "// Extract the NEAR plane", "frustum", "[", "5", "]", "[", "0", "]", "=", "clip", "[", "3", "]", "+", "clip", "[", "2", "]", ";", "frustum", "[", "5", "]", "[", "1", "]", "=", "clip", "[", "7", "]", "+", "clip", "[", "6", "]", ";", "frustum", "[", "5", "]", "[", "2", "]", "=", "clip", "[", "11", "]", "+", "clip", "[", "10", "]", ";", "frustum", "[", "5", "]", "[", "3", "]", "=", "clip", "[", "15", "]", "+", "clip", "[", "14", "]", ";", "// Compute the position", "// http://www.opengl.org/discussion_boards/showthread.php/178484-Extracting-camera-position-from-a-ModelView-Matrix", "final", "Vector4f", "nPos", "=", "view", ".", "invert", "(", ")", ".", "getColumn", "(", "3", ")", ";", "position", "=", "nPos", ".", "div", "(", "nPos", ".", "getW", "(", ")", ")", ".", "toVector3", "(", ")", ";", "// Invalidate the caches", "vertices", "=", "null", ";", "farPlane", "=", "-", "1", ";", "nearPlane", "=", "-", "1", ";", "}" ]
Updates the frustum to match the view and projection matrix. @param projection The projection matrix @param view The view matrix
[ "Updates", "the", "frustum", "to", "match", "the", "view", "and", "projection", "matrix", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/ViewFrustum.java#L46-L87
145,629
flow/commons
src/main/java/com/flowpowered/commons/ViewFrustum.java
ViewFrustum.getNearPlane
public float getNearPlane() { if (nearPlane == -1) { // Recalculate the distance if the cache is invalid final Vector3f nearPos = vertices[0].add(vertices[2]).add(vertices[4]).add(vertices[6]).div(4); nearPlane = nearPos.sub(position).length(); } return nearPlane; }
java
public float getNearPlane() { if (nearPlane == -1) { // Recalculate the distance if the cache is invalid final Vector3f nearPos = vertices[0].add(vertices[2]).add(vertices[4]).add(vertices[6]).div(4); nearPlane = nearPos.sub(position).length(); } return nearPlane; }
[ "public", "float", "getNearPlane", "(", ")", "{", "if", "(", "nearPlane", "==", "-", "1", ")", "{", "// Recalculate the distance if the cache is invalid", "final", "Vector3f", "nearPos", "=", "vertices", "[", "0", "]", ".", "add", "(", "vertices", "[", "2", "]", ")", ".", "add", "(", "vertices", "[", "4", "]", ")", ".", "add", "(", "vertices", "[", "6", "]", ")", ".", "div", "(", "4", ")", ";", "nearPlane", "=", "nearPos", ".", "sub", "(", "position", ")", ".", "length", "(", ")", ";", "}", "return", "nearPlane", ";", "}" ]
Returns the near plane distance of the frustum. @return The near plane
[ "Returns", "the", "near", "plane", "distance", "of", "the", "frustum", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/ViewFrustum.java#L184-L191
145,630
flow/commons
src/main/java/com/flowpowered/commons/ViewFrustum.java
ViewFrustum.getFarPlane
public float getFarPlane() { if (farPlane == -1) { // Recalculate the distance if the cache is invalid final Vector3f farPos = vertices[1].add(vertices[3]).add(vertices[5]).add(vertices[7]).div(4); farPlane = farPos.sub(position).length(); } return farPlane; }
java
public float getFarPlane() { if (farPlane == -1) { // Recalculate the distance if the cache is invalid final Vector3f farPos = vertices[1].add(vertices[3]).add(vertices[5]).add(vertices[7]).div(4); farPlane = farPos.sub(position).length(); } return farPlane; }
[ "public", "float", "getFarPlane", "(", ")", "{", "if", "(", "farPlane", "==", "-", "1", ")", "{", "// Recalculate the distance if the cache is invalid", "final", "Vector3f", "farPos", "=", "vertices", "[", "1", "]", ".", "add", "(", "vertices", "[", "3", "]", ")", ".", "add", "(", "vertices", "[", "5", "]", ")", ".", "add", "(", "vertices", "[", "7", "]", ")", ".", "div", "(", "4", ")", ";", "farPlane", "=", "farPos", ".", "sub", "(", "position", ")", ".", "length", "(", ")", ";", "}", "return", "farPlane", ";", "}" ]
Returns the far plane distance of the frustum. @return The far plane
[ "Returns", "the", "far", "plane", "distance", "of", "the", "frustum", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/ViewFrustum.java#L198-L205
145,631
flow/commons
src/main/java/com/flowpowered/commons/ViewFrustum.java
ViewFrustum.distance
private float distance(int i, float x, float y, float z) { return frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3]; }
java
private float distance(int i, float x, float y, float z) { return frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3]; }
[ "private", "float", "distance", "(", "int", "i", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "return", "frustum", "[", "i", "]", "[", "0", "]", "*", "x", "+", "frustum", "[", "i", "]", "[", "1", "]", "*", "y", "+", "frustum", "[", "i", "]", "[", "2", "]", "*", "z", "+", "frustum", "[", "i", "]", "[", "3", "]", ";", "}" ]
Compute the distance between a point and the given plane. @param i The id of the plane @param x The x coordinate of the point @param y The y coordinate of the point @param z The z coordinate of the point @return The distance
[ "Compute", "the", "distance", "between", "a", "point", "and", "the", "given", "plane", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/ViewFrustum.java#L216-L218
145,632
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/context/ExtendedSpringStatusMessageLookupFunction.java
ExtendedSpringStatusMessageLookupFunction.getLocale
protected Locale getLocale(RequestContext context) { return this.locale != null ? this.locale : context.getExternalContext().getLocale(); }
java
protected Locale getLocale(RequestContext context) { return this.locale != null ? this.locale : context.getExternalContext().getLocale(); }
[ "protected", "Locale", "getLocale", "(", "RequestContext", "context", ")", "{", "return", "this", ".", "locale", "!=", "null", "?", "this", ".", "locale", ":", "context", ".", "getExternalContext", "(", ")", ".", "getLocale", "(", ")", ";", "}" ]
Returns the locale to use when resolving messages. @param context the request context @return the locale to use
[ "Returns", "the", "locale", "to", "use", "when", "resolving", "messages", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/context/ExtendedSpringStatusMessageLookupFunction.java#L96-L98
145,633
javabits/pojo-mbean
pojo-mbean-impl/src/main/java/org/softee/management/helper/IntrospectedDynamicMBean.java
IntrospectedDynamicMBean.getParameterAnnotation
private static <A extends Annotation> A getParameterAnnotation(Method method, int index, Class<A> annotationClass) { for (Annotation a : method.getParameterAnnotations()[index]) { if (annotationClass.isInstance(a)) { return annotationClass.cast(a); } } return null; }
java
private static <A extends Annotation> A getParameterAnnotation(Method method, int index, Class<A> annotationClass) { for (Annotation a : method.getParameterAnnotations()[index]) { if (annotationClass.isInstance(a)) { return annotationClass.cast(a); } } return null; }
[ "private", "static", "<", "A", "extends", "Annotation", ">", "A", "getParameterAnnotation", "(", "Method", "method", ",", "int", "index", ",", "Class", "<", "A", ">", "annotationClass", ")", "{", "for", "(", "Annotation", "a", ":", "method", ".", "getParameterAnnotations", "(", ")", "[", "index", "]", ")", "{", "if", "(", "annotationClass", ".", "isInstance", "(", "a", ")", ")", "{", "return", "annotationClass", ".", "cast", "(", "a", ")", ";", "}", "}", "return", "null", ";", "}" ]
Find an annotation for a parameter on a method. @param <A> The annotation. @param method The method. @param index The index (0 .. n-1) of the parameter in the parameters list @param annotationClass The annotation class @return The annotation, or null
[ "Find", "an", "annotation", "for", "a", "parameter", "on", "a", "method", "." ]
9aa7fb065e560ec1e3e63373b28cd95ad438b26a
https://github.com/javabits/pojo-mbean/blob/9aa7fb065e560ec1e3e63373b28cd95ad438b26a/pojo-mbean-impl/src/main/java/org/softee/management/helper/IntrospectedDynamicMBean.java#L476-L484
145,634
javabits/pojo-mbean
pojo-mbean-impl/src/main/java/org/softee/management/helper/IntrospectedDynamicMBean.java
IntrospectedDynamicMBean.getAnnotation
private static <A extends Annotation> A getAnnotation(AnnotatedElement element, Class<A> annotationClass) { return (element != null) ? element.getAnnotation(annotationClass) : null; }
java
private static <A extends Annotation> A getAnnotation(AnnotatedElement element, Class<A> annotationClass) { return (element != null) ? element.getAnnotation(annotationClass) : null; }
[ "private", "static", "<", "A", "extends", "Annotation", ">", "A", "getAnnotation", "(", "AnnotatedElement", "element", ",", "Class", "<", "A", ">", "annotationClass", ")", "{", "return", "(", "element", "!=", "null", ")", "?", "element", ".", "getAnnotation", "(", "annotationClass", ")", ":", "null", ";", "}" ]
Null safe annotation checker @param <A> @param element element or null @param annotationClass @return the annotation, if element is not null and the annotation is present. Otherwise null
[ "Null", "safe", "annotation", "checker" ]
9aa7fb065e560ec1e3e63373b28cd95ad438b26a
https://github.com/javabits/pojo-mbean/blob/9aa7fb065e560ec1e3e63373b28cd95ad438b26a/pojo-mbean-impl/src/main/java/org/softee/management/helper/IntrospectedDynamicMBean.java#L493-L495
145,635
flow/commons
src/main/java/com/flowpowered/commons/datatable/SerializableHashMap.java
SerializableHashMap.serialize
@Override public byte[] serialize() { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(map); return out.toByteArray(); } catch (IOException ex) { throw new IllegalStateException("Unable to compress SerializableMap"); } }
java
@Override public byte[] serialize() { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(map); return out.toByteArray(); } catch (IOException ex) { throw new IllegalStateException("Unable to compress SerializableMap"); } }
[ "@", "Override", "public", "byte", "[", "]", "serialize", "(", ")", "{", "try", "{", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oos", "=", "new", "ObjectOutputStream", "(", "out", ")", ";", "oos", ".", "writeObject", "(", "map", ")", ";", "return", "out", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Unable to compress SerializableMap\"", ")", ";", "}", "}" ]
This serializes only the data, as opposed to the whole object.
[ "This", "serializes", "only", "the", "data", "as", "opposed", "to", "the", "whole", "object", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/datatable/SerializableHashMap.java#L458-L468
145,636
flow/commons
src/main/java/com/flowpowered/commons/datatable/SerializableHashMap.java
SerializableHashMap.deserialize
@Override @SuppressWarnings ("unchecked") public void deserialize(byte[] serializedData, boolean wipe) throws IOException { if (wipe) { map.clear(); } InputStream in = new ByteArrayInputStream(serializedData); ObjectInputStream ois = new ClassResolverObjectInputStream(in); try { // Because it may be a map of maps, we want to UPDATE inner maps, not overwrite for (Map.Entry<String, ? extends Serializable> e : ((Map<String, ? extends Serializable>) ois.readObject()).entrySet()) { if (e.getValue() instanceof Map && map.get(e.getKey()) instanceof Map) { ((Map) map.get(e.getKey())).putAll((Map) e.getValue()); } else { put(e.getKey(), e.getValue()); } } } catch (ClassNotFoundException ex) { throw new IllegalStateException("Unable to decompress SerializableHashMap", ex); } }
java
@Override @SuppressWarnings ("unchecked") public void deserialize(byte[] serializedData, boolean wipe) throws IOException { if (wipe) { map.clear(); } InputStream in = new ByteArrayInputStream(serializedData); ObjectInputStream ois = new ClassResolverObjectInputStream(in); try { // Because it may be a map of maps, we want to UPDATE inner maps, not overwrite for (Map.Entry<String, ? extends Serializable> e : ((Map<String, ? extends Serializable>) ois.readObject()).entrySet()) { if (e.getValue() instanceof Map && map.get(e.getKey()) instanceof Map) { ((Map) map.get(e.getKey())).putAll((Map) e.getValue()); } else { put(e.getKey(), e.getValue()); } } } catch (ClassNotFoundException ex) { throw new IllegalStateException("Unable to decompress SerializableHashMap", ex); } }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "deserialize", "(", "byte", "[", "]", "serializedData", ",", "boolean", "wipe", ")", "throws", "IOException", "{", "if", "(", "wipe", ")", "{", "map", ".", "clear", "(", ")", ";", "}", "InputStream", "in", "=", "new", "ByteArrayInputStream", "(", "serializedData", ")", ";", "ObjectInputStream", "ois", "=", "new", "ClassResolverObjectInputStream", "(", "in", ")", ";", "try", "{", "// Because it may be a map of maps, we want to UPDATE inner maps, not overwrite", "for", "(", "Map", ".", "Entry", "<", "String", ",", "?", "extends", "Serializable", ">", "e", ":", "(", "(", "Map", "<", "String", ",", "?", "extends", "Serializable", ">", ")", "ois", ".", "readObject", "(", ")", ")", ".", "entrySet", "(", ")", ")", "{", "if", "(", "e", ".", "getValue", "(", ")", "instanceof", "Map", "&&", "map", ".", "get", "(", "e", ".", "getKey", "(", ")", ")", "instanceof", "Map", ")", "{", "(", "(", "Map", ")", "map", ".", "get", "(", "e", ".", "getKey", "(", ")", ")", ")", ".", "putAll", "(", "(", "Map", ")", "e", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "put", "(", "e", ".", "getKey", "(", ")", ",", "e", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "catch", "(", "ClassNotFoundException", "ex", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Unable to decompress SerializableHashMap\"", ",", "ex", ")", ";", "}", "}" ]
This deserializes only the data, as opposed to the whole object.
[ "This", "deserializes", "only", "the", "data", "as", "opposed", "to", "the", "whole", "object", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/datatable/SerializableHashMap.java#L473-L493
145,637
flow/commons
src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java
SubscribableQueue.becomePublisher
public boolean becomePublisher() { if (publisherThreadID.get() != -1) { return false; } publisherThreadID.set(Thread.currentThread().getId()); return true; }
java
public boolean becomePublisher() { if (publisherThreadID.get() != -1) { return false; } publisherThreadID.set(Thread.currentThread().getId()); return true; }
[ "public", "boolean", "becomePublisher", "(", ")", "{", "if", "(", "publisherThreadID", ".", "get", "(", ")", "!=", "-", "1", ")", "{", "return", "false", ";", "}", "publisherThreadID", ".", "set", "(", "Thread", ".", "currentThread", "(", ")", ".", "getId", "(", ")", ")", ";", "return", "true", ";", "}" ]
Attempts to make the thread the publisher, returning true if the attempt succeeded. This is only possible if there's no publisher. @return Whether or not the thread became the publisher
[ "Attempts", "to", "make", "the", "thread", "the", "publisher", "returning", "true", "if", "the", "attempt", "succeeded", ".", "This", "is", "only", "possible", "if", "there", "s", "no", "publisher", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java#L82-L88
145,638
flow/commons
src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java
SubscribableQueue.unsubscribe
public void unsubscribe() { final long id = Thread.currentThread().getId(); queues.remove(id); if (subscriberIdentifiers != null) { for (Iterator<Entry<Object, Long>> iterator = subscriberIdentifiers.entrySet().iterator(); iterator.hasNext(); ) { if (id == iterator.next().getValue()) { iterator.remove(); break; } } } }
java
public void unsubscribe() { final long id = Thread.currentThread().getId(); queues.remove(id); if (subscriberIdentifiers != null) { for (Iterator<Entry<Object, Long>> iterator = subscriberIdentifiers.entrySet().iterator(); iterator.hasNext(); ) { if (id == iterator.next().getValue()) { iterator.remove(); break; } } } }
[ "public", "void", "unsubscribe", "(", ")", "{", "final", "long", "id", "=", "Thread", ".", "currentThread", "(", ")", ".", "getId", "(", ")", ";", "queues", ".", "remove", "(", "id", ")", ";", "if", "(", "subscriberIdentifiers", "!=", "null", ")", "{", "for", "(", "Iterator", "<", "Entry", "<", "Object", ",", "Long", ">", ">", "iterator", "=", "subscriberIdentifiers", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "if", "(", "id", "==", "iterator", ".", "next", "(", ")", ".", "getValue", "(", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "break", ";", "}", "}", "}", "}" ]
Unsubscribes the thread from the queue.
[ "Unsubscribes", "the", "thread", "from", "the", "queue", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java#L124-L135
145,639
flow/commons
src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java
SubscribableQueue.addAll
public boolean addAll(Collection<? extends T> c, Object identifier) { checkNotNullArgument(c); if (isPublisherThread()) { boolean changed = false; if (identifier != null) { final Long id = subscriberIdentifiers.get(identifier); checkNotNullIdentifier(id); changed = queues.get(id).addAll(c); } else { for (Queue<T> queue : queues.values()) { if (queue.addAll(c)) { changed = true; } } } return changed; } return getCurrentThreadQueue().addAll(c); }
java
public boolean addAll(Collection<? extends T> c, Object identifier) { checkNotNullArgument(c); if (isPublisherThread()) { boolean changed = false; if (identifier != null) { final Long id = subscriberIdentifiers.get(identifier); checkNotNullIdentifier(id); changed = queues.get(id).addAll(c); } else { for (Queue<T> queue : queues.values()) { if (queue.addAll(c)) { changed = true; } } } return changed; } return getCurrentThreadQueue().addAll(c); }
[ "public", "boolean", "addAll", "(", "Collection", "<", "?", "extends", "T", ">", "c", ",", "Object", "identifier", ")", "{", "checkNotNullArgument", "(", "c", ")", ";", "if", "(", "isPublisherThread", "(", ")", ")", "{", "boolean", "changed", "=", "false", ";", "if", "(", "identifier", "!=", "null", ")", "{", "final", "Long", "id", "=", "subscriberIdentifiers", ".", "get", "(", "identifier", ")", ";", "checkNotNullIdentifier", "(", "id", ")", ";", "changed", "=", "queues", ".", "get", "(", "id", ")", ".", "addAll", "(", "c", ")", ";", "}", "else", "{", "for", "(", "Queue", "<", "T", ">", "queue", ":", "queues", ".", "values", "(", ")", ")", "{", "if", "(", "queue", ".", "addAll", "(", "c", ")", ")", "{", "changed", "=", "true", ";", "}", "}", "}", "return", "changed", ";", "}", "return", "getCurrentThreadQueue", "(", ")", ".", "addAll", "(", "c", ")", ";", "}" ]
Adds a collection of objects to the queue, targeting only the subscriber identified by the provided identifier object, unless said object is null. The added objects will only be visible to the subscriber. @param c The collection of objects to add @param identifier The identifier object, can be null @return True if this queue changed as a result of the call @see #addAll(java.util.Collection)
[ "Adds", "a", "collection", "of", "objects", "to", "the", "queue", "targeting", "only", "the", "subscriber", "identified", "by", "the", "provided", "identifier", "object", "unless", "said", "object", "is", "null", ".", "The", "added", "objects", "will", "only", "be", "visible", "to", "the", "subscriber", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/queue/SubscribableQueue.java#L195-L213
145,640
agapsys/captcha-servlet
src/main/java/com/agapsys/captcha/CaptchaServlet.java
CaptchaServlet.isValid
public final boolean isValid(HttpServletRequest req, String token) { String storedToken = getStoredToken(req); if (storedToken == null) return false; return storedToken.equals(token); }
java
public final boolean isValid(HttpServletRequest req, String token) { String storedToken = getStoredToken(req); if (storedToken == null) return false; return storedToken.equals(token); }
[ "public", "final", "boolean", "isValid", "(", "HttpServletRequest", "req", ",", "String", "token", ")", "{", "String", "storedToken", "=", "getStoredToken", "(", "req", ")", ";", "if", "(", "storedToken", "==", "null", ")", "return", "false", ";", "return", "storedToken", ".", "equals", "(", "token", ")", ";", "}" ]
Tests given token against stored one. @param req request used to retrieve stored cookie @param token token to be tested @return a boolean indicating if given token is valid.
[ "Tests", "given", "token", "against", "stored", "one", "." ]
35ec59de53f115646f41bfe72dc5f30187204ee4
https://github.com/agapsys/captcha-servlet/blob/35ec59de53f115646f41bfe72dc5f30187204ee4/src/main/java/com/agapsys/captcha/CaptchaServlet.java#L53-L60
145,641
agapsys/captcha-servlet
src/main/java/com/agapsys/captcha/CaptchaServlet.java
CaptchaServlet.store
protected void store(HttpServletRequest req, HttpServletResponse resp, String token) { HttpSession session = req.getSession(); session.setAttribute(ATR_SESSION_TOKEN, token); }
java
protected void store(HttpServletRequest req, HttpServletResponse resp, String token) { HttpSession session = req.getSession(); session.setAttribute(ATR_SESSION_TOKEN, token); }
[ "protected", "void", "store", "(", "HttpServletRequest", "req", ",", "HttpServletResponse", "resp", ",", "String", "token", ")", "{", "HttpSession", "session", "=", "req", ".", "getSession", "(", ")", ";", "session", ".", "setAttribute", "(", "ATR_SESSION_TOKEN", ",", "token", ")", ";", "}" ]
Associates a token with an user. Default implementation stores the token into user session. @param req HTTP request @param resp HTTP response @param token token to be associated with an user.
[ "Associates", "a", "token", "with", "an", "user", ".", "Default", "implementation", "stores", "the", "token", "into", "user", "session", "." ]
35ec59de53f115646f41bfe72dc5f30187204ee4
https://github.com/agapsys/captcha-servlet/blob/35ec59de53f115646f41bfe72dc5f30187204ee4/src/main/java/com/agapsys/captcha/CaptchaServlet.java#L69-L72
145,642
agapsys/captcha-servlet
src/main/java/com/agapsys/captcha/CaptchaServlet.java
CaptchaServlet.getStoredToken
protected String getStoredToken(HttpServletRequest req) { HttpSession session = req.getSession(false); if (session == null) return null; return (String) session.getAttribute(ATR_SESSION_TOKEN); }
java
protected String getStoredToken(HttpServletRequest req) { HttpSession session = req.getSession(false); if (session == null) return null; return (String) session.getAttribute(ATR_SESSION_TOKEN); }
[ "protected", "String", "getStoredToken", "(", "HttpServletRequest", "req", ")", "{", "HttpSession", "session", "=", "req", ".", "getSession", "(", "false", ")", ";", "if", "(", "session", "==", "null", ")", "return", "null", ";", "return", "(", "String", ")", "session", ".", "getAttribute", "(", "ATR_SESSION_TOKEN", ")", ";", "}" ]
Returns the token previously associated with given request. Default implementation retrieves the token from user session. @param req HTTP request @return associated token
[ "Returns", "the", "token", "previously", "associated", "with", "given", "request", ".", "Default", "implementation", "retrieves", "the", "token", "from", "user", "session", "." ]
35ec59de53f115646f41bfe72dc5f30187204ee4
https://github.com/agapsys/captcha-servlet/blob/35ec59de53f115646f41bfe72dc5f30187204ee4/src/main/java/com/agapsys/captcha/CaptchaServlet.java#L80-L87
145,643
luontola/specsy
specsy-groovy/src/main/java/org/specsy/groovy/GroovySpecsy.java
GroovySpecsy.spec
public void spec(String name, Runnable body) { context.spec(name, new GroovyClosure(body)); }
java
public void spec(String name, Runnable body) { context.spec(name, new GroovyClosure(body)); }
[ "public", "void", "spec", "(", "String", "name", ",", "Runnable", "body", ")", "{", "context", ".", "spec", "(", "name", ",", "new", "GroovyClosure", "(", "body", ")", ")", ";", "}" ]
Declares a child spec.
[ "Declares", "a", "child", "spec", "." ]
32ea4792bd91ddcbef86d4a875438c3e00ed65fb
https://github.com/luontola/specsy/blob/32ea4792bd91ddcbef86d4a875438c3e00ed65fb/specsy-groovy/src/main/java/org/specsy/groovy/GroovySpecsy.java#L27-L29
145,644
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/core/DruidIndices.java
DruidIndices.cache
public QueryableIndex cache(String dataSource, Iterable<InputRow> loader, IncrementalIndexSchema indexSchema) throws IOException { IncrementalIndex<?> incIndex = new OnheapIncrementalIndex(indexSchema, true, Integer.MAX_VALUE); for (InputRow row : loader) { incIndex.add(row); } String tmpDir = System.getProperty("druid.segment.dir"); if (tmpDir == null) { tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "druid-tmp-index-"; } File tmpIndexDir = new File(tmpDir + loader.hashCode()); IndexIO indexIO = new IndexIO(new DefaultObjectMapper(), new ColumnConfig() { @Override public int columnCacheSizeBytes() { return 0; } }); if (OSCheck.isWindows()) { new SlowIndexMerger(new DefaultObjectMapper(), indexIO).persist(incIndex, tmpIndexDir, new IndexSpec()); } else { new IndexMerger(new DefaultObjectMapper(), indexIO).persist(incIndex, tmpIndexDir, new IndexSpec()); } this.indexMap.put(dataSource, indexIO.loadIndex(tmpIndexDir)); return this.indexMap.get(dataSource); }
java
public QueryableIndex cache(String dataSource, Iterable<InputRow> loader, IncrementalIndexSchema indexSchema) throws IOException { IncrementalIndex<?> incIndex = new OnheapIncrementalIndex(indexSchema, true, Integer.MAX_VALUE); for (InputRow row : loader) { incIndex.add(row); } String tmpDir = System.getProperty("druid.segment.dir"); if (tmpDir == null) { tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "druid-tmp-index-"; } File tmpIndexDir = new File(tmpDir + loader.hashCode()); IndexIO indexIO = new IndexIO(new DefaultObjectMapper(), new ColumnConfig() { @Override public int columnCacheSizeBytes() { return 0; } }); if (OSCheck.isWindows()) { new SlowIndexMerger(new DefaultObjectMapper(), indexIO).persist(incIndex, tmpIndexDir, new IndexSpec()); } else { new IndexMerger(new DefaultObjectMapper(), indexIO).persist(incIndex, tmpIndexDir, new IndexSpec()); } this.indexMap.put(dataSource, indexIO.loadIndex(tmpIndexDir)); return this.indexMap.get(dataSource); }
[ "public", "QueryableIndex", "cache", "(", "String", "dataSource", ",", "Iterable", "<", "InputRow", ">", "loader", ",", "IncrementalIndexSchema", "indexSchema", ")", "throws", "IOException", "{", "IncrementalIndex", "<", "?", ">", "incIndex", "=", "new", "OnheapIncrementalIndex", "(", "indexSchema", ",", "true", ",", "Integer", ".", "MAX_VALUE", ")", ";", "for", "(", "InputRow", "row", ":", "loader", ")", "{", "incIndex", ".", "add", "(", "row", ")", ";", "}", "String", "tmpDir", "=", "System", ".", "getProperty", "(", "\"druid.segment.dir\"", ")", ";", "if", "(", "tmpDir", "==", "null", ")", "{", "tmpDir", "=", "System", ".", "getProperty", "(", "\"java.io.tmpdir\"", ")", "+", "File", ".", "separator", "+", "\"druid-tmp-index-\"", ";", "}", "File", "tmpIndexDir", "=", "new", "File", "(", "tmpDir", "+", "loader", ".", "hashCode", "(", ")", ")", ";", "IndexIO", "indexIO", "=", "new", "IndexIO", "(", "new", "DefaultObjectMapper", "(", ")", ",", "new", "ColumnConfig", "(", ")", "{", "@", "Override", "public", "int", "columnCacheSizeBytes", "(", ")", "{", "return", "0", ";", "}", "}", ")", ";", "if", "(", "OSCheck", ".", "isWindows", "(", ")", ")", "{", "new", "SlowIndexMerger", "(", "new", "DefaultObjectMapper", "(", ")", ",", "indexIO", ")", ".", "persist", "(", "incIndex", ",", "tmpIndexDir", ",", "new", "IndexSpec", "(", ")", ")", ";", "}", "else", "{", "new", "IndexMerger", "(", "new", "DefaultObjectMapper", "(", ")", ",", "indexIO", ")", ".", "persist", "(", "incIndex", ",", "tmpIndexDir", ",", "new", "IndexSpec", "(", ")", ")", ";", "}", "this", ".", "indexMap", ".", "put", "(", "dataSource", ",", "indexIO", ".", "loadIndex", "(", "tmpIndexDir", ")", ")", ";", "return", "this", ".", "indexMap", ".", "get", "(", "dataSource", ")", ";", "}" ]
Builds and caches a QueryableIndex from an Iterable by building, persisting and reloading an IncrementalIndex @param dataSource Key to store the index under @param loader Iterable&lt;InputRow&gt; object to read data rows from @param indexSchema Schema of the index @return QueryableIndex that was cached @throws IOException
[ "Builds", "and", "caches", "a", "QueryableIndex", "from", "an", "Iterable", "by", "building", "persisting", "and", "reloading", "an", "IncrementalIndex" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/core/DruidIndices.java#L60-L85
145,645
flow/commons
src/main/java/com/flowpowered/commons/StringUtil.java
StringUtil.startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String input, String prefix) { if (input == null || prefix == null || prefix.length() > input.length()) { return false; } else { final char[] inputCharArray = input.toCharArray(); final char[] prefixCharArray = prefix.toCharArray(); for (int i = 0; i < prefixCharArray.length; i++) { if (!equalsIgnoreCase(prefixCharArray[i], inputCharArray[i])) { return false; } } return true; } }
java
public static boolean startsWithIgnoreCase(String input, String prefix) { if (input == null || prefix == null || prefix.length() > input.length()) { return false; } else { final char[] inputCharArray = input.toCharArray(); final char[] prefixCharArray = prefix.toCharArray(); for (int i = 0; i < prefixCharArray.length; i++) { if (!equalsIgnoreCase(prefixCharArray[i], inputCharArray[i])) { return false; } } return true; } }
[ "public", "static", "boolean", "startsWithIgnoreCase", "(", "String", "input", ",", "String", "prefix", ")", "{", "if", "(", "input", "==", "null", "||", "prefix", "==", "null", "||", "prefix", ".", "length", "(", ")", ">", "input", ".", "length", "(", ")", ")", "{", "return", "false", ";", "}", "else", "{", "final", "char", "[", "]", "inputCharArray", "=", "input", ".", "toCharArray", "(", ")", ";", "final", "char", "[", "]", "prefixCharArray", "=", "prefix", ".", "toCharArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "prefixCharArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "equalsIgnoreCase", "(", "prefixCharArray", "[", "i", "]", ",", "inputCharArray", "[", "i", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "}" ]
Tests if this string starts with the specified prefix, ignoring case @param input the input @param prefix the prefix @return True if the input starts with the prefix when ignoring case, False if not
[ "Tests", "if", "this", "string", "starts", "with", "the", "specified", "prefix", "ignoring", "case" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/StringUtil.java#L39-L52
145,646
flow/commons
src/main/java/com/flowpowered/commons/StringUtil.java
StringUtil.matchName
public static <T extends Named> Collection<T> matchName(Collection<T> values, String name) { List<T> result = new ArrayList<>(); for (T value : values) { if (value == null) { continue; } if (startsWithIgnoreCase(value.getName(), name)) { result.add(value); } } return result; }
java
public static <T extends Named> Collection<T> matchName(Collection<T> values, String name) { List<T> result = new ArrayList<>(); for (T value : values) { if (value == null) { continue; } if (startsWithIgnoreCase(value.getName(), name)) { result.add(value); } } return result; }
[ "public", "static", "<", "T", "extends", "Named", ">", "Collection", "<", "T", ">", "matchName", "(", "Collection", "<", "T", ">", "values", ",", "String", "name", ")", "{", "List", "<", "T", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "T", "value", ":", "values", ")", "{", "if", "(", "value", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "startsWithIgnoreCase", "(", "value", ".", "getName", "(", ")", ",", "name", ")", ")", "{", "result", ".", "add", "(", "value", ")", ";", "}", "}", "return", "result", ";", "}" ]
Matches a named class using a name @param values to look into @param name to match against @return a collection of values that matched
[ "Matches", "a", "named", "class", "using", "a", "name" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/StringUtil.java#L92-L103
145,647
flow/commons
src/main/java/com/flowpowered/commons/StringUtil.java
StringUtil.toNamedString
public static String toNamedString(Object object, Object... components) { StringBuilder b = new StringBuilder(components.length * 5 + 2); if (object != null) { b.append(object.getClass().getSimpleName()).append(' '); } b.append('{'); for (int i = 0; i < components.length; i++) { if (i != 0) { b.append(", "); } b.append(components[i]); } b.append('}'); return b.toString(); }
java
public static String toNamedString(Object object, Object... components) { StringBuilder b = new StringBuilder(components.length * 5 + 2); if (object != null) { b.append(object.getClass().getSimpleName()).append(' '); } b.append('{'); for (int i = 0; i < components.length; i++) { if (i != 0) { b.append(", "); } b.append(components[i]); } b.append('}'); return b.toString(); }
[ "public", "static", "String", "toNamedString", "(", "Object", "object", ",", "Object", "...", "components", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", "components", ".", "length", "*", "5", "+", "2", ")", ";", "if", "(", "object", "!=", "null", ")", "{", "b", ".", "append", "(", "object", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "b", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "components", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "{", "b", ".", "append", "(", "\", \"", ")", ";", "}", "b", ".", "append", "(", "components", "[", "i", "]", ")", ";", "}", "b", ".", "append", "(", "'", "'", ")", ";", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Wraps all components in between brackets delimited by ','-signs, appending the class name in front of it. @param object name to append in front @param components to turn into a String @return a String representation of the input
[ "Wraps", "all", "components", "in", "between", "brackets", "delimited", "by", "-", "signs", "appending", "the", "class", "name", "in", "front", "of", "it", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/StringUtil.java#L182-L196
145,648
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/attribute/resolver/SAML2AttributeNameToIdMapperService.java
SAML2AttributeNameToIdMapperService.getAttributeID
public String getAttributeID(String name) { Map<String, String> m = this.getMapping(); return m != null ? m.get(name) : null; }
java
public String getAttributeID(String name) { Map<String, String> m = this.getMapping(); return m != null ? m.get(name) : null; }
[ "public", "String", "getAttributeID", "(", "String", "name", ")", "{", "Map", "<", "String", ",", "String", ">", "m", "=", "this", ".", "getMapping", "(", ")", ";", "return", "m", "!=", "null", "?", "m", ".", "get", "(", "name", ")", ":", "null", ";", "}" ]
Returns the Shibboleth attribute ID that corresponds to the supplied SAML2 attribute name. @param name the attribute name @return the Shibboleth attribute ID or {@code null} if no mapping exists
[ "Returns", "the", "Shibboleth", "attribute", "ID", "that", "corresponds", "to", "the", "supplied", "SAML2", "attribute", "name", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/attribute/resolver/SAML2AttributeNameToIdMapperService.java#L81-L84
145,649
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.initializeServices
protected void initializeServices(ProfileRequestContext<?, ?> profileRequestContext) throws ExternalAutenticationErrorCodeException { this.authnContextService.initializeContext(profileRequestContext); this.signSupportService.initializeContext(profileRequestContext); }
java
protected void initializeServices(ProfileRequestContext<?, ?> profileRequestContext) throws ExternalAutenticationErrorCodeException { this.authnContextService.initializeContext(profileRequestContext); this.signSupportService.initializeContext(profileRequestContext); }
[ "protected", "void", "initializeServices", "(", "ProfileRequestContext", "<", "?", ",", "?", ">", "profileRequestContext", ")", "throws", "ExternalAutenticationErrorCodeException", "{", "this", ".", "authnContextService", ".", "initializeContext", "(", "profileRequestContext", ")", ";", "this", ".", "signSupportService", ".", "initializeContext", "(", "profileRequestContext", ")", ";", "}" ]
Initializes the services for the controller. Subclasses should override this method to initialize their own services. @param profileRequestContext the request context @throws ExternalAutenticationErrorCodeException for errors during initialization
[ "Initializes", "the", "services", "for", "the", "controller", ".", "Subclasses", "should", "override", "this", "method", "to", "initialize", "their", "own", "services", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L212-L215
145,650
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.servicesProcessRequest
protected void servicesProcessRequest(ProfileRequestContext<?, ?> profileRequestContext) throws ExternalAutenticationErrorCodeException { this.authnContextService.processRequest(profileRequestContext); this.signSupportService.processRequest(profileRequestContext); }
java
protected void servicesProcessRequest(ProfileRequestContext<?, ?> profileRequestContext) throws ExternalAutenticationErrorCodeException { this.authnContextService.processRequest(profileRequestContext); this.signSupportService.processRequest(profileRequestContext); }
[ "protected", "void", "servicesProcessRequest", "(", "ProfileRequestContext", "<", "?", ",", "?", ">", "profileRequestContext", ")", "throws", "ExternalAutenticationErrorCodeException", "{", "this", ".", "authnContextService", ".", "processRequest", "(", "profileRequestContext", ")", ";", "this", ".", "signSupportService", ".", "processRequest", "(", "profileRequestContext", ")", ";", "}" ]
Invokes request processing for all installed services. Subclasses should override this method to invoke their own services. @param profileRequestContext the request context @throws ExternalAutenticationErrorCodeException for errors during processing
[ "Invokes", "request", "processing", "for", "all", "installed", "services", ".", "Subclasses", "should", "override", "this", "method", "to", "invoke", "their", "own", "services", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L226-L229
145,651
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.getExternalAuthenticationKey
protected String getExternalAuthenticationKey(HttpServletRequest httpRequest) throws ExternalAuthenticationException { String key = (String) httpRequest.getSession().getAttribute(EXTAUTHN_KEY_ATTRIBUTE_NAME); if (key == null) { throw new ExternalAuthenticationException("No external authentication process is active"); } return key; }
java
protected String getExternalAuthenticationKey(HttpServletRequest httpRequest) throws ExternalAuthenticationException { String key = (String) httpRequest.getSession().getAttribute(EXTAUTHN_KEY_ATTRIBUTE_NAME); if (key == null) { throw new ExternalAuthenticationException("No external authentication process is active"); } return key; }
[ "protected", "String", "getExternalAuthenticationKey", "(", "HttpServletRequest", "httpRequest", ")", "throws", "ExternalAuthenticationException", "{", "String", "key", "=", "(", "String", ")", "httpRequest", ".", "getSession", "(", ")", ".", "getAttribute", "(", "EXTAUTHN_KEY_ATTRIBUTE_NAME", ")", ";", "if", "(", "key", "==", "null", ")", "{", "throw", "new", "ExternalAuthenticationException", "(", "\"No external authentication process is active\"", ")", ";", "}", "return", "key", ";", "}" ]
Returns the Shibboleth external authentication key for the current session. @param httpRequest the HTTP request @return the Shibboleth external authentication key @throws ExternalAuthenticationException if no active session exists
[ "Returns", "the", "Shibboleth", "external", "authentication", "key", "for", "the", "current", "session", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L267-L273
145,652
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.success
protected void success(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String principal, List<Attribute> attributes, String authnContextClassUri, DateTime authnInstant, Boolean cacheForSSO) throws ExternalAuthenticationException, IOException { SubjectBuilder builder = this.getSubjectBuilder(principal); for (Attribute a : attributes) { builder.attribute(a); } builder.authnContextClassRef(authnContextClassUri); this.success(httpRequest, httpResponse, builder.build(), authnInstant, cacheForSSO); }
java
protected void success(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String principal, List<Attribute> attributes, String authnContextClassUri, DateTime authnInstant, Boolean cacheForSSO) throws ExternalAuthenticationException, IOException { SubjectBuilder builder = this.getSubjectBuilder(principal); for (Attribute a : attributes) { builder.attribute(a); } builder.authnContextClassRef(authnContextClassUri); this.success(httpRequest, httpResponse, builder.build(), authnInstant, cacheForSSO); }
[ "protected", "void", "success", "(", "HttpServletRequest", "httpRequest", ",", "HttpServletResponse", "httpResponse", ",", "String", "principal", ",", "List", "<", "Attribute", ">", "attributes", ",", "String", "authnContextClassUri", ",", "DateTime", "authnInstant", ",", "Boolean", "cacheForSSO", ")", "throws", "ExternalAuthenticationException", ",", "IOException", "{", "SubjectBuilder", "builder", "=", "this", ".", "getSubjectBuilder", "(", "principal", ")", ";", "for", "(", "Attribute", "a", ":", "attributes", ")", "{", "builder", ".", "attribute", "(", "a", ")", ";", "}", "builder", ".", "authnContextClassRef", "(", "authnContextClassUri", ")", ";", "this", ".", "success", "(", "httpRequest", ",", "httpResponse", ",", "builder", ".", "build", "(", ")", ",", "authnInstant", ",", "cacheForSSO", ")", ";", "}" ]
Method that should be invoked to exit the external authentication process with a successful result. @param httpRequest the HTTP request @param httpResponse the HTTP response @param principal the principal that was authenticated @param attributes the attributes to release @param authnContextClassUri the authentication context class URI (LoA) @param authnInstant the authentication instant - if {@code null} the current time will be used @param cacheForSSO should the result be cached for later SSO? If {@code null}, see {@link #success(HttpServletRequest, HttpServletResponse, Subject, DateTime, Boolean)} @throws ExternalAuthenticationException for Shibboleth session errors @throws IOException for IO errors
[ "Method", "that", "should", "be", "invoked", "to", "exit", "the", "external", "authentication", "process", "with", "a", "successful", "result", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L370-L380
145,653
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.cancel
protected void cancel(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ExternalAuthenticationException, IOException { this.error(httpRequest, httpResponse, ExtAuthnEventIds.CANCEL_AUTHN); }
java
protected void cancel(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ExternalAuthenticationException, IOException { this.error(httpRequest, httpResponse, ExtAuthnEventIds.CANCEL_AUTHN); }
[ "protected", "void", "cancel", "(", "HttpServletRequest", "httpRequest", ",", "HttpServletResponse", "httpResponse", ")", "throws", "ExternalAuthenticationException", ",", "IOException", "{", "this", ".", "error", "(", "httpRequest", ",", "httpResponse", ",", "ExtAuthnEventIds", ".", "CANCEL_AUTHN", ")", ";", "}" ]
Method that should be invoked before exiting the external authentication process and indicate that the user cancelled the authentication. @param httpRequest the HTTP request @param httpResponse the HTTP response @throws ExternalAuthenticationException for Shibboleth session errors @throws IOException for IO errors
[ "Method", "that", "should", "be", "invoked", "before", "exiting", "the", "external", "authentication", "process", "and", "indicate", "that", "the", "user", "cancelled", "the", "authentication", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L433-L436
145,654
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.error
protected void error(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Status errorStatus) throws ExternalAuthenticationException, IOException { this.error(httpRequest, httpResponse, new IdpErrorStatusException(errorStatus)); }
java
protected void error(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Status errorStatus) throws ExternalAuthenticationException, IOException { this.error(httpRequest, httpResponse, new IdpErrorStatusException(errorStatus)); }
[ "protected", "void", "error", "(", "HttpServletRequest", "httpRequest", ",", "HttpServletResponse", "httpResponse", ",", "Status", "errorStatus", ")", "throws", "ExternalAuthenticationException", ",", "IOException", "{", "this", ".", "error", "(", "httpRequest", ",", "httpResponse", ",", "new", "IdpErrorStatusException", "(", "errorStatus", ")", ")", ";", "}" ]
Method that should be invoked to exit the external authentication process with an error where the SAML status to respond with is given. @param httpRequest the HTTP request @param httpResponse the HTTP response @param errorStatus the SAML status @throws ExternalAuthenticationException for Shibboleth session errors @throws IOException for IO errors @see #error(HttpServletRequest, HttpServletResponse, String) @see #error(HttpServletRequest, HttpServletResponse, Exception)
[ "Method", "that", "should", "be", "invoked", "to", "exit", "the", "external", "authentication", "process", "with", "an", "error", "where", "the", "SAML", "status", "to", "respond", "with", "is", "given", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L515-L518
145,655
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.getBinding
protected String getBinding(ProfileRequestContext<?, ?> context) { SAMLBindingContext samlBinding = this.samlBindingContextLookupStrategy.apply(context); return samlBinding != null ? samlBinding.getBindingUri() : null; }
java
protected String getBinding(ProfileRequestContext<?, ?> context) { SAMLBindingContext samlBinding = this.samlBindingContextLookupStrategy.apply(context); return samlBinding != null ? samlBinding.getBindingUri() : null; }
[ "protected", "String", "getBinding", "(", "ProfileRequestContext", "<", "?", ",", "?", ">", "context", ")", "{", "SAMLBindingContext", "samlBinding", "=", "this", ".", "samlBindingContextLookupStrategy", ".", "apply", "(", "context", ")", ";", "return", "samlBinding", "!=", "null", "?", "samlBinding", ".", "getBindingUri", "(", ")", ":", "null", ";", "}" ]
Utility method that may be used to obtain the binding that was used to pass the AuthnRequest message. @param context the profile context @return the binding URI @see #getBinding(HttpServletRequest)
[ "Utility", "method", "that", "may", "be", "used", "to", "obtain", "the", "binding", "that", "was", "used", "to", "pass", "the", "AuthnRequest", "message", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L617-L620
145,656
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java
AbstractExternalAuthenticationController.getRelayState
protected String getRelayState(ProfileRequestContext<?, ?> context) { SAMLBindingContext samlBinding = this.samlBindingContextLookupStrategy.apply(context); return samlBinding != null ? samlBinding.getRelayState() : null; }
java
protected String getRelayState(ProfileRequestContext<?, ?> context) { SAMLBindingContext samlBinding = this.samlBindingContextLookupStrategy.apply(context); return samlBinding != null ? samlBinding.getRelayState() : null; }
[ "protected", "String", "getRelayState", "(", "ProfileRequestContext", "<", "?", ",", "?", ">", "context", ")", "{", "SAMLBindingContext", "samlBinding", "=", "this", ".", "samlBindingContextLookupStrategy", ".", "apply", "(", "context", ")", ";", "return", "samlBinding", "!=", "null", "?", "samlBinding", ".", "getRelayState", "(", ")", ":", "null", ";", "}" ]
Utility method that may be used to obtain the Relay State for the request. @param context the profile context @return the relay state @see #getRelayState(HttpServletRequest)
[ "Utility", "method", "that", "may", "be", "used", "to", "obtain", "the", "Relay", "State", "for", "the", "request", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/controller/AbstractExternalAuthenticationController.java#L643-L646
145,657
flow/commons
src/main/java/com/flowpowered/commons/StringToUniqueIntegerMap.java
StringToUniqueIntegerMap.convertTo
public int convertTo(StringToUniqueIntegerMap other, int localId) { if (other == null) { throw new IllegalStateException("Other map is null"); } String localKey = store.reverseGet(localId); if (localKey == null) { throw new IllegalArgumentException("Cannot convert an id that is not registered locally."); } Integer foreignId = null; if (other == this) { return localId; } else if (other == parent) { foreignId = thisToParentMap.get(localId); } else if (other.parent == this) { foreignId = other.parentToThisMap.get(localId); } // Cache hit if (foreignId != null) { return foreignId; } Integer integerForeignId = other.store.get(localKey); // The other map doesn't have an entry for this key if (integerForeignId == null) { integerForeignId = other.register(localKey); } // Add the key/value pair to the cache if (other == parent) { thisToParentMap.set(localId, integerForeignId); parentToThisMap.set(integerForeignId, localId); } else if (other.parent == this) { other.thisToParentMap.set(integerForeignId, localId); other.parentToThisMap.set(localId, integerForeignId); } return integerForeignId; }
java
public int convertTo(StringToUniqueIntegerMap other, int localId) { if (other == null) { throw new IllegalStateException("Other map is null"); } String localKey = store.reverseGet(localId); if (localKey == null) { throw new IllegalArgumentException("Cannot convert an id that is not registered locally."); } Integer foreignId = null; if (other == this) { return localId; } else if (other == parent) { foreignId = thisToParentMap.get(localId); } else if (other.parent == this) { foreignId = other.parentToThisMap.get(localId); } // Cache hit if (foreignId != null) { return foreignId; } Integer integerForeignId = other.store.get(localKey); // The other map doesn't have an entry for this key if (integerForeignId == null) { integerForeignId = other.register(localKey); } // Add the key/value pair to the cache if (other == parent) { thisToParentMap.set(localId, integerForeignId); parentToThisMap.set(integerForeignId, localId); } else if (other.parent == this) { other.thisToParentMap.set(integerForeignId, localId); other.parentToThisMap.set(localId, integerForeignId); } return integerForeignId; }
[ "public", "int", "convertTo", "(", "StringToUniqueIntegerMap", "other", ",", "int", "localId", ")", "{", "if", "(", "other", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Other map is null\"", ")", ";", "}", "String", "localKey", "=", "store", ".", "reverseGet", "(", "localId", ")", ";", "if", "(", "localKey", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot convert an id that is not registered locally.\"", ")", ";", "}", "Integer", "foreignId", "=", "null", ";", "if", "(", "other", "==", "this", ")", "{", "return", "localId", ";", "}", "else", "if", "(", "other", "==", "parent", ")", "{", "foreignId", "=", "thisToParentMap", ".", "get", "(", "localId", ")", ";", "}", "else", "if", "(", "other", ".", "parent", "==", "this", ")", "{", "foreignId", "=", "other", ".", "parentToThisMap", ".", "get", "(", "localId", ")", ";", "}", "// Cache hit", "if", "(", "foreignId", "!=", "null", ")", "{", "return", "foreignId", ";", "}", "Integer", "integerForeignId", "=", "other", ".", "store", ".", "get", "(", "localKey", ")", ";", "// The other map doesn't have an entry for this key", "if", "(", "integerForeignId", "==", "null", ")", "{", "integerForeignId", "=", "other", ".", "register", "(", "localKey", ")", ";", "}", "// Add the key/value pair to the cache", "if", "(", "other", "==", "parent", ")", "{", "thisToParentMap", ".", "set", "(", "localId", ",", "integerForeignId", ")", ";", "parentToThisMap", ".", "set", "(", "integerForeignId", ",", "localId", ")", ";", "}", "else", "if", "(", "other", ".", "parent", "==", "this", ")", "{", "other", ".", "thisToParentMap", ".", "set", "(", "integerForeignId", ",", "localId", ")", ";", "other", ".", "parentToThisMap", ".", "set", "(", "localId", ",", "integerForeignId", ")", ";", "}", "return", "integerForeignId", ";", "}" ]
Converts an id local to this map to a foreign id, local to another map. @param other the other map @param localId to convert @return returns the foreign id, or 0 on failure
[ "Converts", "an", "id", "local", "to", "this", "map", "to", "a", "foreign", "id", "local", "to", "another", "map", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/StringToUniqueIntegerMap.java#L105-L146
145,658
flow/commons
src/main/java/com/flowpowered/commons/StringToUniqueIntegerMap.java
StringToUniqueIntegerMap.register
public int register(String key) { Integer id = store.get(key); if (id != null) { return id; } int localId = nextId.getAndIncrement(); while (localId < maxId) { if (store.setIfAbsent(key, localId)) { return localId; } Integer storeId = store.get(key); if (storeId != null) { return storeId; } localId = nextId.getAndIncrement(); } throw new IllegalStateException("StringMap id space exhausted"); }
java
public int register(String key) { Integer id = store.get(key); if (id != null) { return id; } int localId = nextId.getAndIncrement(); while (localId < maxId) { if (store.setIfAbsent(key, localId)) { return localId; } Integer storeId = store.get(key); if (storeId != null) { return storeId; } localId = nextId.getAndIncrement(); } throw new IllegalStateException("StringMap id space exhausted"); }
[ "public", "int", "register", "(", "String", "key", ")", "{", "Integer", "id", "=", "store", ".", "get", "(", "key", ")", ";", "if", "(", "id", "!=", "null", ")", "{", "return", "id", ";", "}", "int", "localId", "=", "nextId", ".", "getAndIncrement", "(", ")", ";", "while", "(", "localId", "<", "maxId", ")", "{", "if", "(", "store", ".", "setIfAbsent", "(", "key", ",", "localId", ")", ")", "{", "return", "localId", ";", "}", "Integer", "storeId", "=", "store", ".", "get", "(", "key", ")", ";", "if", "(", "storeId", "!=", "null", ")", "{", "return", "storeId", ";", "}", "localId", "=", "nextId", ".", "getAndIncrement", "(", ")", ";", "}", "throw", "new", "IllegalStateException", "(", "\"StringMap id space exhausted\"", ")", ";", "}" ]
Registers a key with the map and returns the matching id. The id corresponding to a key will be consistent if registered more than once, including over restarts, subject to the persistence of the store. @param key the key to be added @return returns the local id, or 0 on failure
[ "Registers", "a", "key", "with", "the", "map", "and", "returns", "the", "matching", "id", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/StringToUniqueIntegerMap.java#L166-L188
145,659
politie/cinch
src/main/java/eu/icolumbo/cinch/CinchContext.java
CinchContext.executeJob
public void executeJob() { AbstractApplicationContext springContext = SpringContext.getContext(springConfigurationClass); CinchJob cinchJob = springContext.getBean(CinchJob.class); cinchJob.execute(this); }
java
public void executeJob() { AbstractApplicationContext springContext = SpringContext.getContext(springConfigurationClass); CinchJob cinchJob = springContext.getBean(CinchJob.class); cinchJob.execute(this); }
[ "public", "void", "executeJob", "(", ")", "{", "AbstractApplicationContext", "springContext", "=", "SpringContext", ".", "getContext", "(", "springConfigurationClass", ")", ";", "CinchJob", "cinchJob", "=", "springContext", ".", "getBean", "(", "CinchJob", ".", "class", ")", ";", "cinchJob", ".", "execute", "(", "this", ")", ";", "}" ]
Executes your job from the spring context.
[ "Executes", "your", "job", "from", "the", "spring", "context", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/CinchContext.java#L29-L34
145,660
politie/cinch
src/main/java/eu/icolumbo/cinch/CinchContext.java
CinchContext.function
public <T1, R> Function<T1, R> function(Class<? extends Function<T1, R>> springBeanClass) { return new SpringFunction<>(springConfigurationClass, springBeanClass); }
java
public <T1, R> Function<T1, R> function(Class<? extends Function<T1, R>> springBeanClass) { return new SpringFunction<>(springConfigurationClass, springBeanClass); }
[ "public", "<", "T1", ",", "R", ">", "Function", "<", "T1", ",", "R", ">", "function", "(", "Class", "<", "?", "extends", "Function", "<", "T1", ",", "R", ">", ">", "springBeanClass", ")", "{", "return", "new", "SpringFunction", "<>", "(", "springConfigurationClass", ",", "springBeanClass", ")", ";", "}" ]
Create a new SpringFunction, which implements Spark's Function interface.
[ "Create", "a", "new", "SpringFunction", "which", "implements", "Spark", "s", "Function", "interface", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/CinchContext.java#L39-L41
145,661
politie/cinch
src/main/java/eu/icolumbo/cinch/CinchContext.java
CinchContext.voidFunction
public <T> VoidFunction<T> voidFunction(Class<? extends VoidFunction<T>> springBeanClass) { return new SpringVoidFunction<>(springConfigurationClass, springBeanClass); }
java
public <T> VoidFunction<T> voidFunction(Class<? extends VoidFunction<T>> springBeanClass) { return new SpringVoidFunction<>(springConfigurationClass, springBeanClass); }
[ "public", "<", "T", ">", "VoidFunction", "<", "T", ">", "voidFunction", "(", "Class", "<", "?", "extends", "VoidFunction", "<", "T", ">", ">", "springBeanClass", ")", "{", "return", "new", "SpringVoidFunction", "<>", "(", "springConfigurationClass", ",", "springBeanClass", ")", ";", "}" ]
Create a new SpringVoidFunction, which implements Spark's VoidFunction interface.
[ "Create", "a", "new", "SpringVoidFunction", "which", "implements", "Spark", "s", "VoidFunction", "interface", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/CinchContext.java#L46-L48
145,662
politie/cinch
src/main/java/eu/icolumbo/cinch/CinchContext.java
CinchContext.flatMapFunction
public <T, R> FlatMapFunction<T, R> flatMapFunction(Class<? extends FlatMapFunction<T, R>> springBeanClass) { return new SpringFlatMapFunction<>(springConfigurationClass, springBeanClass); }
java
public <T, R> FlatMapFunction<T, R> flatMapFunction(Class<? extends FlatMapFunction<T, R>> springBeanClass) { return new SpringFlatMapFunction<>(springConfigurationClass, springBeanClass); }
[ "public", "<", "T", ",", "R", ">", "FlatMapFunction", "<", "T", ",", "R", ">", "flatMapFunction", "(", "Class", "<", "?", "extends", "FlatMapFunction", "<", "T", ",", "R", ">", ">", "springBeanClass", ")", "{", "return", "new", "SpringFlatMapFunction", "<>", "(", "springConfigurationClass", ",", "springBeanClass", ")", ";", "}" ]
Create a new SpringFlapMapFunction, which implements Spark's FlatMapFunction interface.
[ "Create", "a", "new", "SpringFlapMapFunction", "which", "implements", "Spark", "s", "FlatMapFunction", "interface", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/CinchContext.java#L53-L55
145,663
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.sendMessage
public void sendMessage(String message, boolean push, boolean ccSelf, final Respoke.TaskCompletionListener completionListener) { if ((null != signalingChannel) && (signalingChannel.connected)) { try { JSONObject data = new JSONObject(); data.put("to", endpointID); data.put("message", message); data.put("push", push); data.put("ccSelf", ccSelf); signalingChannel.sendRESTMessage("post", "/v1/messages", data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding message"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
java
public void sendMessage(String message, boolean push, boolean ccSelf, final Respoke.TaskCompletionListener completionListener) { if ((null != signalingChannel) && (signalingChannel.connected)) { try { JSONObject data = new JSONObject(); data.put("to", endpointID); data.put("message", message); data.put("push", push); data.put("ccSelf", ccSelf); signalingChannel.sendRESTMessage("post", "/v1/messages", data, new RespokeSignalingChannel.RESTListener() { @Override public void onSuccess(Object response) { Respoke.postTaskSuccess(completionListener); } @Override public void onError(final String errorMessage) { Respoke.postTaskError(completionListener, errorMessage); } }); } catch (JSONException e) { Respoke.postTaskError(completionListener, "Error encoding message"); } } else { Respoke.postTaskError(completionListener, "Can't complete request when not connected. Please reconnect!"); } }
[ "public", "void", "sendMessage", "(", "String", "message", ",", "boolean", "push", ",", "boolean", "ccSelf", ",", "final", "Respoke", ".", "TaskCompletionListener", "completionListener", ")", "{", "if", "(", "(", "null", "!=", "signalingChannel", ")", "&&", "(", "signalingChannel", ".", "connected", ")", ")", "{", "try", "{", "JSONObject", "data", "=", "new", "JSONObject", "(", ")", ";", "data", ".", "put", "(", "\"to\"", ",", "endpointID", ")", ";", "data", ".", "put", "(", "\"message\"", ",", "message", ")", ";", "data", ".", "put", "(", "\"push\"", ",", "push", ")", ";", "data", ".", "put", "(", "\"ccSelf\"", ",", "ccSelf", ")", ";", "signalingChannel", ".", "sendRESTMessage", "(", "\"post\"", ",", "\"/v1/messages\"", ",", "data", ",", "new", "RespokeSignalingChannel", ".", "RESTListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "Object", "response", ")", "{", "Respoke", ".", "postTaskSuccess", "(", "completionListener", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Error encoding message\"", ")", ";", "}", "}", "else", "{", "Respoke", ".", "postTaskError", "(", "completionListener", ",", "\"Can't complete request when not connected. Please reconnect!\"", ")", ";", "}", "}" ]
Send a message to the endpoint through the infrastructure. @param message The message to send @param push A flag indicating if a push notification should be sent for this message @param ccSelf A flag indicating if the message should be copied to other devices the client might be logged into @param completionListener A listener to receive a notification on the success of the asynchronous operation
[ "Send", "a", "message", "to", "the", "endpoint", "through", "the", "infrastructure", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L106-L132
145,664
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.startCall
public RespokeCall startCall(RespokeCall.Listener callListener, Context context, GLSurfaceView glView, boolean audioOnly) { RespokeCall call = null; if ((null != signalingChannel) && (signalingChannel.connected)) { call = new RespokeCall(signalingChannel, this, false); call.setListener(callListener); call.startCall(context, glView, audioOnly); } return call; }
java
public RespokeCall startCall(RespokeCall.Listener callListener, Context context, GLSurfaceView glView, boolean audioOnly) { RespokeCall call = null; if ((null != signalingChannel) && (signalingChannel.connected)) { call = new RespokeCall(signalingChannel, this, false); call.setListener(callListener); call.startCall(context, glView, audioOnly); } return call; }
[ "public", "RespokeCall", "startCall", "(", "RespokeCall", ".", "Listener", "callListener", ",", "Context", "context", ",", "GLSurfaceView", "glView", ",", "boolean", "audioOnly", ")", "{", "RespokeCall", "call", "=", "null", ";", "if", "(", "(", "null", "!=", "signalingChannel", ")", "&&", "(", "signalingChannel", ".", "connected", ")", ")", "{", "call", "=", "new", "RespokeCall", "(", "signalingChannel", ",", "this", ",", "false", ")", ";", "call", ".", "setListener", "(", "callListener", ")", ";", "call", ".", "startCall", "(", "context", ",", "glView", ",", "audioOnly", ")", ";", "}", "return", "call", ";", "}" ]
Create a new call with audio and optionally video. @param callListener A listener to receive notifications of call related events @param context An application context with which to access system resources @param glView A GLSurfaceView into which video from the call should be rendered, or null if the call is audio only @param audioOnly Specify true for an audio-only call @return A new RespokeCall instance
[ "Create", "a", "new", "call", "with", "audio", "and", "optionally", "video", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L145-L156
145,665
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.getConnection
public RespokeConnection getConnection(String connectionID, boolean skipCreate) { RespokeConnection connection = null; for (RespokeConnection eachConnection : connections) { if (eachConnection.connectionID.equals(connectionID)) { connection = eachConnection; break; } } if ((null == connection) && !skipCreate) { connection = new RespokeConnection(connectionID, this); connections.add(connection); } return connection; }
java
public RespokeConnection getConnection(String connectionID, boolean skipCreate) { RespokeConnection connection = null; for (RespokeConnection eachConnection : connections) { if (eachConnection.connectionID.equals(connectionID)) { connection = eachConnection; break; } } if ((null == connection) && !skipCreate) { connection = new RespokeConnection(connectionID, this); connections.add(connection); } return connection; }
[ "public", "RespokeConnection", "getConnection", "(", "String", "connectionID", ",", "boolean", "skipCreate", ")", "{", "RespokeConnection", "connection", "=", "null", ";", "for", "(", "RespokeConnection", "eachConnection", ":", "connections", ")", "{", "if", "(", "eachConnection", ".", "connectionID", ".", "equals", "(", "connectionID", ")", ")", "{", "connection", "=", "eachConnection", ";", "break", ";", "}", "}", "if", "(", "(", "null", "==", "connection", ")", "&&", "!", "skipCreate", ")", "{", "connection", "=", "new", "RespokeConnection", "(", "connectionID", ",", "this", ")", ";", "connections", ".", "add", "(", "connection", ")", ";", "}", "return", "connection", ";", "}" ]
Returns a connection with the specified ID, and optionally creates one if it does not exist @param connectionID The ID of the connection @param skipCreate Whether or not to create a new connection if it is not found @return The connection that matches the specified ID, or null if not found and skipCreate is true
[ "Returns", "a", "connection", "with", "the", "specified", "ID", "and", "optionally", "creates", "one", "if", "it", "does", "not", "exist" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L177-L193
145,666
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.didSendMessage
public void didSendMessage(final String message, final Date timestamp) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onMessage(message, timestamp, RespokeEndpoint.this, true); } } } }); }
java
public void didSendMessage(final String message, final Date timestamp) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onMessage(message, timestamp, RespokeEndpoint.this, true); } } } }); }
[ "public", "void", "didSendMessage", "(", "final", "String", "message", ",", "final", "Date", "timestamp", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "listenerReference", ")", "{", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onMessage", "(", "message", ",", "timestamp", ",", "RespokeEndpoint", ".", "this", ",", "true", ")", ";", "}", "}", "}", "}", ")", ";", "}" ]
Process a sent message. This is used internally to the SDK and should not be called directly by your client application. @param message The body of the message @param timestamp The message timestamp
[ "Process", "a", "sent", "message", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L233-L245
145,667
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.setDirectConnection
public void setDirectConnection(RespokeDirectConnection newDirectConnection) { if (null != newDirectConnection) { directConnectionReference = new WeakReference<RespokeDirectConnection>(newDirectConnection); } else { directConnectionReference = null; } }
java
public void setDirectConnection(RespokeDirectConnection newDirectConnection) { if (null != newDirectConnection) { directConnectionReference = new WeakReference<RespokeDirectConnection>(newDirectConnection); } else { directConnectionReference = null; } }
[ "public", "void", "setDirectConnection", "(", "RespokeDirectConnection", "newDirectConnection", ")", "{", "if", "(", "null", "!=", "newDirectConnection", ")", "{", "directConnectionReference", "=", "new", "WeakReference", "<", "RespokeDirectConnection", ">", "(", "newDirectConnection", ")", ";", "}", "else", "{", "directConnectionReference", "=", "null", ";", "}", "}" ]
Associate a direct connection object with this endpoint. This method is used internally by the SDK should not be called by your client application. @param newDirectConnection The direct connection to associate
[ "Associate", "a", "direct", "connection", "object", "with", "this", "endpoint", ".", "This", "method", "is", "used", "internally", "by", "the", "SDK", "should", "not", "be", "called", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L341-L347
145,668
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java
RespokeEndpoint.startDirectConnection
public RespokeDirectConnection startDirectConnection() { // The constructor will call the setDirectConnection method on this endpoint instance with a reference to the new RespokeDirectConnection object RespokeCall call = new RespokeCall(signalingChannel, this, true); call.startCall(null, null, false); return directConnection(); }
java
public RespokeDirectConnection startDirectConnection() { // The constructor will call the setDirectConnection method on this endpoint instance with a reference to the new RespokeDirectConnection object RespokeCall call = new RespokeCall(signalingChannel, this, true); call.startCall(null, null, false); return directConnection(); }
[ "public", "RespokeDirectConnection", "startDirectConnection", "(", ")", "{", "// The constructor will call the setDirectConnection method on this endpoint instance with a reference to the new RespokeDirectConnection object", "RespokeCall", "call", "=", "new", "RespokeCall", "(", "signalingChannel", ",", "this", ",", "true", ")", ";", "call", ".", "startCall", "(", "null", ",", "null", ",", "false", ")", ";", "return", "directConnection", "(", ")", ";", "}" ]
Create a new DirectConnection. This method creates a new Call as well, attaching this DirectConnection to it for the purposes of creating a peer-to-peer link for sending data such as messages to the other endpoint. Information sent through a DirectConnection is not handled by the cloud infrastructure. @return The DirectConnection which can be used to send data and messages directly to the other endpoint.
[ "Create", "a", "new", "DirectConnection", ".", "This", "method", "creates", "a", "new", "Call", "as", "well", "attaching", "this", "DirectConnection", "to", "it", "for", "the", "purposes", "of", "creating", "a", "peer", "-", "to", "-", "peer", "link", "for", "sending", "data", "such", "as", "messages", "to", "the", "other", "endpoint", ".", "Information", "sent", "through", "a", "DirectConnection", "is", "not", "handled", "by", "the", "cloud", "infrastructure", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeEndpoint.java#L357-L363
145,669
flow/commons
src/main/java/com/flowpowered/commons/typechecker/TypeChecker.java
TypeChecker.check
public final T check(Object object, T defaultValue) { try { return check(object); } catch (ClassCastException e) { return defaultValue; } }
java
public final T check(Object object, T defaultValue) { try { return check(object); } catch (ClassCastException e) { return defaultValue; } }
[ "public", "final", "T", "check", "(", "Object", "object", ",", "T", "defaultValue", ")", "{", "try", "{", "return", "check", "(", "object", ")", ";", "}", "catch", "(", "ClassCastException", "e", ")", "{", "return", "defaultValue", ";", "}", "}" ]
Checks and casts an object to the specified type. If casting fails, a default value is returned. @param object The object to be checked @param defaultValue The default value to be returned if casting fails @return The same object, cast to the specified class, or the default value, if casting fails
[ "Checks", "and", "casts", "an", "object", "to", "the", "specified", "type", ".", "If", "casting", "fails", "a", "default", "value", "is", "returned", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/typechecker/TypeChecker.java#L249-L255
145,670
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/app/DruidRunner.java
DruidRunner.run
public Server run() throws Exception { if (server == null) { server = new Server(port); String basePath = "/druid"; buildSwagger(basePath); HandlerList handlers = new HandlerList(); handlers.addHandler(buildContext(basePath)); server.setHandler(handlers); server.start(); } else { throw new IllegalStateException("Server already running"); } return server; }
java
public Server run() throws Exception { if (server == null) { server = new Server(port); String basePath = "/druid"; buildSwagger(basePath); HandlerList handlers = new HandlerList(); handlers.addHandler(buildContext(basePath)); server.setHandler(handlers); server.start(); } else { throw new IllegalStateException("Server already running"); } return server; }
[ "public", "Server", "run", "(", ")", "throws", "Exception", "{", "if", "(", "server", "==", "null", ")", "{", "server", "=", "new", "Server", "(", "port", ")", ";", "String", "basePath", "=", "\"/druid\"", ";", "buildSwagger", "(", "basePath", ")", ";", "HandlerList", "handlers", "=", "new", "HandlerList", "(", ")", ";", "handlers", ".", "addHandler", "(", "buildContext", "(", "basePath", ")", ")", ";", "server", ".", "setHandler", "(", "handlers", ")", ";", "server", ".", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"Server already running\"", ")", ";", "}", "return", "server", ";", "}" ]
Starts the Druid instance and returns the server it is running on @return server hosting Druid @throws Exception
[ "Starts", "the", "Druid", "instance", "and", "returns", "the", "server", "it", "is", "running", "on" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/app/DruidRunner.java#L65-L78
145,671
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/app/DruidRunner.java
DruidRunner.buildSwagger
private static void buildSwagger(String basePath) { // This configures Swagger BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setResourcePackage(QueryResource.class.getPackage().getName()); beanConfig.setBasePath(basePath); beanConfig.setDescription("Embedded Druid"); beanConfig.setTitle("Embedded Druid"); beanConfig.setScan(true); }
java
private static void buildSwagger(String basePath) { // This configures Swagger BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setResourcePackage(QueryResource.class.getPackage().getName()); beanConfig.setBasePath(basePath); beanConfig.setDescription("Embedded Druid"); beanConfig.setTitle("Embedded Druid"); beanConfig.setScan(true); }
[ "private", "static", "void", "buildSwagger", "(", "String", "basePath", ")", "{", "// This configures Swagger", "BeanConfig", "beanConfig", "=", "new", "BeanConfig", "(", ")", ";", "beanConfig", ".", "setVersion", "(", "\"1.0.0\"", ")", ";", "beanConfig", ".", "setResourcePackage", "(", "QueryResource", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ")", ";", "beanConfig", ".", "setBasePath", "(", "basePath", ")", ";", "beanConfig", ".", "setDescription", "(", "\"Embedded Druid\"", ")", ";", "beanConfig", ".", "setTitle", "(", "\"Embedded Druid\"", ")", ";", "beanConfig", ".", "setScan", "(", "true", ")", ";", "}" ]
Builds the Swagger documentation @param basePath Base path where the resources reside
[ "Builds", "the", "Swagger", "documentation" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/app/DruidRunner.java#L85-L94
145,672
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/app/DruidRunner.java
DruidRunner.buildContext
private static ContextHandler buildContext(String basePath) { ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.packages(QueryResource.class.getPackage().getName(), ApiListingResource.class.getPackage().getName()); ServletContainer servletContainer = new ServletContainer(resourceConfig); ServletHolder entityBrowser = new ServletHolder(servletContainer); ServletContextHandler entityBrowserContext = new ServletContextHandler(ServletContextHandler.SESSIONS); entityBrowserContext.setContextPath(basePath); entityBrowserContext.addServlet(entityBrowser, "/*"); FilterHolder corsFilter = new FilterHolder(CrossOriginFilter.class); corsFilter.setAsyncSupported(true); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*"); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*"); corsFilter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,POST,HEAD,DELETE,PUT,OPTIONS"); entityBrowserContext.addFilter(corsFilter, "/*", EnumSet.allOf(DispatcherType.class)); return entityBrowserContext; }
java
private static ContextHandler buildContext(String basePath) { ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.packages(QueryResource.class.getPackage().getName(), ApiListingResource.class.getPackage().getName()); ServletContainer servletContainer = new ServletContainer(resourceConfig); ServletHolder entityBrowser = new ServletHolder(servletContainer); ServletContextHandler entityBrowserContext = new ServletContextHandler(ServletContextHandler.SESSIONS); entityBrowserContext.setContextPath(basePath); entityBrowserContext.addServlet(entityBrowser, "/*"); FilterHolder corsFilter = new FilterHolder(CrossOriginFilter.class); corsFilter.setAsyncSupported(true); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*"); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*"); corsFilter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,POST,HEAD,DELETE,PUT,OPTIONS"); entityBrowserContext.addFilter(corsFilter, "/*", EnumSet.allOf(DispatcherType.class)); return entityBrowserContext; }
[ "private", "static", "ContextHandler", "buildContext", "(", "String", "basePath", ")", "{", "ResourceConfig", "resourceConfig", "=", "new", "ResourceConfig", "(", ")", ";", "resourceConfig", ".", "packages", "(", "QueryResource", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ",", "ApiListingResource", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ")", ";", "ServletContainer", "servletContainer", "=", "new", "ServletContainer", "(", "resourceConfig", ")", ";", "ServletHolder", "entityBrowser", "=", "new", "ServletHolder", "(", "servletContainer", ")", ";", "ServletContextHandler", "entityBrowserContext", "=", "new", "ServletContextHandler", "(", "ServletContextHandler", ".", "SESSIONS", ")", ";", "entityBrowserContext", ".", "setContextPath", "(", "basePath", ")", ";", "entityBrowserContext", ".", "addServlet", "(", "entityBrowser", ",", "\"/*\"", ")", ";", "FilterHolder", "corsFilter", "=", "new", "FilterHolder", "(", "CrossOriginFilter", ".", "class", ")", ";", "corsFilter", ".", "setAsyncSupported", "(", "true", ")", ";", "corsFilter", ".", "setInitParameter", "(", "CrossOriginFilter", ".", "ALLOWED_ORIGINS_PARAM", ",", "\"*\"", ")", ";", "corsFilter", ".", "setInitParameter", "(", "CrossOriginFilter", ".", "ALLOWED_HEADERS_PARAM", ",", "\"*\"", ")", ";", "corsFilter", ".", "setInitParameter", "(", "CrossOriginFilter", ".", "ACCESS_CONTROL_ALLOW_ORIGIN_HEADER", ",", "\"*\"", ")", ";", "corsFilter", ".", "setInitParameter", "(", "CrossOriginFilter", ".", "ALLOWED_METHODS_PARAM", ",", "\"GET,POST,HEAD,DELETE,PUT,OPTIONS\"", ")", ";", "entityBrowserContext", ".", "addFilter", "(", "corsFilter", ",", "\"/*\"", ",", "EnumSet", ".", "allOf", "(", "DispatcherType", ".", "class", ")", ")", ";", "return", "entityBrowserContext", ";", "}" ]
Adds resources to the context to be run on the server @param basePath Path to add the resources on @return ContextHandler to add on the server
[ "Adds", "resources", "to", "the", "context", "to", "be", "run", "on", "the", "server" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/app/DruidRunner.java#L102-L120
145,673
InferlyticsOSS/druidlet
src/main/java/com/inferlytics/druidlet/app/DruidRunner.java
DruidRunner.stop
public void stop() throws Exception { DruidIndices.getInstance().remove(String.valueOf(port)); server.stop(); }
java
public void stop() throws Exception { DruidIndices.getInstance().remove(String.valueOf(port)); server.stop(); }
[ "public", "void", "stop", "(", ")", "throws", "Exception", "{", "DruidIndices", ".", "getInstance", "(", ")", ".", "remove", "(", "String", ".", "valueOf", "(", "port", ")", ")", ";", "server", ".", "stop", "(", ")", ";", "}" ]
Stops the server and removes the index @throws Exception
[ "Stops", "the", "server", "and", "removes", "the", "index" ]
984beb6519ae9f04df44961553ca2b195521c87d
https://github.com/InferlyticsOSS/druidlet/blob/984beb6519ae9f04df44961553ca2b195521c87d/src/main/java/com/inferlytics/druidlet/app/DruidRunner.java#L136-L139
145,674
OSSIndex/java-api
src/main/java/net/ossindex/common/PackageDescriptor.java
PackageDescriptor.getPmPackageId
public String getPmPackageId() { StringBuilder sb = new StringBuilder(); if (pm != null) sb.append(pm); sb.append(":"); if (group != null) sb.append(group); sb.append(":"); if (name != null) sb.append(name); sb.append(":"); if (version != null) sb.append(version); sb.append(":"); return sb.toString(); }
java
public String getPmPackageId() { StringBuilder sb = new StringBuilder(); if (pm != null) sb.append(pm); sb.append(":"); if (group != null) sb.append(group); sb.append(":"); if (name != null) sb.append(name); sb.append(":"); if (version != null) sb.append(version); sb.append(":"); return sb.toString(); }
[ "public", "String", "getPmPackageId", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "pm", "!=", "null", ")", "sb", ".", "append", "(", "pm", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "if", "(", "group", "!=", "null", ")", "sb", ".", "append", "(", "group", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "if", "(", "name", "!=", "null", ")", "sb", ".", "append", "(", "name", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "if", "(", "version", "!=", "null", ")", "sb", ".", "append", "(", "version", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Get a reasonable unique ID for the package, including the package manager name. @return The package ID
[ "Get", "a", "reasonable", "unique", "ID", "for", "the", "package", "including", "the", "package", "manager", "name", "." ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/PackageDescriptor.java#L147-L158
145,675
OSSIndex/java-api
src/main/java/net/ossindex/common/PackageDescriptor.java
PackageDescriptor.getPackageId
public String getPackageId() { StringBuilder sb = new StringBuilder(); if (group != null) sb.append(group); sb.append(":"); if (name != null) sb.append(name); sb.append(":"); if (version != null) sb.append(version); sb.append(":"); return sb.toString(); }
java
public String getPackageId() { StringBuilder sb = new StringBuilder(); if (group != null) sb.append(group); sb.append(":"); if (name != null) sb.append(name); sb.append(":"); if (version != null) sb.append(version); sb.append(":"); return sb.toString(); }
[ "public", "String", "getPackageId", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "group", "!=", "null", ")", "sb", ".", "append", "(", "group", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "if", "(", "name", "!=", "null", ")", "sb", ".", "append", "(", "name", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "if", "(", "version", "!=", "null", ")", "sb", ".", "append", "(", "version", ")", ";", "sb", ".", "append", "(", "\":\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Get a reasonable unique ID for the package. @return The package ID
[ "Get", "a", "reasonable", "unique", "ID", "for", "the", "package", "." ]
9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f
https://github.com/OSSIndex/java-api/blob/9caca34f08a0ca4a6ec6bdad4102de24d1b3fe0f/src/main/java/net/ossindex/common/PackageDescriptor.java#L164-L173
145,676
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/AuthnContextServiceImpl.java
AuthnContextServiceImpl.toSignMessageURI
protected String toSignMessageURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); if (loa == null) { return null; } if (loa.isSignatureMessageUri()) { return uri; } for (LoaEnum l : LoaEnum.values()) { if (l.getBaseUri().equals(loa.getBaseUri()) && l.isSignatureMessageUri() && l.isNotified() == loa.isNotified()) { return l.getUri(); } } return null; }
java
protected String toSignMessageURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); if (loa == null) { return null; } if (loa.isSignatureMessageUri()) { return uri; } for (LoaEnum l : LoaEnum.values()) { if (l.getBaseUri().equals(loa.getBaseUri()) && l.isSignatureMessageUri() && l.isNotified() == loa.isNotified()) { return l.getUri(); } } return null; }
[ "protected", "String", "toSignMessageURI", "(", "String", "uri", ")", "{", "LoaEnum", "loa", "=", "LoaEnum", ".", "parse", "(", "uri", ")", ";", "if", "(", "loa", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "loa", ".", "isSignatureMessageUri", "(", ")", ")", "{", "return", "uri", ";", "}", "for", "(", "LoaEnum", "l", ":", "LoaEnum", ".", "values", "(", ")", ")", "{", "if", "(", "l", ".", "getBaseUri", "(", ")", ".", "equals", "(", "loa", ".", "getBaseUri", "(", ")", ")", "&&", "l", ".", "isSignatureMessageUri", "(", ")", "&&", "l", ".", "isNotified", "(", ")", "==", "loa", ".", "isNotified", "(", ")", ")", "{", "return", "l", ".", "getUri", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Given a base URI, the method returns its corresponding sigmessage URI. @param uri the URI to transform @return the sigmessage URI, or {@code null} if no such exists
[ "Given", "a", "base", "URI", "the", "method", "returns", "its", "corresponding", "sigmessage", "URI", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/AuthnContextServiceImpl.java#L319-L333
145,677
litsec/swedish-eid-shibboleth-base
shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/AuthnContextServiceImpl.java
AuthnContextServiceImpl.toBaseURI
protected String toBaseURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); if (loa != null && loa.isSignatureMessageUri()) { return LoaEnum.minusSigMessage(loa).getUri(); } return uri; }
java
protected String toBaseURI(String uri) { LoaEnum loa = LoaEnum.parse(uri); if (loa != null && loa.isSignatureMessageUri()) { return LoaEnum.minusSigMessage(loa).getUri(); } return uri; }
[ "protected", "String", "toBaseURI", "(", "String", "uri", ")", "{", "LoaEnum", "loa", "=", "LoaEnum", ".", "parse", "(", "uri", ")", ";", "if", "(", "loa", "!=", "null", "&&", "loa", ".", "isSignatureMessageUri", "(", ")", ")", "{", "return", "LoaEnum", ".", "minusSigMessage", "(", "loa", ")", ".", "getUri", "(", ")", ";", "}", "return", "uri", ";", "}" ]
Given an URI its base form is returned. This means that the URI minus any potential sigmessage extension. @param uri the URI to convert @return the base URI
[ "Given", "an", "URI", "its", "base", "form", "is", "returned", ".", "This", "means", "that", "the", "URI", "minus", "any", "potential", "sigmessage", "extension", "." ]
aaaa467ff61f07d7dfa31627fb36851a37da6804
https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/AuthnContextServiceImpl.java#L342-L348
145,678
javabits/pojo-mbean
pojo-mbean-impl/src/main/java/org/softee/management/helper/MBeanRegistration.java
MBeanRegistration.register
public void register() throws ManagementException { try { DynamicMBean dynamicMBean = new IntrospectedDynamicMBean(mBean); mBeanServer.registerMBean(dynamicMBean, mBeanObjectName); } catch (Exception e) { throw new ManagementException(e); } }
java
public void register() throws ManagementException { try { DynamicMBean dynamicMBean = new IntrospectedDynamicMBean(mBean); mBeanServer.registerMBean(dynamicMBean, mBeanObjectName); } catch (Exception e) { throw new ManagementException(e); } }
[ "public", "void", "register", "(", ")", "throws", "ManagementException", "{", "try", "{", "DynamicMBean", "dynamicMBean", "=", "new", "IntrospectedDynamicMBean", "(", "mBean", ")", ";", "mBeanServer", ".", "registerMBean", "(", "dynamicMBean", ",", "mBeanObjectName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ManagementException", "(", "e", ")", ";", "}", "}" ]
Register the MXBean. If the registration fails, a WARN message is logged @throws java.beans.IntrospectionException @throws IntrospectionException @throws NotCompliantMBeanException @throws MBeanRegistrationException @throws InstanceAlreadyExistsException
[ "Register", "the", "MXBean", ".", "If", "the", "registration", "fails", "a", "WARN", "message", "is", "logged" ]
9aa7fb065e560ec1e3e63373b28cd95ad438b26a
https://github.com/javabits/pojo-mbean/blob/9aa7fb065e560ec1e3e63373b28cd95ad438b26a/pojo-mbean-impl/src/main/java/org/softee/management/helper/MBeanRegistration.java#L74-L81
145,679
flow/commons
src/main/java/com/flowpowered/commons/ticking/Timer.java
Timer.sync
public void sync() { if (nextTick < 0) { throw new IllegalStateException("Timer was not started"); } if (tps <= 0) { return; } try { // Sleep until the average sleep time is greater than the time remaining until next tick for (long time1 = getTime(), time2; nextTick - time1 > sleepDurations.average(); time1 = time2) { Thread.sleep(1); // Update average sleep time sleepDurations.add((time2 = getTime()) - time1); } // Slowly dampen sleep average if too high to avoid yielding too much sleepDurations.dampen(); // Yield until the average yield time is greater than the time remaining until next tick for (long time1 = getTime(), time2; nextTick - time1 > yieldDurations.average(); time1 = time2) { Thread.yield(); // Update average yield time yieldDurations.add((time2 = getTime()) - time1); } } catch (InterruptedException ignored) { } // Schedule next frame, drop frames if it's too late for next frame nextTick = Math.max(nextTick + 1000000000 / tps, getTime()); }
java
public void sync() { if (nextTick < 0) { throw new IllegalStateException("Timer was not started"); } if (tps <= 0) { return; } try { // Sleep until the average sleep time is greater than the time remaining until next tick for (long time1 = getTime(), time2; nextTick - time1 > sleepDurations.average(); time1 = time2) { Thread.sleep(1); // Update average sleep time sleepDurations.add((time2 = getTime()) - time1); } // Slowly dampen sleep average if too high to avoid yielding too much sleepDurations.dampen(); // Yield until the average yield time is greater than the time remaining until next tick for (long time1 = getTime(), time2; nextTick - time1 > yieldDurations.average(); time1 = time2) { Thread.yield(); // Update average yield time yieldDurations.add((time2 = getTime()) - time1); } } catch (InterruptedException ignored) { } // Schedule next frame, drop frames if it's too late for next frame nextTick = Math.max(nextTick + 1000000000 / tps, getTime()); }
[ "public", "void", "sync", "(", ")", "{", "if", "(", "nextTick", "<", "0", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Timer was not started\"", ")", ";", "}", "if", "(", "tps", "<=", "0", ")", "{", "return", ";", "}", "try", "{", "// Sleep until the average sleep time is greater than the time remaining until next tick", "for", "(", "long", "time1", "=", "getTime", "(", ")", ",", "time2", ";", "nextTick", "-", "time1", ">", "sleepDurations", ".", "average", "(", ")", ";", "time1", "=", "time2", ")", "{", "Thread", ".", "sleep", "(", "1", ")", ";", "// Update average sleep time", "sleepDurations", ".", "add", "(", "(", "time2", "=", "getTime", "(", ")", ")", "-", "time1", ")", ";", "}", "// Slowly dampen sleep average if too high to avoid yielding too much", "sleepDurations", ".", "dampen", "(", ")", ";", "// Yield until the average yield time is greater than the time remaining until next tick", "for", "(", "long", "time1", "=", "getTime", "(", ")", ",", "time2", ";", "nextTick", "-", "time1", ">", "yieldDurations", ".", "average", "(", ")", ";", "time1", "=", "time2", ")", "{", "Thread", ".", "yield", "(", ")", ";", "// Update average yield time", "yieldDurations", ".", "add", "(", "(", "time2", "=", "getTime", "(", ")", ")", "-", "time1", ")", ";", "}", "}", "catch", "(", "InterruptedException", "ignored", ")", "{", "}", "// Schedule next frame, drop frames if it's too late for next frame", "nextTick", "=", "Math", ".", "max", "(", "nextTick", "+", "1000000000", "/", "tps", ",", "getTime", "(", ")", ")", ";", "}" ]
An accurate sync method that will attempt to run at the tps. It should be called once every tick.
[ "An", "accurate", "sync", "method", "that", "will", "attempt", "to", "run", "at", "the", "tps", ".", "It", "should", "be", "called", "once", "every", "tick", "." ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/ticking/Timer.java#L98-L124
145,680
flow/commons
src/main/java/com/flowpowered/commons/hashing/Int10TripleHashed.java
Int10TripleHashed.setBase
public final void setBase(int bx, int by, int bz) { this.bx = bx; this.by = by; this.bz = bz; }
java
public final void setBase(int bx, int by, int bz) { this.bx = bx; this.by = by; this.bz = bz; }
[ "public", "final", "void", "setBase", "(", "int", "bx", ",", "int", "by", ",", "int", "bz", ")", "{", "this", ".", "bx", "=", "bx", ";", "this", ".", "by", "=", "by", ";", "this", ".", "bz", "=", "bz", ";", "}" ]
Sets the base of the hash to the given values
[ "Sets", "the", "base", "of", "the", "hash", "to", "the", "given", "values" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/hashing/Int10TripleHashed.java#L43-L47
145,681
politie/cinch
src/main/java/eu/icolumbo/cinch/SpringContext.java
SpringContext.getContext
public static synchronized AbstractApplicationContext getContext(Class<?> springConfigurationClass) { if (!CONTEXTS.containsKey(springConfigurationClass)) { AbstractApplicationContext context = new AnnotationConfigApplicationContext(springConfigurationClass); context.registerShutdownHook(); CONTEXTS.put(springConfigurationClass, context); } return CONTEXTS.get(springConfigurationClass); }
java
public static synchronized AbstractApplicationContext getContext(Class<?> springConfigurationClass) { if (!CONTEXTS.containsKey(springConfigurationClass)) { AbstractApplicationContext context = new AnnotationConfigApplicationContext(springConfigurationClass); context.registerShutdownHook(); CONTEXTS.put(springConfigurationClass, context); } return CONTEXTS.get(springConfigurationClass); }
[ "public", "static", "synchronized", "AbstractApplicationContext", "getContext", "(", "Class", "<", "?", ">", "springConfigurationClass", ")", "{", "if", "(", "!", "CONTEXTS", ".", "containsKey", "(", "springConfigurationClass", ")", ")", "{", "AbstractApplicationContext", "context", "=", "new", "AnnotationConfigApplicationContext", "(", "springConfigurationClass", ")", ";", "context", ".", "registerShutdownHook", "(", ")", ";", "CONTEXTS", ".", "put", "(", "springConfigurationClass", ",", "context", ")", ";", "}", "return", "CONTEXTS", ".", "get", "(", "springConfigurationClass", ")", ";", "}" ]
Get application context for configuration class.
[ "Get", "application", "context", "for", "configuration", "class", "." ]
1986b16d397be343a4e1a3f372f14981f70d5de3
https://github.com/politie/cinch/blob/1986b16d397be343a4e1a3f372f14981f70d5de3/src/main/java/eu/icolumbo/cinch/SpringContext.java#L19-L27
145,682
flow/commons
src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntPaletteBackingArray.java
AtomicShortIntPaletteBackingArray.getId
private int getId(int value) throws PaletteFullException { short id = idLookup.get(value); if (!idLookup.isEmptyValue(id)) { return id; } else { id = (short) paletteCounter.getAndIncrement(); if (id >= paletteSize) { throw new PaletteFullException(); } short oldId = idLookup.putIfAbsent(value, id); if (!idLookup.isEmptyValue(oldId)) { id = oldId; } palette.set(id, value); return id; } }
java
private int getId(int value) throws PaletteFullException { short id = idLookup.get(value); if (!idLookup.isEmptyValue(id)) { return id; } else { id = (short) paletteCounter.getAndIncrement(); if (id >= paletteSize) { throw new PaletteFullException(); } short oldId = idLookup.putIfAbsent(value, id); if (!idLookup.isEmptyValue(oldId)) { id = oldId; } palette.set(id, value); return id; } }
[ "private", "int", "getId", "(", "int", "value", ")", "throws", "PaletteFullException", "{", "short", "id", "=", "idLookup", ".", "get", "(", "value", ")", ";", "if", "(", "!", "idLookup", ".", "isEmptyValue", "(", "id", ")", ")", "{", "return", "id", ";", "}", "else", "{", "id", "=", "(", "short", ")", "paletteCounter", ".", "getAndIncrement", "(", ")", ";", "if", "(", "id", ">=", "paletteSize", ")", "{", "throw", "new", "PaletteFullException", "(", ")", ";", "}", "short", "oldId", "=", "idLookup", ".", "putIfAbsent", "(", "value", ",", "id", ")", ";", "if", "(", "!", "idLookup", ".", "isEmptyValue", "(", "oldId", ")", ")", "{", "id", "=", "oldId", ";", "}", "palette", ".", "set", "(", "id", ",", "value", ")", ";", "return", "id", ";", "}", "}" ]
Gets the id for the given value, allocating an id if required @return the id
[ "Gets", "the", "id", "for", "the", "given", "value", "allocating", "an", "id", "if", "required" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/store/block/impl/AtomicShortIntPaletteBackingArray.java#L166-L182
145,683
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.sdpHasVideo
public static boolean sdpHasVideo(JSONObject sdp) { boolean hasVideo = false; if (null != sdp) { try { String sdpString = sdp.getString("sdp"); hasVideo = sdpString.contains("m=video"); } catch (JSONException e) { // Bad SDP? Log.d(TAG, "ERROR: Incoming call appears to have an invalid SDP"); } } return hasVideo; }
java
public static boolean sdpHasVideo(JSONObject sdp) { boolean hasVideo = false; if (null != sdp) { try { String sdpString = sdp.getString("sdp"); hasVideo = sdpString.contains("m=video"); } catch (JSONException e) { // Bad SDP? Log.d(TAG, "ERROR: Incoming call appears to have an invalid SDP"); } } return hasVideo; }
[ "public", "static", "boolean", "sdpHasVideo", "(", "JSONObject", "sdp", ")", "{", "boolean", "hasVideo", "=", "false", ";", "if", "(", "null", "!=", "sdp", ")", "{", "try", "{", "String", "sdpString", "=", "sdp", ".", "getString", "(", "\"sdp\"", ")", ";", "hasVideo", "=", "sdpString", ".", "contains", "(", "\"m=video\"", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "// Bad SDP?", "Log", ".", "d", "(", "TAG", ",", "\"ERROR: Incoming call appears to have an invalid SDP\"", ")", ";", "}", "}", "return", "hasVideo", ";", "}" ]
Determines if the specified SDP data contains definitions for a video stream @param sdp The SDP data to examine @return True if a video stream definition is present, false otherwise
[ "Determines", "if", "the", "specified", "SDP", "data", "contains", "definitions", "for", "a", "video", "stream" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L138-L152
145,684
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.commonConstructor
private void commonConstructor(RespokeSignalingChannel channel) { signalingChannel = channel; iceServers = new ArrayList<PeerConnection.IceServer>(); queuedLocalCandidates = new ArrayList<IceCandidate>(); queuedRemoteCandidates = new ArrayList<IceCandidate>(); collectedLocalCandidates = new ArrayList<IceCandidate>(); sessionID = Respoke.makeGUID(); timestamp = new Date(); queuedRemoteCandidatesSemaphore = new Semaphore(1); // remote candidates queue mutex localCandidatesSemaphore = new Semaphore(1); // local candidates queue mutex if (null != signalingChannel) { RespokeSignalingChannel.Listener signalingChannelListener = signalingChannel.GetListener(); if (null != signalingChannelListener) { signalingChannelListener.callCreated(this); } } //TODO resign active handler? }
java
private void commonConstructor(RespokeSignalingChannel channel) { signalingChannel = channel; iceServers = new ArrayList<PeerConnection.IceServer>(); queuedLocalCandidates = new ArrayList<IceCandidate>(); queuedRemoteCandidates = new ArrayList<IceCandidate>(); collectedLocalCandidates = new ArrayList<IceCandidate>(); sessionID = Respoke.makeGUID(); timestamp = new Date(); queuedRemoteCandidatesSemaphore = new Semaphore(1); // remote candidates queue mutex localCandidatesSemaphore = new Semaphore(1); // local candidates queue mutex if (null != signalingChannel) { RespokeSignalingChannel.Listener signalingChannelListener = signalingChannel.GetListener(); if (null != signalingChannelListener) { signalingChannelListener.callCreated(this); } } //TODO resign active handler? }
[ "private", "void", "commonConstructor", "(", "RespokeSignalingChannel", "channel", ")", "{", "signalingChannel", "=", "channel", ";", "iceServers", "=", "new", "ArrayList", "<", "PeerConnection", ".", "IceServer", ">", "(", ")", ";", "queuedLocalCandidates", "=", "new", "ArrayList", "<", "IceCandidate", ">", "(", ")", ";", "queuedRemoteCandidates", "=", "new", "ArrayList", "<", "IceCandidate", ">", "(", ")", ";", "collectedLocalCandidates", "=", "new", "ArrayList", "<", "IceCandidate", ">", "(", ")", ";", "sessionID", "=", "Respoke", ".", "makeGUID", "(", ")", ";", "timestamp", "=", "new", "Date", "(", ")", ";", "queuedRemoteCandidatesSemaphore", "=", "new", "Semaphore", "(", "1", ")", ";", "// remote candidates queue mutex", "localCandidatesSemaphore", "=", "new", "Semaphore", "(", "1", ")", ";", "// local candidates queue mutex", "if", "(", "null", "!=", "signalingChannel", ")", "{", "RespokeSignalingChannel", ".", "Listener", "signalingChannelListener", "=", "signalingChannel", ".", "GetListener", "(", ")", ";", "if", "(", "null", "!=", "signalingChannelListener", ")", "{", "signalingChannelListener", ".", "callCreated", "(", "this", ")", ";", "}", "}", "//TODO resign active handler?", "}" ]
Common constructor logic @param channel The signaling channel to use for the call
[ "Common", "constructor", "logic" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L229-L248
145,685
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.startCall
public void startCall(final Context context, GLSurfaceView glView, boolean isAudioOnly) { caller = true; audioOnly = isAudioOnly; if (directConnectionOnly) { if (null == directConnection) { actuallyAddDirectConnection(); } directConnectionDidAccept(context); } else { attachVideoRenderer(glView); getTurnServerCredentials(new Respoke.TaskCompletionListener() { @Override public void onSuccess() { Log.d(TAG, "Got TURN credentials"); initializePeerConnection(context); addLocalStreams(context); createOffer(); } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } }
java
public void startCall(final Context context, GLSurfaceView glView, boolean isAudioOnly) { caller = true; audioOnly = isAudioOnly; if (directConnectionOnly) { if (null == directConnection) { actuallyAddDirectConnection(); } directConnectionDidAccept(context); } else { attachVideoRenderer(glView); getTurnServerCredentials(new Respoke.TaskCompletionListener() { @Override public void onSuccess() { Log.d(TAG, "Got TURN credentials"); initializePeerConnection(context); addLocalStreams(context); createOffer(); } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } }
[ "public", "void", "startCall", "(", "final", "Context", "context", ",", "GLSurfaceView", "glView", ",", "boolean", "isAudioOnly", ")", "{", "caller", "=", "true", ";", "audioOnly", "=", "isAudioOnly", ";", "if", "(", "directConnectionOnly", ")", "{", "if", "(", "null", "==", "directConnection", ")", "{", "actuallyAddDirectConnection", "(", ")", ";", "}", "directConnectionDidAccept", "(", "context", ")", ";", "}", "else", "{", "attachVideoRenderer", "(", "glView", ")", ";", "getTurnServerCredentials", "(", "new", "Respoke", ".", "TaskCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Got TURN credentials\"", ")", ";", "initializePeerConnection", "(", "context", ")", ";", "addLocalStreams", "(", "context", ")", ";", "createOffer", "(", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "String", "errorMessage", ")", "{", "postErrorToListener", "(", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "}" ]
Start the outgoing call process. This method is used internally by the SDK and should never be called directly from your client application @param context An application context with which to access shared resources @param glView The GLSurfaceView on which to render video if applicable @param isAudioOnly Specify true if this call should be audio only
[ "Start", "the", "outgoing", "call", "process", ".", "This", "method", "is", "used", "internally", "by", "the", "SDK", "and", "should", "never", "be", "called", "directly", "from", "your", "client", "application" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L278-L306
145,686
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.attachVideoRenderer
public void attachVideoRenderer(GLSurfaceView glView) { if (null != glView) { VideoRendererGui.setView(glView, new Runnable() { @Override public void run() { Log.d(TAG, "VideoRendererGui GL Context ready"); } }); remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); localRender = VideoRendererGui.create(70, 5, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); } }
java
public void attachVideoRenderer(GLSurfaceView glView) { if (null != glView) { VideoRendererGui.setView(glView, new Runnable() { @Override public void run() { Log.d(TAG, "VideoRendererGui GL Context ready"); } }); remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); localRender = VideoRendererGui.create(70, 5, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); } }
[ "public", "void", "attachVideoRenderer", "(", "GLSurfaceView", "glView", ")", "{", "if", "(", "null", "!=", "glView", ")", "{", "VideoRendererGui", ".", "setView", "(", "glView", ",", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"VideoRendererGui GL Context ready\"", ")", ";", "}", "}", ")", ";", "remoteRender", "=", "VideoRendererGui", ".", "create", "(", "0", ",", "0", ",", "100", ",", "100", ",", "VideoRendererGui", ".", "ScalingType", ".", "SCALE_ASPECT_FILL", ",", "false", ")", ";", "localRender", "=", "VideoRendererGui", ".", "create", "(", "70", ",", "5", ",", "25", ",", "25", ",", "VideoRendererGui", ".", "ScalingType", ".", "SCALE_ASPECT_FILL", ",", "false", ")", ";", "}", "}" ]
Attach the call's video renderers to the specified GLSurfaceView @param glView The GLSurfaceView on which to render video
[ "Attach", "the", "call", "s", "video", "renderers", "to", "the", "specified", "GLSurfaceView" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L314-L328
145,687
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.answer
public void answer(final Context context, Listener newListener) { if (!caller) { listenerReference = new WeakReference<Listener>(newListener); getTurnServerCredentials(new Respoke.TaskCompletionListener() { @Override public void onSuccess() { initializePeerConnection(context); addLocalStreams(context); processRemoteSDP(); } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } }
java
public void answer(final Context context, Listener newListener) { if (!caller) { listenerReference = new WeakReference<Listener>(newListener); getTurnServerCredentials(new Respoke.TaskCompletionListener() { @Override public void onSuccess() { initializePeerConnection(context); addLocalStreams(context); processRemoteSDP(); } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } }
[ "public", "void", "answer", "(", "final", "Context", "context", ",", "Listener", "newListener", ")", "{", "if", "(", "!", "caller", ")", "{", "listenerReference", "=", "new", "WeakReference", "<", "Listener", ">", "(", "newListener", ")", ";", "getTurnServerCredentials", "(", "new", "Respoke", ".", "TaskCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", ")", "{", "initializePeerConnection", "(", "context", ")", ";", "addLocalStreams", "(", "context", ")", ";", "processRemoteSDP", "(", ")", ";", "}", "@", "Override", "public", "void", "onError", "(", "String", "errorMessage", ")", "{", "postErrorToListener", "(", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "}" ]
Answer the call and start the process of obtaining media. This method is called automatically on the caller's side. This method must be called on the callee's side to indicate that the endpoint does wish to accept the call. @param context An application context with which to access shared resources @param newListener A listener to receive notifications of call-related events
[ "Answer", "the", "call", "and", "start", "the", "process", "of", "obtaining", "media", ".", "This", "method", "is", "called", "automatically", "on", "the", "caller", "s", "side", ".", "This", "method", "must", "be", "called", "on", "the", "callee", "s", "side", "to", "indicate", "that", "the", "endpoint", "does", "wish", "to", "accept", "the", "call", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L339-L357
145,688
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.hangup
public void hangup(boolean shouldSendHangupSignal) { if (!isHangingUp) { isHangingUp = true; if (shouldSendHangupSignal) { try { JSONObject data = new JSONObject("{'signalType':'bye','version':'1.0'}"); data.put("target", directConnectionOnly ? "directConnection" : "call"); data.put("sessionId", sessionID); data.put("signalId", Respoke.makeGUID()); // Keep a second reference to the listener since the disconnect method will clear it before the success handler is fired final WeakReference<Listener> hangupListener = listenerReference; if (null != signalingChannel) { signalingChannel.sendSignal(data, toEndpointId, toConnection, toType, true, new Respoke.TaskCompletionListener() { @Override public void onSuccess() { if (null != hangupListener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { Listener listener = hangupListener.get(); if (null != listener) { listener.onHangup(RespokeCall.this); } } }); } } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } } catch (JSONException e) { postErrorToListener("Error encoding signal to json"); } } disconnect(); } }
java
public void hangup(boolean shouldSendHangupSignal) { if (!isHangingUp) { isHangingUp = true; if (shouldSendHangupSignal) { try { JSONObject data = new JSONObject("{'signalType':'bye','version':'1.0'}"); data.put("target", directConnectionOnly ? "directConnection" : "call"); data.put("sessionId", sessionID); data.put("signalId", Respoke.makeGUID()); // Keep a second reference to the listener since the disconnect method will clear it before the success handler is fired final WeakReference<Listener> hangupListener = listenerReference; if (null != signalingChannel) { signalingChannel.sendSignal(data, toEndpointId, toConnection, toType, true, new Respoke.TaskCompletionListener() { @Override public void onSuccess() { if (null != hangupListener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { Listener listener = hangupListener.get(); if (null != listener) { listener.onHangup(RespokeCall.this); } } }); } } @Override public void onError(String errorMessage) { postErrorToListener(errorMessage); } }); } } catch (JSONException e) { postErrorToListener("Error encoding signal to json"); } } disconnect(); } }
[ "public", "void", "hangup", "(", "boolean", "shouldSendHangupSignal", ")", "{", "if", "(", "!", "isHangingUp", ")", "{", "isHangingUp", "=", "true", ";", "if", "(", "shouldSendHangupSignal", ")", "{", "try", "{", "JSONObject", "data", "=", "new", "JSONObject", "(", "\"{'signalType':'bye','version':'1.0'}\"", ")", ";", "data", ".", "put", "(", "\"target\"", ",", "directConnectionOnly", "?", "\"directConnection\"", ":", "\"call\"", ")", ";", "data", ".", "put", "(", "\"sessionId\"", ",", "sessionID", ")", ";", "data", ".", "put", "(", "\"signalId\"", ",", "Respoke", ".", "makeGUID", "(", ")", ")", ";", "// Keep a second reference to the listener since the disconnect method will clear it before the success handler is fired", "final", "WeakReference", "<", "Listener", ">", "hangupListener", "=", "listenerReference", ";", "if", "(", "null", "!=", "signalingChannel", ")", "{", "signalingChannel", ".", "sendSignal", "(", "data", ",", "toEndpointId", ",", "toConnection", ",", "toType", ",", "true", ",", "new", "Respoke", ".", "TaskCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", ")", "{", "if", "(", "null", "!=", "hangupListener", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Listener", "listener", "=", "hangupListener", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onHangup", "(", "RespokeCall", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}", "}", "@", "Override", "public", "void", "onError", "(", "String", "errorMessage", ")", "{", "postErrorToListener", "(", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "postErrorToListener", "(", "\"Error encoding signal to json\"", ")", ";", "}", "}", "disconnect", "(", ")", ";", "}", "}" ]
Tear down the call and release resources @param shouldSendHangupSignal Send a hangup signal to the remote party if signal is not false and we have not received a hangup signal from the remote party.
[ "Tear", "down", "the", "call", "and", "release", "resources" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L365-L409
145,689
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.muteVideo
public void muteVideo(boolean mute) { if (!audioOnly && (null != localStream) && (isActive())) { for (MediaStreamTrack eachTrack : localStream.videoTracks) { eachTrack.setEnabled(!mute); } } }
java
public void muteVideo(boolean mute) { if (!audioOnly && (null != localStream) && (isActive())) { for (MediaStreamTrack eachTrack : localStream.videoTracks) { eachTrack.setEnabled(!mute); } } }
[ "public", "void", "muteVideo", "(", "boolean", "mute", ")", "{", "if", "(", "!", "audioOnly", "&&", "(", "null", "!=", "localStream", ")", "&&", "(", "isActive", "(", ")", ")", ")", "{", "for", "(", "MediaStreamTrack", "eachTrack", ":", "localStream", ".", "videoTracks", ")", "{", "eachTrack", ".", "setEnabled", "(", "!", "mute", ")", ";", "}", "}", "}" ]
Mute or unmute the local video @param mute If true, mute the video. If false, unmute the video
[ "Mute", "or", "unmute", "the", "local", "video" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L417-L423
145,690
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.videoIsMuted
public boolean videoIsMuted() { boolean isMuted = true; if (!audioOnly && (null != localStream)) { for (MediaStreamTrack eachTrack : localStream.videoTracks) { if (eachTrack.enabled()) { isMuted = false; } } } return isMuted; }
java
public boolean videoIsMuted() { boolean isMuted = true; if (!audioOnly && (null != localStream)) { for (MediaStreamTrack eachTrack : localStream.videoTracks) { if (eachTrack.enabled()) { isMuted = false; } } } return isMuted; }
[ "public", "boolean", "videoIsMuted", "(", ")", "{", "boolean", "isMuted", "=", "true", ";", "if", "(", "!", "audioOnly", "&&", "(", "null", "!=", "localStream", ")", ")", "{", "for", "(", "MediaStreamTrack", "eachTrack", ":", "localStream", ".", "videoTracks", ")", "{", "if", "(", "eachTrack", ".", "enabled", "(", ")", ")", "{", "isMuted", "=", "false", ";", "}", "}", "}", "return", "isMuted", ";", "}" ]
Indicates if the local video stream is muted @return returns true if the local video stream is currently muted
[ "Indicates", "if", "the", "local", "video", "stream", "is", "muted" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L431-L443
145,691
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.muteAudio
public void muteAudio(boolean mute) { if ((null != localStream) && isActive()) { for (MediaStreamTrack eachTrack : localStream.audioTracks) { eachTrack.setEnabled(!mute); } } }
java
public void muteAudio(boolean mute) { if ((null != localStream) && isActive()) { for (MediaStreamTrack eachTrack : localStream.audioTracks) { eachTrack.setEnabled(!mute); } } }
[ "public", "void", "muteAudio", "(", "boolean", "mute", ")", "{", "if", "(", "(", "null", "!=", "localStream", ")", "&&", "isActive", "(", ")", ")", "{", "for", "(", "MediaStreamTrack", "eachTrack", ":", "localStream", ".", "audioTracks", ")", "{", "eachTrack", ".", "setEnabled", "(", "!", "mute", ")", ";", "}", "}", "}" ]
Mute or unmute the local audio @param mute If true, mute the audio. If false, unmute the audio
[ "Mute", "or", "unmute", "the", "local", "audio" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L451-L457
145,692
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.audioIsMuted
public boolean audioIsMuted() { boolean isMuted = true; if (null != localStream) { for (MediaStreamTrack eachTrack : localStream.audioTracks) { if (eachTrack.enabled()) { isMuted = false; } } } return isMuted; }
java
public boolean audioIsMuted() { boolean isMuted = true; if (null != localStream) { for (MediaStreamTrack eachTrack : localStream.audioTracks) { if (eachTrack.enabled()) { isMuted = false; } } } return isMuted; }
[ "public", "boolean", "audioIsMuted", "(", ")", "{", "boolean", "isMuted", "=", "true", ";", "if", "(", "null", "!=", "localStream", ")", "{", "for", "(", "MediaStreamTrack", "eachTrack", ":", "localStream", ".", "audioTracks", ")", "{", "if", "(", "eachTrack", ".", "enabled", "(", ")", ")", "{", "isMuted", "=", "false", ";", "}", "}", "}", "return", "isMuted", ";", "}" ]
Indicates if the local audio stream is muted @return returns true if the local audio stream is currently muted
[ "Indicates", "if", "the", "local", "audio", "stream", "is", "muted" ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L465-L477
145,693
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.hangupReceived
public void hangupReceived() { if (!isHangingUp) { isHangingUp = true; if (null != listenerReference) { // Disconnect will clear the listenerReference, so grab a reference to the // listener while it's still alive since the listener will be notified in a // different (UI) thread final Listener listener = listenerReference.get(); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listener) { listener.onHangup(RespokeCall.this); } } }); } disconnect(); } }
java
public void hangupReceived() { if (!isHangingUp) { isHangingUp = true; if (null != listenerReference) { // Disconnect will clear the listenerReference, so grab a reference to the // listener while it's still alive since the listener will be notified in a // different (UI) thread final Listener listener = listenerReference.get(); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (null != listener) { listener.onHangup(RespokeCall.this); } } }); } disconnect(); } }
[ "public", "void", "hangupReceived", "(", ")", "{", "if", "(", "!", "isHangingUp", ")", "{", "isHangingUp", "=", "true", ";", "if", "(", "null", "!=", "listenerReference", ")", "{", "// Disconnect will clear the listenerReference, so grab a reference to the", "// listener while it's still alive since the listener will be notified in a", "// different (UI) thread", "final", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "null", "!=", "listener", ")", "{", "listener", ".", "onHangup", "(", "RespokeCall", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}", "disconnect", "(", ")", ";", "}", "}" ]
Process a hangup message received from the remote endpoint. This is used internally to the SDK and should not be called directly by your client application.
[ "Process", "a", "hangup", "message", "received", "from", "the", "remote", "endpoint", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L504-L525
145,694
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.answerReceived
public void answerReceived(JSONObject remoteSDP, String remoteConnection) { if (isActive()) { incomingSDP = remoteSDP; toConnection = remoteConnection; try { JSONObject signalData = new JSONObject("{'signalType':'connected','version':'1.0'}"); signalData.put("target", directConnectionOnly ? "directConnection" : "call"); signalData.put("connectionId", toConnection); signalData.put("sessionId", sessionID); signalData.put("signalId", Respoke.makeGUID()); if (null != signalingChannel) { signalingChannel.sendSignal(signalData, toEndpointId, toConnection, toType, false, new Respoke.TaskCompletionListener() { @Override public void onSuccess() { if (isActive()) { processRemoteSDP(); if (null != listenerReference) { final Listener listener = listenerReference.get(); if (null != listener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { listener.onConnected(RespokeCall.this); } } }); } } } } @Override public void onError(final String errorMessage) { postErrorToListener(errorMessage); } }); } } catch (JSONException e) { postErrorToListener("Error encoding answer signal"); } } }
java
public void answerReceived(JSONObject remoteSDP, String remoteConnection) { if (isActive()) { incomingSDP = remoteSDP; toConnection = remoteConnection; try { JSONObject signalData = new JSONObject("{'signalType':'connected','version':'1.0'}"); signalData.put("target", directConnectionOnly ? "directConnection" : "call"); signalData.put("connectionId", toConnection); signalData.put("sessionId", sessionID); signalData.put("signalId", Respoke.makeGUID()); if (null != signalingChannel) { signalingChannel.sendSignal(signalData, toEndpointId, toConnection, toType, false, new Respoke.TaskCompletionListener() { @Override public void onSuccess() { if (isActive()) { processRemoteSDP(); if (null != listenerReference) { final Listener listener = listenerReference.get(); if (null != listener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { listener.onConnected(RespokeCall.this); } } }); } } } } @Override public void onError(final String errorMessage) { postErrorToListener(errorMessage); } }); } } catch (JSONException e) { postErrorToListener("Error encoding answer signal"); } } }
[ "public", "void", "answerReceived", "(", "JSONObject", "remoteSDP", ",", "String", "remoteConnection", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "incomingSDP", "=", "remoteSDP", ";", "toConnection", "=", "remoteConnection", ";", "try", "{", "JSONObject", "signalData", "=", "new", "JSONObject", "(", "\"{'signalType':'connected','version':'1.0'}\"", ")", ";", "signalData", ".", "put", "(", "\"target\"", ",", "directConnectionOnly", "?", "\"directConnection\"", ":", "\"call\"", ")", ";", "signalData", ".", "put", "(", "\"connectionId\"", ",", "toConnection", ")", ";", "signalData", ".", "put", "(", "\"sessionId\"", ",", "sessionID", ")", ";", "signalData", ".", "put", "(", "\"signalId\"", ",", "Respoke", ".", "makeGUID", "(", ")", ")", ";", "if", "(", "null", "!=", "signalingChannel", ")", "{", "signalingChannel", ".", "sendSignal", "(", "signalData", ",", "toEndpointId", ",", "toConnection", ",", "toType", ",", "false", ",", "new", "Respoke", ".", "TaskCompletionListener", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "processRemoteSDP", "(", ")", ";", "if", "(", "null", "!=", "listenerReference", ")", "{", "final", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "listener", ".", "onConnected", "(", "RespokeCall", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}", "}", "@", "Override", "public", "void", "onError", "(", "final", "String", "errorMessage", ")", "{", "postErrorToListener", "(", "errorMessage", ")", ";", "}", "}", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "postErrorToListener", "(", "\"Error encoding answer signal\"", ")", ";", "}", "}", "}" ]
Process an answer message received from the remote endpoint. This is used internally to the SDK and should not be called directly by your client application. @param remoteSDP Remote SDP data @param remoteConnection Remote connection that answered the call
[ "Process", "an", "answer", "message", "received", "from", "the", "remote", "endpoint", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L534-L578
145,695
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.connectedReceived
public void connectedReceived() { if (null != listenerReference) { final Listener listener = listenerReference.get(); if (null != listener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { listener.onConnected(RespokeCall.this); } } }); } } }
java
public void connectedReceived() { if (null != listenerReference) { final Listener listener = listenerReference.get(); if (null != listener) { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { listener.onConnected(RespokeCall.this); } } }); } } }
[ "public", "void", "connectedReceived", "(", ")", "{", "if", "(", "null", "!=", "listenerReference", ")", "{", "final", "Listener", "listener", "=", "listenerReference", ".", "get", "(", ")", ";", "if", "(", "null", "!=", "listener", ")", "{", "new", "Handler", "(", "Looper", ".", "getMainLooper", "(", ")", ")", ".", "post", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "listener", ".", "onConnected", "(", "RespokeCall", ".", "this", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}" ]
Process a connected messsage received from the remote endpoint. This is used internally to the SDK and should not be called directly by your client application.
[ "Process", "a", "connected", "messsage", "received", "from", "the", "remote", "endpoint", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L584-L597
145,696
respoke/respoke-sdk-android
respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java
RespokeCall.iceCandidatesReceived
public void iceCandidatesReceived(JSONArray candidates) { if (isActive()) { for (int ii = 0; ii < candidates.length(); ii++) { try { JSONObject eachCandidate = (JSONObject) candidates.get(ii); String mid = eachCandidate.getString("sdpMid"); int sdpLineIndex = eachCandidate.getInt("sdpMLineIndex"); String sdp = eachCandidate.getString("candidate"); IceCandidate rtcCandidate = new IceCandidate(mid, sdpLineIndex, sdp); try { // Start critical block queuedRemoteCandidatesSemaphore.acquire(); if (null != queuedRemoteCandidates) { queuedRemoteCandidates.add(rtcCandidate); } else { peerConnection.addIceCandidate(rtcCandidate); } // End critical block queuedRemoteCandidatesSemaphore.release(); } catch (InterruptedException e) { Log.d(TAG, "Error with remote candidates semaphore"); } } catch (JSONException e) { Log.d(TAG, "Error processing remote ice candidate data"); } } } }
java
public void iceCandidatesReceived(JSONArray candidates) { if (isActive()) { for (int ii = 0; ii < candidates.length(); ii++) { try { JSONObject eachCandidate = (JSONObject) candidates.get(ii); String mid = eachCandidate.getString("sdpMid"); int sdpLineIndex = eachCandidate.getInt("sdpMLineIndex"); String sdp = eachCandidate.getString("candidate"); IceCandidate rtcCandidate = new IceCandidate(mid, sdpLineIndex, sdp); try { // Start critical block queuedRemoteCandidatesSemaphore.acquire(); if (null != queuedRemoteCandidates) { queuedRemoteCandidates.add(rtcCandidate); } else { peerConnection.addIceCandidate(rtcCandidate); } // End critical block queuedRemoteCandidatesSemaphore.release(); } catch (InterruptedException e) { Log.d(TAG, "Error with remote candidates semaphore"); } } catch (JSONException e) { Log.d(TAG, "Error processing remote ice candidate data"); } } } }
[ "public", "void", "iceCandidatesReceived", "(", "JSONArray", "candidates", ")", "{", "if", "(", "isActive", "(", ")", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "candidates", ".", "length", "(", ")", ";", "ii", "++", ")", "{", "try", "{", "JSONObject", "eachCandidate", "=", "(", "JSONObject", ")", "candidates", ".", "get", "(", "ii", ")", ";", "String", "mid", "=", "eachCandidate", ".", "getString", "(", "\"sdpMid\"", ")", ";", "int", "sdpLineIndex", "=", "eachCandidate", ".", "getInt", "(", "\"sdpMLineIndex\"", ")", ";", "String", "sdp", "=", "eachCandidate", ".", "getString", "(", "\"candidate\"", ")", ";", "IceCandidate", "rtcCandidate", "=", "new", "IceCandidate", "(", "mid", ",", "sdpLineIndex", ",", "sdp", ")", ";", "try", "{", "// Start critical block", "queuedRemoteCandidatesSemaphore", ".", "acquire", "(", ")", ";", "if", "(", "null", "!=", "queuedRemoteCandidates", ")", "{", "queuedRemoteCandidates", ".", "add", "(", "rtcCandidate", ")", ";", "}", "else", "{", "peerConnection", ".", "addIceCandidate", "(", "rtcCandidate", ")", ";", "}", "// End critical block", "queuedRemoteCandidatesSemaphore", ".", "release", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Error with remote candidates semaphore\"", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Error processing remote ice candidate data\"", ")", ";", "}", "}", "}", "}" ]
Process ICE candidates suggested by the remote endpoint. This is used internally to the SDK and should not be called directly by your client application. @param candidates Array of candidates to evaluate
[ "Process", "ICE", "candidates", "suggested", "by", "the", "remote", "endpoint", ".", "This", "is", "used", "internally", "to", "the", "SDK", "and", "should", "not", "be", "called", "directly", "by", "your", "client", "application", "." ]
34a15f0558d29b1f1bc8481bbc5c505e855e05ef
https://github.com/respoke/respoke-sdk-android/blob/34a15f0558d29b1f1bc8481bbc5c505e855e05ef/respokeSDK/src/main/java/com/digium/respokesdk/RespokeCall.java#L605-L637
145,697
flow/commons
src/main/java/com/flowpowered/commons/hashing/SignedTenBitTripleHashed.java
SignedTenBitTripleHashed.add
public static int add(int key, int x, int y, int z) { int offset = key(x, y, z); return (key + offset) & mask; }
java
public static int add(int key, int x, int y, int z) { int offset = key(x, y, z); return (key + offset) & mask; }
[ "public", "static", "int", "add", "(", "int", "key", ",", "int", "x", ",", "int", "y", ",", "int", "z", ")", "{", "int", "offset", "=", "key", "(", "x", ",", "y", ",", "z", ")", ";", "return", "(", "key", "+", "offset", ")", "&", "mask", ";", "}" ]
Adds the given offset to the packed key @param key the base key @param x the x offset @param y the y offset @param z the z offset @return the new key
[ "Adds", "the", "given", "offset", "to", "the", "packed", "key" ]
0690efdac06fd728fcd7e9cf10f2b1319379c45b
https://github.com/flow/commons/blob/0690efdac06fd728fcd7e9cf10f2b1319379c45b/src/main/java/com/flowpowered/commons/hashing/SignedTenBitTripleHashed.java#L93-L96
145,698
netheosgithub/pcs_api
java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java
PcsUtils.buildCStorageException
public static CStorageException buildCStorageException( CResponse response, String message, CPath path ) { switch ( response.getStatus() ) { case 401: return new CAuthenticationException( message, response ); case 404: message = "No file found at URL " + shortenUrl( response.getUri() ) + " (" + message + ")"; return new CFileNotFoundException( message, path ); default: return new CHttpException( message, response ); } }
java
public static CStorageException buildCStorageException( CResponse response, String message, CPath path ) { switch ( response.getStatus() ) { case 401: return new CAuthenticationException( message, response ); case 404: message = "No file found at URL " + shortenUrl( response.getUri() ) + " (" + message + ")"; return new CFileNotFoundException( message, path ); default: return new CHttpException( message, response ); } }
[ "public", "static", "CStorageException", "buildCStorageException", "(", "CResponse", "response", ",", "String", "message", ",", "CPath", "path", ")", "{", "switch", "(", "response", ".", "getStatus", "(", ")", ")", "{", "case", "401", ":", "return", "new", "CAuthenticationException", "(", "message", ",", "response", ")", ";", "case", "404", ":", "message", "=", "\"No file found at URL \"", "+", "shortenUrl", "(", "response", ".", "getUri", "(", ")", ")", "+", "\" (\"", "+", "message", "+", "\")\"", ";", "return", "new", "CFileNotFoundException", "(", "message", ",", "path", ")", ";", "default", ":", "return", "new", "CHttpException", "(", "message", ",", "response", ")", ";", "}", "}" ]
Some common code between providers. Handles the different status codes, and generates a nice exception @param response The wrapped HTTP response @param message The error message (provided by the server or by the application) @param path The file requested (which failed) @return The exception
[ "Some", "common", "code", "between", "providers", ".", "Handles", "the", "different", "status", "codes", "and", "generates", "a", "nice", "exception" ]
20691e52e144014f99ca75cb7dedc7ba0c18586c
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java#L117-L130
145,699
netheosgithub/pcs_api
java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java
PcsUtils.abbreviate
public static String abbreviate( String source, int maxLen ) { if ( source == null || source.length() <= maxLen ) { return source; } return source.substring( 0, maxLen ) + "..."; }
java
public static String abbreviate( String source, int maxLen ) { if ( source == null || source.length() <= maxLen ) { return source; } return source.substring( 0, maxLen ) + "..."; }
[ "public", "static", "String", "abbreviate", "(", "String", "source", ",", "int", "maxLen", ")", "{", "if", "(", "source", "==", "null", "||", "source", ".", "length", "(", ")", "<=", "maxLen", ")", "{", "return", "source", ";", "}", "return", "source", ".", "substring", "(", "0", ",", "maxLen", ")", "+", "\"...\"", ";", "}" ]
Abbreviate a string if longer than maxLen. @param source may be null @param maxLen must be &gt;= 0. Up to this length, string is not truncated; otherwise truncated to maxLen and three dots as allipsis are added. @return original or truncated string (up tomaxLen+3 characters).
[ "Abbreviate", "a", "string", "if", "longer", "than", "maxLen", "." ]
20691e52e144014f99ca75cb7dedc7ba0c18586c
https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/PcsUtils.java#L151-L157