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:com.stvn.nscreen.my.MyPurchaseListFragment.java

/**
 * VOD ? /*from ww  w.  j a v a2 s .c om*/
 * */
private void requestDisablePurchaseLog(String purchaseID, final int position) {
    ((MyMainActivity) getActivity()).showProgressDialog("", getString(R.string.wait_a_moment));
    String terminalKey = mPref.getWebhasTerminalKey();

    String url = mPref.getWebhasServerUrl() + "/disablePurchaseLog.json?version=1&terminalKey=" + terminalKey
            + "&purchaseEventId=" + purchaseID;
    JYStringRequest request = new JYStringRequest(mPref, Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    ((MyMainActivity) getActivity()).hideProgressDialog();

                    try {
                        JSONObject responseObj = new JSONObject(response);
                        String resultCode = responseObj.getString("resultCode");
                        if (Constants.CODE_WEBHAS_OK.equals(resultCode)) {
                            removeCurrentTabObjectWithIndex(position);
                            changeListData();
                        } else {
                            String errorString = responseObj.getString("errorString");
                            StringBuilder sb = new StringBuilder();
                            sb.append("API: action\nresultCode: ").append(resultCode).append("\nerrorString: ")
                                    .append(errorString);

                            CMAlertUtil.Alert(getActivity(), "", sb.toString());

                            mAdapter.notifyDataSetChanged();
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    ((MyMainActivity) getActivity()).hideProgressDialog();
                    if (mPref.isLogging()) {
                        VolleyLog.d("", "onErrorResponse(): " + error.getMessage());
                    }
                }
            }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("version", String.valueOf(1));
            if (mPref.isLogging()) {
                Log.d("", "getParams()" + params.toString());
            }
            return params;
        }
    };
    mRequestQueue.add(request);
}

From source file:com.stvn.nscreen.my.MyPurchaseListFragment.java

public void requestGetBundleProductDetail(final JSONObject object) {

    String terminalKey = mPref.getWebhasTerminalKey();
    String productID = null;//w w  w .  j a  v a2s  .  c om
    try {
        productID = object.getString("productId");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    String url = mPref.getWebhasServerUrl() + "/getBundleProductInfo.json?version=1&terminalKey=" + terminalKey
            + "&productId=" + productID + "&productProfile=1";

    JYStringRequest request = new JYStringRequest(mPref, Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        JSONObject responseObject = new JSONObject(response);

                        if (responseObject.getString("resultCode").equalsIgnoreCase("100")) {
                            startActivityAssetOrBundle(object.getString("assetId"), object);
                        } else {
                            String alertTitle = getString(R.string.my_cnm_alert_title_expired);
                            String alertMessage1 = getString(R.string.my_cnm_alert_message1_expired);
                            CMAlertUtil.Alert(getActivity(), alertTitle, alertMessage1, "", true, false,
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                        }
                                    }, true);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    ((MyMainActivity) getActivity()).hideProgressDialog();
                    if (mPref.isLogging()) {
                        VolleyLog.d("", "onErrorResponse(): " + error.getMessage());
                    }
                }
            }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("version", String.valueOf(1));
            if (mPref.isLogging()) {
                Log.d("", "getParams()" + params.toString());
            }
            return params;
        }
    };
    mRequestQueue.add(request);
}

From source file:moe.yuna.palinuridae.xutilsmodel.cache.XUtilsRedisCacheImpl.java

@Override
@Redis(shard = true)/*from   ww  w .ja va2 s  . c o m*/
public <T extends XUtilsModel> T get(Object primaryValue, Class<T> clazz) {
    try {
        XUtilsModelInfo info = XUtilsModelPropertiesHolder.getXUtilsModelInfo(clazz);
        if (info.getTableInfo().getCacheExpired() <= 0) {
            log.debug("model:" + clazz.getSimpleName() + " not cache");
            return null;
        }
        Map<String, String> hgetAll = null;
        String key = formatCacheKey(clazz.getName(), primaryValue, info.getTableInfo().getCacheVersion());
        hgetAll = jedis.hgetAll(key);
        if (hgetAll == null || hgetAll.isEmpty()) {
            jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(CACHE_MISS_COUNT_KEY), 1);
            jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(MODEL_CACHE_MISS_COUNT_KEY, clazz.getName()), 1);
            jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(CACHE_USE_COUNT_KEY), 1);
            jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(MODEL_CACHE_USE_COUNT_KEY, clazz.getName()), 1);
            log.debug("miss cache!!key:" + key);
            return null;
        }
        jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(CACHE_HIT_COUNT_KEY), 1);
        jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(MODEL_CACHE_HIT_COUNT_KEY, clazz.getName()), 1);
        jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(CACHE_HIT_COUNT_KEY), 1);
        jedis.hincrBy(CACHE_COUNT_MAP_KEY, String.format(MODEL_CACHE_HIT_COUNT_KEY, clazz.getName()), 1);
        log.debug("hit cache!!key:" + key + ",value:" + hgetAll.toString());
        T bean = clazz.newInstance();
        for (Entry<String, String> entry : hgetAll.entrySet()) {
            AbstractXUtilsColumn columnInfo = info.getAllColumns().get(entry.getKey());
            Field field = columnInfo.getField();
            columnInfo.getSetMethod().invoke(bean, formatOjbect(field, entry.getValue()));
        }
        return bean;
    } catch (IllegalArgumentException | IllegalAccessException | InstantiationException
            | InvocationTargetException | XUtilsModelNotFoundException ex) {
        log.error("params:" + primaryValue + ",Class:" + clazz.getName(), ex);
        return null;
    }
}

From source file:org.apache.ofbiz.base.util.UtilHttp.java

/**
 * Given the prefix of a composite parameter, recomposes a single Object from
 * the composite according to compositeType. For example, consider the following
 * form widget field,/*from w  ww  .  j a v  a 2 s  . c om*/
 *
 * <pre>
 * {@code
 * <field name="meetingDate">
 *     <date-time type="timestamp" input-method="time-dropdown">
 * </field>
 * }
 * </pre>
 *
 * The result in HTML is three input boxes to input the date, hour and minutes separately.
 * The parameter names are named meetingDate_c_date, meetingDate_c_hour, meetingDate_c_minutes.
 * Additionally, there will be a field named meetingDate_c_compositeType with a value of "Timestamp".
 * where _c_ is the COMPOSITE_DELIMITER. These parameters will then be recomposed into a Timestamp
 * object from the composite fields.
 *
 * @param request
 * @param prefix
 * @return Composite object from data or null if not supported or a parsing error occurred.
 */
public static Object makeParamValueFromComposite(HttpServletRequest request, String prefix, Locale locale) {
    String compositeType = request.getParameter(makeCompositeParam(prefix, "compositeType"));
    if (UtilValidate.isEmpty(compositeType))
        return null;

    // collect the composite fields into a map
    Map<String, String> data = new HashMap<String, String>();
    for (Enumeration<String> names = UtilGenerics.cast(request.getParameterNames()); names.hasMoreElements();) {
        String name = names.nextElement();
        if (!name.startsWith(prefix + COMPOSITE_DELIMITER))
            continue;

        // extract the suffix of the composite name
        String suffix = name.substring(name.indexOf(COMPOSITE_DELIMITER) + COMPOSITE_DELIMITER_LENGTH);

        // and the value of this parameter
        String value = request.getParameter(name);

        // key = suffix, value = parameter data
        data.put(suffix, value);
    }
    if (Debug.verboseOn()) {
        Debug.logVerbose("Creating composite type with parameter data: " + data.toString(), module);
    }

    // handle recomposition of data into the compositeType
    if ("Timestamp".equals(compositeType)) {
        String date = data.get("date");
        String hour = data.get("hour");
        String minutes = data.get("minutes");
        String ampm = data.get("ampm");
        if (date == null || date.length() < 10)
            return null;
        if (UtilValidate.isEmpty(hour))
            return null;
        if (UtilValidate.isEmpty(minutes))
            return null;
        boolean isTwelveHour = UtilValidate.isNotEmpty(ampm);

        // create the timestamp from the data
        try {
            int h = Integer.parseInt(hour);
            Timestamp timestamp = Timestamp.valueOf(date.substring(0, 10) + " 00:00:00.000");
            Calendar cal = Calendar.getInstance(locale);
            cal.setTime(timestamp);
            if (isTwelveHour) {
                boolean isAM = ("AM".equals(ampm) ? true : false);
                if (isAM && h == 12)
                    h = 0;
                if (!isAM && h < 12)
                    h += 12;
            }
            cal.set(Calendar.HOUR_OF_DAY, h);
            cal.set(Calendar.MINUTE, Integer.parseInt(minutes));
            return new Timestamp(cal.getTimeInMillis());
        } catch (IllegalArgumentException e) {
            Debug.logWarning("User input for composite timestamp was invalid: " + e.getMessage(), module);
            return null;
        }
    }

    // we don't support any other compositeTypes (yet)
    return null;
}

From source file:com.skilrock.lms.web.scratchService.gameMgmt.common.GameUploadAction.java

public void displayTicketsUploadInventoryAjax() {
    System.out.println("displayTicketsUploadInventoryAjax == " + getGameType() + " ,callFlag = " + callFlag);
    PrintWriter out;/*from   w  ww.j a  va2s  .c o m*/
    try {
        out = getResponse().getWriter();
        response.setContentType("text/html");
        GameuploadHelper gameuploadHelper = new GameuploadHelper();
        ArrayList<GameBean> gameList = gameuploadHelper.fatchGameList(getGameType());
        StringBuilder gameString = new StringBuilder();
        ;
        for (GameBean gameBean : gameList) {
            gameString.append("," + gameBean.getGameName());
        }
        gameString.delete(0, 1);
        // get the supplier list first time
        if (callFlag != null && "FIRST".equalsIgnoreCase(callFlag.trim())) {
            Map<Integer, String> supplierList = gameuploadHelper.fatchSupplierList();
            String supplierString = supplierList.toString().replace("{", "").replace("}", "");
            gameString = gameString.append("||" + supplierString);
        }
        out.print(gameString.toString());
        System.out.println("commited data == " + gameString);

    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.apache.hadoop.hive.ql.metadata.formatting.TextMetaDataFormatter.java

/**
 * Describe a database/*from www .  ja  v  a2 s  .c om*/
 */
@Override
public void showDatabaseDescription(DataOutputStream outStream, String database, String comment,
        String location, String ownerName, String ownerType, Map<String, String> params) throws HiveException {
    try {
        outStream.write(database.getBytes("UTF-8"));
        outStream.write(separator);
        if (comment != null) {
            outStream.write(HiveStringUtils.escapeJava(comment).getBytes("UTF-8"));
        }
        outStream.write(separator);
        if (location != null) {
            outStream.write(location.getBytes("UTF-8"));
        }
        outStream.write(separator);
        if (ownerName != null) {
            outStream.write(ownerName.getBytes("UTF-8"));
        }
        outStream.write(separator);
        if (ownerType != null) {
            outStream.write(ownerType.getBytes("UTF-8"));
        }
        outStream.write(separator);
        if (params != null && !params.isEmpty()) {
            outStream.write(params.toString().getBytes("UTF-8"));
        }
        outStream.write(terminator);
    } catch (IOException e) {
        throw new HiveException(e);
    }
}

From source file:iristk.util.Record.java

@Override
public String toString() {
    Map map = toMap();
    for (Object key : new ArrayList<String>(map.keySet())) {
        Object val = map.get(key);
        if (val instanceof Double || val instanceof Float) {
            map.put(key, String.format(Locale.US, "%.2f", val));
        }/*from ww w .java  2s . c om*/
        if (map.get(key) == null)
            map.remove(key);
    }
    return getClass().getSimpleName() + map.toString();
}

From source file:com.stvn.nscreen.my.MyPurchaseListFragment.java

/**
 * VOD ? /*from  ww  w.  j  a va 2 s .  c  o  m*/
 * */
private void requestGetPurchasedProductList() {
    ((MyMainActivity) getActivity()).showProgressDialog("", getString(R.string.wait_a_moment));
    String terminalKey = mPref.getWebhasTerminalKey();

    String logStartDate = null;
    String logEndDate = null;
    try {
        logStartDate = URLEncoder.encode(CMDateUtil.getBeforeTodayWithFormat(-60, "yyyy-MM-dd HH:mm:ss"),
                "utf-8");
        logEndDate = URLEncoder.encode(CMDateUtil.getDateWithFormat(new Date(), "yyyy-MM-dd HH:mm:ss"),
                "utf-8");
    } catch (Exception e) {
        e.printStackTrace();
    }

    String url = mPref.getWebhasServerUrl() + "/getPurchasedProductList.json?version=1&terminalKey="
            + terminalKey + "&purchaseLogProfile=4";

    if (TextUtils.isEmpty(logStartDate) == false && TextUtils.isEmpty(logEndDate) == false) {
        url += "&expiredLogStartTime=" + logStartDate + "&expiredLogEndTime=" + logEndDate;
    }

    JYStringRequest request = new JYStringRequest(mPref, Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        JSONObject responseObject = new JSONObject(response);
                        JSONArray puchaseArray = responseObject.getJSONArray("purchaseLogList");

                        HashMap<String, Boolean> mapBundel = new HashMap<>();
                        for (int i = 0; i < puchaseArray.length(); i++) {
                            JSONObject jsonObj = puchaseArray.getJSONObject(i);
                            ListViewDataObject obj = new ListViewDataObject(i, 0, jsonObj.toString());

                            String productId = jsonObj.getString("productId");
                            String productType = jsonObj.getString("productType").toLowerCase();
                            String paymentType = jsonObj.getString("paymentType").toLowerCase();
                            if (checkAddListWithPaymentType(paymentType)
                                    && checkAddListWithProductType(productType)) {
                                String purchasedTime = jsonObj.getString("purchasedTime");

                                obj.puchaseSecond = CMDateUtil.changeSecondToDate(purchasedTime);
                                obj.viewablePeriodState = jsonObj.getString("viewablePeriodState");

                                mResponseList.add(obj);

                                if ("bundle".equals(productType)) {
                                    mapBundel.put(productId, false);
                                }
                            }
                        }
                        drawPurchaseList();
                        //                    requestGetBundleProductInfo(mapBundel);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    ((MyMainActivity) getActivity()).hideProgressDialog();
                    if (mPref.isLogging()) {
                        VolleyLog.d("", "onErrorResponse(): " + error.getMessage());
                    }
                }
            }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("version", String.valueOf(1));
            if (mPref.isLogging()) {
                Log.d("", "getParams()" + params.toString());
            }
            return params;
        }
    };
    mRequestQueue.add(request);
}

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

@Override
@GraphTransaction//  www. j  a  v  a  2s  .c  om
public AtlasEntityWithExtInfo getByUniqueAttributes(AtlasEntityType entityType,
        Map<String, Object> uniqAttributes) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> getByUniqueAttribute({}, {})", entityType.getTypeName(), uniqAttributes);
    }

    AtlasVertex entityVertex = AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes);

    EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry);

    AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(entityVertex);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND,
                entityType.getTypeName(), uniqAttributes.toString());
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== getByUniqueAttribute({}, {}): {}", entityType.getTypeName(), uniqAttributes, ret);
    }

    return ret;
}