当前位置: 首页>>代码示例>>Java>>正文


Java Strings类代码示例

本文整理汇总了Java中me.hao0.common.util.Strings的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Strings类属于me.hao0.common.util包,在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkApp

import me.hao0.common.util.Strings; //导入依赖的package包/类
private App checkApp(String appName, String appKey){
    Response<App> appResp = appService.findByName(appName);
    if (!appResp.isSuccess()){
        Logs.error("failed to find app(name={}), cause: {}", appName, appResp.getErr());
        throw new IllegalStateException(appResp.getErr());
    }

    App app = appResp.getData();
    if (app == null){
        Logs.warn("the app(name={}) isn't exist.", appName);
        throw new IllegalArgumentException("app["+ appName +"] not exist");
    }

    if (!Strings.isNullOrEmpty(appKey)){
        if (!Objects.equal(appKey, app.getAppKey())){
            throw new IllegalArgumentException("app["+ appName +"]'s appKey isn't right.");
        }
    }

    return app;
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:22,代码来源:ClientServiceImpl.java

示例2: filterSigningParams

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * 对签名参数过滤处理,出去值为"", null, sign, signType
 * @param signingParams 签名参数
 * @return 过滤后的签名参数
 */
Map<String, String> filterSigningParams(Map<String, String> signingParams) {

    Map<String, String> validParams = new HashMap<>();

    for(Map.Entry<String, String> kv : signingParams.entrySet()){
        if (Strings.isNullOrEmpty(kv.getValue())
                || AlipayField.SIGN.field().equals(kv.getKey())
                || AlipayField.SIGN_TYPE.field().equals(kv.getKey())){
            continue;
        }
        validParams.put(kv.getKey(), kv.getValue());
    }

    return validParams;
}
 
开发者ID:dzzgml,项目名称:alipay,代码行数:21,代码来源:Component.java

示例3: doSign

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * 支付请求前签名
 * @param params 参数(已经升序, 排出非空值和sign)
 * @return MD5的签名字符串(大写)
 */
protected String doSign(final Map<String, String> params) {
    StringBuilder signing = new StringBuilder();

    for (Map.Entry<String, String> entry : params.entrySet()) {
        if (!Strings.isNullOrEmpty(entry.getValue())){
            signing.append(entry.getKey()).append('=').append(entry.getValue()).append("&");
        }
    }

    // append key
    signing.append("key=").append(wepay.getAppKey());

    // md5
    return MD5.generate(signing.toString(), false).toUpperCase();
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:21,代码来源:Component.java

示例4: renderQueryResp

import me.hao0.common.util.Strings; //导入依赖的package包/类
private RefundQueryResponse renderQueryResp(Map<String, Object> refundData) {
    RefundQueryResponse queryResp = new RefundQueryResponse();

    queryResp.setOutTradeNo((String)refundData.get(WepayField.OUT_TRADE_NO));
    queryResp.setTransactionId((String)refundData.get(WepayField.TRANSACTION_ID));
    queryResp.setTotalFee(Integer.parseInt((String)refundData.get(WepayField.TOTAL_FEE)));
    queryResp.setCashFee(Integer.parseInt((String) refundData.get(WepayField.CASH_FEE)));
    String feeType = (String)refundData.get(WepayField.FEE_TYPE);
    if (!Strings.isNullOrEmpty(feeType)){
        queryResp.setFeeType(FeeType.from(feeType));
    }

    Integer refundCount = Integer.parseInt((String) refundData.get(WepayField.REFUND_COUNT));

    List<RefundItem> refundItems = new ArrayList<>();
    RefundItem refundItem;
    for (int refundIndex = 0; refundIndex < refundCount; refundIndex++){
        refundItem = renderRefundItem(refundData, refundIndex);
        refundItems.add(refundItem);
    }
    queryResp.setItems(refundItems);

    return queryResp;
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:25,代码来源:Refunds.java

示例5: checkApplyParams

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * 校验退款参数
 * @param request 退款请求对象
 */
private void checkApplyParams(RefundApplyRequest request) {
    checkNotNull(wepay.certs, "merchant certs can't be null before apply refund");
    checkNotNullAndEmpty(wepay.certPasswd, "certPasswd");
    checkNotNull(request, "apply request can't be null");
    if (Strings.isNullOrEmpty(request.getTransactionId())){
        checkNotNullAndEmpty(request.getOutTradeNo(), "transactionId && outTradeNo");
    }
    checkNotNullAndEmpty(request.getOutRefundNo(), "outRefundNo");
    checkNotNullAndEmpty(request.getOpUserId(), "opUserId");
    Integer totalFee = request.getTotalFee();
    Integer refundFee = request.getRefundFee();
    checkPositive(totalFee, "totalFee");
    checkPositive(refundFee, "refundFee");
    checkPositive(totalFee - refundFee, "totalFee - refundFee");
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:20,代码来源:Refunds.java

示例6: get

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * Get the config's latest value as JSON object
 * @param configName config name
 * @param classType object class type
 * @param <T> class generic type
 * @return the config's latest JSON object
 */
public <T> T get(String configName, Class<T> classType){
    String configJson = configValues.get(configName);
    if (Strings.isNullOrEmpty(configJson)){
        return null;
    }
    return JsonUtil.INSTANCE.fromJson(configJson, classType);
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:15,代码来源:SimpleDiabloClient.java

示例7: doRequest

import me.hao0.common.util.Strings; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T doRequest(String server, String uri, HttpMethod method,
                        Map<String, String> headers, Map<String, Object> params, int readTimeout, Object respType){

    String reqUri = Constants.HTTP_PREFIX + server + ClientUris.CLIENT_API + uri;

    Http http;
    if (method == HttpMethod.GET){
        http = Http.get(reqUri);
    } else {
        http = Http.post(reqUri);
    }

    if (readTimeout > 0){
        http.readTimeout(readTimeout);
    }

    if (headers != null){
        http.headers(headers);
    }

    String resp = http.params(params).request();
    if (Strings.isNullOrEmpty(resp)){
        return null;
    }

    checkRespErr(resp);

    return respType instanceof JavaType ?
            (T)JsonUtil.INSTANCE.fromJson(resp, (JavaType) respType) :
            JsonUtil.INSTANCE.fromJson(resp, (Class<T>) respType);
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:33,代码来源:DiabloAgent.java

示例8: pagingConfig

import me.hao0.common.util.Strings; //导入依赖的package包/类
@Override
public Response<Page<Config>> pagingConfig(Long appId, String configName, Integer pageNo, Integer pageSize) {
    try {

        // find by name
        if (!Strings.isNullOrEmpty(configName)){
            Config config = configDao.findByName(appId, configName);
            if (config == null){
                return Response.ok(Page.empty());
            }
            return Response.ok(new Page<>(1L, Lists.newArrayList(config)));
        }

        // find paging
        Long totalCount = configDao.countByAppId(appId);
        if (totalCount <= 0L){
            return Response.ok(Page.empty());
        }

        Paging paging = new Paging(pageNo, pageSize);
        List<Config> configs = configDao.listByAppId(appId, paging.getOffset(), paging.getLimit());
        return Response.ok(new Page<>(totalCount, configs));

    } catch (Exception e){
        Logs.error("failed to paging config(appId={}, pageNo={}, pageSize={}), cause: {}",
                appId, pageNo, pageSize, Throwables.getStackTraceAsString(e));
        return Response.notOk(messages.get("config.find.failed"));
    }
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:30,代码来源:ConfigServiceImpl.java

示例9: pagingApp

import me.hao0.common.util.Strings; //导入依赖的package包/类
@Override
public Response<Page<App>> pagingApp(String appName, Integer pageNo, Integer pageSize) {
    try {

        // find an app by name
        if (!Strings.isNullOrEmpty(appName)){
            App app = appDao.findByName(appName);
            if (app == null){
                return Response.ok(Page.empty());
            }
            return Response.ok(new Page<>(1L, Lists.newArrayList(app)));
        }

        // find apps
        Long totalCount = appDao.count();
        if (totalCount <= 0L){
            return Response.ok(Page.empty());
        }

        Paging paging = new Paging(pageNo, pageSize);
        List<App> apps = appDao.list(paging.getOffset(), paging.getLimit());

        return Response.ok(new Page<>(totalCount, apps));
    } catch (Exception e){
        Logs.error("failed to paging app(pageNo={}, pageSize={}), cause: {}",
                pageNo, pageSize, Throwables.getStackTraceAsString(e));
        return Response.notOk(messages.get("app.find.failed"));
    }
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:30,代码来源:AppServiceImpl.java

示例10: buildRefundParams

import me.hao0.common.util.Strings; //导入依赖的package包/类
private Map<String, String> buildRefundParams(RefundDetail refundDetail) {

        Map<String, String> refundParams = new HashMap<>();

        // 配置参数
        refundParams.putAll(alipay.refundConfig);

        // 接口名
        refundParams.put(AlipayField.SERVICE.field(), Service.REFUND_NO_PWD.value());

        if (!Strings.isNullOrEmpty(alipay.email)){
            refundParams.put(AlipayField.SELLER_EMAIL.field(), alipay.email);
        }

        // 通知URL
        if (!Strings.isNullOrEmpty(refundDetail.getNotifyUrl())){
            refundParams.put(AlipayField.NOTIFY_URL.field(), refundDetail.getNotifyUrl());
        }

        // 卖家ID
        refundParams.put(AlipayField.SELLER_USER_ID.field(), alipay.merchantId);

        // 退款日期
        refundParams.put(AlipayField.REFUND_DATE.field(), Dates.now("yyyy-MM-dd HH:mm:ss"));

        // 退款批次号
        checkNotNullAndEmpty(refundDetail.getBatchNo(), "batchNo");
        refundParams.put(AlipayField.BATCH_NO.field(), refundDetail.getBatchNo());

        // 退款明细
        List<RefundDetailData> detailDatas = refundDetail.getDetailDatas();
        checkNotNullAndEmpty(detailDatas, "detail datas");
        refundParams.put(AlipayField.BATCH_NUM.field(), Integer.toString(detailDatas.size()));
        refundParams.put(AlipayField.DETAIL_DATA.field(), refundDetail.formatDetailDatas());

        // md5签名参数
        buildMd5SignParams(refundParams);

        return refundParams;
    }
 
开发者ID:dzzgml,项目名称:alipay,代码行数:41,代码来源:Refunds.java

示例11: deserialize

import me.hao0.common.util.Strings; //导入依赖的package包/类
@Override
public RefundChannel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    String val = jp.getValueAsString();
    if (Strings.isNullOrEmpty(val)){
        return null;
    }
    return RefundChannel.from(val);
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:9,代码来源:RefundChannelDeserializer.java

示例12: toMap

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * 转换微信XML为Map(仅支持2级)
 * @param xml xml内容
 * @return Map对象
 */
public static Map<String, Object> toMap(String xml){
    xml = xml.replaceAll("(\\r|\\n)", "");
    if (Strings.isNullOrEmpty(xml)){
        return Collections.emptyMap();
    }
    XmlReaders readers = XmlReaders.create(xml);
    return toMap(readers);
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:14,代码来源:Maps.java

示例13: toXml

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * Map转换为XML
 * @param params Map参数
 * @return XML字符串
 */
public static String toXml(final Map<String, String> params) {
    XmlWriters writers = XmlWriters.create();
    for (Map.Entry<String, String> param : params.entrySet()){
        if (!Strings.isNullOrEmpty(param.getValue())){
            writers.element(param.getKey(), param.getValue());
        }
    }
    return writers.build();
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:15,代码来源:Maps.java

示例14: renderRefundItem

import me.hao0.common.util.Strings; //导入依赖的package包/类
private RefundItem renderRefundItem(Map<String, Object> refundData, int refundItemIndex) {
    RefundItem refundItem = new RefundItem();
    refundItem.setOutRefundNo((String)refundData.get(WepayField.OUT_REFUND_NO + "_" + refundItemIndex));
    refundItem.setRefundId((String)refundData.get(WepayField.REFUND_ID + "_" + refundItemIndex));
    refundItem.setChannel(RefundChannel.from((String) refundData.get(WepayField.REFUND_CHANNEL + "_" + refundItemIndex)));
    refundItem.setRefundFee(Integer.parseInt((String)refundData.get(WepayField.REFUND_FEE + "_" + refundItemIndex)));
    refundItem.setRefundStatus(RefundStatus.from((String)refundData.get(WepayField.REFUND_STATUS + "_" + refundItemIndex)));

    String settlementRefundFee = (String)refundData.get(WepayField.SETTLEMENT_REFUND_FEE + "_" + refundItemIndex);
    if (!Strings.isNullOrEmpty(settlementRefundFee)){
        refundItem.setSettlementRefundFee(Integer.parseInt(settlementRefundFee));
    }

    refundItem.setRefundRecvAccout((String)refundData.get(WepayField.REFUND_RECV_ACCOUNT + "_" + refundItemIndex));

    Object couponRefundFee = refundData.get(WepayField.COUPON_REFUND_FEE + "_" + refundItemIndex);
    if (couponRefundFee != null){
        refundItem.setCouponRefundFee(Integer.parseInt((String)couponRefundFee));
    }
    Object couponRefundCountObj = refundData.get(WepayField.COUPON_REFUND_COUNT + "_" + refundItemIndex);
    if (couponRefundCountObj != null){
        Integer couponRefundCount = Integer.parseInt((String)couponRefundCountObj);
        if (couponRefundCount > 0){
            List<Coupon> couponItems = new ArrayList<>();
            Coupon couponItem;
            for (int couponItemIndex = 0; couponItemIndex < couponRefundCount; couponItemIndex++){
                couponItem = Coupon.newCoupon(
                        (String) refundData.get(WepayField.COUPON_REFUND_BATCH_ID + "_" + refundItemIndex + "_" + couponItemIndex),
                        (String) refundData.get(WepayField.COUPON_REFUND_ID + "_" + refundItemIndex + "_" + couponItemIndex),
                        Integer.parseInt((String) refundData.get(WepayField.COUPON_REFUND_FEE + "_" + refundItemIndex + "_" + couponItemIndex))
                );
                couponItems.add(couponItem);
            }
            refundItem.setCoupons(couponItems);
        }
    }

    return refundItem;
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:40,代码来源:Refunds.java

示例15: init

import me.hao0.common.util.Strings; //导入依赖的package包/类
/**
 * 初始化操作
 * @return this
 */
public Wepay init(){
    pays = new Pays(this);
    orders = new Orders(this);
    refunds = new Refunds(this);
    notifies = new Notifies(this);
    bills = new Bills(this);
    if (certs != null && !Strings.isNullOrEmpty(certPasswd)){
        sslSocketFactory = initSSLSocketFactory();
    }
    return this;
}
 
开发者ID:ihaolin,项目名称:wepay,代码行数:16,代码来源:Wepay.java


注:本文中的me.hao0.common.util.Strings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。