List of usage examples for com.google.gson.internal LinkedTreeMap get
@Override
public V get(Object key)
From source file:controller.EmotionController.java
public void sendImage() { this.reponse.setText(""); this.iotHubConnection = this.mainApp.getIotHubConnection(); EmotionContext context = new EmotionContext(); LinkedTreeMap<String, Object> json = context.sendImage(message.getText()); if (json.isEmpty()) { reponse.setText("No information found..."); } else {//from w w w . ja va 2s.c om LinkedTreeMap<String, Object> score = (LinkedTreeMap<String, Object>) json.get("scores"); String resultat = "Anger : " + score.get("anger").toString() + "\nContempt: " + score.get("contempt").toString() + "\nDisgust: " + score.get("disgust").toString() + "\nFear: " + score.get("fear").toString() + "\nHappiness: " + score.get("happiness").toString() + "\nNeutral: " + score.get("neutral").toString() + "\nSadness: " + score.get("sadness").toString() + "\nSurprise: " + score.get("surprise").toString(); iotHubConnection.SendEmotionRecognition(json); reponse.setText(resultat); } }
From source file:controller.TextAnalyticsController.java
public void sendMessage() { reponse.setText(""); this.iotHubConnection = this.mainApp.getIotHubConnection(); TextRecognitionContext context = new TextRecognitionContext(); LinkedTreeMap<String, Object> res = (LinkedTreeMap<String, Object>) context.sendPost(message.getText()); String resultat = "Name : " + res.get("name").toString() + "\nIso : " + res.get("iso6391Name") + "\nScore : " + Double.toString((Double) res.get("score")); iotHubConnection.sendMessageTextRecognition(res); reponse.setText(resultat);/*from ww w.j a v a2s .c o m*/ }
From source file:ddf.catalog.source.solr.rest.SolrRest.java
License:Open Source License
private void setSimilarities() { if (CollectionUtils.isNotEmpty(fieldTypes)) { LinkedTreeMap<String, Object> replaceField = new LinkedTreeMap<>(); for (Object fieldType : fieldTypes) { LinkedTreeMap<String, Object> objectLinkedTreeMap = (LinkedTreeMap<String, Object>) fieldType; Object nameObj = objectLinkedTreeMap.get("name"); if (nameObj instanceof String) { String name = (String) nameObj; if (name.contains("suggest")) { LOGGER.trace("Skipping suggest field"); continue; }//from w ww . j a va 2 s .c o m } objectLinkedTreeMap.put("similarity", similarityFormat); replaceField.put("replace-field-type", objectLinkedTreeMap); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Replacing field: {}", gson.toJson(replaceField)); } String response = solrCatalogSchemaClientFactory.getClient() .replaceField(gson.toJson(replaceField)); LOGGER.trace("Catalog Configuration update response: {}", response); response = solrMetacardCacheSchemaClientFactory.getClient().replaceField(gson.toJson(replaceField)); LOGGER.trace("Metacard Cache Configuration update response: {}", response); } } }
From source file:edu.vt.vbi.patric.portlets.TranscriptomicsGene.java
License:Apache License
public String getAuthorizationToken(PortletRequest request) { String token = null;//from w ww . j a v a 2s . c o m String sessionId = request.getPortletSession(true).getId(); Gson gson = new Gson(); LinkedTreeMap sessionMap = gson.fromJson(SessionHandler.getInstance().get(sessionId), LinkedTreeMap.class); if (sessionMap.containsKey("authorizationToken")) { token = (String) sessionMap.get("authorizationToken"); } return token; }
From source file:edu.vt.vbi.patric.portlets.WorkspacePortlet.java
License:Apache License
public String getUserId(PortletRequest request) { String userId = null;/*from w ww . jav a 2 s .c om*/ String sessionId = request.getPortletSession(true).getId(); Gson gson = new Gson(); LinkedTreeMap sessionMap = gson.fromJson(SessionHandler.getInstance().get(sessionId), LinkedTreeMap.class); Map<String, Object> profile = (Map) sessionMap.get("userProfile"); if (profile != null) { userId = profile.get("id").toString().replace("@patricbrc.org", ""); } return userId; }
From source file:edu.vt.vbi.patric.portlets.WorkspacePortlet.java
License:Apache License
public String getUserWorkspacePath(PortletRequest request, String defaultWorkspaceName) { String path = null;/* w w w . j av a 2 s. co m*/ String sessionId = request.getPortletSession(true).getId(); Gson gson = new Gson(); LinkedTreeMap sessionMap = gson.fromJson(SessionHandler.getInstance().get(sessionId), LinkedTreeMap.class); Map<String, Object> profile = (Map) sessionMap.get("userProfile"); if (profile != null) { path = "/" + profile.get("id").toString() + defaultWorkspaceName; } return path; }
From source file:eu.focusnet.app.model.widgets.FormWidgetInstance.java
License:Open Source License
/** * Specific configuration:/* ww w . j a va 2 s. c o m*/ * - iterate through fields and create field instances accordingly */ @Override protected void processSpecificConfig() { this.fields = new LinkedHashMap<>(); for (Map.Entry e : this.config.entrySet()) { String fieldName = (String) e.getKey(); LinkedTreeMap<String, Object> fieldConfig = (LinkedTreeMap<String, Object>) e.getValue(); if (fieldConfig == null) { this.markAsInvalid(); return; } FieldInstance newField; String type; Object rawType = fieldConfig.get(FieldInstance.FIELD_LABEL_TYPE); if (rawType == null) { markAsInvalid(); return; } try { type = TypesHelper.asString(rawType); } catch (FocusBadTypeException ex) { this.markAsInvalid(); return; } switch (type) { case Constant.DataModelTypes.FIELD_TYPE_TEXTFIELD: newField = new TextfieldFieldInstance(fieldName, fieldConfig, this.dataContext); break; case Constant.DataModelTypes.FIELD_TYPE_TEXTAREA: newField = new TextareaFieldInstance(fieldName, fieldConfig, this.dataContext); break; case Constant.DataModelTypes.FIELD_TYPE_CHECKBOX: newField = new CheckboxFieldInstance(fieldName, fieldConfig, this.dataContext); break; case Constant.DataModelTypes.FIELD_TYPE_SELECT: newField = new SelectFieldInstance(fieldName, fieldConfig, this.dataContext); break; default: this.markAsInvalid(); return; } this.fields.put(fieldName, newField); if (!newField.isValid()) { this.markAsInvalid(); } } }
From source file:GestionCodePostal.CodePostal.java
private void decode(String json) { Map<String, Object> fromJson = new Gson().fromJson(json, Map.class); // obtention du nombre de ville Object Scount = fromJson.get("count"); int count = (int) Double.parseDouble(Scount.toString()); // System.out.println("nombre de ville : " + count); for (int i = 1; i <= count; i++) { LinkedTreeMap get = (LinkedTreeMap) fromJson.get(String.valueOf(i)); String ville = (String) get.get("ville"); ville = ville.toLowerCase();// w ww. java 2 s . com ville = ville.substring(0, 1).toUpperCase() + ville.substring(1); lesVilles.add(ville); } }
From source file:im.neon.activity.FallbackLoginActivity.java
License:Apache License
private void launchWebView() { mWebView.loadUrl(mHomeServerUrl + "_matrix/static/client/login/"); mWebView.setWebViewClient(new WebViewClient() { @Override//from w ww. j a va 2 s . co m public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { final SslErrorHandler fHander = handler; AlertDialog.Builder builder = new AlertDialog.Builder(FallbackLoginActivity.this); builder.setMessage(R.string.ssl_could_not_verify); builder.setPositiveButton(R.string.ssl_trust, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fHander.proceed(); } }); builder.setNegativeButton(R.string.ssl_do_not_trust, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fHander.cancel(); } }); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { fHander.cancel(); dialog.dismiss(); return true; } return false; } }); AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); // on error case, close this activity FallbackLoginActivity.this.runOnUiThread(new Runnable() { @Override public void run() { FallbackLoginActivity.this.finish(); } }); } @Override public void onPageFinished(WebView view, String url) { // avoid infinite onPageFinished call if (url.startsWith("http")) { // Generic method to make a bridge between JS and the UIWebView final String MXCJavascriptSendObjectMessage = "javascript:window.matrixLogin.sendObjectMessage = function(parameters) { var iframe = document.createElement('iframe'); iframe.setAttribute('src', 'js:' + JSON.stringify(parameters)); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); iframe = null; };"; view.loadUrl(MXCJavascriptSendObjectMessage); // The function the fallback page calls when the registration is complete final String MXCJavascriptOnRegistered = "javascript:window.matrixLogin.onLogin = function(homeserverUrl, userId, accessToken) { matrixLogin.sendObjectMessage({ 'action': 'onLogin', 'homeServer': homeserverUrl,'userId': userId, 'accessToken': accessToken }); };"; view.loadUrl(MXCJavascriptOnRegistered); } } @Override public boolean shouldOverrideUrlLoading(android.webkit.WebView view, java.lang.String url) { if ((null != url) && url.startsWith("js:")) { String json = url.substring(3); HashMap<String, Object> serverParams = null; try { // URL decode json = URLDecoder.decode(json, "UTF-8"); serverParams = new Gson().fromJson(json, new TypeToken<HashMap<String, Object>>() { }.getType()); } catch (Exception e) { Log.e(LOG_TAG, "## shouldOverrideUrlLoading() : fromJson failed " + e.getMessage()); } // succeeds to parse parameters if (null != serverParams) { try { String action = (String) serverParams.get("action"); LinkedTreeMap<String, String> parameters = (LinkedTreeMap<String, String>) serverParams .get("homeServer"); if (TextUtils.equals("onLogin", action) && (null != parameters)) { final String userId = parameters.get("user_id"); final String accessToken = parameters.get("access_token"); final String homeServer = parameters.get("home_server"); // remove the trailing / if (mHomeServerUrl.endsWith("/")) { mHomeServerUrl = mHomeServerUrl.substring(0, mHomeServerUrl.length() - 1); } // check if the parameters are defined if ((null != homeServer) && (null != userId) && (null != accessToken)) { FallbackLoginActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Intent returnIntent = new Intent(); returnIntent.putExtra("homeServerUrl", mHomeServerUrl); returnIntent.putExtra("homeServer", homeServer); returnIntent.putExtra("userId", userId); returnIntent.putExtra("accessToken", accessToken); setResult(RESULT_OK, returnIntent); FallbackLoginActivity.this.finish(); } }); } } } catch (Exception e) { Log.e(LOG_TAG, "## shouldOverrideUrlLoading() : failed " + e.getMessage()); } } return true; } return false; } }); }
From source file:io.bitsquare.pricefeed.providers.BtcAverageProvider.java
License:Open Source License
private Map<String, PriceData> getMap(String json) { Map<String, PriceData> marketPriceMap = new HashMap<>(); LinkedTreeMap<String, Object> treeMap = new Gson().<LinkedTreeMap<String, Object>>fromJson(json, LinkedTreeMap.class); treeMap.entrySet().stream().forEach(e -> { Object value = e.getValue(); // We need to check the type as we get an unexpected "timestamp" object at the end: if (value instanceof LinkedTreeMap) { LinkedTreeMap<String, Object> data = (LinkedTreeMap) value; String currencyCode = e.getKey().substring(3); marketPriceMap.put(currencyCode, new PriceData(currencyCode, (double) data.get("ask"), (double) data.get("bid"), (double) data.get("last"))); }/*from www.j av a 2 s .c o m*/ }); return marketPriceMap; }