Example usage for java.util Map toString

List of usage examples for java.util Map toString

Introduction

In this page you can find the example usage for java.util Map toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:bkampfbot.modes.Jagd.java

public void run() {
     Output.printClockLn("Wrterjagd", 1);

     int availablePoints;
     int score;/*from   ww  w . ja v a 2s.co m*/
     try {
         do {
             JSONObject result = Utils.getJSON("games/getWheelData");
             JSONArray data = result.getJSONArray("data");

             availablePoints = result.getJSONArray("credit").getJSONObject(0).getInt("highscore");
             score = result.getJSONArray("credit").getJSONObject(0).getInt("sloganhighscore");

             Output.printTabLn("Aktuelle Punktzahl: " + availablePoints, 2);

             if (data.length() != 5) {
                 Output.println("Etwas stimmt nicht. Abbruch.", Output.ERROR);
             }

             for (int i = 0; i < 5 && availablePoints > 20 && score < percent && doMore(); i++) {
                 JSONObject current = data.getJSONObject(i);

                 Output.printTab(names[i] + ": ", Output.DEBUG);

                 if (current.getInt("result") == 1) {

                     Output.println(" erledigt", Output.DEBUG);
                     continue;

                 }

                 Output.println(" zu lsen", Output.DEBUG);

                 if (letterMax > 0) {
                     ArrayList<Character> alpha = new ArrayList<Character>();
                     for (int j = 65; j < 65 + 26; j++) {
                         alpha.add((char) j);
                     }

                     // check for letters
                     for (int z = 0; z < letterMax; z++) {
                         if (availablePoints < current.getInt("costletter")) {
                             return;
                         }

                         if (z >= letterMin && Math.random() > 0.4) {
                             continue;
                         }
                         int currentAlpha = (new Random()).nextInt(alpha.size() - 1);
                         char currentLetter = alpha.get(currentAlpha);
                         alpha.remove(currentAlpha);

                         Output.printTabLn("Kaufe ein " + currentLetter, Output.INFO);

                         List<NameValuePair> nvps = new ArrayList<NameValuePair>();
                         nvps.add(new BasicNameValuePair("buyletter", currentLetter + ""));
                         nvps.add(new BasicNameValuePair("type", "letter"));
                         Utils.getString("games/buyWheel", nvps);

                         availablePoints -= current.getInt("costletter");

                         Control.sleep(45);
                     }
                 }

                 String md5;
                 try {

                     String dec = decrypt(current.getJSONArray("slogan"));

                     Output.printTab(dec + ": ", Output.INFO);

                     SimpleFile.append("Jagd." + names[i] + ".txt", dec + "\n");

                     MessageDigest m = MessageDigest.getInstance("MD5");
                     byte[] data1 = ("OsShlljuozll11T670OO00OO" + dec.replaceAll("\\s", "")).getBytes();
                     m.update(data1, 0, data1.length);
                     BigInteger in = new BigInteger(1, m.digest());
                     md5 = String.format("%1$032X", in);
                 } catch (NoSuchAlgorithmException e) {
                     Output.error(e);
                     return;
                 }

                 md5 = md5.toLowerCase();

                 List<NameValuePair> nvpn = new ArrayList<NameValuePair>();
                 nvpn.add(new BasicNameValuePair("type", "slogan"));
                 nvpn.add(new BasicNameValuePair("secret", md5));

                 Control.sleep(new Random().nextInt(100) + 100);

                 String res = Utils.getString("games/buyWheel", nvpn);

                 if (res.equals("errorStatus=ok&right=right")) {
                     Output.println("richtig", Output.INFO);
                     score++;
                     wordsSolved++;
                 } else {
                     Output.println("falsch", Output.INFO);
                     break;
                 }

                 availablePoints -= 20;

             }

             // Auf gut Glck -klicken
             if (score >= percent && luck) {
                 int level = 0;

                 if (score >= 100) {
                     level = 100;
                 } else if (score >= 75) {
                     level = 75;
                 } else if (score >= 50) {
                     level = 50;
                 } else if (score >= 20) {
                     level = 20;
                 } else if (score >= 10) {
                     level = 10;
                 }

                 if (level > 0) {
                     Control.sleep(40, Output.INFO);

                     // errorStatus=ok&modus=item&item_pic=wurf387.png&item_type=ring&wintext=Teekessel+mit+ohrenbet%C3%A4ubender+Pfeife
                     String line = Utils.getString("games/payout");
                     Map<String, String> para = Utils.getUrlParameters(line);

                     if (para.get("modus").equals("item")) {
                         Output.printClockLn("Gewinn: " + para.get("item_type") + ", " + para.get("wintext"),
                                 Output.INFO);
                     } else if (para.get("modus").equals("trost")) {
                         Output.printClockLn("Gewinn: " + para.get("wintext") + " " + para.get("preis"),
                                 Output.INFO);
                     } else {
                         Output.println(para.toString(), Output.INFO);
                     }

                     score -= level;
                 }
             }

         } while (availablePoints > 20 && score < percent && doMore());

     } catch (JSONException e) {
         Output.error(e);
         return;
     }
 }

From source file:net.wedjaa.elasticparser.ESSearch.java

public Map<String, Class<?>> getFields(String query) {

    Map<String, Class<?>> result = new HashMap<String, Class<?>>();
    logger.debug("Getting fields using " + query);

    // Let runQuery prepare the pager
    runQuery(query);//from   w  w  w.  ja  v  a  2  s  .c o  m
    result = pager.getResponseFields();
    close();

    logger.debug("Fields: " + result.toString());
    return result;
}

From source file:net.di2e.ecdr.source.rest.CDRSourceConfiguration.java

public void setParameterMap(List<String> parameterMapStr) {
    Map<String, String> convertedMap = SearchUtils.convertToMap(parameterMapStr);
    Map<String, String> translateMap = new HashMap<>(convertedMap.size());
    for (Entry<String, String> entry : convertedMap.entrySet()) {
        if (parameterMatchMap.containsKey(entry.getKey())) {
            translateMap.put(parameterMatchMap.get(entry.getKey()), entry.getValue());
        } else {//from w ww. j  a  v  a2  s  . com
            translateMap.put(entry.getKey(), entry.getValue());
        }
    }
    LOGGER.debug("ConfigUpdate: Updating parameterMap with new entries: {}", convertedMap.toString());
    parameterMap = translateMap;
}

From source file:com.prey.net.PreyRestHttpClient.java

public PreyHttpResponse getAutentication(String url, Map<String, String> params, PreyConfig preyConfig)
        throws IOException {
    HttpPost method = new HttpPost(url);

    method.setHeader("Accept", "*/*");
    if (params != null) {
        method.setEntity(new UrlEncodedFormEntity(getHttpParamsFromMap(params), HTTP.UTF_8));
    }//from   w w w .j  a va2 s .  c  o  m
    PreyLogger.i("apikey:" + preyConfig.getApiKey());
    method.addHeader("Authorization", "Basic " + getCredentials(preyConfig.getApiKey(), "X"));

    // method.setParams(getHttpParamsFromMap(params));
    PreyLogger.d("Sending using 'GET' - URI: " + url + " - parameters: "
            + (params != null ? params.toString() : ""));
    httpclient.setRedirectHandler(new NotRedirectHandler());
    HttpResponse httpResponse = httpclient.execute(method);
    PreyHttpResponse response = new PreyHttpResponse(httpResponse);
    //PreyLogger.d("Response from server: " + response.toString());
    return response;
}

From source file:org.apache.solr.update.InvenioKeepRecidUpdated.java

private void runSynchronously(Map<String, Object> data, SolrQueryRequest req)
        throws MalformedURLException, IOException, InterruptedException {

    log.info("=============================================================================");
    log.info(data.toString());
    log.info(req.toString());//from www .ja  v  a 2 s .co m
    log.info(req.getParamString());
    log.info("=============================================================================");

    SolrParams params = req.getParams();
    SolrCore core = req.getCore();

    String importurl = params.get(PARAM_IMPORT, null);
    String updateurl = params.get(PARAM_UPDATE, null);
    String deleteurl = params.get(PARAM_DELETE, null);

    @SuppressWarnings("unchecked")
    HashMap<String, int[]> dictData = (HashMap<String, int[]>) data.get("dictData");
    Properties prop = (Properties) req.getContext().get(IKRU_PROPERTIES);

    if (dictData.containsKey(ADDED) && dictData.get(ADDED).length > 0) {
        setWorkerMessage("Phase 1/3. Adding records: " + dictData.get(ADDED).length);
        if (importurl != null) {
            if (importurl.equals("blankrecords")) {
                runProcessingAdded(dictData.get(ADDED), req);
            } else {
                runProcessing(core, importurl, dictData.get(ADDED), req);
            }
        }
    }

    if (dictData.containsKey(UPDATED) && dictData.get(UPDATED).length > 0) {
        setWorkerMessage("Phase 2/3. Updating records: " + dictData.get(UPDATED).length);
        if (updateurl != null) {
            if (updateurl.equals("blankrecords")) {
                runProcessingUpdated(dictData.get(UPDATED), req);
            } else {
                runProcessing(core, updateurl, dictData.get(UPDATED), req);
            }
        }
    }

    if (dictData.containsKey(DELETED) && dictData.get(DELETED).length > 0) {
        setWorkerMessage("Phase 3/3. deleting records: " + dictData.get(DELETED).length);
        if (deleteurl != null) {
            if (deleteurl.equals("blankrecords")) {
                runProcessingDeleted(dictData.get(DELETED), req);
            } else {
                runProcessing(core, deleteurl, dictData.get(DELETED), req);
            }
        }
    }

    // save the state into the properties (the modification date must be there
    // in all situations 
    prop.put(LAST_UPDATE, (String) data.get(LAST_UPDATE));
    prop.put(LAST_RECID, String.valueOf((Integer) data.get(LAST_RECID)));
    prop.remove(PARAM_BATCHSIZE);
    prop.remove(PARAM_MAXIMPORT);
    prop.remove(PARAM_TOKEN);
    saveProperties(prop);

    if (params.getBool(PARAM_COMMIT, false)) {
        setWorkerMessage("Phase 3/3. Writing index...");
        CommitUpdateCommand updateCmd = new CommitUpdateCommand(req, false);
        req.getCore().getUpdateHandler().commit(updateCmd);
    }

}

From source file:org.nuxeo.usermapper.extension.AbstractUserMapper.java

@Override
public NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(Object userObject, boolean createIfNeeded,
        boolean update, Map<String, Serializable> params) {

    DocumentModel userModel = null;//from  w ww .  j a va2 s . co m

    Map<String, Serializable> searchAttributes = new HashMap<>();
    Map<String, Serializable> userAttributes = new HashMap<>();
    final Map<String, Serializable> profileAttributes = new HashMap<>();

    if (params != null) {
        searchAttributes.putAll(params);
    }

    resolveAttributes(userObject, searchAttributes, userAttributes, profileAttributes);

    String userId = (String) searchAttributes.get(userManager.getUserIdField());

    if (userId != null) {
        userModel = userManager.getUserModel(userId);
    }
    if (userModel == null) {
        if (searchAttributes.size() > 0) {
            DocumentModelList userDocs = userManager.searchUsers(searchAttributes,
                    Collections.<String>emptySet());
            if (userDocs.size() > 1) {
                log.warn("Can not map user with filter " + searchAttributes.toString() + " : too many results");
            }
            if (userDocs.size() == 1) {
                userModel = userDocs.get(0);
            }
        }
    }
    if (userModel != null) {
        if (update) {
            updatePrincipal(userAttributes, userModel);
        }
    } else {
        if (!createIfNeeded) {
            return null;
        }
        for (String k : searchAttributes.keySet()) {
            if (!userAttributes.containsKey(k)) {
                userAttributes.put(k, searchAttributes.get(k));
            }
        }
        userModel = createPrincipal(userAttributes);
    }

    if (userModel != null && profileAttributes.size() > 0 && update) {
        UserProfileService UPS = Framework.getService(UserProfileService.class);
        if (UPS != null) {

            final String login = (String) userModel.getPropertyValue(userManager.getUserIdField());

            String repoName = Framework.getService(RepositoryManager.class).getDefaultRepositoryName();
            new UnrestrictedSessionRunner(repoName) {
                @Override
                public void run() {
                    DocumentModel profile = UPS.getUserProfileDocument(login, session);
                    updateProfile(session, profileAttributes, profile);
                }
            }.runUnrestricted();
        }
    }

    if (userModel != null) {
        userId = (String) userModel.getPropertyValue(userManager.getUserIdField());
        return userManager.getPrincipal(userId);
    }
    return null;
}

From source file:org.apache.kylin.rest.controller.CubeController.java

/**
 * Initiate the very beginning of a streaming cube. Will seek the latest offests of each partition from streaming
 * source (kafka) and record in the cube descriptor; In the first build job, it will use these offests as the start point.
 * @param cubeName/*  w ww. j  a  v  a  2  s.  co m*/
 * @return
 */
@RequestMapping(value = "/{cubeName}/init_start_offsets", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public GeneralResponse initStartOffsets(@PathVariable String cubeName) {
    checkCubeName(cubeName);
    CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
    if (cubeInstance.getSourceType() != ISourceAware.ID_STREAMING) {
        String msg = "Cube '" + cubeName + "' is not a Streaming Cube.";
        throw new IllegalArgumentException(msg);
    }

    final GeneralResponse response = new GeneralResponse();
    try {
        final Map<Integer, Long> startOffsets = KafkaClient.getLatestOffsets(cubeInstance);
        CubeDesc desc = cubeInstance.getDescriptor();
        desc.setPartitionOffsetStart(startOffsets);
        cubeService.getCubeDescManager().updateCubeDesc(desc);
        response.setProperty("result", "success");
        response.setProperty("offsets", startOffsets.toString());
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }

    return response;
}

From source file:org.apache.atlas.repository.store.graph.v1.AtlasRelationshipStoreV1.java

private void validateEnd(AtlasObjectId end) throws AtlasBaseException {
    String guid = end.getGuid();//ww  w .  jav  a 2 s. co m
    String typeName = end.getTypeName();
    Map<String, Object> uniqueAttributes = end.getUniqueAttributes();
    AtlasVertex endVertex = AtlasGraphUtilsV1.findByGuid(guid);

    if (!AtlasTypeUtil.isValidGuid(guid) || endVertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
    } else if (MapUtils.isNotEmpty(uniqueAttributes)) {
        AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);

        if (AtlasGraphUtilsV1.findByUniqueAttributes(entityType, uniqueAttributes) == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName,
                    uniqueAttributes.toString());
        }
    }
}

From source file:org.apache.cxf.fediz.service.idp.beans.SigninParametersCacheAction.java

public void restore(RequestContext context) {

    String uuidKey = (String) WebUtils.getAttributeFromFlowScope(context, FederationConstants.PARAM_CONTEXT);

    // TODO Abstract the concept of a context to cater for either protocol
    if (uuidKey == null) {
        uuidKey = (String) WebUtils.getAttributeFromFlowScope(context, SAMLSSOConstants.RELAY_STATE);
    }/*  w ww.ja  va2  s  .c  o m*/
    @SuppressWarnings("unchecked")
    Map<String, Object> signinParams = (Map<String, Object>) WebUtils.getAttributeFromExternalContext(context,
            uuidKey);

    if (signinParams != null) {
        String value = (String) signinParams.get(FederationConstants.PARAM_REPLY);
        if (value != null) {
            WebUtils.putAttributeInFlowScope(context, FederationConstants.PARAM_REPLY, value);
        }
        value = (String) signinParams.get(FederationConstants.PARAM_TREALM);
        if (value != null) {
            WebUtils.putAttributeInFlowScope(context, FederationConstants.PARAM_TREALM, value);
        }
        value = (String) signinParams.get(FederationConstants.PARAM_HOME_REALM);
        if (value != null) {
            WebUtils.putAttributeInFlowScope(context, FederationConstants.PARAM_HOME_REALM, value);
        }

        LOG.debug("SignIn parameters restored: {}", signinParams.toString());
        WebUtils.removeAttributeFromFlowScope(context, FederationConstants.PARAM_CONTEXT);
        LOG.info("SignIn parameters restored and " + FederationConstants.PARAM_CONTEXT + "[" + uuidKey
                + "] cleared.");
    } else {
        LOG.debug("Error in restoring security context");
    }
}

From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java

void postgetData() {

    ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha);
    progressbarsandaha.setVisibility(View.VISIBLE);

    MyRequestQueue = Volley.newRequestQueue(this);

    String url = "http://telyar.dmedia.ir/webservice/Get_adviser_profile/";
    StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {

                @Override/* w w w.j  a  v a 2 s  .  com*/
                public void onResponse(String response) {
                    //This code is executed if the server responds, whether or not the response contains data.
                    //The String 'response' contains the server's response.
                    Log.i("ExplainMoshaver", response);
                    //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show();
                    updatelistview(response);

                }
            }, new Response.ErrorListener() { //Create an error listener to handle errors appropriately.
                @Override
                public void onErrorResponse(VolleyError error) {
                    //This code is executed if there is an error.
                }
            }) {
        protected Map<String, String> getParams() {
            Map<String, String> MyData = new HashMap<String, String>();
            //Log.i("asasasasasasa",adviseridm+"/"+GlobalVar.getDeviceID());
            MyData.put("adviserid", adviseridm); //Add the data you'd like to send to the server.
            MyData.put("deviceid", GlobalVar.getDeviceID()); //Add the data you'd like to send to the server.
            MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server.
            Log.i("ExplainMoshaver", MyData.toString());

            return MyData;
        }

        @Override
        protected void onFinish() {

            ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha);
            progressbarsandaha.setVisibility(View.INVISIBLE);

            TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);

            TabHost.TabSpec tabSpec3 = tabHost.newTabSpec("nazar");
            TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("madarek");
            TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("map");

            tabSpec3.setIndicator("");
            Intent intent1 = new Intent(ExplainMoshaver.this, ListeComments.class);
            intent1.putExtra("adviseridm", adviseridm);
            intent1.putExtra("comments", comments);
            /*intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            Log.i("aaaaaaaaaaaaaaa", comments + " ");
            tabSpec3.setContent(intent1);

            tabSpec2.setIndicator("");
            Intent intent2 = new Intent(ExplainMoshaver.this, ListeLiecence.class);
            intent2.putExtra("adviseridm", adviseridm);
            intent2.putExtra("License", License);
            /*intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            tabSpec2.setContent(intent2);

            tabSpec1.setIndicator("");
            final Intent intent = new Intent(ExplainMoshaver.this, MapsActivity.class);
            intent.putExtra("adviseridm", adviseridm);
            intent.putExtra("Mainplace", Mainplace);
            intent.putExtra("menuya", "ya");
            /*intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/
            tabSpec1.setContent(intent);

            tabHost.addTab(tabSpec1);
            tabHost.addTab(tabSpec2);
            tabHost.addTab(tabSpec3);

            tabHost.setCurrentTab(2);
        }
    };

    MyRequestQueue.add(MyStringRequest);
}