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
11,200
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/Request.java
Request.upload
public void upload(Context context, final File file, final ProgressListener progressListener, ResponseListener responseListener) { setContext(context); super.upload(file, progressListener, responseListener); }
java
public void upload(Context context, final File file, final ProgressListener progressListener, ResponseListener responseListener) { setContext(context); super.upload(file, progressListener, responseListener); }
[ "public", "void", "upload", "(", "Context", "context", ",", "final", "File", "file", ",", "final", "ProgressListener", "progressListener", ",", "ResponseListener", "responseListener", ")", "{", "setContext", "(", "context", ")", ";", "super", ".", "upload", "(", "file", ",", "progressListener", ",", "responseListener", ")", ";", "}" ]
Upload a file asynchronously. This method does not set any Content-Type header; if such a header is required, it must be set before calling this method. @param context The context that will be passed to authentication listener. @param file The file to upload @param progressListener The listener that monitors the upload progress @param responseListener The listener whose onSuccess or onFailure methods will be called when this request finishes
[ "Upload", "a", "file", "asynchronously", ".", "This", "method", "does", "not", "set", "any", "Content", "-", "Type", "header", ";", "if", "such", "a", "header", "is", "required", "it", "must", "be", "set", "before", "calling", "this", "method", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/Request.java#L365-L368
11,201
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/taglib/ImagePathTag.java
ImagePathTag.getImgSrcToRender
protected String getImgSrcToRender() throws JspException { BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) pageContext.getServletContext() .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE); if (null == binaryRsHandler) throw new JspException( "You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred."); HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); return ImageTagUtils.getImageUrl(src, base64, binaryRsHandler, request, response); }
java
protected String getImgSrcToRender() throws JspException { BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) pageContext.getServletContext() .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE); if (null == binaryRsHandler) throw new JspException( "You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred."); HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); return ImageTagUtils.getImageUrl(src, base64, binaryRsHandler, request, response); }
[ "protected", "String", "getImgSrcToRender", "(", ")", "throws", "JspException", "{", "BinaryResourcesHandler", "binaryRsHandler", "=", "(", "BinaryResourcesHandler", ")", "pageContext", ".", "getServletContext", "(", ")", ".", "getAttribute", "(", "JawrConstant", ".", "BINARY_CONTEXT_ATTRIBUTE", ")", ";", "if", "(", "null", "==", "binaryRsHandler", ")", "throw", "new", "JspException", "(", "\"You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.\"", ")", ";", "HttpServletResponse", "response", "=", "(", "HttpServletResponse", ")", "pageContext", ".", "getResponse", "(", ")", ";", "HttpServletRequest", "request", "=", "(", "HttpServletRequest", ")", "pageContext", ".", "getRequest", "(", ")", ";", "return", "ImageTagUtils", ".", "getImageUrl", "(", "src", ",", "base64", ",", "binaryRsHandler", ",", "request", ",", "response", ")", ";", "}" ]
Returns the image source to render @return the image source to render @throws JspException if a JSP exception occurs.
[ "Returns", "the", "image", "source", "to", "render" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/taglib/ImagePathTag.java#L158-L171
11,202
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssDebugUrlRewriter.java
CssDebugUrlRewriter.rewriteGeneratedBinaryResourceDebugUrl
public static String rewriteGeneratedBinaryResourceDebugUrl(String requestPath, String content, String binaryServletMapping) { // Write the content of the CSS in the Stringwriter if (binaryServletMapping == null) { binaryServletMapping = ""; } // Define the replacement pattern for the generated binary resource // (like jar:img/myImg.png) String relativeRootUrlPath = PathNormalizer.getRootRelativePath(requestPath); String replacementPattern = PathNormalizer .normalizePath("$1" + relativeRootUrlPath + binaryServletMapping + "/$5_cbDebug/$7$8"); Matcher matcher = GENERATED_BINARY_RESOURCE_PATTERN.matcher(content); // Rewrite the images define in the classpath, to point to the image // servlet StringBuffer result = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(result, replacementPattern); } matcher.appendTail(result); return result.toString(); }
java
public static String rewriteGeneratedBinaryResourceDebugUrl(String requestPath, String content, String binaryServletMapping) { // Write the content of the CSS in the Stringwriter if (binaryServletMapping == null) { binaryServletMapping = ""; } // Define the replacement pattern for the generated binary resource // (like jar:img/myImg.png) String relativeRootUrlPath = PathNormalizer.getRootRelativePath(requestPath); String replacementPattern = PathNormalizer .normalizePath("$1" + relativeRootUrlPath + binaryServletMapping + "/$5_cbDebug/$7$8"); Matcher matcher = GENERATED_BINARY_RESOURCE_PATTERN.matcher(content); // Rewrite the images define in the classpath, to point to the image // servlet StringBuffer result = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(result, replacementPattern); } matcher.appendTail(result); return result.toString(); }
[ "public", "static", "String", "rewriteGeneratedBinaryResourceDebugUrl", "(", "String", "requestPath", ",", "String", "content", ",", "String", "binaryServletMapping", ")", "{", "// Write the content of the CSS in the Stringwriter", "if", "(", "binaryServletMapping", "==", "null", ")", "{", "binaryServletMapping", "=", "\"\"", ";", "}", "// Define the replacement pattern for the generated binary resource", "// (like jar:img/myImg.png)", "String", "relativeRootUrlPath", "=", "PathNormalizer", ".", "getRootRelativePath", "(", "requestPath", ")", ";", "String", "replacementPattern", "=", "PathNormalizer", ".", "normalizePath", "(", "\"$1\"", "+", "relativeRootUrlPath", "+", "binaryServletMapping", "+", "\"/$5_cbDebug/$7$8\"", ")", ";", "Matcher", "matcher", "=", "GENERATED_BINARY_RESOURCE_PATTERN", ".", "matcher", "(", "content", ")", ";", "// Rewrite the images define in the classpath, to point to the image", "// servlet", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "result", ",", "replacementPattern", ")", ";", "}", "matcher", ".", "appendTail", "(", "result", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Rewrites the generated binary resource URL for debug mode @param requestPath the request path @param content the content to rewrite @param binaryServletMapping the binary servlet mapping @return the rewritten content
[ "Rewrites", "the", "generated", "binary", "resource", "URL", "for", "debug", "mode" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssDebugUrlRewriter.java#L44-L68
11,203
ibm-bluemix-mobile-services/bms-clientsdk-android-core
app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java
MainActivity.performInitializations
private void performInitializations() { try { BMSClient.getInstance().initialize(getApplicationContext(), backendURL, backendGUID, BMSClient.REGION_US_SOUTH); } catch (MalformedURLException e) { e.printStackTrace(); } MCAAuthorizationManager mcaAuthorizationManager = MCAAuthorizationManager.createInstance(this.getApplicationContext()); mcaAuthorizationManager.registerAuthenticationListener(customRealm, new MyChallengeHandler()); // to make the authorization happen next time mcaAuthorizationManager.clearAuthorizationData(); BMSClient.getInstance().setAuthorizationManager(mcaAuthorizationManager); Logger.setLogLevel(Logger.LEVEL.DEBUG); Logger.setSDKDebugLoggingEnabled(true); }
java
private void performInitializations() { try { BMSClient.getInstance().initialize(getApplicationContext(), backendURL, backendGUID, BMSClient.REGION_US_SOUTH); } catch (MalformedURLException e) { e.printStackTrace(); } MCAAuthorizationManager mcaAuthorizationManager = MCAAuthorizationManager.createInstance(this.getApplicationContext()); mcaAuthorizationManager.registerAuthenticationListener(customRealm, new MyChallengeHandler()); // to make the authorization happen next time mcaAuthorizationManager.clearAuthorizationData(); BMSClient.getInstance().setAuthorizationManager(mcaAuthorizationManager); Logger.setLogLevel(Logger.LEVEL.DEBUG); Logger.setSDKDebugLoggingEnabled(true); }
[ "private", "void", "performInitializations", "(", ")", "{", "try", "{", "BMSClient", ".", "getInstance", "(", ")", ".", "initialize", "(", "getApplicationContext", "(", ")", ",", "backendURL", ",", "backendGUID", ",", "BMSClient", ".", "REGION_US_SOUTH", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "MCAAuthorizationManager", "mcaAuthorizationManager", "=", "MCAAuthorizationManager", ".", "createInstance", "(", "this", ".", "getApplicationContext", "(", ")", ")", ";", "mcaAuthorizationManager", ".", "registerAuthenticationListener", "(", "customRealm", ",", "new", "MyChallengeHandler", "(", ")", ")", ";", "// to make the authorization happen next time", "mcaAuthorizationManager", ".", "clearAuthorizationData", "(", ")", ";", "BMSClient", ".", "getInstance", "(", ")", ".", "setAuthorizationManager", "(", "mcaAuthorizationManager", ")", ";", "Logger", ".", "setLogLevel", "(", "Logger", ".", "LEVEL", ".", "DEBUG", ")", ";", "Logger", ".", "setSDKDebugLoggingEnabled", "(", "true", ")", ";", "}" ]
Initialize BMSClient and set the authorization manager
[ "Initialize", "BMSClient", "and", "set", "the", "authorization", "manager" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java#L64-L80
11,204
ibm-bluemix-mobile-services/bms-clientsdk-android-core
app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java
MainActivity.getNetworkInfo
private void getNetworkInfo() { // Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection) NetworkConnectionListener listener = new NetworkConnectionListener() { @Override public void networkChanged(NetworkConnectionType newConnection) { Log.i("BMSCore", "New network connection: " + newConnection.toString()); } }; // Initilize the network monitor with the application context and network change listener this.networkMonitor = new NetworkMonitor(getApplicationContext(), listener); // Start listening for network changes networkMonitor.startMonitoringNetworkChanges(); // See if the device currently has internet access, and see what type of connection it is using Log.i("BMSCore", "Is connected to the internet: " + networkMonitor.isInternetAccessAvailable()); Log.i("BMSCore", "Connection type: " + networkMonitor.getCurrentConnectionType().toString()); // Check that the user has given permissions to read the phone's state. // If permission is granted, get the type of mobile data network being used. int networkPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE); if (networkPermission == PackageManager.PERMISSION_GRANTED) { Log.i("BMSCore", "Mobile network type: " + networkMonitor.getMobileNetworkType()); } else { Log.i("BMSCore", "Obtaining permission to read phone state"); if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) { // Asynchronously explain to the user why you are attempting to request this permission. // Once this is done, try to request the permission again. } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_READ_PHONE_STATE); } } }
java
private void getNetworkInfo() { // Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection) NetworkConnectionListener listener = new NetworkConnectionListener() { @Override public void networkChanged(NetworkConnectionType newConnection) { Log.i("BMSCore", "New network connection: " + newConnection.toString()); } }; // Initilize the network monitor with the application context and network change listener this.networkMonitor = new NetworkMonitor(getApplicationContext(), listener); // Start listening for network changes networkMonitor.startMonitoringNetworkChanges(); // See if the device currently has internet access, and see what type of connection it is using Log.i("BMSCore", "Is connected to the internet: " + networkMonitor.isInternetAccessAvailable()); Log.i("BMSCore", "Connection type: " + networkMonitor.getCurrentConnectionType().toString()); // Check that the user has given permissions to read the phone's state. // If permission is granted, get the type of mobile data network being used. int networkPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE); if (networkPermission == PackageManager.PERMISSION_GRANTED) { Log.i("BMSCore", "Mobile network type: " + networkMonitor.getMobileNetworkType()); } else { Log.i("BMSCore", "Obtaining permission to read phone state"); if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) { // Asynchronously explain to the user why you are attempting to request this permission. // Once this is done, try to request the permission again. } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_READ_PHONE_STATE); } } }
[ "private", "void", "getNetworkInfo", "(", ")", "{", "// Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection)", "NetworkConnectionListener", "listener", "=", "new", "NetworkConnectionListener", "(", ")", "{", "@", "Override", "public", "void", "networkChanged", "(", "NetworkConnectionType", "newConnection", ")", "{", "Log", ".", "i", "(", "\"BMSCore\"", ",", "\"New network connection: \"", "+", "newConnection", ".", "toString", "(", ")", ")", ";", "}", "}", ";", "// Initilize the network monitor with the application context and network change listener", "this", ".", "networkMonitor", "=", "new", "NetworkMonitor", "(", "getApplicationContext", "(", ")", ",", "listener", ")", ";", "// Start listening for network changes", "networkMonitor", ".", "startMonitoringNetworkChanges", "(", ")", ";", "// See if the device currently has internet access, and see what type of connection it is using", "Log", ".", "i", "(", "\"BMSCore\"", ",", "\"Is connected to the internet: \"", "+", "networkMonitor", ".", "isInternetAccessAvailable", "(", ")", ")", ";", "Log", ".", "i", "(", "\"BMSCore\"", ",", "\"Connection type: \"", "+", "networkMonitor", ".", "getCurrentConnectionType", "(", ")", ".", "toString", "(", ")", ")", ";", "// Check that the user has given permissions to read the phone's state.", "// If permission is granted, get the type of mobile data network being used.", "int", "networkPermission", "=", "ContextCompat", ".", "checkSelfPermission", "(", "this", ",", "Manifest", ".", "permission", ".", "READ_PHONE_STATE", ")", ";", "if", "(", "networkPermission", "==", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "Log", ".", "i", "(", "\"BMSCore\"", ",", "\"Mobile network type: \"", "+", "networkMonitor", ".", "getMobileNetworkType", "(", ")", ")", ";", "}", "else", "{", "Log", ".", "i", "(", "\"BMSCore\"", ",", "\"Obtaining permission to read phone state\"", ")", ";", "if", "(", "ActivityCompat", ".", "shouldShowRequestPermissionRationale", "(", "this", ",", "Manifest", ".", "permission", ".", "READ_PHONE_STATE", ")", ")", "{", "// Asynchronously explain to the user why you are attempting to request this permission.", "// Once this is done, try to request the permission again.", "}", "else", "{", "ActivityCompat", ".", "requestPermissions", "(", "this", ",", "new", "String", "[", "]", "{", "Manifest", ".", "permission", ".", "READ_PHONE_STATE", "}", ",", "MY_PERMISSIONS_READ_PHONE_STATE", ")", ";", "}", "}", "}" ]
Exercise the NetworkMonitor API
[ "Exercise", "the", "NetworkMonitor", "API" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java#L83-L119
11,205
ibm-bluemix-mobile-services/bms-clientsdk-android-core
app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java
MainActivity.sendSomeRequests
private void sendSomeRequests() { ResponseListener responseListener = new MyResponseListener(); sendCustomUrlRequest(responseListener); sendAutoRetryRequest(responseListener); downloadImage(responseListener); uploadData(responseListener); uploadFile(responseListener); uploadText(responseListener); }
java
private void sendSomeRequests() { ResponseListener responseListener = new MyResponseListener(); sendCustomUrlRequest(responseListener); sendAutoRetryRequest(responseListener); downloadImage(responseListener); uploadData(responseListener); uploadFile(responseListener); uploadText(responseListener); }
[ "private", "void", "sendSomeRequests", "(", ")", "{", "ResponseListener", "responseListener", "=", "new", "MyResponseListener", "(", ")", ";", "sendCustomUrlRequest", "(", "responseListener", ")", ";", "sendAutoRetryRequest", "(", "responseListener", ")", ";", "downloadImage", "(", "responseListener", ")", ";", "uploadData", "(", "responseListener", ")", ";", "uploadFile", "(", "responseListener", ")", ";", "uploadText", "(", "responseListener", ")", ";", "}" ]
Exercise the Request and Response APIs
[ "Exercise", "the", "Request", "and", "Response", "APIs" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/app/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MainActivity.java#L122-L131
11,206
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.startAuthorizationProcess
public void startAuthorizationProcess(final Context context, ResponseListener listener) { authorizationQueue.add(listener); //start the authorization process only if this is the first time we ask for authorization if (authorizationQueue.size() == 1) { try { if (preferences.clientId.get() == null) { logger.info("starting registration process"); invokeInstanceRegistrationRequest(context); } else { logger.info("starting authorization process"); invokeAuthorizationRequest(context); } } catch (Throwable t) { handleAuthorizationFailure(t); } } else{ logger.info("authorization process already running, adding response listener to the queue"); logger.debug(String.format("authorization process currently handling %d requests", authorizationQueue.size())); } }
java
public void startAuthorizationProcess(final Context context, ResponseListener listener) { authorizationQueue.add(listener); //start the authorization process only if this is the first time we ask for authorization if (authorizationQueue.size() == 1) { try { if (preferences.clientId.get() == null) { logger.info("starting registration process"); invokeInstanceRegistrationRequest(context); } else { logger.info("starting authorization process"); invokeAuthorizationRequest(context); } } catch (Throwable t) { handleAuthorizationFailure(t); } } else{ logger.info("authorization process already running, adding response listener to the queue"); logger.debug(String.format("authorization process currently handling %d requests", authorizationQueue.size())); } }
[ "public", "void", "startAuthorizationProcess", "(", "final", "Context", "context", ",", "ResponseListener", "listener", ")", "{", "authorizationQueue", ".", "add", "(", "listener", ")", ";", "//start the authorization process only if this is the first time we ask for authorization", "if", "(", "authorizationQueue", ".", "size", "(", ")", "==", "1", ")", "{", "try", "{", "if", "(", "preferences", ".", "clientId", ".", "get", "(", ")", "==", "null", ")", "{", "logger", ".", "info", "(", "\"starting registration process\"", ")", ";", "invokeInstanceRegistrationRequest", "(", "context", ")", ";", "}", "else", "{", "logger", ".", "info", "(", "\"starting authorization process\"", ")", ";", "invokeAuthorizationRequest", "(", "context", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "handleAuthorizationFailure", "(", "t", ")", ";", "}", "}", "else", "{", "logger", ".", "info", "(", "\"authorization process already running, adding response listener to the queue\"", ")", ";", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"authorization process currently handling %d requests\"", ",", "authorizationQueue", ".", "size", "(", ")", ")", ")", ";", "}", "}" ]
Main method to start authorization process @param context android context @param listener response listener that will get the result of the process
[ "Main", "method", "to", "start", "authorization", "process" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L94-L116
11,207
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.invokeInstanceRegistrationRequest
private void invokeInstanceRegistrationRequest(final Context context) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createRegistrationParams(); options.headers = createRegistrationHeaders(); options.requestMethod = Request.POST; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { saveCertificateFromResponse(response); invokeAuthorizationRequest(context); } }; authorizationRequestSend(null, "clients/instance", options, listener); }
java
private void invokeInstanceRegistrationRequest(final Context context) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createRegistrationParams(); options.headers = createRegistrationHeaders(); options.requestMethod = Request.POST; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { saveCertificateFromResponse(response); invokeAuthorizationRequest(context); } }; authorizationRequestSend(null, "clients/instance", options, listener); }
[ "private", "void", "invokeInstanceRegistrationRequest", "(", "final", "Context", "context", ")", "{", "AuthorizationRequestManager", ".", "RequestOptions", "options", "=", "new", "AuthorizationRequestManager", ".", "RequestOptions", "(", ")", ";", "options", ".", "parameters", "=", "createRegistrationParams", "(", ")", ";", "options", ".", "headers", "=", "createRegistrationHeaders", "(", ")", ";", "options", ".", "requestMethod", "=", "Request", ".", "POST", ";", "InnerAuthorizationResponseListener", "listener", "=", "new", "InnerAuthorizationResponseListener", "(", ")", "{", "@", "Override", "public", "void", "handleAuthorizationSuccessResponse", "(", "Response", "response", ")", "throws", "Exception", "{", "saveCertificateFromResponse", "(", "response", ")", ";", "invokeAuthorizationRequest", "(", "context", ")", ";", "}", "}", ";", "authorizationRequestSend", "(", "null", ",", "\"clients/instance\"", ",", "options", ",", "listener", ")", ";", "}" ]
Invoke request for registration, the result of the request should contain ClientId. @param context android context
[ "Invoke", "request", "for", "registration", "the", "result", "of", "the", "request", "should", "contain", "ClientId", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L140-L157
11,208
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.createRegistrationParams
private HashMap<String, String> createRegistrationParams() { registrationKeyPair = KeyPairUtility.generateRandomKeyPair(); JSONObject csrJSON = new JSONObject(); HashMap<String, String> params; try { DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap()); AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap()); csrJSON.put("deviceId", deviceData.getId()); csrJSON.put("deviceOs", "" + deviceData.getOS()); csrJSON.put("deviceModel", deviceData.getModel()); csrJSON.put("applicationId", applicationData.getId()); csrJSON.put("applicationVersion", applicationData.getVersion()); csrJSON.put("environment", "android"); String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON); params = new HashMap<>(1); params.put("CSR", csrValue); return params; } catch (Exception e) { throw new RuntimeException("Failed to create registration params", e); } }
java
private HashMap<String, String> createRegistrationParams() { registrationKeyPair = KeyPairUtility.generateRandomKeyPair(); JSONObject csrJSON = new JSONObject(); HashMap<String, String> params; try { DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap()); AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap()); csrJSON.put("deviceId", deviceData.getId()); csrJSON.put("deviceOs", "" + deviceData.getOS()); csrJSON.put("deviceModel", deviceData.getModel()); csrJSON.put("applicationId", applicationData.getId()); csrJSON.put("applicationVersion", applicationData.getVersion()); csrJSON.put("environment", "android"); String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON); params = new HashMap<>(1); params.put("CSR", csrValue); return params; } catch (Exception e) { throw new RuntimeException("Failed to create registration params", e); } }
[ "private", "HashMap", "<", "String", ",", "String", ">", "createRegistrationParams", "(", ")", "{", "registrationKeyPair", "=", "KeyPairUtility", ".", "generateRandomKeyPair", "(", ")", ";", "JSONObject", "csrJSON", "=", "new", "JSONObject", "(", ")", ";", "HashMap", "<", "String", ",", "String", ">", "params", ";", "try", "{", "DeviceIdentity", "deviceData", "=", "new", "BaseDeviceIdentity", "(", "preferences", ".", "deviceIdentity", ".", "getAsMap", "(", ")", ")", ";", "AppIdentity", "applicationData", "=", "new", "BaseAppIdentity", "(", "preferences", ".", "appIdentity", ".", "getAsMap", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"deviceId\"", ",", "deviceData", ".", "getId", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"deviceOs\"", ",", "\"\"", "+", "deviceData", ".", "getOS", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"deviceModel\"", ",", "deviceData", ".", "getModel", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"applicationId\"", ",", "applicationData", ".", "getId", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"applicationVersion\"", ",", "applicationData", ".", "getVersion", "(", ")", ")", ";", "csrJSON", ".", "put", "(", "\"environment\"", ",", "\"android\"", ")", ";", "String", "csrValue", "=", "jsonSigner", ".", "sign", "(", "registrationKeyPair", ",", "csrJSON", ")", ";", "params", "=", "new", "HashMap", "<>", "(", "1", ")", ";", "params", ".", "put", "(", "\"CSR\"", ",", "csrValue", ")", ";", "return", "params", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to create registration params\"", ",", "e", ")", ";", "}", "}" ]
Generate the params that will be used during the registration phase @return Map with all the parameters
[ "Generate", "the", "params", "that", "will", "be", "used", "during", "the", "registration", "phase" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L163-L189
11,209
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.createRegistrationHeaders
private HashMap<String, String> createRegistrationHeaders() { HashMap<String, String> headers = new HashMap<>(); addSessionIdHeader(headers); return headers; }
java
private HashMap<String, String> createRegistrationHeaders() { HashMap<String, String> headers = new HashMap<>(); addSessionIdHeader(headers); return headers; }
[ "private", "HashMap", "<", "String", ",", "String", ">", "createRegistrationHeaders", "(", ")", "{", "HashMap", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<>", "(", ")", ";", "addSessionIdHeader", "(", "headers", ")", ";", "return", "headers", ";", "}" ]
Generate the headers that will be used during the registration phase @return Map with all the headers
[ "Generate", "the", "headers", "that", "will", "be", "used", "during", "the", "registration", "phase" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L195-L200
11,210
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.createTokenRequestParams
private HashMap<String, String> createTokenRequestParams(String grantCode) { HashMap<String, String> params = new HashMap<>(); params.put("code", grantCode); params.put("client_id", preferences.clientId.get()); params.put("grant_type", "authorization_code"); params.put("redirect_uri", HTTP_LOCALHOST); return params; }
java
private HashMap<String, String> createTokenRequestParams(String grantCode) { HashMap<String, String> params = new HashMap<>(); params.put("code", grantCode); params.put("client_id", preferences.clientId.get()); params.put("grant_type", "authorization_code"); params.put("redirect_uri", HTTP_LOCALHOST); return params; }
[ "private", "HashMap", "<", "String", ",", "String", ">", "createTokenRequestParams", "(", "String", "grantCode", ")", "{", "HashMap", "<", "String", ",", "String", ">", "params", "=", "new", "HashMap", "<>", "(", ")", ";", "params", ".", "put", "(", "\"code\"", ",", "grantCode", ")", ";", "params", ".", "put", "(", "\"client_id\"", ",", "preferences", ".", "clientId", ".", "get", "(", ")", ")", ";", "params", ".", "put", "(", "\"grant_type\"", ",", "\"authorization_code\"", ")", ";", "params", ".", "put", "(", "\"redirect_uri\"", ",", "HTTP_LOCALHOST", ")", ";", "return", "params", ";", "}" ]
Generate the params that will be used during the token request phase @param grantCode from the authorization phase @return Map with all the headers
[ "Generate", "the", "params", "that", "will", "be", "used", "during", "the", "token", "request", "phase" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L207-L217
11,211
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.saveCertificateFromResponse
private void saveCertificateFromResponse(Response response) { try { String responseBody = response.getResponseText(); JSONObject jsonResponse = new JSONObject(responseBody); //handle certificate String certificateString = jsonResponse.getString("certificate"); X509Certificate certificate = CertificatesUtility.base64StringToCertificate(certificateString); CertificatesUtility.checkValidityWithPublicKey(certificate, registrationKeyPair.getPublic()); certificateStore.saveCertificate(registrationKeyPair, certificate); //save the clientId separately preferences.clientId.set(jsonResponse.getString("clientId")); } catch (Exception e) { throw new RuntimeException("Failed to save certificate from response", e); } logger.debug("certificate successfully saved"); }
java
private void saveCertificateFromResponse(Response response) { try { String responseBody = response.getResponseText(); JSONObject jsonResponse = new JSONObject(responseBody); //handle certificate String certificateString = jsonResponse.getString("certificate"); X509Certificate certificate = CertificatesUtility.base64StringToCertificate(certificateString); CertificatesUtility.checkValidityWithPublicKey(certificate, registrationKeyPair.getPublic()); certificateStore.saveCertificate(registrationKeyPair, certificate); //save the clientId separately preferences.clientId.set(jsonResponse.getString("clientId")); } catch (Exception e) { throw new RuntimeException("Failed to save certificate from response", e); } logger.debug("certificate successfully saved"); }
[ "private", "void", "saveCertificateFromResponse", "(", "Response", "response", ")", "{", "try", "{", "String", "responseBody", "=", "response", ".", "getResponseText", "(", ")", ";", "JSONObject", "jsonResponse", "=", "new", "JSONObject", "(", "responseBody", ")", ";", "//handle certificate", "String", "certificateString", "=", "jsonResponse", ".", "getString", "(", "\"certificate\"", ")", ";", "X509Certificate", "certificate", "=", "CertificatesUtility", ".", "base64StringToCertificate", "(", "certificateString", ")", ";", "CertificatesUtility", ".", "checkValidityWithPublicKey", "(", "certificate", ",", "registrationKeyPair", ".", "getPublic", "(", ")", ")", ";", "certificateStore", ".", "saveCertificate", "(", "registrationKeyPair", ",", "certificate", ")", ";", "//save the clientId separately", "preferences", ".", "clientId", ".", "set", "(", "jsonResponse", ".", "getString", "(", "\"clientId\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to save certificate from response\"", ",", "e", ")", ";", "}", "logger", ".", "debug", "(", "\"certificate successfully saved\"", ")", ";", "}" ]
Extract the certificate data from response and save it on local storage @param response contains the certificate data
[ "Extract", "the", "certificate", "data", "from", "response", "and", "save", "it", "on", "local", "storage" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L223-L244
11,212
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.invokeAuthorizationRequest
private void invokeAuthorizationRequest(Context context) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createAuthorizationParams(); options.headers = new HashMap<>(1); addSessionIdHeader(options.headers); options.requestMethod = Request.GET; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { String location = extractLocationHeader(response); String grantCode = extractGrantCode(location); invokeTokenRequest(grantCode); } }; authorizationRequestSend(context, "authorization", options, listener); }
java
private void invokeAuthorizationRequest(Context context) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createAuthorizationParams(); options.headers = new HashMap<>(1); addSessionIdHeader(options.headers); options.requestMethod = Request.GET; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { String location = extractLocationHeader(response); String grantCode = extractGrantCode(location); invokeTokenRequest(grantCode); } }; authorizationRequestSend(context, "authorization", options, listener); }
[ "private", "void", "invokeAuthorizationRequest", "(", "Context", "context", ")", "{", "AuthorizationRequestManager", ".", "RequestOptions", "options", "=", "new", "AuthorizationRequestManager", ".", "RequestOptions", "(", ")", ";", "options", ".", "parameters", "=", "createAuthorizationParams", "(", ")", ";", "options", ".", "headers", "=", "new", "HashMap", "<>", "(", "1", ")", ";", "addSessionIdHeader", "(", "options", ".", "headers", ")", ";", "options", ".", "requestMethod", "=", "Request", ".", "GET", ";", "InnerAuthorizationResponseListener", "listener", "=", "new", "InnerAuthorizationResponseListener", "(", ")", "{", "@", "Override", "public", "void", "handleAuthorizationSuccessResponse", "(", "Response", "response", ")", "throws", "Exception", "{", "String", "location", "=", "extractLocationHeader", "(", "response", ")", ";", "String", "grantCode", "=", "extractGrantCode", "(", "location", ")", ";", "invokeTokenRequest", "(", "grantCode", ")", ";", "}", "}", ";", "authorizationRequestSend", "(", "context", ",", "\"authorization\"", ",", "options", ",", "listener", ")", ";", "}" ]
Invoke the authorization request, the result of the request should be a grant code @param context android activity that will handle authentication (facebook, google)
[ "Invoke", "the", "authorization", "request", "the", "result", "of", "the", "request", "should", "be", "a", "grant", "code" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L251-L271
11,213
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.createAuthorizationParams
private HashMap<String, String> createAuthorizationParams() { HashMap<String, String> params = new HashMap<>(3); params.put("response_type", "code"); params.put("client_id", preferences.clientId.get()); params.put("redirect_uri", HTTP_LOCALHOST); return params; }
java
private HashMap<String, String> createAuthorizationParams() { HashMap<String, String> params = new HashMap<>(3); params.put("response_type", "code"); params.put("client_id", preferences.clientId.get()); params.put("redirect_uri", HTTP_LOCALHOST); return params; }
[ "private", "HashMap", "<", "String", ",", "String", ">", "createAuthorizationParams", "(", ")", "{", "HashMap", "<", "String", ",", "String", ">", "params", "=", "new", "HashMap", "<>", "(", "3", ")", ";", "params", ".", "put", "(", "\"response_type\"", ",", "\"code\"", ")", ";", "params", ".", "put", "(", "\"client_id\"", ",", "preferences", ".", "clientId", ".", "get", "(", ")", ")", ";", "params", ".", "put", "(", "\"redirect_uri\"", ",", "HTTP_LOCALHOST", ")", ";", "return", "params", ";", "}" ]
Generate the params that will be used during the authorization phase @return Map with all the params
[ "Generate", "the", "params", "that", "will", "be", "used", "during", "the", "authorization", "phase" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L287-L295
11,214
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.extractGrantCode
private String extractGrantCode(String urlString) throws MalformedURLException { URL url = new URL(urlString); String code = Utils.getParameterValueFromQuery(url.getQuery(), "code"); if (code == null){ throw new RuntimeException("Failed to extract grant code from url"); } logger.debug("Grant code extracted successfully"); return code; }
java
private String extractGrantCode(String urlString) throws MalformedURLException { URL url = new URL(urlString); String code = Utils.getParameterValueFromQuery(url.getQuery(), "code"); if (code == null){ throw new RuntimeException("Failed to extract grant code from url"); } logger.debug("Grant code extracted successfully"); return code; }
[ "private", "String", "extractGrantCode", "(", "String", "urlString", ")", "throws", "MalformedURLException", "{", "URL", "url", "=", "new", "URL", "(", "urlString", ")", ";", "String", "code", "=", "Utils", ".", "getParameterValueFromQuery", "(", "url", ".", "getQuery", "(", ")", ",", "\"code\"", ")", ";", "if", "(", "code", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to extract grant code from url\"", ")", ";", "}", "logger", ".", "debug", "(", "\"Grant code extracted successfully\"", ")", ";", "return", "code", ";", "}" ]
Extract grant code from url string @param urlString url that contain the grant code @return grant code @throws MalformedURLException in case of illegal url format
[ "Extract", "grant", "code", "from", "url", "string" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L318-L329
11,215
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.invokeTokenRequest
private void invokeTokenRequest(String grantCode) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createTokenRequestParams(grantCode); options.headers = createTokenRequestHeaders(grantCode); addSessionIdHeader(options.headers); options.requestMethod = Request.POST; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { saveTokenFromResponse(response); handleAuthorizationSuccess(response); } }; authorizationRequestSend(null, "token", options, listener); }
java
private void invokeTokenRequest(String grantCode) { AuthorizationRequestManager.RequestOptions options = new AuthorizationRequestManager.RequestOptions(); options.parameters = createTokenRequestParams(grantCode); options.headers = createTokenRequestHeaders(grantCode); addSessionIdHeader(options.headers); options.requestMethod = Request.POST; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener() { @Override public void handleAuthorizationSuccessResponse(Response response) throws Exception { saveTokenFromResponse(response); handleAuthorizationSuccess(response); } }; authorizationRequestSend(null, "token", options, listener); }
[ "private", "void", "invokeTokenRequest", "(", "String", "grantCode", ")", "{", "AuthorizationRequestManager", ".", "RequestOptions", "options", "=", "new", "AuthorizationRequestManager", ".", "RequestOptions", "(", ")", ";", "options", ".", "parameters", "=", "createTokenRequestParams", "(", "grantCode", ")", ";", "options", ".", "headers", "=", "createTokenRequestHeaders", "(", "grantCode", ")", ";", "addSessionIdHeader", "(", "options", ".", "headers", ")", ";", "options", ".", "requestMethod", "=", "Request", ".", "POST", ";", "InnerAuthorizationResponseListener", "listener", "=", "new", "InnerAuthorizationResponseListener", "(", ")", "{", "@", "Override", "public", "void", "handleAuthorizationSuccessResponse", "(", "Response", "response", ")", "throws", "Exception", "{", "saveTokenFromResponse", "(", "response", ")", ";", "handleAuthorizationSuccess", "(", "response", ")", ";", "}", "}", ";", "authorizationRequestSend", "(", "null", ",", "\"token\"", ",", "options", ",", "listener", ")", ";", "}" ]
Invoke request to get token, the result of the response should be a valid token @param grantCode grant code that will be used during the request
[ "Invoke", "request", "to", "get", "token", "the", "result", "of", "the", "response", "should", "be", "a", "valid", "token" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L335-L353
11,216
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.createTokenRequestHeaders
private HashMap<String, String> createTokenRequestHeaders(String grantCode) { JSONObject payload = new JSONObject(); HashMap<String, String> headers; try { payload.put("code", grantCode); KeyPair keyPair = certificateStore.getStoredKeyPair(); String jws = jsonSigner.sign(keyPair, payload); headers = new HashMap<>(1); headers.put("X-WL-Authenticate", jws); } catch (Exception e) { throw new RuntimeException("Failed to create token request headers", e); } return headers; }
java
private HashMap<String, String> createTokenRequestHeaders(String grantCode) { JSONObject payload = new JSONObject(); HashMap<String, String> headers; try { payload.put("code", grantCode); KeyPair keyPair = certificateStore.getStoredKeyPair(); String jws = jsonSigner.sign(keyPair, payload); headers = new HashMap<>(1); headers.put("X-WL-Authenticate", jws); } catch (Exception e) { throw new RuntimeException("Failed to create token request headers", e); } return headers; }
[ "private", "HashMap", "<", "String", ",", "String", ">", "createTokenRequestHeaders", "(", "String", "grantCode", ")", "{", "JSONObject", "payload", "=", "new", "JSONObject", "(", ")", ";", "HashMap", "<", "String", ",", "String", ">", "headers", ";", "try", "{", "payload", ".", "put", "(", "\"code\"", ",", "grantCode", ")", ";", "KeyPair", "keyPair", "=", "certificateStore", ".", "getStoredKeyPair", "(", ")", ";", "String", "jws", "=", "jsonSigner", ".", "sign", "(", "keyPair", ",", "payload", ")", ";", "headers", "=", "new", "HashMap", "<>", "(", "1", ")", ";", "headers", ".", "put", "(", "\"X-WL-Authenticate\"", ",", "jws", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to create token request headers\"", ",", "e", ")", ";", "}", "return", "headers", ";", "}" ]
Generate the headers that will be used during the token request phase @param grantCode from the authorization phase @return Map with all the headers
[ "Generate", "the", "headers", "that", "will", "be", "used", "during", "the", "token", "request", "phase" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L361-L378
11,217
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.saveTokenFromResponse
private void saveTokenFromResponse(Response response) { try { JSONObject responseJSON = ((ResponseImpl)response).getResponseJSON(); String accessToken = responseJSON.getString("access_token"); String idToken = responseJSON.getString("id_token"); //save the tokens preferences.accessToken.set(accessToken); preferences.idToken.set(idToken); //save the user identity separately String[] idTokenData = idToken.split("\\."); byte[] decodedIdTokenData = Base64.decode(idTokenData[1], Base64.DEFAULT); String decodedIdTokenString = new String(decodedIdTokenData); JSONObject idTokenJSON = new JSONObject(decodedIdTokenString); if (idTokenJSON.has("imf.user")) { preferences.userIdentity.set(idTokenJSON.getJSONObject("imf.user")); } logger.debug("token successfully saved"); } catch (Exception e) { throw new RuntimeException("Failed to save token from response", e); } }
java
private void saveTokenFromResponse(Response response) { try { JSONObject responseJSON = ((ResponseImpl)response).getResponseJSON(); String accessToken = responseJSON.getString("access_token"); String idToken = responseJSON.getString("id_token"); //save the tokens preferences.accessToken.set(accessToken); preferences.idToken.set(idToken); //save the user identity separately String[] idTokenData = idToken.split("\\."); byte[] decodedIdTokenData = Base64.decode(idTokenData[1], Base64.DEFAULT); String decodedIdTokenString = new String(decodedIdTokenData); JSONObject idTokenJSON = new JSONObject(decodedIdTokenString); if (idTokenJSON.has("imf.user")) { preferences.userIdentity.set(idTokenJSON.getJSONObject("imf.user")); } logger.debug("token successfully saved"); } catch (Exception e) { throw new RuntimeException("Failed to save token from response", e); } }
[ "private", "void", "saveTokenFromResponse", "(", "Response", "response", ")", "{", "try", "{", "JSONObject", "responseJSON", "=", "(", "(", "ResponseImpl", ")", "response", ")", ".", "getResponseJSON", "(", ")", ";", "String", "accessToken", "=", "responseJSON", ".", "getString", "(", "\"access_token\"", ")", ";", "String", "idToken", "=", "responseJSON", ".", "getString", "(", "\"id_token\"", ")", ";", "//save the tokens", "preferences", ".", "accessToken", ".", "set", "(", "accessToken", ")", ";", "preferences", ".", "idToken", ".", "set", "(", "idToken", ")", ";", "//save the user identity separately", "String", "[", "]", "idTokenData", "=", "idToken", ".", "split", "(", "\"\\\\.\"", ")", ";", "byte", "[", "]", "decodedIdTokenData", "=", "Base64", ".", "decode", "(", "idTokenData", "[", "1", "]", ",", "Base64", ".", "DEFAULT", ")", ";", "String", "decodedIdTokenString", "=", "new", "String", "(", "decodedIdTokenData", ")", ";", "JSONObject", "idTokenJSON", "=", "new", "JSONObject", "(", "decodedIdTokenString", ")", ";", "if", "(", "idTokenJSON", ".", "has", "(", "\"imf.user\"", ")", ")", "{", "preferences", ".", "userIdentity", ".", "set", "(", "idTokenJSON", ".", "getJSONObject", "(", "\"imf.user\"", ")", ")", ";", "}", "logger", ".", "debug", "(", "\"token successfully saved\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to save token from response\"", ",", "e", ")", ";", "}", "}" ]
Extract token from response and save it locally @param response response that contain the token
[ "Extract", "token", "from", "response", "and", "save", "it", "locally" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L384-L409
11,218
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.authorizationRequestSend
private void authorizationRequestSend(final Context context, String path, AuthorizationRequestManager.RequestOptions options, ResponseListener listener) { try { AuthorizationRequestManager authorizationRequestManager = new AuthorizationRequestManager(); authorizationRequestManager.initialize(context, listener); authorizationRequestManager.sendRequest(path, options); } catch (Exception e) { throw new RuntimeException("Failed to send authorization request", e); } }
java
private void authorizationRequestSend(final Context context, String path, AuthorizationRequestManager.RequestOptions options, ResponseListener listener) { try { AuthorizationRequestManager authorizationRequestManager = new AuthorizationRequestManager(); authorizationRequestManager.initialize(context, listener); authorizationRequestManager.sendRequest(path, options); } catch (Exception e) { throw new RuntimeException("Failed to send authorization request", e); } }
[ "private", "void", "authorizationRequestSend", "(", "final", "Context", "context", ",", "String", "path", ",", "AuthorizationRequestManager", ".", "RequestOptions", "options", ",", "ResponseListener", "listener", ")", "{", "try", "{", "AuthorizationRequestManager", "authorizationRequestManager", "=", "new", "AuthorizationRequestManager", "(", ")", ";", "authorizationRequestManager", ".", "initialize", "(", "context", ",", "listener", ")", ";", "authorizationRequestManager", ".", "sendRequest", "(", "path", ",", "options", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to send authorization request\"", ",", "e", ")", ";", "}", "}" ]
Use authorization request agent for sending the request @param context android activity that will handle authentication (facebook, google) @param path path to the server @param options send options @param listener response listener
[ "Use", "authorization", "request", "agent", "for", "sending", "the", "request" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L418-L426
11,219
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.handleAuthorizationFailure
private void handleAuthorizationFailure(Response response, Throwable t, JSONObject extendedInfo) { logger.error("authorization process failed"); if (t != null) { t.printStackTrace(); } Iterator<ResponseListener> iterator = authorizationQueue.iterator(); while(iterator.hasNext()) { ResponseListener next = iterator.next(); next.onFailure(response, t, extendedInfo); iterator.remove(); } }
java
private void handleAuthorizationFailure(Response response, Throwable t, JSONObject extendedInfo) { logger.error("authorization process failed"); if (t != null) { t.printStackTrace(); } Iterator<ResponseListener> iterator = authorizationQueue.iterator(); while(iterator.hasNext()) { ResponseListener next = iterator.next(); next.onFailure(response, t, extendedInfo); iterator.remove(); } }
[ "private", "void", "handleAuthorizationFailure", "(", "Response", "response", ",", "Throwable", "t", ",", "JSONObject", "extendedInfo", ")", "{", "logger", ".", "error", "(", "\"authorization process failed\"", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "}", "Iterator", "<", "ResponseListener", ">", "iterator", "=", "authorizationQueue", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "ResponseListener", "next", "=", "iterator", ".", "next", "(", ")", ";", "next", ".", "onFailure", "(", "response", ",", "t", ",", "extendedInfo", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "}" ]
Handle failure in the authorization process. All the response listeners will be updated with failure @param response response that caused to failure @param t additional info about the failure
[ "Handle", "failure", "in", "the", "authorization", "process", ".", "All", "the", "response", "listeners", "will", "be", "updated", "with", "failure" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L443-L457
11,220
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java
AuthorizationProcessManager.handleAuthorizationSuccess
private void handleAuthorizationSuccess(Response response) { Iterator<ResponseListener> iterator = authorizationQueue.iterator(); while(iterator.hasNext()) { ResponseListener next = iterator.next(); next.onSuccess(response); iterator.remove(); } }
java
private void handleAuthorizationSuccess(Response response) { Iterator<ResponseListener> iterator = authorizationQueue.iterator(); while(iterator.hasNext()) { ResponseListener next = iterator.next(); next.onSuccess(response); iterator.remove(); } }
[ "private", "void", "handleAuthorizationSuccess", "(", "Response", "response", ")", "{", "Iterator", "<", "ResponseListener", ">", "iterator", "=", "authorizationQueue", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "ResponseListener", "next", "=", "iterator", ".", "next", "(", ")", ";", "next", ".", "onSuccess", "(", "response", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "}" ]
Handle success in the authorization process. All the response listeners will be updated with success @param response final success response from the server
[ "Handle", "success", "in", "the", "authorization", "process", ".", "All", "the", "response", "listeners", "will", "be", "updated", "with", "success" ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L464-L473
11,221
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.setProxy
public void setProxy(Proxy proxy) { if(proxy != null) { java.net.Proxy p = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort())); client.setProxy(p); } else client.setProxy(java.net.Proxy.NO_PROXY); }
java
public void setProxy(Proxy proxy) { if(proxy != null) { java.net.Proxy p = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort())); client.setProxy(p); } else client.setProxy(java.net.Proxy.NO_PROXY); }
[ "public", "void", "setProxy", "(", "Proxy", "proxy", ")", "{", "if", "(", "proxy", "!=", "null", ")", "{", "java", ".", "net", ".", "Proxy", "p", "=", "new", "java", ".", "net", ".", "Proxy", "(", "java", ".", "net", ".", "Proxy", ".", "Type", ".", "HTTP", ",", "new", "InetSocketAddress", "(", "proxy", ".", "getHost", "(", ")", ",", "proxy", ".", "getPort", "(", ")", ")", ")", ";", "client", ".", "setProxy", "(", "p", ")", ";", "}", "else", "client", ".", "setProxy", "(", "java", ".", "net", ".", "Proxy", ".", "NO_PROXY", ")", ";", "}" ]
Set the proxy configuration to use for this client. @param proxy The proxy configuration
[ "Set", "the", "proxy", "configuration", "to", "use", "for", "this", "client", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L131-L141
11,222
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.setKeepAliveConfiguration
public void setKeepAliveConfiguration(KeepAliveConfiguration keepAliveConfiguration) { if(keepAliveConfiguration != null) client.setConnectionPool(new ConnectionPool(keepAliveConfiguration.getMaxIdleConnections(), keepAliveConfiguration.getKeepAliveDurationMs())); }
java
public void setKeepAliveConfiguration(KeepAliveConfiguration keepAliveConfiguration) { if(keepAliveConfiguration != null) client.setConnectionPool(new ConnectionPool(keepAliveConfiguration.getMaxIdleConnections(), keepAliveConfiguration.getKeepAliveDurationMs())); }
[ "public", "void", "setKeepAliveConfiguration", "(", "KeepAliveConfiguration", "keepAliveConfiguration", ")", "{", "if", "(", "keepAliveConfiguration", "!=", "null", ")", "client", ".", "setConnectionPool", "(", "new", "ConnectionPool", "(", "keepAliveConfiguration", ".", "getMaxIdleConnections", "(", ")", ",", "keepAliveConfiguration", ".", "getKeepAliveDurationMs", "(", ")", ")", ")", ";", "}" ]
Set the keep alive configuration to use for this client. @param keepAliveConfiguration The keep alive configuration
[ "Set", "the", "keep", "alive", "configuration", "to", "use", "for", "this", "client", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L147-L152
11,223
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.setLogger
public void setLogger(String logger) { if(logger != null && logger.trim().length() > 0) this.logger = LoggerFactory.getLogger(logger); }
java
public void setLogger(String logger) { if(logger != null && logger.trim().length() > 0) this.logger = LoggerFactory.getLogger(logger); }
[ "public", "void", "setLogger", "(", "String", "logger", ")", "{", "if", "(", "logger", "!=", "null", "&&", "logger", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "this", ".", "logger", "=", "LoggerFactory", ".", "getLogger", "(", "logger", ")", ";", "}" ]
Set an alternate logger for this client to use for log statements. This can be used to direct client logs to different destinations. The default value is "com.dottydingo.hyperion.client.HyperionClient" @param logger The logger to use
[ "Set", "an", "alternate", "logger", "for", "this", "client", "to", "use", "for", "log", "statements", ".", "This", "can", "be", "used", "to", "direct", "client", "logs", "to", "different", "destinations", ".", "The", "default", "value", "is", "com", ".", "dottydingo", ".", "hyperion", ".", "client", ".", "HyperionClient" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L177-L181
11,224
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.buildHttpRequest
protected com.squareup.okhttp.Request buildHttpRequest(Request request) { RequestBody requestBody = null; if(request.getRequestMethod().isBodyRequest()) requestBody = RequestBody.create(JSON, serializeBody(request)); return new com.squareup.okhttp.Request.Builder() .url(buildUrl(request)) .headers(getHeaders(request)) .method(request.getRequestMethod().name(),requestBody) .build(); }
java
protected com.squareup.okhttp.Request buildHttpRequest(Request request) { RequestBody requestBody = null; if(request.getRequestMethod().isBodyRequest()) requestBody = RequestBody.create(JSON, serializeBody(request)); return new com.squareup.okhttp.Request.Builder() .url(buildUrl(request)) .headers(getHeaders(request)) .method(request.getRequestMethod().name(),requestBody) .build(); }
[ "protected", "com", ".", "squareup", ".", "okhttp", ".", "Request", "buildHttpRequest", "(", "Request", "request", ")", "{", "RequestBody", "requestBody", "=", "null", ";", "if", "(", "request", ".", "getRequestMethod", "(", ")", ".", "isBodyRequest", "(", ")", ")", "requestBody", "=", "RequestBody", ".", "create", "(", "JSON", ",", "serializeBody", "(", "request", ")", ")", ";", "return", "new", "com", ".", "squareup", ".", "okhttp", ".", "Request", ".", "Builder", "(", ")", ".", "url", "(", "buildUrl", "(", "request", ")", ")", ".", "headers", "(", "getHeaders", "(", "request", ")", ")", ".", "method", "(", "request", ".", "getRequestMethod", "(", ")", ".", "name", "(", ")", ",", "requestBody", ")", ".", "build", "(", ")", ";", "}" ]
Build the actual http request @param request The data service request @return The http request
[ "Build", "the", "actual", "http", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L282-L293
11,225
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.readResponse
protected <T> T readResponse(Response response,JavaType javaType) { try { return objectMapper.readValue(response.body().byteStream(), javaType); } catch (IOException e) { throw new ClientMarshallingException("Error reading results.",e); } }
java
protected <T> T readResponse(Response response,JavaType javaType) { try { return objectMapper.readValue(response.body().byteStream(), javaType); } catch (IOException e) { throw new ClientMarshallingException("Error reading results.",e); } }
[ "protected", "<", "T", ">", "T", "readResponse", "(", "Response", "response", ",", "JavaType", "javaType", ")", "{", "try", "{", "return", "objectMapper", ".", "readValue", "(", "response", ".", "body", "(", ")", ".", "byteStream", "(", ")", ",", "javaType", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "ClientMarshallingException", "(", "\"Error reading results.\"", ",", "e", ")", ";", "}", "}" ]
Read the response and unmarshall into the expected type @param response The http response @param javaType The type to return @return The response value
[ "Read", "the", "response", "and", "unmarshall", "into", "the", "expected", "type" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L371-L381
11,226
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.serializeBody
protected String serializeBody(Request request) { try { return objectMapper.writeValueAsString(request.getRequestBody()); } catch (JsonProcessingException e) { throw new ClientMarshallingException("Error writing request.",e); } }
java
protected String serializeBody(Request request) { try { return objectMapper.writeValueAsString(request.getRequestBody()); } catch (JsonProcessingException e) { throw new ClientMarshallingException("Error writing request.",e); } }
[ "protected", "String", "serializeBody", "(", "Request", "request", ")", "{", "try", "{", "return", "objectMapper", ".", "writeValueAsString", "(", "request", ".", "getRequestBody", "(", ")", ")", ";", "}", "catch", "(", "JsonProcessingException", "e", ")", "{", "throw", "new", "ClientMarshallingException", "(", "\"Error writing request.\"", ",", "e", ")", ";", "}", "}" ]
Serialize the request body @param request The data service request @return The JSON representation of the request
[ "Serialize", "the", "request", "body" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L388-L398
11,227
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.readException
protected HyperionException readException(Response response) throws IOException { ErrorResponse errorResponse = null; try { errorResponse = objectMapper.readValue(response.body().byteStream(), ErrorResponse.class); } catch (Exception ignore) { } HyperionException resolvedException = null; if (errorResponse != null) { try { Class exceptionClass = Class.forName(errorResponse.getType()); resolvedException = (HyperionException) exceptionClass.getConstructor(String.class) .newInstance(errorResponse.getMessage()); } catch (Throwable ignore) { } if (resolvedException == null) { resolvedException = new HyperionException(errorResponse.getStatusCode(), errorResponse.getMessage()); } resolvedException.setErrorDetails(errorResponse.getErrorDetails()); resolvedException.setErrorTime(errorResponse.getErrorTime()); resolvedException.setRequestId(errorResponse.getRequestId()); } if (resolvedException == null) { resolvedException = new HyperionException(response.code(), response.message()); } return resolvedException; }
java
protected HyperionException readException(Response response) throws IOException { ErrorResponse errorResponse = null; try { errorResponse = objectMapper.readValue(response.body().byteStream(), ErrorResponse.class); } catch (Exception ignore) { } HyperionException resolvedException = null; if (errorResponse != null) { try { Class exceptionClass = Class.forName(errorResponse.getType()); resolvedException = (HyperionException) exceptionClass.getConstructor(String.class) .newInstance(errorResponse.getMessage()); } catch (Throwable ignore) { } if (resolvedException == null) { resolvedException = new HyperionException(errorResponse.getStatusCode(), errorResponse.getMessage()); } resolvedException.setErrorDetails(errorResponse.getErrorDetails()); resolvedException.setErrorTime(errorResponse.getErrorTime()); resolvedException.setRequestId(errorResponse.getRequestId()); } if (resolvedException == null) { resolvedException = new HyperionException(response.code(), response.message()); } return resolvedException; }
[ "protected", "HyperionException", "readException", "(", "Response", "response", ")", "throws", "IOException", "{", "ErrorResponse", "errorResponse", "=", "null", ";", "try", "{", "errorResponse", "=", "objectMapper", ".", "readValue", "(", "response", ".", "body", "(", ")", ".", "byteStream", "(", ")", ",", "ErrorResponse", ".", "class", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "HyperionException", "resolvedException", "=", "null", ";", "if", "(", "errorResponse", "!=", "null", ")", "{", "try", "{", "Class", "exceptionClass", "=", "Class", ".", "forName", "(", "errorResponse", ".", "getType", "(", ")", ")", ";", "resolvedException", "=", "(", "HyperionException", ")", "exceptionClass", ".", "getConstructor", "(", "String", ".", "class", ")", ".", "newInstance", "(", "errorResponse", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "ignore", ")", "{", "}", "if", "(", "resolvedException", "==", "null", ")", "{", "resolvedException", "=", "new", "HyperionException", "(", "errorResponse", ".", "getStatusCode", "(", ")", ",", "errorResponse", ".", "getMessage", "(", ")", ")", ";", "}", "resolvedException", ".", "setErrorDetails", "(", "errorResponse", ".", "getErrorDetails", "(", ")", ")", ";", "resolvedException", ".", "setErrorTime", "(", "errorResponse", ".", "getErrorTime", "(", ")", ")", ";", "resolvedException", ".", "setRequestId", "(", "errorResponse", ".", "getRequestId", "(", ")", ")", ";", "}", "if", "(", "resolvedException", "==", "null", ")", "{", "resolvedException", "=", "new", "HyperionException", "(", "response", ".", "code", "(", ")", ",", "response", ".", "message", "(", ")", ")", ";", "}", "return", "resolvedException", ";", "}" ]
Create the proper exception for the error response @param response The http response @return The exception for the error response @throws IOException
[ "Create", "the", "proper", "exception", "for", "the", "error", "response" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L407-L450
11,228
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.buildUrl
protected String buildUrl(Request request) { StringBuilder sb = new StringBuilder(512); sb.append(baseUrl).append(request.getEntityName()).append("/"); if(request.getPath() != null) sb.append(request.getPath()); String queryString = buildQueryString(request); if(queryString.length()>0) { sb.append("?").append(queryString); } return sb.toString(); }
java
protected String buildUrl(Request request) { StringBuilder sb = new StringBuilder(512); sb.append(baseUrl).append(request.getEntityName()).append("/"); if(request.getPath() != null) sb.append(request.getPath()); String queryString = buildQueryString(request); if(queryString.length()>0) { sb.append("?").append(queryString); } return sb.toString(); }
[ "protected", "String", "buildUrl", "(", "Request", "request", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "512", ")", ";", "sb", ".", "append", "(", "baseUrl", ")", ".", "append", "(", "request", ".", "getEntityName", "(", ")", ")", ".", "append", "(", "\"/\"", ")", ";", "if", "(", "request", ".", "getPath", "(", ")", "!=", "null", ")", "sb", ".", "append", "(", "request", ".", "getPath", "(", ")", ")", ";", "String", "queryString", "=", "buildQueryString", "(", "request", ")", ";", "if", "(", "queryString", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\"?\"", ")", ".", "append", "(", "queryString", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Build the URL for the specified request @param request the data service request @return The URL string
[ "Build", "the", "URL", "for", "the", "specified", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L467-L481
11,229
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.buildQueryString
protected String buildQueryString(Request request) { MultiMap resolvedParameters = null; if(parameterFactory != null) { resolvedParameters = parameterFactory.getParameters(); } if(hasEntries(resolvedParameters)) resolvedParameters = resolvedParameters.merge(request.getParameters()); else resolvedParameters = request.getParameters(); if(authorizationFactory != null) { MultiMap authEntries = authorizationFactory.getParameters(); if(hasEntries(authEntries)) resolvedParameters = resolvedParameters.merge(authEntries); } int ct = 0; StringBuilder sb = new StringBuilder(512); for (Map.Entry<String, List<String>> entry : resolvedParameters.entries()) { for (String value : entry.getValue()) { if(ct++ > 0) sb.append("&"); sb.append(encode(entry.getKey())).append("=").append(encode(value)); } } return sb.toString(); }
java
protected String buildQueryString(Request request) { MultiMap resolvedParameters = null; if(parameterFactory != null) { resolvedParameters = parameterFactory.getParameters(); } if(hasEntries(resolvedParameters)) resolvedParameters = resolvedParameters.merge(request.getParameters()); else resolvedParameters = request.getParameters(); if(authorizationFactory != null) { MultiMap authEntries = authorizationFactory.getParameters(); if(hasEntries(authEntries)) resolvedParameters = resolvedParameters.merge(authEntries); } int ct = 0; StringBuilder sb = new StringBuilder(512); for (Map.Entry<String, List<String>> entry : resolvedParameters.entries()) { for (String value : entry.getValue()) { if(ct++ > 0) sb.append("&"); sb.append(encode(entry.getKey())).append("=").append(encode(value)); } } return sb.toString(); }
[ "protected", "String", "buildQueryString", "(", "Request", "request", ")", "{", "MultiMap", "resolvedParameters", "=", "null", ";", "if", "(", "parameterFactory", "!=", "null", ")", "{", "resolvedParameters", "=", "parameterFactory", ".", "getParameters", "(", ")", ";", "}", "if", "(", "hasEntries", "(", "resolvedParameters", ")", ")", "resolvedParameters", "=", "resolvedParameters", ".", "merge", "(", "request", ".", "getParameters", "(", ")", ")", ";", "else", "resolvedParameters", "=", "request", ".", "getParameters", "(", ")", ";", "if", "(", "authorizationFactory", "!=", "null", ")", "{", "MultiMap", "authEntries", "=", "authorizationFactory", ".", "getParameters", "(", ")", ";", "if", "(", "hasEntries", "(", "authEntries", ")", ")", "resolvedParameters", "=", "resolvedParameters", ".", "merge", "(", "authEntries", ")", ";", "}", "int", "ct", "=", "0", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "512", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "String", ">", ">", "entry", ":", "resolvedParameters", ".", "entries", "(", ")", ")", "{", "for", "(", "String", "value", ":", "entry", ".", "getValue", "(", ")", ")", "{", "if", "(", "ct", "++", ">", "0", ")", "sb", ".", "append", "(", "\"&\"", ")", ";", "sb", ".", "append", "(", "encode", "(", "entry", ".", "getKey", "(", ")", ")", ")", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "encode", "(", "value", ")", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Build the query string for the specified request @param request the data service request @return The query string
[ "Build", "the", "query", "string", "for", "the", "specified", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L488-L522
11,230
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.getHeaders
protected Headers getHeaders(Request request) { Headers.Builder headers = new Headers.Builder(); MultiMap resolvedHeaders = null; if(headerFactory != null) resolvedHeaders = headerFactory.getHeaders(); if(hasEntries(resolvedHeaders)) resolvedHeaders = resolvedHeaders.merge(request.getHeaders()); else resolvedHeaders = request.getHeaders(); if(authorizationFactory != null) { MultiMap authEntries = authorizationFactory.getHeaders(); if(hasEntries(authEntries)) resolvedHeaders = resolvedHeaders.merge(authEntries); } if(resolvedHeaders.getFirst("user-agent") == null) headers.add("user-agent",userAgent); if(resolvedHeaders.getFirst(CLIENT_VERSION_HEADER_NAME) == null) headers.add(CLIENT_VERSION_HEADER_NAME,getClientVersion()); for (Map.Entry<String, List<String>> entry : resolvedHeaders.entries()) { for (String value : entry.getValue()) { headers.add(entry.getKey(), value); } } return headers.build(); }
java
protected Headers getHeaders(Request request) { Headers.Builder headers = new Headers.Builder(); MultiMap resolvedHeaders = null; if(headerFactory != null) resolvedHeaders = headerFactory.getHeaders(); if(hasEntries(resolvedHeaders)) resolvedHeaders = resolvedHeaders.merge(request.getHeaders()); else resolvedHeaders = request.getHeaders(); if(authorizationFactory != null) { MultiMap authEntries = authorizationFactory.getHeaders(); if(hasEntries(authEntries)) resolvedHeaders = resolvedHeaders.merge(authEntries); } if(resolvedHeaders.getFirst("user-agent") == null) headers.add("user-agent",userAgent); if(resolvedHeaders.getFirst(CLIENT_VERSION_HEADER_NAME) == null) headers.add(CLIENT_VERSION_HEADER_NAME,getClientVersion()); for (Map.Entry<String, List<String>> entry : resolvedHeaders.entries()) { for (String value : entry.getValue()) { headers.add(entry.getKey(), value); } } return headers.build(); }
[ "protected", "Headers", "getHeaders", "(", "Request", "request", ")", "{", "Headers", ".", "Builder", "headers", "=", "new", "Headers", ".", "Builder", "(", ")", ";", "MultiMap", "resolvedHeaders", "=", "null", ";", "if", "(", "headerFactory", "!=", "null", ")", "resolvedHeaders", "=", "headerFactory", ".", "getHeaders", "(", ")", ";", "if", "(", "hasEntries", "(", "resolvedHeaders", ")", ")", "resolvedHeaders", "=", "resolvedHeaders", ".", "merge", "(", "request", ".", "getHeaders", "(", ")", ")", ";", "else", "resolvedHeaders", "=", "request", ".", "getHeaders", "(", ")", ";", "if", "(", "authorizationFactory", "!=", "null", ")", "{", "MultiMap", "authEntries", "=", "authorizationFactory", ".", "getHeaders", "(", ")", ";", "if", "(", "hasEntries", "(", "authEntries", ")", ")", "resolvedHeaders", "=", "resolvedHeaders", ".", "merge", "(", "authEntries", ")", ";", "}", "if", "(", "resolvedHeaders", ".", "getFirst", "(", "\"user-agent\"", ")", "==", "null", ")", "headers", ".", "add", "(", "\"user-agent\"", ",", "userAgent", ")", ";", "if", "(", "resolvedHeaders", ".", "getFirst", "(", "CLIENT_VERSION_HEADER_NAME", ")", "==", "null", ")", "headers", ".", "add", "(", "CLIENT_VERSION_HEADER_NAME", ",", "getClientVersion", "(", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "String", ">", ">", "entry", ":", "resolvedHeaders", ".", "entries", "(", ")", ")", "{", "for", "(", "String", "value", ":", "entry", ".", "getValue", "(", ")", ")", "{", "headers", ".", "add", "(", "entry", ".", "getKey", "(", ")", ",", "value", ")", ";", "}", "}", "return", "headers", ".", "build", "(", ")", ";", "}" ]
Return the headers for the supplied request @param request The data service request @return The headers
[ "Return", "the", "headers", "for", "the", "supplied", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L529-L562
11,231
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java
HyperionClient.encode
protected String encode(String value) { try { return URLEncoder.encode(value,"UTF-8"); } catch (UnsupportedEncodingException e) { throw new ClientException(500,"Error encoding parameter.",e); } }
java
protected String encode(String value) { try { return URLEncoder.encode(value,"UTF-8"); } catch (UnsupportedEncodingException e) { throw new ClientException(500,"Error encoding parameter.",e); } }
[ "protected", "String", "encode", "(", "String", "value", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "value", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "ClientException", "(", "500", ",", "\"Error encoding parameter.\"", ",", "e", ")", ";", "}", "}" ]
Encode the supplied string @param value The string @return The enclded value
[ "Encode", "the", "supplied", "string" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/HyperionClient.java#L578-L588
11,232
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/S.java
S.keyIterator
IntIterator keyIterator() { return new IntIterator() { final IntIterator setitr = set.keyIterator(); public boolean hasNext() { return setitr.hasNext(); } public int next() { return setitr.next(); } }; }
java
IntIterator keyIterator() { return new IntIterator() { final IntIterator setitr = set.keyIterator(); public boolean hasNext() { return setitr.hasNext(); } public int next() { return setitr.next(); } }; }
[ "IntIterator", "keyIterator", "(", ")", "{", "return", "new", "IntIterator", "(", ")", "{", "final", "IntIterator", "setitr", "=", "set", ".", "keyIterator", "(", ")", ";", "public", "boolean", "hasNext", "(", ")", "{", "return", "setitr", ".", "hasNext", "(", ")", ";", "}", "public", "int", "next", "(", ")", "{", "return", "setitr", ".", "next", "(", ")", ";", "}", "}", ";", "}" ]
Returns an iterator over the keys of this map. The keys are returned in no particular order. @return an iterator over the keys of this map.
[ "Returns", "an", "iterator", "over", "the", "keys", "of", "this", "map", ".", "The", "keys", "are", "returned", "in", "no", "particular", "order", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/S.java#L89-L103
11,233
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/util/ServletContextUtils.java
ServletContextUtils.getContextPath
public static String getContextPath(ServletContext servletContext) { String contextPath = DEFAULT_CONTEXT_PATH; // Get the context path if (servletContext != null) { contextPath = servletContext.getContextPath(); if (StringUtils.isEmpty(contextPath)) { contextPath = DEFAULT_CONTEXT_PATH; } } return contextPath; }
java
public static String getContextPath(ServletContext servletContext) { String contextPath = DEFAULT_CONTEXT_PATH; // Get the context path if (servletContext != null) { contextPath = servletContext.getContextPath(); if (StringUtils.isEmpty(contextPath)) { contextPath = DEFAULT_CONTEXT_PATH; } } return contextPath; }
[ "public", "static", "String", "getContextPath", "(", "ServletContext", "servletContext", ")", "{", "String", "contextPath", "=", "DEFAULT_CONTEXT_PATH", ";", "// Get the context path", "if", "(", "servletContext", "!=", "null", ")", "{", "contextPath", "=", "servletContext", ".", "getContextPath", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "contextPath", ")", ")", "{", "contextPath", "=", "DEFAULT_CONTEXT_PATH", ";", "}", "}", "return", "contextPath", ";", "}" ]
Returns the context path associated to the servlet context @param servletContext the servlet context @return the context path associated to the servlet context
[ "Returns", "the", "context", "path", "associated", "to", "the", "servlet", "context" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/util/ServletContextUtils.java#L38-L50
11,234
dottydingo/hyperion
core/src/main/java/com/dottydingo/hyperion/core/endpoint/pipeline/phase/CreatePhase.java
CreatePhase.processCollectionRequest
protected void processCollectionRequest(HyperionContext hyperionContext) { EndpointRequest request = hyperionContext.getEndpointRequest(); EndpointResponse response = hyperionContext.getEndpointResponse(); ApiVersionPlugin<ApiObject<Serializable>,PersistentObject<Serializable>,Serializable> apiVersionPlugin = hyperionContext.getVersionPlugin(); EntityPlugin plugin = hyperionContext.getEntityPlugin(); List<ApiObject<Serializable>> clientObjects = null; try { clientObjects = marshaller.unmarshallCollection(request.getInputStream(), apiVersionPlugin.getApiClass()); } catch (WriteLimitException e) { throw new BadRequestException(messageSource.getErrorMessage(ERROR_WRITE_LIMIT,hyperionContext.getLocale(),e.getWriteLimit()),e); } catch (MarshallingException e) { throw new BadRequestException(messageSource.getErrorMessage(ERROR_READING_REQUEST,hyperionContext.getLocale(),e.getMessage()),e); } PersistenceContext persistenceContext = buildPersistenceContext(hyperionContext); Set<String> fieldSet = persistenceContext.getRequestedFields(); if(fieldSet != null) fieldSet.add("id"); List<ApiObject> saved = plugin.getPersistenceOperations().createOrUpdateItems(clientObjects, persistenceContext); processChangeEvents(hyperionContext,persistenceContext); response.setResponseCode(200); EntityList<ApiObject> entityResponse = new EntityList<>(); entityResponse.setEntries(saved); hyperionContext.setResult(entityResponse); }
java
protected void processCollectionRequest(HyperionContext hyperionContext) { EndpointRequest request = hyperionContext.getEndpointRequest(); EndpointResponse response = hyperionContext.getEndpointResponse(); ApiVersionPlugin<ApiObject<Serializable>,PersistentObject<Serializable>,Serializable> apiVersionPlugin = hyperionContext.getVersionPlugin(); EntityPlugin plugin = hyperionContext.getEntityPlugin(); List<ApiObject<Serializable>> clientObjects = null; try { clientObjects = marshaller.unmarshallCollection(request.getInputStream(), apiVersionPlugin.getApiClass()); } catch (WriteLimitException e) { throw new BadRequestException(messageSource.getErrorMessage(ERROR_WRITE_LIMIT,hyperionContext.getLocale(),e.getWriteLimit()),e); } catch (MarshallingException e) { throw new BadRequestException(messageSource.getErrorMessage(ERROR_READING_REQUEST,hyperionContext.getLocale(),e.getMessage()),e); } PersistenceContext persistenceContext = buildPersistenceContext(hyperionContext); Set<String> fieldSet = persistenceContext.getRequestedFields(); if(fieldSet != null) fieldSet.add("id"); List<ApiObject> saved = plugin.getPersistenceOperations().createOrUpdateItems(clientObjects, persistenceContext); processChangeEvents(hyperionContext,persistenceContext); response.setResponseCode(200); EntityList<ApiObject> entityResponse = new EntityList<>(); entityResponse.setEntries(saved); hyperionContext.setResult(entityResponse); }
[ "protected", "void", "processCollectionRequest", "(", "HyperionContext", "hyperionContext", ")", "{", "EndpointRequest", "request", "=", "hyperionContext", ".", "getEndpointRequest", "(", ")", ";", "EndpointResponse", "response", "=", "hyperionContext", ".", "getEndpointResponse", "(", ")", ";", "ApiVersionPlugin", "<", "ApiObject", "<", "Serializable", ">", ",", "PersistentObject", "<", "Serializable", ">", ",", "Serializable", ">", "apiVersionPlugin", "=", "hyperionContext", ".", "getVersionPlugin", "(", ")", ";", "EntityPlugin", "plugin", "=", "hyperionContext", ".", "getEntityPlugin", "(", ")", ";", "List", "<", "ApiObject", "<", "Serializable", ">", ">", "clientObjects", "=", "null", ";", "try", "{", "clientObjects", "=", "marshaller", ".", "unmarshallCollection", "(", "request", ".", "getInputStream", "(", ")", ",", "apiVersionPlugin", ".", "getApiClass", "(", ")", ")", ";", "}", "catch", "(", "WriteLimitException", "e", ")", "{", "throw", "new", "BadRequestException", "(", "messageSource", ".", "getErrorMessage", "(", "ERROR_WRITE_LIMIT", ",", "hyperionContext", ".", "getLocale", "(", ")", ",", "e", ".", "getWriteLimit", "(", ")", ")", ",", "e", ")", ";", "}", "catch", "(", "MarshallingException", "e", ")", "{", "throw", "new", "BadRequestException", "(", "messageSource", ".", "getErrorMessage", "(", "ERROR_READING_REQUEST", ",", "hyperionContext", ".", "getLocale", "(", ")", ",", "e", ".", "getMessage", "(", ")", ")", ",", "e", ")", ";", "}", "PersistenceContext", "persistenceContext", "=", "buildPersistenceContext", "(", "hyperionContext", ")", ";", "Set", "<", "String", ">", "fieldSet", "=", "persistenceContext", ".", "getRequestedFields", "(", ")", ";", "if", "(", "fieldSet", "!=", "null", ")", "fieldSet", ".", "add", "(", "\"id\"", ")", ";", "List", "<", "ApiObject", ">", "saved", "=", "plugin", ".", "getPersistenceOperations", "(", ")", ".", "createOrUpdateItems", "(", "clientObjects", ",", "persistenceContext", ")", ";", "processChangeEvents", "(", "hyperionContext", ",", "persistenceContext", ")", ";", "response", ".", "setResponseCode", "(", "200", ")", ";", "EntityList", "<", "ApiObject", ">", "entityResponse", "=", "new", "EntityList", "<>", "(", ")", ";", "entityResponse", ".", "setEntries", "(", "saved", ")", ";", "hyperionContext", ".", "setResult", "(", "entityResponse", ")", ";", "}" ]
Process a multi-item request @param hyperionContext The context
[ "Process", "a", "multi", "-", "item", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/core/src/main/java/com/dottydingo/hyperion/core/endpoint/pipeline/phase/CreatePhase.java#L85-L122
11,235
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/R.java
R.store
void store(int A, int r, int B) { getB(A, r).add(B); getA(B, r).add(A); }
java
void store(int A, int r, int B) { getB(A, r).add(B); getA(B, r).add(A); }
[ "void", "store", "(", "int", "A", ",", "int", "r", ",", "int", "B", ")", "{", "getB", "(", "A", ",", "r", ")", ".", "add", "(", "B", ")", ";", "getA", "(", "B", ",", "r", ")", ".", "add", "(", "A", ")", ";", "}" ]
Record A [ r.B @param A @param r @param B
[ "Record", "A", "[", "r", ".", "B" ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/R.java#L48-L51
11,236
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/R.java
R1.subtract
public void subtract(R1 relationships) { if (null == base) { throw new AssertionError(""); } for (int i = 0; i < base.length; i++) { if (null == base[i]) { continue; } final IConceptSet set = data[i] = new SparseConceptHashSet(); set.addAll(base[i]); if (null != relationships.data[i]) { set.removeAll(relationships.data[i]); } } }
java
public void subtract(R1 relationships) { if (null == base) { throw new AssertionError(""); } for (int i = 0; i < base.length; i++) { if (null == base[i]) { continue; } final IConceptSet set = data[i] = new SparseConceptHashSet(); set.addAll(base[i]); if (null != relationships.data[i]) { set.removeAll(relationships.data[i]); } } }
[ "public", "void", "subtract", "(", "R1", "relationships", ")", "{", "if", "(", "null", "==", "base", ")", "{", "throw", "new", "AssertionError", "(", "\"\"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "base", ".", "length", ";", "i", "++", ")", "{", "if", "(", "null", "==", "base", "[", "i", "]", ")", "{", "continue", ";", "}", "final", "IConceptSet", "set", "=", "data", "[", "i", "]", "=", "new", "SparseConceptHashSet", "(", ")", ";", "set", ".", "addAll", "(", "base", "[", "i", "]", ")", ";", "if", "(", "null", "!=", "relationships", ".", "data", "[", "i", "]", ")", "{", "set", ".", "removeAll", "(", "relationships", ".", "data", "[", "i", "]", ")", ";", "}", "}", "}" ]
This should only ever be called when the relationships wrap an initial state and no other methods have been called. @param relationships
[ "This", "should", "only", "ever", "be", "called", "when", "the", "relationships", "wrap", "an", "initial", "state", "and", "no", "other", "methods", "have", "been", "called", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/R.java#L115-L130
11,237
d-michail/jheaps
src/main/java/org/jheaps/array/DaryArrayAddressableHeap.java
DaryArrayAddressableHeap.handlesIterator
public Iterator<AddressableHeap.Handle<K, V>> handlesIterator() { return new Iterator<AddressableHeap.Handle<K, V>>() { private int pos = 1; public boolean hasNext() { return pos <= size; } public AddressableHeap.Handle<K, V> next() { return array[pos++]; } public void remove() { throw new UnsupportedOperationException(); } }; }
java
public Iterator<AddressableHeap.Handle<K, V>> handlesIterator() { return new Iterator<AddressableHeap.Handle<K, V>>() { private int pos = 1; public boolean hasNext() { return pos <= size; } public AddressableHeap.Handle<K, V> next() { return array[pos++]; } public void remove() { throw new UnsupportedOperationException(); } }; }
[ "public", "Iterator", "<", "AddressableHeap", ".", "Handle", "<", "K", ",", "V", ">", ">", "handlesIterator", "(", ")", "{", "return", "new", "Iterator", "<", "AddressableHeap", ".", "Handle", "<", "K", ",", "V", ">", ">", "(", ")", "{", "private", "int", "pos", "=", "1", ";", "public", "boolean", "hasNext", "(", ")", "{", "return", "pos", "<=", "size", ";", "}", "public", "AddressableHeap", ".", "Handle", "<", "K", ",", "V", ">", "next", "(", ")", "{", "return", "array", "[", "pos", "++", "]", ";", "}", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "}", ";", "}" ]
Get an iterator for all handles currently in the heap. This method is especially useful when building a heap using the heapify method. Unspecified behavior will occur if the heap is modified while using this iterator. @return an iterator which will return all handles of the heap
[ "Get", "an", "iterator", "for", "all", "handles", "currently", "in", "the", "heap", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/DaryArrayAddressableHeap.java#L337-L353
11,238
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/handler/reader/PathPrefixedServletContextResourceReader.java
PathPrefixedServletContextResourceReader.getFullPath
public String getFullPath(String path) { if (StringUtils.isEmpty(pathPrefix)) { return path; } return PathNormalizer.asPath(pathPrefix + path); }
java
public String getFullPath(String path) { if (StringUtils.isEmpty(pathPrefix)) { return path; } return PathNormalizer.asPath(pathPrefix + path); }
[ "public", "String", "getFullPath", "(", "String", "path", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "pathPrefix", ")", ")", "{", "return", "path", ";", "}", "return", "PathNormalizer", ".", "asPath", "(", "pathPrefix", "+", "path", ")", ";", "}" ]
Returns the full path for the specified resource @param path the resource path @return the full path for the specified resource
[ "Returns", "the", "full", "path", "for", "the", "specified", "resource" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/handler/reader/PathPrefixedServletContextResourceReader.java#L61-L68
11,239
d-michail/jheaps
src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java
BinaryTreeSoftAddressableHeap.updateSuffixMin
@SuppressWarnings("unchecked") private void updateSuffixMin(RootListNode<K, V> t) { if (comparator == null) { while (t != null) { if (t.next == null) { t.suffixMin = t; } else { RootListNode<K, V> nextSuffixMin = t.next.suffixMin; if (((Comparable<? super K>) t.root.cKey).compareTo(nextSuffixMin.root.cKey) <= 0) { t.suffixMin = t; } else { t.suffixMin = nextSuffixMin; } } t = t.prev; } } else { while (t != null) { if (t.next == null) { t.suffixMin = t; } else { RootListNode<K, V> nextSuffixMin = t.next.suffixMin; if (comparator.compare(t.root.cKey, nextSuffixMin.root.cKey) <= 0) { t.suffixMin = t; } else { t.suffixMin = nextSuffixMin; } } t = t.prev; } } }
java
@SuppressWarnings("unchecked") private void updateSuffixMin(RootListNode<K, V> t) { if (comparator == null) { while (t != null) { if (t.next == null) { t.suffixMin = t; } else { RootListNode<K, V> nextSuffixMin = t.next.suffixMin; if (((Comparable<? super K>) t.root.cKey).compareTo(nextSuffixMin.root.cKey) <= 0) { t.suffixMin = t; } else { t.suffixMin = nextSuffixMin; } } t = t.prev; } } else { while (t != null) { if (t.next == null) { t.suffixMin = t; } else { RootListNode<K, V> nextSuffixMin = t.next.suffixMin; if (comparator.compare(t.root.cKey, nextSuffixMin.root.cKey) <= 0) { t.suffixMin = t; } else { t.suffixMin = nextSuffixMin; } } t = t.prev; } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "updateSuffixMin", "(", "RootListNode", "<", "K", ",", "V", ">", "t", ")", "{", "if", "(", "comparator", "==", "null", ")", "{", "while", "(", "t", "!=", "null", ")", "{", "if", "(", "t", ".", "next", "==", "null", ")", "{", "t", ".", "suffixMin", "=", "t", ";", "}", "else", "{", "RootListNode", "<", "K", ",", "V", ">", "nextSuffixMin", "=", "t", ".", "next", ".", "suffixMin", ";", "if", "(", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "t", ".", "root", ".", "cKey", ")", ".", "compareTo", "(", "nextSuffixMin", ".", "root", ".", "cKey", ")", "<=", "0", ")", "{", "t", ".", "suffixMin", "=", "t", ";", "}", "else", "{", "t", ".", "suffixMin", "=", "nextSuffixMin", ";", "}", "}", "t", "=", "t", ".", "prev", ";", "}", "}", "else", "{", "while", "(", "t", "!=", "null", ")", "{", "if", "(", "t", ".", "next", "==", "null", ")", "{", "t", ".", "suffixMin", "=", "t", ";", "}", "else", "{", "RootListNode", "<", "K", ",", "V", ">", "nextSuffixMin", "=", "t", ".", "next", ".", "suffixMin", ";", "if", "(", "comparator", ".", "compare", "(", "t", ".", "root", ".", "cKey", ",", "nextSuffixMin", ".", "root", ".", "cKey", ")", "<=", "0", ")", "{", "t", ".", "suffixMin", "=", "t", ";", "}", "else", "{", "t", ".", "suffixMin", "=", "nextSuffixMin", ";", "}", "}", "t", "=", "t", ".", "prev", ";", "}", "}", "}" ]
Update all suffix minimum pointers for a node and all its predecessors in the root list. @param t the node
[ "Update", "all", "suffix", "minimum", "pointers", "for", "a", "node", "and", "all", "its", "predecessors", "in", "the", "root", "list", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java#L663-L694
11,240
d-michail/jheaps
src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java
BinaryTreeSoftAddressableHeap.delete
private void delete(RootListNode<K, V> n) { RootListNode<K, V> nPrev = n.prev; if (nPrev != null) { nPrev.next = n.next; } else { rootList.head = n.next; } if (n.next != null) { n.next.prev = nPrev; } else { rootList.tail = nPrev; } n.prev = null; n.next = null; }
java
private void delete(RootListNode<K, V> n) { RootListNode<K, V> nPrev = n.prev; if (nPrev != null) { nPrev.next = n.next; } else { rootList.head = n.next; } if (n.next != null) { n.next.prev = nPrev; } else { rootList.tail = nPrev; } n.prev = null; n.next = null; }
[ "private", "void", "delete", "(", "RootListNode", "<", "K", ",", "V", ">", "n", ")", "{", "RootListNode", "<", "K", ",", "V", ">", "nPrev", "=", "n", ".", "prev", ";", "if", "(", "nPrev", "!=", "null", ")", "{", "nPrev", ".", "next", "=", "n", ".", "next", ";", "}", "else", "{", "rootList", ".", "head", "=", "n", ".", "next", ";", "}", "if", "(", "n", ".", "next", "!=", "null", ")", "{", "n", ".", "next", ".", "prev", "=", "nPrev", ";", "}", "else", "{", "rootList", ".", "tail", "=", "nPrev", ";", "}", "n", ".", "prev", "=", "null", ";", "n", ".", "next", "=", "null", ";", "}" ]
Delete a node from the root list. @param n the node
[ "Delete", "a", "node", "from", "the", "root", "list", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java#L897-L914
11,241
d-michail/jheaps
src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java
BinaryTreeSoftAddressableHeap.delete
@SuppressWarnings("unchecked") private void delete(SoftHandle<K, V> n) { if (n.tree == null) { throw new IllegalArgumentException("Invalid handle!"); } /* * Delete from belonging list. Care must be taken as the tree reference * is valid only if the node is the first in the list. */ TreeNode<K, V> tree = n.tree; if (tree.cHead != n) { /* * Not first in list. Each case, remove and leave as ghost element. */ if (n.next != null) { n.next.prev = n.prev; } n.prev.next = n.next; } else { /* * First in list */ SoftHandle<K, V> nNext = n.next; tree.cHead = nNext; if (nNext != null) { /* * More elements exists, remove and leave as ghost element. * Update new first element to point to correct tree. */ nNext.prev = null; nNext.tree = tree; } else { /* * No more elements, sift. */ sift(tree); /* * If still no elements, remove tree. */ if (tree.cHead == null) { if (tree.parent instanceof TreeNode) { TreeNode<K, V> p = (TreeNode<K, V>) tree.parent; if (p.left == tree) { p.left = null; } else { p.right = null; } } else { delete((RootListNode<K, V>) tree.parent); } } } } n.tree = null; n.prev = null; n.next = null; size--; }
java
@SuppressWarnings("unchecked") private void delete(SoftHandle<K, V> n) { if (n.tree == null) { throw new IllegalArgumentException("Invalid handle!"); } /* * Delete from belonging list. Care must be taken as the tree reference * is valid only if the node is the first in the list. */ TreeNode<K, V> tree = n.tree; if (tree.cHead != n) { /* * Not first in list. Each case, remove and leave as ghost element. */ if (n.next != null) { n.next.prev = n.prev; } n.prev.next = n.next; } else { /* * First in list */ SoftHandle<K, V> nNext = n.next; tree.cHead = nNext; if (nNext != null) { /* * More elements exists, remove and leave as ghost element. * Update new first element to point to correct tree. */ nNext.prev = null; nNext.tree = tree; } else { /* * No more elements, sift. */ sift(tree); /* * If still no elements, remove tree. */ if (tree.cHead == null) { if (tree.parent instanceof TreeNode) { TreeNode<K, V> p = (TreeNode<K, V>) tree.parent; if (p.left == tree) { p.left = null; } else { p.right = null; } } else { delete((RootListNode<K, V>) tree.parent); } } } } n.tree = null; n.prev = null; n.next = null; size--; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "delete", "(", "SoftHandle", "<", "K", ",", "V", ">", "n", ")", "{", "if", "(", "n", ".", "tree", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid handle!\"", ")", ";", "}", "/*\n * Delete from belonging list. Care must be taken as the tree reference\n * is valid only if the node is the first in the list.\n */", "TreeNode", "<", "K", ",", "V", ">", "tree", "=", "n", ".", "tree", ";", "if", "(", "tree", ".", "cHead", "!=", "n", ")", "{", "/*\n * Not first in list. Each case, remove and leave as ghost element.\n */", "if", "(", "n", ".", "next", "!=", "null", ")", "{", "n", ".", "next", ".", "prev", "=", "n", ".", "prev", ";", "}", "n", ".", "prev", ".", "next", "=", "n", ".", "next", ";", "}", "else", "{", "/*\n * First in list\n */", "SoftHandle", "<", "K", ",", "V", ">", "nNext", "=", "n", ".", "next", ";", "tree", ".", "cHead", "=", "nNext", ";", "if", "(", "nNext", "!=", "null", ")", "{", "/*\n * More elements exists, remove and leave as ghost element.\n * Update new first element to point to correct tree.\n */", "nNext", ".", "prev", "=", "null", ";", "nNext", ".", "tree", "=", "tree", ";", "}", "else", "{", "/*\n * No more elements, sift.\n */", "sift", "(", "tree", ")", ";", "/*\n * If still no elements, remove tree.\n */", "if", "(", "tree", ".", "cHead", "==", "null", ")", "{", "if", "(", "tree", ".", "parent", "instanceof", "TreeNode", ")", "{", "TreeNode", "<", "K", ",", "V", ">", "p", "=", "(", "TreeNode", "<", "K", ",", "V", ">", ")", "tree", ".", "parent", ";", "if", "(", "p", ".", "left", "==", "tree", ")", "{", "p", ".", "left", "=", "null", ";", "}", "else", "{", "p", ".", "right", "=", "null", ";", "}", "}", "else", "{", "delete", "(", "(", "RootListNode", "<", "K", ",", "V", ">", ")", "tree", ".", "parent", ")", ";", "}", "}", "}", "}", "n", ".", "tree", "=", "null", ";", "n", ".", "prev", "=", "null", ";", "n", ".", "next", "=", "null", ";", "size", "--", ";", "}" ]
Delete an element. @param n the element to delete
[ "Delete", "an", "element", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/BinaryTreeSoftAddressableHeap.java#L922-L985
11,242
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.eq
public QueryExpression eq(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.EQUAL,wrap(value)); }
java
public QueryExpression eq(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.EQUAL,wrap(value)); }
[ "public", "QueryExpression", "eq", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "EQUAL", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create an equals expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "an", "equals", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L26-L29
11,243
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.ne
public QueryExpression ne(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.NOT_EQUAL,wrap(value)); }
java
public QueryExpression ne(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.NOT_EQUAL,wrap(value)); }
[ "public", "QueryExpression", "ne", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "NOT_EQUAL", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create a not equals expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "a", "not", "equals", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L92-L95
11,244
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.gt
public QueryExpression gt(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.GREATER_THAN,wrap(value)); }
java
public QueryExpression gt(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.GREATER_THAN,wrap(value)); }
[ "public", "QueryExpression", "gt", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "GREATER_THAN", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create a greater than expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "a", "greater", "than", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L158-L161
11,245
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.lt
public QueryExpression lt(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.LESS_THAN,wrap(value)); }
java
public QueryExpression lt(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.LESS_THAN,wrap(value)); }
[ "public", "QueryExpression", "lt", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "LESS_THAN", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create a less than expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "a", "less", "than", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L213-L216
11,246
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.ge
public QueryExpression ge(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.GREATER_THAN_OR_EQUAL,wrap(value)); }
java
public QueryExpression ge(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.GREATER_THAN_OR_EQUAL,wrap(value)); }
[ "public", "QueryExpression", "ge", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "GREATER_THAN_OR_EQUAL", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create a greater than or equals expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "a", "greater", "than", "or", "equals", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L268-L271
11,247
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.le
public QueryExpression le(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.LESS_THAN_OR_EQUAL,wrap(value)); }
java
public QueryExpression le(String propertyName,String value) { return new SimpleQueryExpression(propertyName, ComparisonOperator.LESS_THAN_OR_EQUAL,wrap(value)); }
[ "public", "QueryExpression", "le", "(", "String", "propertyName", ",", "String", "value", ")", "{", "return", "new", "SimpleQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "LESS_THAN_OR_EQUAL", ",", "wrap", "(", "value", ")", ")", ";", "}" ]
Create a less than or equals expression @param propertyName The propery name @param value The value @return The query expression
[ "Create", "a", "less", "than", "or", "equals", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L323-L326
11,248
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.in
public QueryExpression in(String propertyName,String... values) { return new MultiValueQueryExpression(propertyName, ComparisonOperator.IN,wrap(values)); }
java
public QueryExpression in(String propertyName,String... values) { return new MultiValueQueryExpression(propertyName, ComparisonOperator.IN,wrap(values)); }
[ "public", "QueryExpression", "in", "(", "String", "propertyName", ",", "String", "...", "values", ")", "{", "return", "new", "MultiValueQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "IN", ",", "wrap", "(", "values", ")", ")", ";", "}" ]
Create an in expression @param propertyName The propery name @param values The values @return The query expression
[ "Create", "an", "in", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L378-L381
11,249
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java
QueryBuilder.notIn
public QueryExpression notIn(String propertyName,String... values) { return new MultiValueQueryExpression(propertyName, ComparisonOperator.NOT_IN,wrap(values)); }
java
public QueryExpression notIn(String propertyName,String... values) { return new MultiValueQueryExpression(propertyName, ComparisonOperator.NOT_IN,wrap(values)); }
[ "public", "QueryExpression", "notIn", "(", "String", "propertyName", ",", "String", "...", "values", ")", "{", "return", "new", "MultiValueQueryExpression", "(", "propertyName", ",", "ComparisonOperator", ".", "NOT_IN", ",", "wrap", "(", "values", ")", ")", ";", "}" ]
Create a not in expression @param propertyName The propery name @param values The values @return The query expression
[ "Create", "a", "not", "in", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/query/QueryBuilder.java#L434-L437
11,250
d-michail/jheaps
src/main/java/org/jheaps/tree/PairingHeap.java
PairingHeap.decreaseKey
@SuppressWarnings("unchecked") private void decreaseKey(Node<K, V> n, K newKey) { int c; if (comparator == null) { c = ((Comparable<? super K>) newKey).compareTo(n.key); } else { c = comparator.compare(newKey, n.key); } if (c > 0) { throw new IllegalArgumentException("Keys can only be decreased!"); } n.key = newKey; if (c == 0 || root == n) { return; } if (n.o_s == null) { throw new IllegalArgumentException("Invalid handle!"); } // unlink from parent if (n.y_s != null) { n.y_s.o_s = n.o_s; } if (n.o_s.o_c == n) { // I am the oldest :( n.o_s.o_c = n.y_s; } else { // I have an older sibling! n.o_s.y_s = n.y_s; } n.y_s = null; n.o_s = null; // merge with root if (comparator == null) { root = link(root, n); } else { root = linkWithComparator(root, n); } }
java
@SuppressWarnings("unchecked") private void decreaseKey(Node<K, V> n, K newKey) { int c; if (comparator == null) { c = ((Comparable<? super K>) newKey).compareTo(n.key); } else { c = comparator.compare(newKey, n.key); } if (c > 0) { throw new IllegalArgumentException("Keys can only be decreased!"); } n.key = newKey; if (c == 0 || root == n) { return; } if (n.o_s == null) { throw new IllegalArgumentException("Invalid handle!"); } // unlink from parent if (n.y_s != null) { n.y_s.o_s = n.o_s; } if (n.o_s.o_c == n) { // I am the oldest :( n.o_s.o_c = n.y_s; } else { // I have an older sibling! n.o_s.y_s = n.y_s; } n.y_s = null; n.o_s = null; // merge with root if (comparator == null) { root = link(root, n); } else { root = linkWithComparator(root, n); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "decreaseKey", "(", "Node", "<", "K", ",", "V", ">", "n", ",", "K", "newKey", ")", "{", "int", "c", ";", "if", "(", "comparator", "==", "null", ")", "{", "c", "=", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "newKey", ")", ".", "compareTo", "(", "n", ".", "key", ")", ";", "}", "else", "{", "c", "=", "comparator", ".", "compare", "(", "newKey", ",", "n", ".", "key", ")", ";", "}", "if", "(", "c", ">", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Keys can only be decreased!\"", ")", ";", "}", "n", ".", "key", "=", "newKey", ";", "if", "(", "c", "==", "0", "||", "root", "==", "n", ")", "{", "return", ";", "}", "if", "(", "n", ".", "o_s", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid handle!\"", ")", ";", "}", "// unlink from parent", "if", "(", "n", ".", "y_s", "!=", "null", ")", "{", "n", ".", "y_s", ".", "o_s", "=", "n", ".", "o_s", ";", "}", "if", "(", "n", ".", "o_s", ".", "o_c", "==", "n", ")", "{", "// I am the oldest :(", "n", ".", "o_s", ".", "o_c", "=", "n", ".", "y_s", ";", "}", "else", "{", "// I have an older sibling!", "n", ".", "o_s", ".", "y_s", "=", "n", ".", "y_s", ";", "}", "n", ".", "y_s", "=", "null", ";", "n", ".", "o_s", "=", "null", ";", "// merge with root", "if", "(", "comparator", "==", "null", ")", "{", "root", "=", "link", "(", "root", ",", "n", ")", ";", "}", "else", "{", "root", "=", "linkWithComparator", "(", "root", ",", "n", ")", ";", "}", "}" ]
Decrease the key of a node. @param n the node @param newKey the new key
[ "Decrease", "the", "key", "of", "a", "node", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/PairingHeap.java#L407-L446
11,251
d-michail/jheaps
src/main/java/org/jheaps/tree/PairingHeap.java
PairingHeap.cutChildren
private Node<K, V> cutChildren(Node<K, V> n) { Node<K, V> child = n.o_c; n.o_c = null; if (child != null) { child.o_s = null; } return child; }
java
private Node<K, V> cutChildren(Node<K, V> n) { Node<K, V> child = n.o_c; n.o_c = null; if (child != null) { child.o_s = null; } return child; }
[ "private", "Node", "<", "K", ",", "V", ">", "cutChildren", "(", "Node", "<", "K", ",", "V", ">", "n", ")", "{", "Node", "<", "K", ",", "V", ">", "child", "=", "n", ".", "o_c", ";", "n", ".", "o_c", "=", "null", ";", "if", "(", "child", "!=", "null", ")", "{", "child", ".", "o_s", "=", "null", ";", "}", "return", "child", ";", "}" ]
Cut the children of a node and return the list. @param n the node @return the first node in the children list
[ "Cut", "the", "children", "of", "a", "node", "and", "return", "the", "list", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/PairingHeap.java#L593-L600
11,252
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java
SnorocketReasoner.transformLiteralToModel
protected Literal transformLiteralToModel(AbstractLiteral al) { if(al instanceof BigIntegerLiteral) { return new au.csiro.ontology.model.BigIntegerLiteral(((BigIntegerLiteral) al).getValue()); } else if(al instanceof DateLiteral) { return new au.csiro.ontology.model.DateLiteral(((DateLiteral) al).getValue()); } else if(al instanceof DecimalLiteral) { return new au.csiro.ontology.model.DecimalLiteral(((DecimalLiteral) al).getValue()); } else if(al instanceof FloatLiteral) { return new au.csiro.ontology.model.FloatLiteral(((FloatLiteral) al).getValue()); } else if(al instanceof IntegerLiteral) { return new au.csiro.ontology.model.IntegerLiteral(((IntegerLiteral) al).getValue()); } else if(al instanceof StringLiteral) { return new au.csiro.ontology.model.StringLiteral(((StringLiteral) al).getValue()); } else { throw new RuntimeException("Unexpected abstract literal "+al); } }
java
protected Literal transformLiteralToModel(AbstractLiteral al) { if(al instanceof BigIntegerLiteral) { return new au.csiro.ontology.model.BigIntegerLiteral(((BigIntegerLiteral) al).getValue()); } else if(al instanceof DateLiteral) { return new au.csiro.ontology.model.DateLiteral(((DateLiteral) al).getValue()); } else if(al instanceof DecimalLiteral) { return new au.csiro.ontology.model.DecimalLiteral(((DecimalLiteral) al).getValue()); } else if(al instanceof FloatLiteral) { return new au.csiro.ontology.model.FloatLiteral(((FloatLiteral) al).getValue()); } else if(al instanceof IntegerLiteral) { return new au.csiro.ontology.model.IntegerLiteral(((IntegerLiteral) al).getValue()); } else if(al instanceof StringLiteral) { return new au.csiro.ontology.model.StringLiteral(((StringLiteral) al).getValue()); } else { throw new RuntimeException("Unexpected abstract literal "+al); } }
[ "protected", "Literal", "transformLiteralToModel", "(", "AbstractLiteral", "al", ")", "{", "if", "(", "al", "instanceof", "BigIntegerLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "BigIntegerLiteral", "(", "(", "(", "BigIntegerLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "al", "instanceof", "DateLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "DateLiteral", "(", "(", "(", "DateLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "al", "instanceof", "DecimalLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "DecimalLiteral", "(", "(", "(", "DecimalLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "al", "instanceof", "FloatLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "FloatLiteral", "(", "(", "(", "FloatLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "al", "instanceof", "IntegerLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "IntegerLiteral", "(", "(", "(", "IntegerLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "al", "instanceof", "StringLiteral", ")", "{", "return", "new", "au", ".", "csiro", ".", "ontology", ".", "model", ".", "StringLiteral", "(", "(", "(", "StringLiteral", ")", "al", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Unexpected abstract literal \"", "+", "al", ")", ";", "}", "}" ]
Transforms literal from the internal representation to the canonical representation. @param al @return
[ "Transforms", "literal", "from", "the", "internal", "representation", "to", "the", "canonical", "representation", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java#L256-L272
11,253
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java
SnorocketReasoner.filterEquivalents
private IConceptSet filterEquivalents(final IConceptSet concepts) { int[] cArray = concepts.toArray(); boolean[] toExclude = new boolean[cArray.length]; for(int i = 0; i < cArray.length; i++) { if(toExclude[i]) continue; final IConceptSet iAncestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, cArray[i])); for(int j = i+1; j < cArray.length; j++) { if(iAncestors.contains(cArray[j])) { final IConceptSet jAncestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, cArray[j])); if(jAncestors.contains(cArray[i])) { // These concepts are equivalent to mark the second concept as excluded toExclude[j] = true; } } } } IConceptSet res = IConceptSet.FACTORY.createConceptSet(); for(int i = 0; i < cArray.length; i++) { if(!toExclude[i]) { res.add(cArray[i]); } } return res; }
java
private IConceptSet filterEquivalents(final IConceptSet concepts) { int[] cArray = concepts.toArray(); boolean[] toExclude = new boolean[cArray.length]; for(int i = 0; i < cArray.length; i++) { if(toExclude[i]) continue; final IConceptSet iAncestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, cArray[i])); for(int j = i+1; j < cArray.length; j++) { if(iAncestors.contains(cArray[j])) { final IConceptSet jAncestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, cArray[j])); if(jAncestors.contains(cArray[i])) { // These concepts are equivalent to mark the second concept as excluded toExclude[j] = true; } } } } IConceptSet res = IConceptSet.FACTORY.createConceptSet(); for(int i = 0; i < cArray.length; i++) { if(!toExclude[i]) { res.add(cArray[i]); } } return res; }
[ "private", "IConceptSet", "filterEquivalents", "(", "final", "IConceptSet", "concepts", ")", "{", "int", "[", "]", "cArray", "=", "concepts", ".", "toArray", "(", ")", ";", "boolean", "[", "]", "toExclude", "=", "new", "boolean", "[", "cArray", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "toExclude", "[", "i", "]", ")", "continue", ";", "final", "IConceptSet", "iAncestors", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", "getAncestors", "(", "no", ",", "cArray", "[", "i", "]", ")", ")", ";", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "cArray", ".", "length", ";", "j", "++", ")", "{", "if", "(", "iAncestors", ".", "contains", "(", "cArray", "[", "j", "]", ")", ")", "{", "final", "IConceptSet", "jAncestors", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", "getAncestors", "(", "no", ",", "cArray", "[", "j", "]", ")", ")", ";", "if", "(", "jAncestors", ".", "contains", "(", "cArray", "[", "i", "]", ")", ")", "{", "// These concepts are equivalent to mark the second concept as excluded", "toExclude", "[", "j", "]", "=", "true", ";", "}", "}", "}", "}", "IConceptSet", "res", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "toExclude", "[", "i", "]", ")", "{", "res", ".", "add", "(", "cArray", "[", "i", "]", ")", ";", "}", "}", "return", "res", ";", "}" ]
Identifies any equivalent concepts and retains only one of them. @param concepts @return
[ "Identifies", "any", "equivalent", "concepts", "and", "retains", "only", "one", "of", "them", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java#L409-L435
11,254
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java
SnorocketReasoner.getLeaves
private IConceptSet getLeaves(final IConceptSet concepts) { // Deal with any equivalent concepts. If there are equivalent concepts in the set then we only keep one of them. // Otherwise, both will get eliminated from the final set. final IConceptSet filtered = filterEquivalents(concepts); final IConceptSet leafBs = IConceptSet.FACTORY.createConceptSet(filtered); final IConceptSet set = IConceptSet.FACTORY.createConceptSet(leafBs); for (final IntIterator bItr = set.iterator(); bItr.hasNext(); ) { final int b = bItr.next(); final IConceptSet ancestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, b)); ancestors.remove(b); leafBs.removeAll(ancestors); } return leafBs; }
java
private IConceptSet getLeaves(final IConceptSet concepts) { // Deal with any equivalent concepts. If there are equivalent concepts in the set then we only keep one of them. // Otherwise, both will get eliminated from the final set. final IConceptSet filtered = filterEquivalents(concepts); final IConceptSet leafBs = IConceptSet.FACTORY.createConceptSet(filtered); final IConceptSet set = IConceptSet.FACTORY.createConceptSet(leafBs); for (final IntIterator bItr = set.iterator(); bItr.hasNext(); ) { final int b = bItr.next(); final IConceptSet ancestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, b)); ancestors.remove(b); leafBs.removeAll(ancestors); } return leafBs; }
[ "private", "IConceptSet", "getLeaves", "(", "final", "IConceptSet", "concepts", ")", "{", "// Deal with any equivalent concepts. If there are equivalent concepts in the set then we only keep one of them.", "// Otherwise, both will get eliminated from the final set.", "final", "IConceptSet", "filtered", "=", "filterEquivalents", "(", "concepts", ")", ";", "final", "IConceptSet", "leafBs", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", "filtered", ")", ";", "final", "IConceptSet", "set", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", "leafBs", ")", ";", "for", "(", "final", "IntIterator", "bItr", "=", "set", ".", "iterator", "(", ")", ";", "bItr", ".", "hasNext", "(", ")", ";", ")", "{", "final", "int", "b", "=", "bItr", ".", "next", "(", ")", ";", "final", "IConceptSet", "ancestors", "=", "IConceptSet", ".", "FACTORY", ".", "createConceptSet", "(", "getAncestors", "(", "no", ",", "b", ")", ")", ";", "ancestors", ".", "remove", "(", "b", ")", ";", "leafBs", ".", "removeAll", "(", "ancestors", ")", ";", "}", "return", "leafBs", ";", "}" ]
Given a set of concepts, computes the subset such that no member of the subset is subsumed by another member. result = {c | c in bs and not c' in b such that c' [ c} @param concepts set of subsumptions to filter @return
[ "Given", "a", "set", "of", "concepts", "computes", "the", "subset", "such", "that", "no", "member", "of", "the", "subset", "is", "subsumed", "by", "another", "member", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java#L445-L461
11,255
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java
SnorocketReasoner.printConcept
protected String printConcept(int id) { Object oid = factory.lookupConceptId(id); if(factory.isVirtualConcept(id)) { if(oid instanceof AbstractConcept) { return printAbstractConcept((AbstractConcept) oid); } else { return oid.toString(); } } else { return (String) oid; } }
java
protected String printConcept(int id) { Object oid = factory.lookupConceptId(id); if(factory.isVirtualConcept(id)) { if(oid instanceof AbstractConcept) { return printAbstractConcept((AbstractConcept) oid); } else { return oid.toString(); } } else { return (String) oid; } }
[ "protected", "String", "printConcept", "(", "int", "id", ")", "{", "Object", "oid", "=", "factory", ".", "lookupConceptId", "(", "id", ")", ";", "if", "(", "factory", ".", "isVirtualConcept", "(", "id", ")", ")", "{", "if", "(", "oid", "instanceof", "AbstractConcept", ")", "{", "return", "printAbstractConcept", "(", "(", "AbstractConcept", ")", "oid", ")", ";", "}", "else", "{", "return", "oid", ".", "toString", "(", ")", ";", "}", "}", "else", "{", "return", "(", "String", ")", "oid", ";", "}", "}" ]
Prints a concept given its internal id. Useful for debugging. @param id @return
[ "Prints", "a", "concept", "given", "its", "internal", "id", ".", "Useful", "for", "debugging", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java#L469-L480
11,256
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java
SnorocketReasoner.printAbstractConcept
private String printAbstractConcept(AbstractConcept ac) { if(ac instanceof au.csiro.snorocket.core.model.Concept) { au.csiro.snorocket.core.model.Concept c = (au.csiro.snorocket.core.model.Concept) ac; Object o = factory.lookupConceptId(c.hashCode()); if(o instanceof String) { return (String) o; } else { return printAbstractConcept((AbstractConcept) o); } } else if(ac instanceof au.csiro.snorocket.core.model.Conjunction) { au.csiro.snorocket.core.model.Conjunction c = (au.csiro.snorocket.core.model.Conjunction) ac; AbstractConcept[] acs = c.getConcepts(); StringBuilder sb = new StringBuilder(); if(acs != null && acs.length > 0) { sb.append(printAbstractConcept(acs[0])); for(int i = 1; i < acs.length; i++) { sb.append(" + "); sb.append(printAbstractConcept(acs[i])); } } return sb.toString(); } else if(ac instanceof au.csiro.snorocket.core.model.Existential) { au.csiro.snorocket.core.model.Existential e = (au.csiro.snorocket.core.model.Existential) ac; return "E"+factory.lookupRoleId(e.getRole()).toString()+"."+printAbstractConcept(e.getConcept()); } else if(ac instanceof au.csiro.snorocket.core.model.Datatype) { au.csiro.snorocket.core.model.Datatype d = (au.csiro.snorocket.core.model.Datatype) ac; return "F"+factory.lookupFeatureId(d.getFeature())+".("+d.getOperator()+", "+d.getLiteral()+")"; } else { throw new RuntimeException("Unexpected concept: " + ac); } }
java
private String printAbstractConcept(AbstractConcept ac) { if(ac instanceof au.csiro.snorocket.core.model.Concept) { au.csiro.snorocket.core.model.Concept c = (au.csiro.snorocket.core.model.Concept) ac; Object o = factory.lookupConceptId(c.hashCode()); if(o instanceof String) { return (String) o; } else { return printAbstractConcept((AbstractConcept) o); } } else if(ac instanceof au.csiro.snorocket.core.model.Conjunction) { au.csiro.snorocket.core.model.Conjunction c = (au.csiro.snorocket.core.model.Conjunction) ac; AbstractConcept[] acs = c.getConcepts(); StringBuilder sb = new StringBuilder(); if(acs != null && acs.length > 0) { sb.append(printAbstractConcept(acs[0])); for(int i = 1; i < acs.length; i++) { sb.append(" + "); sb.append(printAbstractConcept(acs[i])); } } return sb.toString(); } else if(ac instanceof au.csiro.snorocket.core.model.Existential) { au.csiro.snorocket.core.model.Existential e = (au.csiro.snorocket.core.model.Existential) ac; return "E"+factory.lookupRoleId(e.getRole()).toString()+"."+printAbstractConcept(e.getConcept()); } else if(ac instanceof au.csiro.snorocket.core.model.Datatype) { au.csiro.snorocket.core.model.Datatype d = (au.csiro.snorocket.core.model.Datatype) ac; return "F"+factory.lookupFeatureId(d.getFeature())+".("+d.getOperator()+", "+d.getLiteral()+")"; } else { throw new RuntimeException("Unexpected concept: " + ac); } }
[ "private", "String", "printAbstractConcept", "(", "AbstractConcept", "ac", ")", "{", "if", "(", "ac", "instanceof", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Concept", ")", "{", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Concept", "c", "=", "(", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Concept", ")", "ac", ";", "Object", "o", "=", "factory", ".", "lookupConceptId", "(", "c", ".", "hashCode", "(", ")", ")", ";", "if", "(", "o", "instanceof", "String", ")", "{", "return", "(", "String", ")", "o", ";", "}", "else", "{", "return", "printAbstractConcept", "(", "(", "AbstractConcept", ")", "o", ")", ";", "}", "}", "else", "if", "(", "ac", "instanceof", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Conjunction", ")", "{", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Conjunction", "c", "=", "(", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Conjunction", ")", "ac", ";", "AbstractConcept", "[", "]", "acs", "=", "c", ".", "getConcepts", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "acs", "!=", "null", "&&", "acs", ".", "length", ">", "0", ")", "{", "sb", ".", "append", "(", "printAbstractConcept", "(", "acs", "[", "0", "]", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "acs", ".", "length", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "\" + \"", ")", ";", "sb", ".", "append", "(", "printAbstractConcept", "(", "acs", "[", "i", "]", ")", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "ac", "instanceof", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Existential", ")", "{", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Existential", "e", "=", "(", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Existential", ")", "ac", ";", "return", "\"E\"", "+", "factory", ".", "lookupRoleId", "(", "e", ".", "getRole", "(", ")", ")", ".", "toString", "(", ")", "+", "\".\"", "+", "printAbstractConcept", "(", "e", ".", "getConcept", "(", ")", ")", ";", "}", "else", "if", "(", "ac", "instanceof", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Datatype", ")", "{", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Datatype", "d", "=", "(", "au", ".", "csiro", ".", "snorocket", ".", "core", ".", "model", ".", "Datatype", ")", "ac", ";", "return", "\"F\"", "+", "factory", ".", "lookupFeatureId", "(", "d", ".", "getFeature", "(", ")", ")", "+", "\".(\"", "+", "d", ".", "getOperator", "(", ")", "+", "\", \"", "+", "d", ".", "getLiteral", "(", ")", "+", "\")\"", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Unexpected concept: \"", "+", "ac", ")", ";", "}", "}" ]
Prints an abstract concept. Useful for debugging. @param ac @return
[ "Prints", "an", "abstract", "concept", ".", "Useful", "for", "debugging", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/SnorocketReasoner.java#L488-L518
11,257
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java
Utils.getParameterValueFromQuery
public static String getParameterValueFromQuery(String query, String paramName) { String[] components = query.split("&"); for (String keyValuePair : components) { String[] pairComponents = keyValuePair.split("="); if (pairComponents.length == 2) { try { String key = URLDecoder.decode(pairComponents[0], "utf-8"); if (key.compareTo(paramName) == 0) { return URLDecoder.decode(pairComponents[1], "utf-8"); } } catch (UnsupportedEncodingException e) { logger.error("getParameterValueFromQuery failed with exception: " + e.getLocalizedMessage(), e); } } } return null; }
java
public static String getParameterValueFromQuery(String query, String paramName) { String[] components = query.split("&"); for (String keyValuePair : components) { String[] pairComponents = keyValuePair.split("="); if (pairComponents.length == 2) { try { String key = URLDecoder.decode(pairComponents[0], "utf-8"); if (key.compareTo(paramName) == 0) { return URLDecoder.decode(pairComponents[1], "utf-8"); } } catch (UnsupportedEncodingException e) { logger.error("getParameterValueFromQuery failed with exception: " + e.getLocalizedMessage(), e); } } } return null; }
[ "public", "static", "String", "getParameterValueFromQuery", "(", "String", "query", ",", "String", "paramName", ")", "{", "String", "[", "]", "components", "=", "query", ".", "split", "(", "\"&\"", ")", ";", "for", "(", "String", "keyValuePair", ":", "components", ")", "{", "String", "[", "]", "pairComponents", "=", "keyValuePair", ".", "split", "(", "\"=\"", ")", ";", "if", "(", "pairComponents", ".", "length", "==", "2", ")", "{", "try", "{", "String", "key", "=", "URLDecoder", ".", "decode", "(", "pairComponents", "[", "0", "]", ",", "\"utf-8\"", ")", ";", "if", "(", "key", ".", "compareTo", "(", "paramName", ")", "==", "0", ")", "{", "return", "URLDecoder", ".", "decode", "(", "pairComponents", "[", "1", "]", ",", "\"utf-8\"", ")", ";", "}", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "logger", ".", "error", "(", "\"getParameterValueFromQuery failed with exception: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Obtains a parameter with specified name from from query string. The query should be in format param=value&param=value ... @param query Queery in "url" format. @param paramName Parameter name. @return Parameter value, or null.
[ "Obtains", "a", "parameter", "with", "specified", "name", "from", "from", "query", "string", ".", "The", "query", "should", "be", "in", "format", "param", "=", "value&param", "=", "value", "..." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java#L48-L68
11,258
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java
Utils.extractSecureJson
public static JSONObject extractSecureJson(Response response) { try { String responseText = response.getResponseText(); if (!responseText.startsWith(SECURE_PATTERN_START) || !responseText.endsWith(SECURE_PATTERN_END)) { return null; } int startIndex = responseText.indexOf(SECURE_PATTERN_START); int endIndex = responseText.indexOf(SECURE_PATTERN_END, responseText.length() - SECURE_PATTERN_END.length() - 1); String jsonString = responseText.substring(startIndex + SECURE_PATTERN_START.length(), endIndex); return new JSONObject(jsonString); } catch (Throwable t) { logger.error("extractSecureJson failed with exception: " + t.getLocalizedMessage(), t); return null; } }
java
public static JSONObject extractSecureJson(Response response) { try { String responseText = response.getResponseText(); if (!responseText.startsWith(SECURE_PATTERN_START) || !responseText.endsWith(SECURE_PATTERN_END)) { return null; } int startIndex = responseText.indexOf(SECURE_PATTERN_START); int endIndex = responseText.indexOf(SECURE_PATTERN_END, responseText.length() - SECURE_PATTERN_END.length() - 1); String jsonString = responseText.substring(startIndex + SECURE_PATTERN_START.length(), endIndex); return new JSONObject(jsonString); } catch (Throwable t) { logger.error("extractSecureJson failed with exception: " + t.getLocalizedMessage(), t); return null; } }
[ "public", "static", "JSONObject", "extractSecureJson", "(", "Response", "response", ")", "{", "try", "{", "String", "responseText", "=", "response", ".", "getResponseText", "(", ")", ";", "if", "(", "!", "responseText", ".", "startsWith", "(", "SECURE_PATTERN_START", ")", "||", "!", "responseText", ".", "endsWith", "(", "SECURE_PATTERN_END", ")", ")", "{", "return", "null", ";", "}", "int", "startIndex", "=", "responseText", ".", "indexOf", "(", "SECURE_PATTERN_START", ")", ";", "int", "endIndex", "=", "responseText", ".", "indexOf", "(", "SECURE_PATTERN_END", ",", "responseText", ".", "length", "(", ")", "-", "SECURE_PATTERN_END", ".", "length", "(", ")", "-", "1", ")", ";", "String", "jsonString", "=", "responseText", ".", "substring", "(", "startIndex", "+", "SECURE_PATTERN_START", ".", "length", "(", ")", ",", "endIndex", ")", ";", "return", "new", "JSONObject", "(", "jsonString", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"extractSecureJson failed with exception: \"", "+", "t", ".", "getLocalizedMessage", "(", ")", ",", "t", ")", ";", "return", "null", ";", "}", "}" ]
Extracts a JSON object from server response with secured string. @param response Server response @return Extracted secured JSON or null.
[ "Extracts", "a", "JSON", "object", "from", "server", "response", "with", "secured", "string", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java#L77-L95
11,259
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java
Utils.buildRewriteDomain
public static String buildRewriteDomain(String backendRoute, String subzone) throws MalformedURLException { if (backendRoute == null || backendRoute.isEmpty()) { logger.error("Backend route can't be null."); return null; } String applicationRoute = backendRoute; if (!applicationRoute.startsWith(BMSClient.HTTP_SCHEME)) { applicationRoute = String.format("%s://%s", BMSClient.HTTPS_SCHEME, applicationRoute); } else if (!applicationRoute.startsWith(BMSClient.HTTPS_SCHEME) && applicationRoute.contains(BLUEMIX_NAME)) { applicationRoute = applicationRoute.replace(BMSClient.HTTP_SCHEME, BMSClient.HTTPS_SCHEME); } URL url = new URL(applicationRoute); String host = url.getHost(); String rewriteDomain; String regionInDomain = "ng"; int port = url.getPort(); String serviceUrl = String.format("%s://%s", url.getProtocol(), host); if (port != 0) { serviceUrl += ":" + String.valueOf(port); } String[] hostElements = host.split("\\."); if (!serviceUrl.contains(STAGE1_NAME)) { // Multi-region: myApp.eu-gb.mybluemix.net // US: myApp.mybluemix.net if (hostElements.length == 4) { regionInDomain = hostElements[hostElements.length - 3]; } // this is production, because STAGE1 is not found // Multi-Region Eg: eu-gb.bluemix.net // US Eg: ng.bluemix.net rewriteDomain = String.format("%s.%s", regionInDomain, BLUEMIX_DOMAIN); } else { // Multi-region: myApp.stage1.eu-gb.mybluemix.net // US: myApp.stage1.mybluemix.net if (hostElements.length == 5) { regionInDomain = hostElements[hostElements.length - 3]; } if (subzone != null && !subzone.isEmpty()) { // Multi-region Dev subzone Eg: stage1-Dev.eu-gb.bluemix.net // US Dev subzone Eg: stage1-Dev.ng.bluemix.net rewriteDomain = String.format("%s-%s.%s.%s", STAGE1_NAME, subzone, regionInDomain, BLUEMIX_DOMAIN); } else { // Multi-region Eg: stage1.eu-gb.bluemix.net // US Eg: stage1.ng.bluemix.net rewriteDomain = String.format("%s.%s.%s", STAGE1_NAME, regionInDomain, BLUEMIX_DOMAIN); } } return rewriteDomain; }
java
public static String buildRewriteDomain(String backendRoute, String subzone) throws MalformedURLException { if (backendRoute == null || backendRoute.isEmpty()) { logger.error("Backend route can't be null."); return null; } String applicationRoute = backendRoute; if (!applicationRoute.startsWith(BMSClient.HTTP_SCHEME)) { applicationRoute = String.format("%s://%s", BMSClient.HTTPS_SCHEME, applicationRoute); } else if (!applicationRoute.startsWith(BMSClient.HTTPS_SCHEME) && applicationRoute.contains(BLUEMIX_NAME)) { applicationRoute = applicationRoute.replace(BMSClient.HTTP_SCHEME, BMSClient.HTTPS_SCHEME); } URL url = new URL(applicationRoute); String host = url.getHost(); String rewriteDomain; String regionInDomain = "ng"; int port = url.getPort(); String serviceUrl = String.format("%s://%s", url.getProtocol(), host); if (port != 0) { serviceUrl += ":" + String.valueOf(port); } String[] hostElements = host.split("\\."); if (!serviceUrl.contains(STAGE1_NAME)) { // Multi-region: myApp.eu-gb.mybluemix.net // US: myApp.mybluemix.net if (hostElements.length == 4) { regionInDomain = hostElements[hostElements.length - 3]; } // this is production, because STAGE1 is not found // Multi-Region Eg: eu-gb.bluemix.net // US Eg: ng.bluemix.net rewriteDomain = String.format("%s.%s", regionInDomain, BLUEMIX_DOMAIN); } else { // Multi-region: myApp.stage1.eu-gb.mybluemix.net // US: myApp.stage1.mybluemix.net if (hostElements.length == 5) { regionInDomain = hostElements[hostElements.length - 3]; } if (subzone != null && !subzone.isEmpty()) { // Multi-region Dev subzone Eg: stage1-Dev.eu-gb.bluemix.net // US Dev subzone Eg: stage1-Dev.ng.bluemix.net rewriteDomain = String.format("%s-%s.%s.%s", STAGE1_NAME, subzone, regionInDomain, BLUEMIX_DOMAIN); } else { // Multi-region Eg: stage1.eu-gb.bluemix.net // US Eg: stage1.ng.bluemix.net rewriteDomain = String.format("%s.%s.%s", STAGE1_NAME, regionInDomain, BLUEMIX_DOMAIN); } } return rewriteDomain; }
[ "public", "static", "String", "buildRewriteDomain", "(", "String", "backendRoute", ",", "String", "subzone", ")", "throws", "MalformedURLException", "{", "if", "(", "backendRoute", "==", "null", "||", "backendRoute", ".", "isEmpty", "(", ")", ")", "{", "logger", ".", "error", "(", "\"Backend route can't be null.\"", ")", ";", "return", "null", ";", "}", "String", "applicationRoute", "=", "backendRoute", ";", "if", "(", "!", "applicationRoute", ".", "startsWith", "(", "BMSClient", ".", "HTTP_SCHEME", ")", ")", "{", "applicationRoute", "=", "String", ".", "format", "(", "\"%s://%s\"", ",", "BMSClient", ".", "HTTPS_SCHEME", ",", "applicationRoute", ")", ";", "}", "else", "if", "(", "!", "applicationRoute", ".", "startsWith", "(", "BMSClient", ".", "HTTPS_SCHEME", ")", "&&", "applicationRoute", ".", "contains", "(", "BLUEMIX_NAME", ")", ")", "{", "applicationRoute", "=", "applicationRoute", ".", "replace", "(", "BMSClient", ".", "HTTP_SCHEME", ",", "BMSClient", ".", "HTTPS_SCHEME", ")", ";", "}", "URL", "url", "=", "new", "URL", "(", "applicationRoute", ")", ";", "String", "host", "=", "url", ".", "getHost", "(", ")", ";", "String", "rewriteDomain", ";", "String", "regionInDomain", "=", "\"ng\"", ";", "int", "port", "=", "url", ".", "getPort", "(", ")", ";", "String", "serviceUrl", "=", "String", ".", "format", "(", "\"%s://%s\"", ",", "url", ".", "getProtocol", "(", ")", ",", "host", ")", ";", "if", "(", "port", "!=", "0", ")", "{", "serviceUrl", "+=", "\":\"", "+", "String", ".", "valueOf", "(", "port", ")", ";", "}", "String", "[", "]", "hostElements", "=", "host", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "!", "serviceUrl", ".", "contains", "(", "STAGE1_NAME", ")", ")", "{", "// Multi-region: myApp.eu-gb.mybluemix.net", "// US: myApp.mybluemix.net", "if", "(", "hostElements", ".", "length", "==", "4", ")", "{", "regionInDomain", "=", "hostElements", "[", "hostElements", ".", "length", "-", "3", "]", ";", "}", "// this is production, because STAGE1 is not found", "// Multi-Region Eg: eu-gb.bluemix.net", "// US Eg: ng.bluemix.net", "rewriteDomain", "=", "String", ".", "format", "(", "\"%s.%s\"", ",", "regionInDomain", ",", "BLUEMIX_DOMAIN", ")", ";", "}", "else", "{", "// Multi-region: myApp.stage1.eu-gb.mybluemix.net", "// US: myApp.stage1.mybluemix.net", "if", "(", "hostElements", ".", "length", "==", "5", ")", "{", "regionInDomain", "=", "hostElements", "[", "hostElements", ".", "length", "-", "3", "]", ";", "}", "if", "(", "subzone", "!=", "null", "&&", "!", "subzone", ".", "isEmpty", "(", ")", ")", "{", "// Multi-region Dev subzone Eg: stage1-Dev.eu-gb.bluemix.net", "// US Dev subzone Eg: stage1-Dev.ng.bluemix.net", "rewriteDomain", "=", "String", ".", "format", "(", "\"%s-%s.%s.%s\"", ",", "STAGE1_NAME", ",", "subzone", ",", "regionInDomain", ",", "BLUEMIX_DOMAIN", ")", ";", "}", "else", "{", "// Multi-region Eg: stage1.eu-gb.bluemix.net", "// US Eg: stage1.ng.bluemix.net", "rewriteDomain", "=", "String", ".", "format", "(", "\"%s.%s.%s\"", ",", "STAGE1_NAME", ",", "regionInDomain", ",", "BLUEMIX_DOMAIN", ")", ";", "}", "}", "return", "rewriteDomain", ";", "}" ]
Builds rewrite domain from backend route url. @param backendRoute Backend route. @param subzone Subzone @return Rewrite domain. @throws MalformedURLException if backendRoute parameter has invalid format.
[ "Builds", "rewrite", "domain", "from", "backend", "route", "url", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java#L105-L164
11,260
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java
Utils.concatenateUrls
public static String concatenateUrls(String rootUrl, String path) { if (rootUrl == null || rootUrl.isEmpty()) { return path; } if (path == null || path.isEmpty()) { return rootUrl; } String finalUrl; if (rootUrl.charAt(rootUrl.length() - 1) == '/' && path.charAt(0) == '/') { finalUrl = rootUrl.substring(0, rootUrl.length() - 2) + path; } else if (rootUrl.charAt(rootUrl.length() - 1) != '/' && path.charAt(0) != '/') { finalUrl = rootUrl + "/" + path; } else { finalUrl = rootUrl + path; } return finalUrl; }
java
public static String concatenateUrls(String rootUrl, String path) { if (rootUrl == null || rootUrl.isEmpty()) { return path; } if (path == null || path.isEmpty()) { return rootUrl; } String finalUrl; if (rootUrl.charAt(rootUrl.length() - 1) == '/' && path.charAt(0) == '/') { finalUrl = rootUrl.substring(0, rootUrl.length() - 2) + path; } else if (rootUrl.charAt(rootUrl.length() - 1) != '/' && path.charAt(0) != '/') { finalUrl = rootUrl + "/" + path; } else { finalUrl = rootUrl + path; } return finalUrl; }
[ "public", "static", "String", "concatenateUrls", "(", "String", "rootUrl", ",", "String", "path", ")", "{", "if", "(", "rootUrl", "==", "null", "||", "rootUrl", ".", "isEmpty", "(", ")", ")", "{", "return", "path", ";", "}", "if", "(", "path", "==", "null", "||", "path", ".", "isEmpty", "(", ")", ")", "{", "return", "rootUrl", ";", "}", "String", "finalUrl", ";", "if", "(", "rootUrl", ".", "charAt", "(", "rootUrl", ".", "length", "(", ")", "-", "1", ")", "==", "'", "'", "&&", "path", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "finalUrl", "=", "rootUrl", ".", "substring", "(", "0", ",", "rootUrl", ".", "length", "(", ")", "-", "2", ")", "+", "path", ";", "}", "else", "if", "(", "rootUrl", ".", "charAt", "(", "rootUrl", ".", "length", "(", ")", "-", "1", ")", "!=", "'", "'", "&&", "path", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "{", "finalUrl", "=", "rootUrl", "+", "\"/\"", "+", "path", ";", "}", "else", "{", "finalUrl", "=", "rootUrl", "+", "path", ";", "}", "return", "finalUrl", ";", "}" ]
Concatenates two URLs. The function checks for trailing and preceding slashes in rootUrl and path. @param rootUrl first part of the url @param path second part of the url @return Concatenated string containing rootUrl and path.
[ "Concatenates", "two", "URLs", ".", "The", "function", "checks", "for", "trailing", "and", "preceding", "slashes", "in", "rootUrl", "and", "path", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/Utils.java#L172-L192
11,261
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java
Context.init
private void init(NormalisedOntology ont) { parentTodo = ont.getTodo(); contextIndex = ont.getContextIndex(); ontologyNF1 = ont.getOntologyNF1(); ontologyNF2 = ont.getOntologyNF2(); ontologyNF3 = ont.getOntologyNF3(); ontologyNF4 = ont.getOntologyNF4(); ontologyNF5 = ont.getOntologyNF5(); reflexiveRoles = ont.getReflexiveRoles(); ontologyNF7 = ont.getOntologyNF7(); ontologyNF8 = ont.getOntologyNF8(); functionalFeatures = ont.getFunctionalFeatures(); roleClosureCache = ont.getRoleClosureCache(); factory = ont.getFactory(); affectedContexts = ont.getAffectedContexts(); }
java
private void init(NormalisedOntology ont) { parentTodo = ont.getTodo(); contextIndex = ont.getContextIndex(); ontologyNF1 = ont.getOntologyNF1(); ontologyNF2 = ont.getOntologyNF2(); ontologyNF3 = ont.getOntologyNF3(); ontologyNF4 = ont.getOntologyNF4(); ontologyNF5 = ont.getOntologyNF5(); reflexiveRoles = ont.getReflexiveRoles(); ontologyNF7 = ont.getOntologyNF7(); ontologyNF8 = ont.getOntologyNF8(); functionalFeatures = ont.getFunctionalFeatures(); roleClosureCache = ont.getRoleClosureCache(); factory = ont.getFactory(); affectedContexts = ont.getAffectedContexts(); }
[ "private", "void", "init", "(", "NormalisedOntology", "ont", ")", "{", "parentTodo", "=", "ont", ".", "getTodo", "(", ")", ";", "contextIndex", "=", "ont", ".", "getContextIndex", "(", ")", ";", "ontologyNF1", "=", "ont", ".", "getOntologyNF1", "(", ")", ";", "ontologyNF2", "=", "ont", ".", "getOntologyNF2", "(", ")", ";", "ontologyNF3", "=", "ont", ".", "getOntologyNF3", "(", ")", ";", "ontologyNF4", "=", "ont", ".", "getOntologyNF4", "(", ")", ";", "ontologyNF5", "=", "ont", ".", "getOntologyNF5", "(", ")", ";", "reflexiveRoles", "=", "ont", ".", "getReflexiveRoles", "(", ")", ";", "ontologyNF7", "=", "ont", ".", "getOntologyNF7", "(", ")", ";", "ontologyNF8", "=", "ont", ".", "getOntologyNF8", "(", ")", ";", "functionalFeatures", "=", "ont", ".", "getFunctionalFeatures", "(", ")", ";", "roleClosureCache", "=", "ont", ".", "getRoleClosureCache", "(", ")", ";", "factory", "=", "ont", ".", "getFactory", "(", ")", ";", "affectedContexts", "=", "ont", ".", "getAffectedContexts", "(", ")", ";", "}" ]
Initialises the shared variables. @param ont
[ "Initialises", "the", "shared", "variables", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java#L201-L216
11,262
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java
Context.primeQueuesIncremental
public void primeQueuesIncremental( MonotonicCollection<IConjunctionQueueEntry> conceptEntries, MonotonicCollection<IRoleQueueEntry> roleEntries, MonotonicCollection<IFeatureQueueEntry> featureEntries) { if (conceptEntries != null) addToConceptQueue(conceptEntries); if (roleEntries != null) roleQueue.addAll(roleEntries); if (featureEntries != null) featureQueue.addAll(featureEntries); }
java
public void primeQueuesIncremental( MonotonicCollection<IConjunctionQueueEntry> conceptEntries, MonotonicCollection<IRoleQueueEntry> roleEntries, MonotonicCollection<IFeatureQueueEntry> featureEntries) { if (conceptEntries != null) addToConceptQueue(conceptEntries); if (roleEntries != null) roleQueue.addAll(roleEntries); if (featureEntries != null) featureQueue.addAll(featureEntries); }
[ "public", "void", "primeQueuesIncremental", "(", "MonotonicCollection", "<", "IConjunctionQueueEntry", ">", "conceptEntries", ",", "MonotonicCollection", "<", "IRoleQueueEntry", ">", "roleEntries", ",", "MonotonicCollection", "<", "IFeatureQueueEntry", ">", "featureEntries", ")", "{", "if", "(", "conceptEntries", "!=", "null", ")", "addToConceptQueue", "(", "conceptEntries", ")", ";", "if", "(", "roleEntries", "!=", "null", ")", "roleQueue", ".", "addAll", "(", "roleEntries", ")", ";", "if", "(", "featureEntries", "!=", "null", ")", "featureQueue", ".", "addAll", "(", "featureEntries", ")", ";", "}" ]
Adds queue entries for this concept based on the new axioms added in an incremental classification. @param conceptEntries @param roleEntries @param featureEntries
[ "Adds", "queue", "entries", "for", "this", "concept", "based", "on", "the", "new", "axioms", "added", "in", "an", "incremental", "classification", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java#L270-L280
11,263
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java
Context.deactivate
public void deactivate() { active.set(false); if (!(conceptQueue.isEmpty() && roleQueue.isEmpty() && featureQueue.isEmpty())) { if (activate()) { parentTodo.add(this); } } }
java
public void deactivate() { active.set(false); if (!(conceptQueue.isEmpty() && roleQueue.isEmpty() && featureQueue.isEmpty())) { if (activate()) { parentTodo.add(this); } } }
[ "public", "void", "deactivate", "(", ")", "{", "active", ".", "set", "(", "false", ")", ";", "if", "(", "!", "(", "conceptQueue", ".", "isEmpty", "(", ")", "&&", "roleQueue", ".", "isEmpty", "(", ")", "&&", "featureQueue", ".", "isEmpty", "(", ")", ")", ")", "{", "if", "(", "activate", "(", ")", ")", "{", "parentTodo", ".", "add", "(", "this", ")", ";", "}", "}", "}" ]
Deactivates the context. Returns true if the context was active and was deactivated by this method call or false otherwise.
[ "Deactivates", "the", "context", ".", "Returns", "true", "if", "the", "context", "was", "active", "and", "was", "deactivated", "by", "this", "method", "call", "or", "false", "otherwise", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java#L323-L330
11,264
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/taglib/AbstractImageTag.java
AbstractImageTag.doEndTag
@Override public int doEndTag() throws JspException { try { BinaryResourcesHandler rsHandler = null; if ((rsHandler = (BinaryResourcesHandler) pageContext.getServletContext() .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE)) == null) throw new IllegalStateException( "Binary ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred."); JawrConfig jawrConfig = rsHandler.getConfig(); this.renderer = RendererFactory.getImgRenderer(jawrConfig, isPlainImage()); this.renderer.renderImage(getImgSrcToRender(), getAttributeMap(), pageContext.getOut()); } catch (IOException e) { throw new JspException(e); } finally { // Reset the Thread local for the Jawr context ThreadLocalJawrContext.reset(); } return (EVAL_PAGE); }
java
@Override public int doEndTag() throws JspException { try { BinaryResourcesHandler rsHandler = null; if ((rsHandler = (BinaryResourcesHandler) pageContext.getServletContext() .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE)) == null) throw new IllegalStateException( "Binary ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred."); JawrConfig jawrConfig = rsHandler.getConfig(); this.renderer = RendererFactory.getImgRenderer(jawrConfig, isPlainImage()); this.renderer.renderImage(getImgSrcToRender(), getAttributeMap(), pageContext.getOut()); } catch (IOException e) { throw new JspException(e); } finally { // Reset the Thread local for the Jawr context ThreadLocalJawrContext.reset(); } return (EVAL_PAGE); }
[ "@", "Override", "public", "int", "doEndTag", "(", ")", "throws", "JspException", "{", "try", "{", "BinaryResourcesHandler", "rsHandler", "=", "null", ";", "if", "(", "(", "rsHandler", "=", "(", "BinaryResourcesHandler", ")", "pageContext", ".", "getServletContext", "(", ")", ".", "getAttribute", "(", "JawrConstant", ".", "BINARY_CONTEXT_ATTRIBUTE", ")", ")", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "\"Binary ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred.\"", ")", ";", "JawrConfig", "jawrConfig", "=", "rsHandler", ".", "getConfig", "(", ")", ";", "this", ".", "renderer", "=", "RendererFactory", ".", "getImgRenderer", "(", "jawrConfig", ",", "isPlainImage", "(", ")", ")", ";", "this", ".", "renderer", ".", "renderImage", "(", "getImgSrcToRender", "(", ")", ",", "getAttributeMap", "(", ")", ",", "pageContext", ".", "getOut", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "JspException", "(", "e", ")", ";", "}", "finally", "{", "// Reset the Thread local for the Jawr context", "ThreadLocalJawrContext", ".", "reset", "(", ")", ";", "}", "return", "(", "EVAL_PAGE", ")", ";", "}" ]
Render the IMG tag. @throws JspException if a JSP exception has occurred
[ "Render", "the", "IMG", "tag", "." ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/taglib/AbstractImageTag.java#L240-L262
11,265
d-michail/jheaps
src/main/java/org/jheaps/array/BinaryArrayBulkInsertWeakHeap.java
BinaryArrayBulkInsertWeakHeap.isBulkInsertionBufferFull
protected boolean isBulkInsertionBufferFull() { if (insertionBufferSize >= insertionBuffer.length) { return true; } double sizeAsDouble = size + insertionBufferSize; return Math.getExponent(sizeAsDouble) + 3 >= insertionBuffer.length; }
java
protected boolean isBulkInsertionBufferFull() { if (insertionBufferSize >= insertionBuffer.length) { return true; } double sizeAsDouble = size + insertionBufferSize; return Math.getExponent(sizeAsDouble) + 3 >= insertionBuffer.length; }
[ "protected", "boolean", "isBulkInsertionBufferFull", "(", ")", "{", "if", "(", "insertionBufferSize", ">=", "insertionBuffer", ".", "length", ")", "{", "return", "true", ";", "}", "double", "sizeAsDouble", "=", "size", "+", "insertionBufferSize", ";", "return", "Math", ".", "getExponent", "(", "sizeAsDouble", ")", "+", "3", ">=", "insertionBuffer", ".", "length", ";", "}" ]
Check if the bulk insertion buffer is full. @return true if the bulk insertion buffer is full, false otherwise
[ "Check", "if", "the", "bulk", "insertion", "buffer", "is", "full", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/BinaryArrayBulkInsertWeakHeap.java#L451-L457
11,266
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
GeneratorRegistry.initCommonGenerators
protected void initCommonGenerators() { commonGenerators.put(new PrefixedPathResolver(MESSAGE_BUNDLE_PREFIX), ResourceBundleMessagesGenerator.class); Class<?> classPathGeneratorClass = null; Class<?> webJarsGeneratorClass = null; boolean isWebJarsLocatorPresent = ClassLoaderResourceUtils.isClassPresent(WEBJARS_LOCATOR_CLASSNAME); if (resourceType.equals(JawrConstant.JS_TYPE)) { classPathGeneratorClass = ClasspathJSGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorJSGenerator.class; } else { webJarsGeneratorClass = WebJarsJSGenerator.class; } } else if (resourceType.equals(JawrConstant.CSS_TYPE)) { classPathGeneratorClass = ClassPathCSSGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorCssGenerator.class; } else { webJarsGeneratorClass = WebJarsCssGenerator.class; } } else { classPathGeneratorClass = ClassPathBinaryResourceGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorBinaryResourceGenerator.class; } else { webJarsGeneratorClass = WebJarsBinaryResourceGenerator.class; } } commonGenerators.put(new PrefixedPathResolver(CLASSPATH_RESOURCE_BUNDLE_PREFIX), classPathGeneratorClass); commonGenerators.put(new PrefixedPathResolver(WEBJARS_GENERATOR_PREFIX), webJarsGeneratorClass); if (resourceType.equals(JawrConstant.JS_TYPE)) { commonGenerators.put(new PrefixedPathResolver(COMMONS_VALIDATOR_PREFIX), CommonsValidatorGenerator.class); commonGenerators.put(new PrefixedPathResolver(SKIN_SWTICHER_GENERATOR_PREFIX), SkinSwitcherJsGenerator.class); commonGenerators.put(new SuffixedPathResolver(COFEESCRIPT_GENERATOR_SUFFIX), CoffeeScriptGenerator.class); } if (resourceType.equals(JawrConstant.CSS_TYPE)) { commonGenerators.put(new PrefixedPathResolver(IE_CSS_GENERATOR_PREFIX), IECssBundleGenerator.class); commonGenerators.put(new PrefixedPathResolver(SKIN_GENERATOR_PREFIX), CssSkinGenerator.class); commonGenerators.put(new SuffixedPathResolver(LESS_GENERATOR_SUFFIX), LessCssGenerator.class); String sassGenerator = config.getProperty(SASS_GENERATOR_TYPE, SASS_GENERATOR_VAADIN); if (!sassGenerator.equals(SASS_GENERATOR_VAADIN) && !sassGenerator.equals(SASS_GENERATOR_RUBY)) { throw new BundlingProcessException("The value '" + sassGenerator + "' is not allowed for property '" + SASS_GENERATOR_TYPE + "'. Please check your configuration."); } if (sassGenerator.equals(SASS_GENERATOR_VAADIN)) { commonGenerators.put(new SuffixedPathResolver(SASS_GENERATOR_SUFFIX), SassVaadinGenerator.class); } else { commonGenerators.put(new SuffixedPathResolver(SASS_GENERATOR_SUFFIX), SassRubyGenerator.class); } } if ((resourceType.equals(JawrConstant.CSS_TYPE) || resourceType.equals(JawrConstant.BINARY_TYPE))) { commonGenerators.put(new PrefixedPathResolver(SPRITE_GENERATOR_PREFIX), SpriteGenerator.class); } }
java
protected void initCommonGenerators() { commonGenerators.put(new PrefixedPathResolver(MESSAGE_BUNDLE_PREFIX), ResourceBundleMessagesGenerator.class); Class<?> classPathGeneratorClass = null; Class<?> webJarsGeneratorClass = null; boolean isWebJarsLocatorPresent = ClassLoaderResourceUtils.isClassPresent(WEBJARS_LOCATOR_CLASSNAME); if (resourceType.equals(JawrConstant.JS_TYPE)) { classPathGeneratorClass = ClasspathJSGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorJSGenerator.class; } else { webJarsGeneratorClass = WebJarsJSGenerator.class; } } else if (resourceType.equals(JawrConstant.CSS_TYPE)) { classPathGeneratorClass = ClassPathCSSGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorCssGenerator.class; } else { webJarsGeneratorClass = WebJarsCssGenerator.class; } } else { classPathGeneratorClass = ClassPathBinaryResourceGenerator.class; if (isWebJarsLocatorPresent) { webJarsGeneratorClass = WebJarsLocatorBinaryResourceGenerator.class; } else { webJarsGeneratorClass = WebJarsBinaryResourceGenerator.class; } } commonGenerators.put(new PrefixedPathResolver(CLASSPATH_RESOURCE_BUNDLE_PREFIX), classPathGeneratorClass); commonGenerators.put(new PrefixedPathResolver(WEBJARS_GENERATOR_PREFIX), webJarsGeneratorClass); if (resourceType.equals(JawrConstant.JS_TYPE)) { commonGenerators.put(new PrefixedPathResolver(COMMONS_VALIDATOR_PREFIX), CommonsValidatorGenerator.class); commonGenerators.put(new PrefixedPathResolver(SKIN_SWTICHER_GENERATOR_PREFIX), SkinSwitcherJsGenerator.class); commonGenerators.put(new SuffixedPathResolver(COFEESCRIPT_GENERATOR_SUFFIX), CoffeeScriptGenerator.class); } if (resourceType.equals(JawrConstant.CSS_TYPE)) { commonGenerators.put(new PrefixedPathResolver(IE_CSS_GENERATOR_PREFIX), IECssBundleGenerator.class); commonGenerators.put(new PrefixedPathResolver(SKIN_GENERATOR_PREFIX), CssSkinGenerator.class); commonGenerators.put(new SuffixedPathResolver(LESS_GENERATOR_SUFFIX), LessCssGenerator.class); String sassGenerator = config.getProperty(SASS_GENERATOR_TYPE, SASS_GENERATOR_VAADIN); if (!sassGenerator.equals(SASS_GENERATOR_VAADIN) && !sassGenerator.equals(SASS_GENERATOR_RUBY)) { throw new BundlingProcessException("The value '" + sassGenerator + "' is not allowed for property '" + SASS_GENERATOR_TYPE + "'. Please check your configuration."); } if (sassGenerator.equals(SASS_GENERATOR_VAADIN)) { commonGenerators.put(new SuffixedPathResolver(SASS_GENERATOR_SUFFIX), SassVaadinGenerator.class); } else { commonGenerators.put(new SuffixedPathResolver(SASS_GENERATOR_SUFFIX), SassRubyGenerator.class); } } if ((resourceType.equals(JawrConstant.CSS_TYPE) || resourceType.equals(JawrConstant.BINARY_TYPE))) { commonGenerators.put(new PrefixedPathResolver(SPRITE_GENERATOR_PREFIX), SpriteGenerator.class); } }
[ "protected", "void", "initCommonGenerators", "(", ")", "{", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "MESSAGE_BUNDLE_PREFIX", ")", ",", "ResourceBundleMessagesGenerator", ".", "class", ")", ";", "Class", "<", "?", ">", "classPathGeneratorClass", "=", "null", ";", "Class", "<", "?", ">", "webJarsGeneratorClass", "=", "null", ";", "boolean", "isWebJarsLocatorPresent", "=", "ClassLoaderResourceUtils", ".", "isClassPresent", "(", "WEBJARS_LOCATOR_CLASSNAME", ")", ";", "if", "(", "resourceType", ".", "equals", "(", "JawrConstant", ".", "JS_TYPE", ")", ")", "{", "classPathGeneratorClass", "=", "ClasspathJSGenerator", ".", "class", ";", "if", "(", "isWebJarsLocatorPresent", ")", "{", "webJarsGeneratorClass", "=", "WebJarsLocatorJSGenerator", ".", "class", ";", "}", "else", "{", "webJarsGeneratorClass", "=", "WebJarsJSGenerator", ".", "class", ";", "}", "}", "else", "if", "(", "resourceType", ".", "equals", "(", "JawrConstant", ".", "CSS_TYPE", ")", ")", "{", "classPathGeneratorClass", "=", "ClassPathCSSGenerator", ".", "class", ";", "if", "(", "isWebJarsLocatorPresent", ")", "{", "webJarsGeneratorClass", "=", "WebJarsLocatorCssGenerator", ".", "class", ";", "}", "else", "{", "webJarsGeneratorClass", "=", "WebJarsCssGenerator", ".", "class", ";", "}", "}", "else", "{", "classPathGeneratorClass", "=", "ClassPathBinaryResourceGenerator", ".", "class", ";", "if", "(", "isWebJarsLocatorPresent", ")", "{", "webJarsGeneratorClass", "=", "WebJarsLocatorBinaryResourceGenerator", ".", "class", ";", "}", "else", "{", "webJarsGeneratorClass", "=", "WebJarsBinaryResourceGenerator", ".", "class", ";", "}", "}", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "CLASSPATH_RESOURCE_BUNDLE_PREFIX", ")", ",", "classPathGeneratorClass", ")", ";", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "WEBJARS_GENERATOR_PREFIX", ")", ",", "webJarsGeneratorClass", ")", ";", "if", "(", "resourceType", ".", "equals", "(", "JawrConstant", ".", "JS_TYPE", ")", ")", "{", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "COMMONS_VALIDATOR_PREFIX", ")", ",", "CommonsValidatorGenerator", ".", "class", ")", ";", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "SKIN_SWTICHER_GENERATOR_PREFIX", ")", ",", "SkinSwitcherJsGenerator", ".", "class", ")", ";", "commonGenerators", ".", "put", "(", "new", "SuffixedPathResolver", "(", "COFEESCRIPT_GENERATOR_SUFFIX", ")", ",", "CoffeeScriptGenerator", ".", "class", ")", ";", "}", "if", "(", "resourceType", ".", "equals", "(", "JawrConstant", ".", "CSS_TYPE", ")", ")", "{", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "IE_CSS_GENERATOR_PREFIX", ")", ",", "IECssBundleGenerator", ".", "class", ")", ";", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "SKIN_GENERATOR_PREFIX", ")", ",", "CssSkinGenerator", ".", "class", ")", ";", "commonGenerators", ".", "put", "(", "new", "SuffixedPathResolver", "(", "LESS_GENERATOR_SUFFIX", ")", ",", "LessCssGenerator", ".", "class", ")", ";", "String", "sassGenerator", "=", "config", ".", "getProperty", "(", "SASS_GENERATOR_TYPE", ",", "SASS_GENERATOR_VAADIN", ")", ";", "if", "(", "!", "sassGenerator", ".", "equals", "(", "SASS_GENERATOR_VAADIN", ")", "&&", "!", "sassGenerator", ".", "equals", "(", "SASS_GENERATOR_RUBY", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The value '\"", "+", "sassGenerator", "+", "\"' is not allowed for property '\"", "+", "SASS_GENERATOR_TYPE", "+", "\"'. Please check your configuration.\"", ")", ";", "}", "if", "(", "sassGenerator", ".", "equals", "(", "SASS_GENERATOR_VAADIN", ")", ")", "{", "commonGenerators", ".", "put", "(", "new", "SuffixedPathResolver", "(", "SASS_GENERATOR_SUFFIX", ")", ",", "SassVaadinGenerator", ".", "class", ")", ";", "}", "else", "{", "commonGenerators", ".", "put", "(", "new", "SuffixedPathResolver", "(", "SASS_GENERATOR_SUFFIX", ")", ",", "SassRubyGenerator", ".", "class", ")", ";", "}", "}", "if", "(", "(", "resourceType", ".", "equals", "(", "JawrConstant", ".", "CSS_TYPE", ")", "||", "resourceType", ".", "equals", "(", "JawrConstant", ".", "BINARY_TYPE", ")", ")", ")", "{", "commonGenerators", ".", "put", "(", "new", "PrefixedPathResolver", "(", "SPRITE_GENERATOR_PREFIX", ")", ",", "SpriteGenerator", ".", "class", ")", ";", "}", "}" ]
Initialize the common generators
[ "Initialize", "the", "common", "generators" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L184-L246
11,267
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/servlet/util/MIMETypesSupport.java
MIMETypesSupport.getSupportedProperties
public static Map<Object, Object> getSupportedProperties(Object ref) { if (null == supportedMIMETypes) { synchronized (MIMETypesSupport.class) { if (null == supportedMIMETypes) { // Load the supported MIME types out of a properties file try (InputStream is = ClassLoaderResourceUtils.getResourceAsStream(MIME_PROPS_LOCATION, ref)) { supportedMIMETypes = new Properties(); supportedMIMETypes.load(is); } catch (FileNotFoundException e) { throw new BundlingProcessException( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings"); } catch (IOException e) { throw new BundlingProcessException( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings"); } } } } return supportedMIMETypes; }
java
public static Map<Object, Object> getSupportedProperties(Object ref) { if (null == supportedMIMETypes) { synchronized (MIMETypesSupport.class) { if (null == supportedMIMETypes) { // Load the supported MIME types out of a properties file try (InputStream is = ClassLoaderResourceUtils.getResourceAsStream(MIME_PROPS_LOCATION, ref)) { supportedMIMETypes = new Properties(); supportedMIMETypes.load(is); } catch (FileNotFoundException e) { throw new BundlingProcessException( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings"); } catch (IOException e) { throw new BundlingProcessException( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings"); } } } } return supportedMIMETypes; }
[ "public", "static", "Map", "<", "Object", ",", "Object", ">", "getSupportedProperties", "(", "Object", "ref", ")", "{", "if", "(", "null", "==", "supportedMIMETypes", ")", "{", "synchronized", "(", "MIMETypesSupport", ".", "class", ")", "{", "if", "(", "null", "==", "supportedMIMETypes", ")", "{", "// Load the supported MIME types out of a properties file", "try", "(", "InputStream", "is", "=", "ClassLoaderResourceUtils", ".", "getResourceAsStream", "(", "MIME_PROPS_LOCATION", ",", "ref", ")", ")", "{", "supportedMIMETypes", "=", "new", "Properties", "(", ")", ";", "supportedMIMETypes", ".", "load", "(", "is", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Error retrieving \"", "+", "MIME_PROPS_LOCATION", "+", "\". Please check your classloader settings\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Error retrieving \"", "+", "MIME_PROPS_LOCATION", "+", "\". Please check your classloader settings\"", ")", ";", "}", "}", "}", "}", "return", "supportedMIMETypes", ";", "}" ]
Returns a Map object containing all the supported media extensions, paired to their MIME type. @param ref An object reference to anchor the classpath (any 'this' reference does). @return
[ "Returns", "a", "Map", "object", "containing", "all", "the", "supported", "media", "extensions", "paired", "to", "their", "MIME", "type", "." ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/servlet/util/MIMETypesSupport.java#L51-L72
11,268
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java
RequestFactory.create
public CreateSingleRequestBuilder<T,ID> create(T item) { return new CreateSingleRequestBuilder<>(version,type,entityName,item); }
java
public CreateSingleRequestBuilder<T,ID> create(T item) { return new CreateSingleRequestBuilder<>(version,type,entityName,item); }
[ "public", "CreateSingleRequestBuilder", "<", "T", ",", "ID", ">", "create", "(", "T", "item", ")", "{", "return", "new", "CreateSingleRequestBuilder", "<>", "(", "version", ",", "type", ",", "entityName", ",", "item", ")", ";", "}" ]
Create a request builder for a create operation for a single item @param item The item to create @return The request builder
[ "Create", "a", "request", "builder", "for", "a", "create", "operation", "for", "a", "single", "item" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java#L52-L55
11,269
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java
RequestFactory.query
public QueryRequestBuilder<T,ID> query(QueryExpression query) { return new QueryRequestBuilder<T, ID>(version,type,entityName,query.build()); }
java
public QueryRequestBuilder<T,ID> query(QueryExpression query) { return new QueryRequestBuilder<T, ID>(version,type,entityName,query.build()); }
[ "public", "QueryRequestBuilder", "<", "T", ",", "ID", ">", "query", "(", "QueryExpression", "query", ")", "{", "return", "new", "QueryRequestBuilder", "<", "T", ",", "ID", ">", "(", "version", ",", "type", ",", "entityName", ",", "query", ".", "build", "(", ")", ")", ";", "}" ]
Create a request builder for a query operation using the specified query expression @param query The the query expression @return The request builder
[ "Create", "a", "request", "builder", "for", "a", "query", "operation", "using", "the", "specified", "query", "expression" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java#L102-L105
11,270
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java
RequestFactory.query
public QueryRequestBuilder<T,ID> query() { return new QueryRequestBuilder<T, ID>(version,type,entityName); }
java
public QueryRequestBuilder<T,ID> query() { return new QueryRequestBuilder<T, ID>(version,type,entityName); }
[ "public", "QueryRequestBuilder", "<", "T", ",", "ID", ">", "query", "(", ")", "{", "return", "new", "QueryRequestBuilder", "<", "T", ",", "ID", ">", "(", "version", ",", "type", ",", "entityName", ")", ";", "}" ]
Create a request builder for a query operation using the specified no query @return The request builder
[ "Create", "a", "request", "builder", "for", "a", "query", "operation", "using", "the", "specified", "no", "query" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java#L111-L114
11,271
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java
RequestFactory.find
public GetRequestBuilder<T,ID> find(ID... ids) { return new GetRequestBuilder<T, ID>(version,type,entityName,ids); }
java
public GetRequestBuilder<T,ID> find(ID... ids) { return new GetRequestBuilder<T, ID>(version,type,entityName,ids); }
[ "public", "GetRequestBuilder", "<", "T", ",", "ID", ">", "find", "(", "ID", "...", "ids", ")", "{", "return", "new", "GetRequestBuilder", "<", "T", ",", "ID", ">", "(", "version", ",", "type", ",", "entityName", ",", "ids", ")", ";", "}" ]
Create a request builder for a find operation using the specified IDs @param ids The ids to find @return The request builder
[ "Create", "a", "request", "builder", "for", "a", "find", "operation", "using", "the", "specified", "IDs" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java#L121-L124
11,272
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java
RequestFactory.update
public UpdateSingleRequestBuilder<T,ID> update(T item) { return new UpdateSingleRequestBuilder<>(version,type,entityName,item); }
java
public UpdateSingleRequestBuilder<T,ID> update(T item) { return new UpdateSingleRequestBuilder<>(version,type,entityName,item); }
[ "public", "UpdateSingleRequestBuilder", "<", "T", ",", "ID", ">", "update", "(", "T", "item", ")", "{", "return", "new", "UpdateSingleRequestBuilder", "<>", "(", "version", ",", "type", ",", "entityName", ",", "item", ")", ";", "}" ]
Create a request builder for an update operation for a single item @param item The item to update @return The request builder
[ "Create", "a", "request", "builder", "for", "an", "update", "operation", "for", "a", "single", "item" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestFactory.java#L131-L134
11,273
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
ResourceBundlesHandlerImpl.initCompositeBundleMap
private void initCompositeBundleMap(List<JoinableResourceBundle> bundles) { for (JoinableResourceBundle bundle : bundles) { if (bundle.isComposite()) { List<JoinableResourceBundle> childBundles = ((CompositeResourceBundle) bundle).getChildBundles(); for (JoinableResourceBundle childBundle : childBundles) { List<JoinableResourceBundle> associatedBundles = compositeResourceBundleMap .get(childBundle.getId()); if (associatedBundles == null) { associatedBundles = new ArrayList<>(); } associatedBundles.add(bundle); compositeResourceBundleMap.put(childBundle.getId(), associatedBundles); } } } }
java
private void initCompositeBundleMap(List<JoinableResourceBundle> bundles) { for (JoinableResourceBundle bundle : bundles) { if (bundle.isComposite()) { List<JoinableResourceBundle> childBundles = ((CompositeResourceBundle) bundle).getChildBundles(); for (JoinableResourceBundle childBundle : childBundles) { List<JoinableResourceBundle> associatedBundles = compositeResourceBundleMap .get(childBundle.getId()); if (associatedBundles == null) { associatedBundles = new ArrayList<>(); } associatedBundles.add(bundle); compositeResourceBundleMap.put(childBundle.getId(), associatedBundles); } } } }
[ "private", "void", "initCompositeBundleMap", "(", "List", "<", "JoinableResourceBundle", ">", "bundles", ")", "{", "for", "(", "JoinableResourceBundle", "bundle", ":", "bundles", ")", "{", "if", "(", "bundle", ".", "isComposite", "(", ")", ")", "{", "List", "<", "JoinableResourceBundle", ">", "childBundles", "=", "(", "(", "CompositeResourceBundle", ")", "bundle", ")", ".", "getChildBundles", "(", ")", ";", "for", "(", "JoinableResourceBundle", "childBundle", ":", "childBundles", ")", "{", "List", "<", "JoinableResourceBundle", ">", "associatedBundles", "=", "compositeResourceBundleMap", ".", "get", "(", "childBundle", ".", "getId", "(", ")", ")", ";", "if", "(", "associatedBundles", "==", "null", ")", "{", "associatedBundles", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "associatedBundles", ".", "add", "(", "bundle", ")", ";", "compositeResourceBundleMap", ".", "put", "(", "childBundle", ".", "getId", "(", ")", ",", "associatedBundles", ")", ";", "}", "}", "}", "}" ]
Initialize the composite bundle map @param bundles list of resource bundle
[ "Initialize", "the", "composite", "bundle", "map" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L366-L381
11,274
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java
ResourceBundlesHandlerImpl.getBundlesToRebuild
private List<JoinableResourceBundle> getBundlesToRebuild() { List<JoinableResourceBundle> bundlesToRebuild = new ArrayList<>(); if (config.getUseSmartBundling()) { for (JoinableResourceBundle bundle : globalBundles) { if (bundle.isDirty()) { bundlesToRebuild.add(bundle); } } for (JoinableResourceBundle bundle : contextBundles) { if (bundle.isDirty()) { bundlesToRebuild.add(bundle); } } } return bundlesToRebuild; }
java
private List<JoinableResourceBundle> getBundlesToRebuild() { List<JoinableResourceBundle> bundlesToRebuild = new ArrayList<>(); if (config.getUseSmartBundling()) { for (JoinableResourceBundle bundle : globalBundles) { if (bundle.isDirty()) { bundlesToRebuild.add(bundle); } } for (JoinableResourceBundle bundle : contextBundles) { if (bundle.isDirty()) { bundlesToRebuild.add(bundle); } } } return bundlesToRebuild; }
[ "private", "List", "<", "JoinableResourceBundle", ">", "getBundlesToRebuild", "(", ")", "{", "List", "<", "JoinableResourceBundle", ">", "bundlesToRebuild", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "config", ".", "getUseSmartBundling", "(", ")", ")", "{", "for", "(", "JoinableResourceBundle", "bundle", ":", "globalBundles", ")", "{", "if", "(", "bundle", ".", "isDirty", "(", ")", ")", "{", "bundlesToRebuild", ".", "add", "(", "bundle", ")", ";", "}", "}", "for", "(", "JoinableResourceBundle", "bundle", ":", "contextBundles", ")", "{", "if", "(", "bundle", ".", "isDirty", "(", ")", ")", "{", "bundlesToRebuild", ".", "add", "(", "bundle", ")", ";", "}", "}", "}", "return", "bundlesToRebuild", ";", "}" ]
Returns the bundles which needs to be rebuild @return the bundles which needs to be rebuild
[ "Returns", "the", "bundles", "which", "needs", "to", "be", "rebuild" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L799-L816
11,275
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java
ClosureGlobalPostProcessor.initModulesArgs
private void initModulesArgs(Map<String, String> resultBundlePathMapping, List<String> args, List<JoinableResourceBundle> bundles, Map<String, JoinableResourceBundle> bundleMap, String modules, List<String> depModulesArgs, List<String> globalBundleDependencies) { // Define Jawr root module // The JAWR_ROOT_MODULE is a fake module to give a root module to the // dependency graph // This is it's only purpose. It is the root dependency for any module // This is used because Google Closure use a unique module as root for // dependency management // in advance mode args.add(JS_ARG); args.add(JAWR_ROOT_MODULE_JS); args.add(MODULE_ARG); args.add(JAWR_ROOT_MODULE_NAME + ":1:"); resultBundlePathMapping.put(JAWR_ROOT_MODULE_NAME, JAWR_ROOT_MODULE_JS); if (StringUtils.isNotEmpty(modules)) { String[] moduleSpecs = modules.split(";"); for (String moduleSpec : moduleSpecs) { int moduleNameSeparatorIdx = moduleSpec.indexOf(":"); if (moduleNameSeparatorIdx < 0) { throw new BundlingProcessException( "The property 'jawr.js.closure.modules' is not properly defined. Please check your configuration."); } // Check module name String bundleName = moduleSpec.substring(0, moduleNameSeparatorIdx); checkBundleName(bundleName, bundleMap); JoinableResourceBundle bundle = bundleMap.get(bundleName); List<String> dependencies = Arrays .asList(moduleSpec.substring(moduleNameSeparatorIdx + 1).split(MODULE_DEPENDENCIES_SEPARATOR)); dependencies.addAll(0, globalBundleDependencies); generateBundleModuleArgs(depModulesArgs, bundleMap, resultBundlePathMapping, bundle, dependencies); // Remove the bundle from the list of bundle to treat bundles.remove(bundle); } } }
java
private void initModulesArgs(Map<String, String> resultBundlePathMapping, List<String> args, List<JoinableResourceBundle> bundles, Map<String, JoinableResourceBundle> bundleMap, String modules, List<String> depModulesArgs, List<String> globalBundleDependencies) { // Define Jawr root module // The JAWR_ROOT_MODULE is a fake module to give a root module to the // dependency graph // This is it's only purpose. It is the root dependency for any module // This is used because Google Closure use a unique module as root for // dependency management // in advance mode args.add(JS_ARG); args.add(JAWR_ROOT_MODULE_JS); args.add(MODULE_ARG); args.add(JAWR_ROOT_MODULE_NAME + ":1:"); resultBundlePathMapping.put(JAWR_ROOT_MODULE_NAME, JAWR_ROOT_MODULE_JS); if (StringUtils.isNotEmpty(modules)) { String[] moduleSpecs = modules.split(";"); for (String moduleSpec : moduleSpecs) { int moduleNameSeparatorIdx = moduleSpec.indexOf(":"); if (moduleNameSeparatorIdx < 0) { throw new BundlingProcessException( "The property 'jawr.js.closure.modules' is not properly defined. Please check your configuration."); } // Check module name String bundleName = moduleSpec.substring(0, moduleNameSeparatorIdx); checkBundleName(bundleName, bundleMap); JoinableResourceBundle bundle = bundleMap.get(bundleName); List<String> dependencies = Arrays .asList(moduleSpec.substring(moduleNameSeparatorIdx + 1).split(MODULE_DEPENDENCIES_SEPARATOR)); dependencies.addAll(0, globalBundleDependencies); generateBundleModuleArgs(depModulesArgs, bundleMap, resultBundlePathMapping, bundle, dependencies); // Remove the bundle from the list of bundle to treat bundles.remove(bundle); } } }
[ "private", "void", "initModulesArgs", "(", "Map", "<", "String", ",", "String", ">", "resultBundlePathMapping", ",", "List", "<", "String", ">", "args", ",", "List", "<", "JoinableResourceBundle", ">", "bundles", ",", "Map", "<", "String", ",", "JoinableResourceBundle", ">", "bundleMap", ",", "String", "modules", ",", "List", "<", "String", ">", "depModulesArgs", ",", "List", "<", "String", ">", "globalBundleDependencies", ")", "{", "// Define Jawr root module", "// The JAWR_ROOT_MODULE is a fake module to give a root module to the", "// dependency graph", "// This is it's only purpose. It is the root dependency for any module", "// This is used because Google Closure use a unique module as root for", "// dependency management", "// in advance mode", "args", ".", "add", "(", "JS_ARG", ")", ";", "args", ".", "add", "(", "JAWR_ROOT_MODULE_JS", ")", ";", "args", ".", "add", "(", "MODULE_ARG", ")", ";", "args", ".", "add", "(", "JAWR_ROOT_MODULE_NAME", "+", "\":1:\"", ")", ";", "resultBundlePathMapping", ".", "put", "(", "JAWR_ROOT_MODULE_NAME", ",", "JAWR_ROOT_MODULE_JS", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "modules", ")", ")", "{", "String", "[", "]", "moduleSpecs", "=", "modules", ".", "split", "(", "\";\"", ")", ";", "for", "(", "String", "moduleSpec", ":", "moduleSpecs", ")", "{", "int", "moduleNameSeparatorIdx", "=", "moduleSpec", ".", "indexOf", "(", "\":\"", ")", ";", "if", "(", "moduleNameSeparatorIdx", "<", "0", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The property 'jawr.js.closure.modules' is not properly defined. Please check your configuration.\"", ")", ";", "}", "// Check module name", "String", "bundleName", "=", "moduleSpec", ".", "substring", "(", "0", ",", "moduleNameSeparatorIdx", ")", ";", "checkBundleName", "(", "bundleName", ",", "bundleMap", ")", ";", "JoinableResourceBundle", "bundle", "=", "bundleMap", ".", "get", "(", "bundleName", ")", ";", "List", "<", "String", ">", "dependencies", "=", "Arrays", ".", "asList", "(", "moduleSpec", ".", "substring", "(", "moduleNameSeparatorIdx", "+", "1", ")", ".", "split", "(", "MODULE_DEPENDENCIES_SEPARATOR", ")", ")", ";", "dependencies", ".", "addAll", "(", "0", ",", "globalBundleDependencies", ")", ";", "generateBundleModuleArgs", "(", "depModulesArgs", ",", "bundleMap", ",", "resultBundlePathMapping", ",", "bundle", ",", "dependencies", ")", ";", "// Remove the bundle from the list of bundle to treat", "bundles", ".", "remove", "(", "bundle", ")", ";", "}", "}", "}" ]
Initialize the modules arguments @param resultBundlePathMapping the map for the result bundle path @param args the arguments @param bundles the list of bundles @param bundleMap the bundle map @param modules the modules @param depModulesArgs the dependency modules arguments @param globalBundleDependencies the global bundle dependencies
[ "Initialize", "the", "modules", "arguments" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/postprocessor/google/closure/ClosureGlobalPostProcessor.java#L371-L411
11,276
aehrc/snorocket
snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/CR.java
CR.getRoles
public int[] getRoles() { List<Integer> roles = new ArrayList<Integer>(); for(int i = 0; i < data.length; i++) { if(data[i] != null) { roles.add(i); } } int[] res = new int[roles.size()]; for(int i = 0; i < res.length; i++) { res[i] = roles.get(i); } return res; }
java
public int[] getRoles() { List<Integer> roles = new ArrayList<Integer>(); for(int i = 0; i < data.length; i++) { if(data[i] != null) { roles.add(i); } } int[] res = new int[roles.size()]; for(int i = 0; i < res.length; i++) { res[i] = roles.get(i); } return res; }
[ "public", "int", "[", "]", "getRoles", "(", ")", "{", "List", "<", "Integer", ">", "roles", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "if", "(", "data", "[", "i", "]", "!=", "null", ")", "{", "roles", ".", "add", "(", "i", ")", ";", "}", "}", "int", "[", "]", "res", "=", "new", "int", "[", "roles", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "res", ".", "length", ";", "i", "++", ")", "{", "res", "[", "i", "]", "=", "roles", ".", "get", "(", "i", ")", ";", "}", "return", "res", ";", "}" ]
Returns the roles stored in this data structure. @return
[ "Returns", "the", "roles", "stored", "in", "this", "data", "structure", "." ]
e33c1e216f8a66d6502e3a14e80876811feedd8b
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/CR.java#L128-L141
11,277
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java
ResponseImpl.getContentLength
public long getContentLength() { try { return getInternalResponse().body().contentLength(); } catch (NullPointerException e){ logger.error("Failed to get the response content length from " + getRequestURL() + ". Error: " + e.getMessage()); return 0; } }
java
public long getContentLength() { try { return getInternalResponse().body().contentLength(); } catch (NullPointerException e){ logger.error("Failed to get the response content length from " + getRequestURL() + ". Error: " + e.getMessage()); return 0; } }
[ "public", "long", "getContentLength", "(", ")", "{", "try", "{", "return", "getInternalResponse", "(", ")", ".", "body", "(", ")", ".", "contentLength", "(", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "logger", ".", "error", "(", "\"Failed to get the response content length from \"", "+", "getRequestURL", "(", ")", "+", "\". Error: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "return", "0", ";", "}", "}" ]
This method gets the Content-Length of the response body. @return The content length of the response.
[ "This", "method", "gets", "the", "Content", "-", "Length", "of", "the", "response", "body", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java#L99-L106
11,278
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java
ResponseImpl.getHeaders
public Map<String, List<String>> getHeaders() { if (headers == null) { return null; } return headers.toMultimap(); }
java
public Map<String, List<String>> getHeaders() { if (headers == null) { return null; } return headers.toMultimap(); }
[ "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "getHeaders", "(", ")", "{", "if", "(", "headers", "==", "null", ")", "{", "return", "null", ";", "}", "return", "headers", ".", "toMultimap", "(", ")", ";", "}" ]
Get the HTTP headers from the response. @return A map with all the headers, and the corresponding values for each one.
[ "Get", "the", "HTTP", "headers", "from", "the", "response", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java#L215-L220
11,279
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java
ResponseImpl.getHeader
public List<String> getHeader(String name) { if (headers == null) { return null; } return headers.values(name); }
java
public List<String> getHeader(String name) { if (headers == null) { return null; } return headers.values(name); }
[ "public", "List", "<", "String", ">", "getHeader", "(", "String", "name", ")", "{", "if", "(", "headers", "==", "null", ")", "{", "return", "null", ";", "}", "return", "headers", ".", "values", "(", "name", ")", ";", "}" ]
Get the header values for the given header name, if it exists. There can be more than one value for a given header name. @param name the name of the header to get @return the values of the given header name
[ "Get", "the", "header", "values", "for", "the", "given", "header", "name", "if", "it", "exists", ".", "There", "can", "be", "more", "than", "one", "value", "for", "a", "given", "header", "name", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java#L229-L234
11,280
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java
ResponseImpl.getFirstHeader
public String getFirstHeader(String name) { List<String> headerValues = getHeader(name); if (headerValues == null || headerValues.size() == 0) { return null; } return headerValues.get(0); }
java
public String getFirstHeader(String name) { List<String> headerValues = getHeader(name); if (headerValues == null || headerValues.size() == 0) { return null; } return headerValues.get(0); }
[ "public", "String", "getFirstHeader", "(", "String", "name", ")", "{", "List", "<", "String", ">", "headerValues", "=", "getHeader", "(", "name", ")", ";", "if", "(", "headerValues", "==", "null", "||", "headerValues", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "return", "headerValues", ".", "get", "(", "0", ")", ";", "}" ]
Get the first header value for the given header name, if it exists. @param name the name of the header to get @return the first value of the given header name
[ "Get", "the", "first", "header", "value", "for", "the", "given", "header", "name", "if", "it", "exists", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/ResponseImpl.java#L242-L250
11,281
d-michail/jheaps
src/main/java/org/jheaps/tree/BinaryTreeSoftHeap.java
BinaryTreeSoftHeap.sift
@SuppressWarnings("unchecked") private void sift(TreeNode<K> x) { Deque<TreeNode<K>> stack = new ArrayDeque<TreeNode<K>>(); stack.push(x); while (!stack.isEmpty()) { x = stack.peek(); TreeNode<K> xLeft = x.left; TreeNode<K> xRight = x.right; // if leaf or list has enough elements, skip if (xLeft == null && xRight == null || x.cSize >= targetSize(x.rank)) { stack.pop(); continue; } // swap if needed if (xLeft == null || xRight != null && ((comparator == null && ((Comparable<? super K>) xLeft.cKey).compareTo(xRight.cKey) > 0) || (comparator != null && comparator.compare(xLeft.cKey, xRight.cKey) > 0))) { x.left = xRight; x.right = xLeft; xLeft = x.left; xRight = x.right; } // grab non-empty list from left child xLeft.cTail.next = x.cHead; x.cHead = xLeft.cHead; if (x.cTail == null) { x.cTail = xLeft.cTail; } x.cSize += xLeft.cSize; // set new corrupted key x.cKey = xLeft.cKey; // clear left child list xLeft.cKey = null; xLeft.cHead = null; xLeft.cTail = null; xLeft.cSize = 0; // recursively to left child if not a leaf if (xLeft.left != null || xLeft.right != null) { stack.push(xLeft); } else { x.left = null; } } }
java
@SuppressWarnings("unchecked") private void sift(TreeNode<K> x) { Deque<TreeNode<K>> stack = new ArrayDeque<TreeNode<K>>(); stack.push(x); while (!stack.isEmpty()) { x = stack.peek(); TreeNode<K> xLeft = x.left; TreeNode<K> xRight = x.right; // if leaf or list has enough elements, skip if (xLeft == null && xRight == null || x.cSize >= targetSize(x.rank)) { stack.pop(); continue; } // swap if needed if (xLeft == null || xRight != null && ((comparator == null && ((Comparable<? super K>) xLeft.cKey).compareTo(xRight.cKey) > 0) || (comparator != null && comparator.compare(xLeft.cKey, xRight.cKey) > 0))) { x.left = xRight; x.right = xLeft; xLeft = x.left; xRight = x.right; } // grab non-empty list from left child xLeft.cTail.next = x.cHead; x.cHead = xLeft.cHead; if (x.cTail == null) { x.cTail = xLeft.cTail; } x.cSize += xLeft.cSize; // set new corrupted key x.cKey = xLeft.cKey; // clear left child list xLeft.cKey = null; xLeft.cHead = null; xLeft.cTail = null; xLeft.cSize = 0; // recursively to left child if not a leaf if (xLeft.left != null || xLeft.right != null) { stack.push(xLeft); } else { x.left = null; } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "sift", "(", "TreeNode", "<", "K", ">", "x", ")", "{", "Deque", "<", "TreeNode", "<", "K", ">>", "stack", "=", "new", "ArrayDeque", "<", "TreeNode", "<", "K", ">", ">", "(", ")", ";", "stack", ".", "push", "(", "x", ")", ";", "while", "(", "!", "stack", ".", "isEmpty", "(", ")", ")", "{", "x", "=", "stack", ".", "peek", "(", ")", ";", "TreeNode", "<", "K", ">", "xLeft", "=", "x", ".", "left", ";", "TreeNode", "<", "K", ">", "xRight", "=", "x", ".", "right", ";", "// if leaf or list has enough elements, skip", "if", "(", "xLeft", "==", "null", "&&", "xRight", "==", "null", "||", "x", ".", "cSize", ">=", "targetSize", "(", "x", ".", "rank", ")", ")", "{", "stack", ".", "pop", "(", ")", ";", "continue", ";", "}", "// swap if needed", "if", "(", "xLeft", "==", "null", "||", "xRight", "!=", "null", "&&", "(", "(", "comparator", "==", "null", "&&", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "xLeft", ".", "cKey", ")", ".", "compareTo", "(", "xRight", ".", "cKey", ")", ">", "0", ")", "||", "(", "comparator", "!=", "null", "&&", "comparator", ".", "compare", "(", "xLeft", ".", "cKey", ",", "xRight", ".", "cKey", ")", ">", "0", ")", ")", ")", "{", "x", ".", "left", "=", "xRight", ";", "x", ".", "right", "=", "xLeft", ";", "xLeft", "=", "x", ".", "left", ";", "xRight", "=", "x", ".", "right", ";", "}", "// grab non-empty list from left child", "xLeft", ".", "cTail", ".", "next", "=", "x", ".", "cHead", ";", "x", ".", "cHead", "=", "xLeft", ".", "cHead", ";", "if", "(", "x", ".", "cTail", "==", "null", ")", "{", "x", ".", "cTail", "=", "xLeft", ".", "cTail", ";", "}", "x", ".", "cSize", "+=", "xLeft", ".", "cSize", ";", "// set new corrupted key", "x", ".", "cKey", "=", "xLeft", ".", "cKey", ";", "// clear left child list", "xLeft", ".", "cKey", "=", "null", ";", "xLeft", ".", "cHead", "=", "null", ";", "xLeft", ".", "cTail", "=", "null", ";", "xLeft", ".", "cSize", "=", "0", ";", "// recursively to left child if not a leaf", "if", "(", "xLeft", ".", "left", "!=", "null", "||", "xLeft", ".", "right", "!=", "null", ")", "{", "stack", ".", "push", "(", "xLeft", ")", ";", "}", "else", "{", "x", ".", "left", "=", "null", ";", "}", "}", "}" ]
Sift elements from children nodes until the current node has enough elements in its list. @param x the node
[ "Sift", "elements", "from", "children", "nodes", "until", "the", "current", "node", "has", "enough", "elements", "in", "its", "list", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/BinaryTreeSoftHeap.java#L435-L485
11,282
d-michail/jheaps
src/main/java/org/jheaps/tree/BinaryTreeSoftHeap.java
BinaryTreeSoftHeap.combine
private TreeNode<K> combine(TreeNode<K> x, TreeNode<K> y) { TreeNode<K> z = new TreeNode<K>(); z.left = x; z.right = y; z.rank = x.rank + 1; sift(z); return z; }
java
private TreeNode<K> combine(TreeNode<K> x, TreeNode<K> y) { TreeNode<K> z = new TreeNode<K>(); z.left = x; z.right = y; z.rank = x.rank + 1; sift(z); return z; }
[ "private", "TreeNode", "<", "K", ">", "combine", "(", "TreeNode", "<", "K", ">", "x", ",", "TreeNode", "<", "K", ">", "y", ")", "{", "TreeNode", "<", "K", ">", "z", "=", "new", "TreeNode", "<", "K", ">", "(", ")", ";", "z", ".", "left", "=", "x", ";", "z", ".", "right", "=", "y", ";", "z", ".", "rank", "=", "x", ".", "rank", "+", "1", ";", "sift", "(", "z", ")", ";", "return", "z", ";", "}" ]
Combine two trees into a new tree. @param x the first tree @param y the second tree @return the combined tree
[ "Combine", "two", "trees", "into", "a", "new", "tree", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/BinaryTreeSoftHeap.java#L496-L503
11,283
d-michail/jheaps
src/main/java/org/jheaps/monotone/AbstractRadixHeap.java
AbstractRadixHeap.computeBucket
protected int computeBucket(K key, K minKey) { return 1 + Math.min(msd(key, minKey), buckets.length - 2); }
java
protected int computeBucket(K key, K minKey) { return 1 + Math.min(msd(key, minKey), buckets.length - 2); }
[ "protected", "int", "computeBucket", "(", "K", "key", ",", "K", "minKey", ")", "{", "return", "1", "+", "Math", ".", "min", "(", "msd", "(", "key", ",", "minKey", ")", ",", "buckets", ".", "length", "-", "2", ")", ";", "}" ]
Compute the bucket of a key based on a minimum key. @param key the key @param minKey the minimum key @return the bucket where the key should go
[ "Compute", "the", "bucket", "of", "a", "key", "based", "on", "a", "minimum", "key", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/monotone/AbstractRadixHeap.java#L274-L276
11,284
d-michail/jheaps
src/main/java/org/jheaps/tree/SkewHeap.java
SkewHeap.delete
protected void delete(Node<K, V> n) { if (n == root) { deleteMin(); return; } if (n.y_s == null) { throw new IllegalArgumentException("Invalid handle!"); } // disconnect and union children of node Node<K, V> childTree = unlinkAndUnionChildren(n); // find parent Node<K, V> p = getParent(n); // link children tree in place of node if (childTree == null) { // no children, just unlink from parent if (p.o_c == n) { if (n.y_s == p) { p.o_c = null; } else { p.o_c = n.y_s; } } else { p.o_c.y_s = p; } } else { // link children tree to parent if (p.o_c == n) { childTree.y_s = n.y_s; p.o_c = childTree; } else { p.o_c.y_s = childTree; childTree.y_s = p; } } size--; n.o_c = null; n.y_s = null; }
java
protected void delete(Node<K, V> n) { if (n == root) { deleteMin(); return; } if (n.y_s == null) { throw new IllegalArgumentException("Invalid handle!"); } // disconnect and union children of node Node<K, V> childTree = unlinkAndUnionChildren(n); // find parent Node<K, V> p = getParent(n); // link children tree in place of node if (childTree == null) { // no children, just unlink from parent if (p.o_c == n) { if (n.y_s == p) { p.o_c = null; } else { p.o_c = n.y_s; } } else { p.o_c.y_s = p; } } else { // link children tree to parent if (p.o_c == n) { childTree.y_s = n.y_s; p.o_c = childTree; } else { p.o_c.y_s = childTree; childTree.y_s = p; } } size--; n.o_c = null; n.y_s = null; }
[ "protected", "void", "delete", "(", "Node", "<", "K", ",", "V", ">", "n", ")", "{", "if", "(", "n", "==", "root", ")", "{", "deleteMin", "(", ")", ";", "return", ";", "}", "if", "(", "n", ".", "y_s", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid handle!\"", ")", ";", "}", "// disconnect and union children of node", "Node", "<", "K", ",", "V", ">", "childTree", "=", "unlinkAndUnionChildren", "(", "n", ")", ";", "// find parent", "Node", "<", "K", ",", "V", ">", "p", "=", "getParent", "(", "n", ")", ";", "// link children tree in place of node", "if", "(", "childTree", "==", "null", ")", "{", "// no children, just unlink from parent", "if", "(", "p", ".", "o_c", "==", "n", ")", "{", "if", "(", "n", ".", "y_s", "==", "p", ")", "{", "p", ".", "o_c", "=", "null", ";", "}", "else", "{", "p", ".", "o_c", "=", "n", ".", "y_s", ";", "}", "}", "else", "{", "p", ".", "o_c", ".", "y_s", "=", "p", ";", "}", "}", "else", "{", "// link children tree to parent", "if", "(", "p", ".", "o_c", "==", "n", ")", "{", "childTree", ".", "y_s", "=", "n", ".", "y_s", ";", "p", ".", "o_c", "=", "childTree", ";", "}", "else", "{", "p", ".", "o_c", ".", "y_s", "=", "childTree", ";", "childTree", ".", "y_s", "=", "p", ";", "}", "}", "size", "--", ";", "n", ".", "o_c", "=", "null", ";", "n", ".", "y_s", "=", "null", ";", "}" ]
Delete a node from the heap. @param n the node
[ "Delete", "a", "node", "from", "the", "heap", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/SkewHeap.java#L435-L477
11,285
d-michail/jheaps
src/main/java/org/jheaps/tree/SkewHeap.java
SkewHeap.unlinkAndUnionChildren
protected Node<K, V> unlinkAndUnionChildren(Node<K, V> n) { // disconnect children Node<K, V> child1 = n.o_c; if (child1 == null) { return null; } n.o_c = null; Node<K, V> child2 = child1.y_s; if (child2 == n) { child2 = null; } else { child2.y_s = null; } child1.y_s = null; if (comparator == null) { return union(child1, child2); } else { return unionWithComparator(child1, child2); } }
java
protected Node<K, V> unlinkAndUnionChildren(Node<K, V> n) { // disconnect children Node<K, V> child1 = n.o_c; if (child1 == null) { return null; } n.o_c = null; Node<K, V> child2 = child1.y_s; if (child2 == n) { child2 = null; } else { child2.y_s = null; } child1.y_s = null; if (comparator == null) { return union(child1, child2); } else { return unionWithComparator(child1, child2); } }
[ "protected", "Node", "<", "K", ",", "V", ">", "unlinkAndUnionChildren", "(", "Node", "<", "K", ",", "V", ">", "n", ")", "{", "// disconnect children", "Node", "<", "K", ",", "V", ">", "child1", "=", "n", ".", "o_c", ";", "if", "(", "child1", "==", "null", ")", "{", "return", "null", ";", "}", "n", ".", "o_c", "=", "null", ";", "Node", "<", "K", ",", "V", ">", "child2", "=", "child1", ".", "y_s", ";", "if", "(", "child2", "==", "n", ")", "{", "child2", "=", "null", ";", "}", "else", "{", "child2", ".", "y_s", "=", "null", ";", "}", "child1", ".", "y_s", "=", "null", ";", "if", "(", "comparator", "==", "null", ")", "{", "return", "union", "(", "child1", ",", "child2", ")", ";", "}", "else", "{", "return", "unionWithComparator", "(", "child1", ",", "child2", ")", ";", "}", "}" ]
Unlink the two children of a node and union them forming a new tree. @param n the node @return the tree which is formed by the two children subtrees of the node
[ "Unlink", "the", "two", "children", "of", "a", "node", "and", "union", "them", "forming", "a", "new", "tree", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/SkewHeap.java#L486-L507
11,286
d-michail/jheaps
src/main/java/org/jheaps/tree/SkewHeap.java
SkewHeap.unlinkRightChild
protected Node<K, V> unlinkRightChild(Node<K, V> n) { Node<K, V> left = n.o_c; if (left == null || left.y_s == n) { return null; } Node<K, V> right = left.y_s; left.y_s = n; right.y_s = null; return right; }
java
protected Node<K, V> unlinkRightChild(Node<K, V> n) { Node<K, V> left = n.o_c; if (left == null || left.y_s == n) { return null; } Node<K, V> right = left.y_s; left.y_s = n; right.y_s = null; return right; }
[ "protected", "Node", "<", "K", ",", "V", ">", "unlinkRightChild", "(", "Node", "<", "K", ",", "V", ">", "n", ")", "{", "Node", "<", "K", ",", "V", ">", "left", "=", "n", ".", "o_c", ";", "if", "(", "left", "==", "null", "||", "left", ".", "y_s", "==", "n", ")", "{", "return", "null", ";", "}", "Node", "<", "K", ",", "V", ">", "right", "=", "left", ".", "y_s", ";", "left", ".", "y_s", "=", "n", ";", "right", ".", "y_s", "=", "null", ";", "return", "right", ";", "}" ]
Unlink the right child of a node. @param n the node @return the right child after unlinking
[ "Unlink", "the", "right", "child", "of", "a", "node", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/SkewHeap.java#L538-L547
11,287
d-michail/jheaps
src/main/java/org/jheaps/tree/SkewHeap.java
SkewHeap.union
@SuppressWarnings("unchecked") protected Node<K, V> union(Node<K, V> root1, Node<K, V> root2) { if (root1 == null) { return root2; } else if (root2 == null) { return root1; } Node<K, V> newRoot; Node<K, V> cur; // find initial int c = ((Comparable<? super K>) root1.key).compareTo(root2.key); if (c <= 0) { newRoot = root1; root1 = unlinkRightChild(root1); } else { newRoot = root2; root2 = unlinkRightChild(root2); } cur = newRoot; // merge while (root1 != null && root2 != null) { c = ((Comparable<? super K>) root1.key).compareTo(root2.key); if (c <= 0) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } else { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } } while (root1 != null) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } while (root2 != null) { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } return newRoot; }
java
@SuppressWarnings("unchecked") protected Node<K, V> union(Node<K, V> root1, Node<K, V> root2) { if (root1 == null) { return root2; } else if (root2 == null) { return root1; } Node<K, V> newRoot; Node<K, V> cur; // find initial int c = ((Comparable<? super K>) root1.key).compareTo(root2.key); if (c <= 0) { newRoot = root1; root1 = unlinkRightChild(root1); } else { newRoot = root2; root2 = unlinkRightChild(root2); } cur = newRoot; // merge while (root1 != null && root2 != null) { c = ((Comparable<? super K>) root1.key).compareTo(root2.key); if (c <= 0) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } else { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } } while (root1 != null) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } while (root2 != null) { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } return newRoot; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "Node", "<", "K", ",", "V", ">", "union", "(", "Node", "<", "K", ",", "V", ">", "root1", ",", "Node", "<", "K", ",", "V", ">", "root2", ")", "{", "if", "(", "root1", "==", "null", ")", "{", "return", "root2", ";", "}", "else", "if", "(", "root2", "==", "null", ")", "{", "return", "root1", ";", "}", "Node", "<", "K", ",", "V", ">", "newRoot", ";", "Node", "<", "K", ",", "V", ">", "cur", ";", "// find initial", "int", "c", "=", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "root1", ".", "key", ")", ".", "compareTo", "(", "root2", ".", "key", ")", ";", "if", "(", "c", "<=", "0", ")", "{", "newRoot", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "else", "{", "newRoot", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "cur", "=", "newRoot", ";", "// merge", "while", "(", "root1", "!=", "null", "&&", "root2", "!=", "null", ")", "{", "c", "=", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "root1", ".", "key", ")", ".", "compareTo", "(", "root2", ".", "key", ")", ";", "if", "(", "c", "<=", "0", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root1", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root1", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root1", ";", "cur", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "else", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root2", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root2", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root2", ";", "cur", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "}", "while", "(", "root1", "!=", "null", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root1", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root1", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root1", ";", "cur", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "while", "(", "root2", "!=", "null", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root2", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root2", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root2", ";", "cur", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "return", "newRoot", ";", "}" ]
Top-down union of two skew heaps. @param root1 the root of the first heap @param root2 the root of the right heap @return the new root of the merged heap
[ "Top", "-", "down", "union", "of", "two", "skew", "heaps", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/SkewHeap.java#L558-L631
11,288
d-michail/jheaps
src/main/java/org/jheaps/tree/SkewHeap.java
SkewHeap.unionWithComparator
protected Node<K, V> unionWithComparator(Node<K, V> root1, Node<K, V> root2) { if (root1 == null) { return root2; } else if (root2 == null) { return root1; } Node<K, V> newRoot; Node<K, V> cur; // find initial int c = comparator.compare(root1.key, root2.key); if (c <= 0) { newRoot = root1; root1 = unlinkRightChild(root1); } else { newRoot = root2; root2 = unlinkRightChild(root2); } cur = newRoot; // merge while (root1 != null && root2 != null) { c = comparator.compare(root1.key, root2.key); if (c <= 0) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } else { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } } while (root1 != null) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } while (root2 != null) { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } return newRoot; }
java
protected Node<K, V> unionWithComparator(Node<K, V> root1, Node<K, V> root2) { if (root1 == null) { return root2; } else if (root2 == null) { return root1; } Node<K, V> newRoot; Node<K, V> cur; // find initial int c = comparator.compare(root1.key, root2.key); if (c <= 0) { newRoot = root1; root1 = unlinkRightChild(root1); } else { newRoot = root2; root2 = unlinkRightChild(root2); } cur = newRoot; // merge while (root1 != null && root2 != null) { c = comparator.compare(root1.key, root2.key); if (c <= 0) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } else { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } } while (root1 != null) { // link as left child of cur if (cur.o_c == null) { root1.y_s = cur; } else { root1.y_s = cur.o_c; } cur.o_c = root1; cur = root1; root1 = unlinkRightChild(root1); } while (root2 != null) { // link as left child of cur if (cur.o_c == null) { root2.y_s = cur; } else { root2.y_s = cur.o_c; } cur.o_c = root2; cur = root2; root2 = unlinkRightChild(root2); } return newRoot; }
[ "protected", "Node", "<", "K", ",", "V", ">", "unionWithComparator", "(", "Node", "<", "K", ",", "V", ">", "root1", ",", "Node", "<", "K", ",", "V", ">", "root2", ")", "{", "if", "(", "root1", "==", "null", ")", "{", "return", "root2", ";", "}", "else", "if", "(", "root2", "==", "null", ")", "{", "return", "root1", ";", "}", "Node", "<", "K", ",", "V", ">", "newRoot", ";", "Node", "<", "K", ",", "V", ">", "cur", ";", "// find initial", "int", "c", "=", "comparator", ".", "compare", "(", "root1", ".", "key", ",", "root2", ".", "key", ")", ";", "if", "(", "c", "<=", "0", ")", "{", "newRoot", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "else", "{", "newRoot", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "cur", "=", "newRoot", ";", "// merge", "while", "(", "root1", "!=", "null", "&&", "root2", "!=", "null", ")", "{", "c", "=", "comparator", ".", "compare", "(", "root1", ".", "key", ",", "root2", ".", "key", ")", ";", "if", "(", "c", "<=", "0", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root1", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root1", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root1", ";", "cur", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "else", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root2", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root2", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root2", ";", "cur", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "}", "while", "(", "root1", "!=", "null", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root1", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root1", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root1", ";", "cur", "=", "root1", ";", "root1", "=", "unlinkRightChild", "(", "root1", ")", ";", "}", "while", "(", "root2", "!=", "null", ")", "{", "// link as left child of cur", "if", "(", "cur", ".", "o_c", "==", "null", ")", "{", "root2", ".", "y_s", "=", "cur", ";", "}", "else", "{", "root2", ".", "y_s", "=", "cur", ".", "o_c", ";", "}", "cur", ".", "o_c", "=", "root2", ";", "cur", "=", "root2", ";", "root2", "=", "unlinkRightChild", "(", "root2", ")", ";", "}", "return", "newRoot", ";", "}" ]
Top-down union of two skew heaps with comparator. @param root1 the root of the first heap @param root2 the root of the right heap @return the new root of the merged heap
[ "Top", "-", "down", "union", "of", "two", "skew", "heaps", "with", "comparator", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/SkewHeap.java#L642-L714
11,289
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java
MultiMap.get
public List<String> get(String key) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); return map.get(key); }
java
public List<String> get(String key) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); return map.get(key); }
[ "public", "List", "<", "String", ">", "get", "(", "String", "key", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null keys not allowed.\"", ")", ";", "return", "map", ".", "get", "(", "key", ")", ";", "}" ]
Return the values stored for the supplied key @param key The key @return The values stored for this key, null if there are no values stored
[ "Return", "the", "values", "stored", "for", "the", "supplied", "key" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java#L17-L23
11,290
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java
MultiMap.getFirst
public String getFirst(String key) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); List<String> vals = map.get(key); if(vals == null || vals.size() == 0) return null; return vals.get(0); }
java
public String getFirst(String key) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); List<String> vals = map.get(key); if(vals == null || vals.size() == 0) return null; return vals.get(0); }
[ "public", "String", "getFirst", "(", "String", "key", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null keys not allowed.\"", ")", ";", "List", "<", "String", ">", "vals", "=", "map", ".", "get", "(", "key", ")", ";", "if", "(", "vals", "==", "null", "||", "vals", ".", "size", "(", ")", "==", "0", ")", "return", "null", ";", "return", "vals", ".", "get", "(", "0", ")", ";", "}" ]
Return the first value stored for the supplied key @param key The key @return the first value stored for the key, null if there are no values stored
[ "Return", "the", "first", "value", "stored", "for", "the", "supplied", "key" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java#L30-L40
11,291
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java
MultiMap.set
public void set(String key, String value) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); if(value == null) throw new IllegalArgumentException("Null values not allowed."); ArrayList<String> vals = new ArrayList<String>(); vals.add(value); map.put(key,vals); }
java
public void set(String key, String value) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); if(value == null) throw new IllegalArgumentException("Null values not allowed."); ArrayList<String> vals = new ArrayList<String>(); vals.add(value); map.put(key,vals); }
[ "public", "void", "set", "(", "String", "key", ",", "String", "value", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null keys not allowed.\"", ")", ";", "if", "(", "value", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null values not allowed.\"", ")", ";", "ArrayList", "<", "String", ">", "vals", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "vals", ".", "add", "(", "value", ")", ";", "map", ".", "put", "(", "key", ",", "vals", ")", ";", "}" ]
Set a value for the supplied key. This will overwrite any values that are currently stored for this key. @param key The key @param value The value to store
[ "Set", "a", "value", "for", "the", "supplied", "key", ".", "This", "will", "overwrite", "any", "values", "that", "are", "currently", "stored", "for", "this", "key", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java#L47-L59
11,292
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java
MultiMap.add
public void add(String key, String value) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); if(value == null) throw new IllegalArgumentException("Null values not allowed."); List<String> vals = map.get(key); if(vals == null) { vals = new ArrayList<String>(); map.put(key,vals); } vals.add(value); }
java
public void add(String key, String value) { if(key == null) throw new IllegalArgumentException("Null keys not allowed."); if(value == null) throw new IllegalArgumentException("Null values not allowed."); List<String> vals = map.get(key); if(vals == null) { vals = new ArrayList<String>(); map.put(key,vals); } vals.add(value); }
[ "public", "void", "add", "(", "String", "key", ",", "String", "value", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null keys not allowed.\"", ")", ";", "if", "(", "value", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Null values not allowed.\"", ")", ";", "List", "<", "String", ">", "vals", "=", "map", ".", "get", "(", "key", ")", ";", "if", "(", "vals", "==", "null", ")", "{", "vals", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "map", ".", "put", "(", "key", ",", "vals", ")", ";", "}", "vals", ".", "add", "(", "value", ")", ";", "}" ]
Add a value for the supplied key. This will add the value to any existing values stored for this key. @param key the key @param value The value
[ "Add", "a", "value", "for", "the", "supplied", "key", ".", "This", "will", "add", "the", "value", "to", "any", "existing", "values", "stored", "for", "this", "key", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java#L66-L82
11,293
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java
MultiMap.merge
public MultiMap merge(MultiMap multiMap) { MultiMap result = new MultiMap(); result.map.putAll(this.map); result.map.putAll(multiMap.map); return result; }
java
public MultiMap merge(MultiMap multiMap) { MultiMap result = new MultiMap(); result.map.putAll(this.map); result.map.putAll(multiMap.map); return result; }
[ "public", "MultiMap", "merge", "(", "MultiMap", "multiMap", ")", "{", "MultiMap", "result", "=", "new", "MultiMap", "(", ")", ";", "result", ".", "map", ".", "putAll", "(", "this", ".", "map", ")", ";", "result", ".", "map", ".", "putAll", "(", "multiMap", ".", "map", ")", ";", "return", "result", ";", "}" ]
Merge the values in the specified map with the values in this map and return the results in a new map. @param multiMap The map to merge @return A new map containing the merged values
[ "Merge", "the", "values", "in", "the", "specified", "map", "with", "the", "values", "in", "this", "map", "and", "return", "the", "results", "in", "a", "new", "map", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/MultiMap.java#L107-L113
11,294
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.addParameter
public RequestBuilder<T,ID> addParameter(String name,String value) { parameters.add(name, value); return this; }
java
public RequestBuilder<T,ID> addParameter(String name,String value) { parameters.add(name, value); return this; }
[ "public", "RequestBuilder", "<", "T", ",", "ID", ">", "addParameter", "(", "String", "name", ",", "String", "value", ")", "{", "parameters", ".", "add", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add a parameter to the request. Adds this value to any existing values for this name. @param name The name of the parameter @param value The value @return The request builder
[ "Add", "a", "parameter", "to", "the", "request", ".", "Adds", "this", "value", "to", "any", "existing", "values", "for", "this", "name", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L44-L48
11,295
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.setParameter
public RequestBuilder<T,ID> setParameter(String name,String value) { parameters.set(name, value); return this; }
java
public RequestBuilder<T,ID> setParameter(String name,String value) { parameters.set(name, value); return this; }
[ "public", "RequestBuilder", "<", "T", ",", "ID", ">", "setParameter", "(", "String", "name", ",", "String", "value", ")", "{", "parameters", ".", "set", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Set a parameter on the request. Replaces any existing values for the name. @param name The name of the parameter @param value The value @return The request builder
[ "Set", "a", "parameter", "on", "the", "request", ".", "Replaces", "any", "existing", "values", "for", "the", "name", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L56-L60
11,296
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.addHeader
public RequestBuilder<T,ID> addHeader(String name,String value) { headers.add(name, value); return this; }
java
public RequestBuilder<T,ID> addHeader(String name,String value) { headers.add(name, value); return this; }
[ "public", "RequestBuilder", "<", "T", ",", "ID", ">", "addHeader", "(", "String", "name", ",", "String", "value", ")", "{", "headers", ".", "add", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add a header to the request. Adds this value to any existing values for this name. @param name The name of the header @param value The value @return The request builder
[ "Add", "a", "header", "to", "the", "request", ".", "Adds", "this", "value", "to", "any", "existing", "values", "for", "this", "name", "." ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L68-L72
11,297
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.build
public Request<T> build() { MultiMap headers = resolveHeaders(); MultiMap parameters = resolveParameters(); parameters.add("version",Integer.toString(version)); Request<T> request = new Request<T>(); request.setEntityName(entityName); request.setEntityType(objectType); request.setHeaders(headers); request.setParameters(parameters); return request; }
java
public Request<T> build() { MultiMap headers = resolveHeaders(); MultiMap parameters = resolveParameters(); parameters.add("version",Integer.toString(version)); Request<T> request = new Request<T>(); request.setEntityName(entityName); request.setEntityType(objectType); request.setHeaders(headers); request.setParameters(parameters); return request; }
[ "public", "Request", "<", "T", ">", "build", "(", ")", "{", "MultiMap", "headers", "=", "resolveHeaders", "(", ")", ";", "MultiMap", "parameters", "=", "resolveParameters", "(", ")", ";", "parameters", ".", "add", "(", "\"version\"", ",", "Integer", ".", "toString", "(", "version", ")", ")", ";", "Request", "<", "T", ">", "request", "=", "new", "Request", "<", "T", ">", "(", ")", ";", "request", ".", "setEntityName", "(", "entityName", ")", ";", "request", ".", "setEntityType", "(", "objectType", ")", ";", "request", ".", "setHeaders", "(", "headers", ")", ";", "request", ".", "setParameters", "(", "parameters", ")", ";", "return", "request", ";", "}" ]
Build the request @return The request
[ "Build", "the", "request" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L112-L126
11,298
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.resolveHeaders
protected MultiMap resolveHeaders() { MultiMap resolved = null; if(headerFactory != null) resolved = headerFactory.getHeaders(); if(resolved != null) resolved = resolved.merge(headers); else resolved = headers; return resolved; }
java
protected MultiMap resolveHeaders() { MultiMap resolved = null; if(headerFactory != null) resolved = headerFactory.getHeaders(); if(resolved != null) resolved = resolved.merge(headers); else resolved = headers; return resolved; }
[ "protected", "MultiMap", "resolveHeaders", "(", ")", "{", "MultiMap", "resolved", "=", "null", ";", "if", "(", "headerFactory", "!=", "null", ")", "resolved", "=", "headerFactory", ".", "getHeaders", "(", ")", ";", "if", "(", "resolved", "!=", "null", ")", "resolved", "=", "resolved", ".", "merge", "(", "headers", ")", ";", "else", "resolved", "=", "headers", ";", "return", "resolved", ";", "}" ]
Combine any locally defined headers with any headers from the header factory @return The headers to use for this request
[ "Combine", "any", "locally", "defined", "headers", "with", "any", "headers", "from", "the", "header", "factory" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L132-L144
11,299
dottydingo/hyperion
client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java
RequestBuilder.resolveParameters
protected MultiMap resolveParameters() { MultiMap resolved = null; if(parameterFactory != null) resolved = parameterFactory.getParameters(); if(resolved != null) resolved = resolved.merge(parameters); else resolved = parameters; return resolved; }
java
protected MultiMap resolveParameters() { MultiMap resolved = null; if(parameterFactory != null) resolved = parameterFactory.getParameters(); if(resolved != null) resolved = resolved.merge(parameters); else resolved = parameters; return resolved; }
[ "protected", "MultiMap", "resolveParameters", "(", ")", "{", "MultiMap", "resolved", "=", "null", ";", "if", "(", "parameterFactory", "!=", "null", ")", "resolved", "=", "parameterFactory", ".", "getParameters", "(", ")", ";", "if", "(", "resolved", "!=", "null", ")", "resolved", "=", "resolved", ".", "merge", "(", "parameters", ")", ";", "else", "resolved", "=", "parameters", ";", "return", "resolved", ";", "}" ]
Combine any locally defined parameters with any parameters from the parameter factory @return The parameters to use for this request
[ "Combine", "any", "locally", "defined", "parameters", "with", "any", "parameters", "from", "the", "parameter", "factory" ]
c4d119c90024a88c0335d7d318e9ccdb70149764
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/client/src/main/java/com/dottydingo/hyperion/client/builder/RequestBuilder.java#L150-L162