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


Java Convert.emptyToNull方法代码示例

本文整理汇总了Java中nxt.util.Convert.emptyToNull方法的典型用法代码示例。如果您正苦于以下问题:Java Convert.emptyToNull方法的具体用法?Java Convert.emptyToNull怎么用?Java Convert.emptyToNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nxt.util.Convert的用法示例。


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

示例1: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {

    String transactionBytes = Convert.emptyToNull(req.getParameter("transactionBytes"));
    String transactionJSON = Convert.emptyToNull(req.getParameter("transactionJSON"));
    Transaction transaction = ParameterParser.parseTransaction(transactionBytes, transactionJSON);
    JSONObject response = JSONData.unconfirmedTransaction(transaction);
    try {
        transaction.validate();
    } catch (NxtException.ValidationException|RuntimeException e) {
        Logger.logDebugMessage(e.getMessage(), e);
        response.put("validate", false);
        response.put("errorCode", 4);
        response.put("errorDescription", "Invalid transaction: " + e.toString());
        response.put("error", e.getMessage());
    }
    response.put("verify", transaction.verifySignature() && transaction.verifyPublicKey());
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:ParseTransaction.java

示例2: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {

    String unsignedBytesString = Convert.emptyToNull(req.getParameter("unsignedTransactionBytes"));
    String signatureHashString = Convert.emptyToNull(req.getParameter("signatureHash"));

    if (unsignedBytesString == null) {
        return MISSING_UNSIGNED_BYTES;
    } else if (signatureHashString == null) {
        return MISSING_SIGNATURE_HASH;
    }

    MessageDigest digest = Crypto.sha256();
    digest.update(Convert.parseHexString(unsignedBytesString));
    byte[] fullHash = digest.digest(Convert.parseHexString(signatureHashString));
    JSONObject response = new JSONObject();
    response.put("fullHash", Convert.toHexString(fullHash));

    return response;

}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:CalculateFullHash.java

示例3: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {

    long accountId;
    String secretPhrase = Convert.emptyToNull(req.getParameter("secretPhrase"));
    String publicKeyString = Convert.emptyToNull(req.getParameter("publicKey"));
    if (secretPhrase != null) {
        byte[] publicKey = Crypto.getPublicKey(secretPhrase);
        accountId = Account.getId(publicKey);
        publicKeyString = Convert.toHexString(publicKey);
    } else if (publicKeyString != null) {
        accountId = Account.getId(Convert.parseHexString(publicKeyString));
    } else {
        return MISSING_SECRET_PHRASE_OR_PUBLIC_KEY;
    }

    JSONObject response = new JSONObject();
    JSONData.putAccount(response, "account", accountId);
    response.put("publicKey", publicKeyString);

    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:23,代码来源:GetAccountId.java

示例4: getAlias

import nxt.util.Convert; //导入方法依赖的package包/类
static Alias getAlias(HttpServletRequest req) throws ParameterException {
    long aliasId;
    try {
        aliasId = Convert.parseUnsignedLong(Convert.emptyToNull(req.getParameter("alias")));
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_ALIAS);
    }
    String aliasName = Convert.emptyToNull(req.getParameter("aliasName"));
    Alias alias;
    if (aliasId != 0) {
        alias = Alias.getAlias(aliasId);
    } else if (aliasName != null) {
        alias = Alias.getAlias(aliasName);
    } else {
        throw new ParameterException(MISSING_ALIAS_OR_ALIAS_NAME);
    }
    if (alias == null) {
        throw new ParameterException(UNKNOWN_ALIAS);
    }
    return alias;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:ParameterParser.java

示例5: getAmountNQT

import nxt.util.Convert; //导入方法依赖的package包/类
static long getAmountNQT(HttpServletRequest req) throws ParameterException {
    String amountValueNQT = Convert.emptyToNull(req.getParameter("amountNQT"));
    if (amountValueNQT == null) {
        throw new ParameterException(MISSING_AMOUNT);
    }
    long amountNQT;
    try {
        amountNQT = Long.parseLong(amountValueNQT);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_AMOUNT);
    }
    if (amountNQT <= 0 || amountNQT >= Constants.MAX_BALANCE_NQT) {
        throw new ParameterException(INCORRECT_AMOUNT);
    }
    return amountNQT;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java

示例6: getFeeNQT

import nxt.util.Convert; //导入方法依赖的package包/类
static long getFeeNQT(HttpServletRequest req) throws ParameterException {
    String feeValueNQT = Convert.emptyToNull(req.getParameter("feeNQT"));
    if (feeValueNQT == null) {
        throw new ParameterException(MISSING_FEE);
    }
    long feeNQT;
    try {
        feeNQT = Long.parseLong(feeValueNQT);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_FEE);
    }
    if (feeNQT < 0 || feeNQT >= Constants.MAX_BALANCE_NQT) {
        throw new ParameterException(INCORRECT_FEE);
    }
    return feeNQT;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java

示例7: getPriceNQT

import nxt.util.Convert; //导入方法依赖的package包/类
static long getPriceNQT(HttpServletRequest req) throws ParameterException {
    String priceValueNQT = Convert.emptyToNull(req.getParameter("priceNQT"));
    if (priceValueNQT == null) {
        throw new ParameterException(MISSING_PRICE);
    }
    long priceNQT;
    try {
        priceNQT = Long.parseLong(priceValueNQT);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_PRICE);
    }
    if (priceNQT <= 0 || priceNQT > Constants.MAX_BALANCE_NQT) {
        throw new ParameterException(INCORRECT_PRICE);
    }
    return priceNQT;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java

示例8: getRecipientId

import nxt.util.Convert; //导入方法依赖的package包/类
static long getRecipientId(HttpServletRequest req) throws ParameterException {
    String recipientValue = Convert.emptyToNull(req.getParameter("recipient"));
    if (recipientValue == null || "0".equals(recipientValue)) {
        throw new ParameterException(MISSING_RECIPIENT);
    }
    long recipientId;
    try {
        recipientId = Convert.parseAccountId(recipientValue);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_RECIPIENT);
    }
    if (recipientId == 0) {
        throw new ParameterException(INCORRECT_RECIPIENT);
    }
    return recipientId;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java

示例9: getQuantityQNT

import nxt.util.Convert; //导入方法依赖的package包/类
static long getQuantityQNT(HttpServletRequest req) throws ParameterException {
    String quantityValueQNT = Convert.emptyToNull(req.getParameter("quantityQNT"));
    if (quantityValueQNT == null) {
        throw new ParameterException(MISSING_QUANTITY);
    }
    long quantityQNT;
    try {
        quantityQNT = Long.parseLong(quantityValueQNT);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_QUANTITY);
    }
    if (quantityQNT <= 0 || quantityQNT > Constants.MAX_ASSET_QUANTITY_QNT) {
        throw new ParameterException(INCORRECT_ASSET_QUANTITY);
    }
    return quantityQNT;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java

示例10: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {

    String transactionBytes = Convert.emptyToNull(req.getParameter("transactionBytes"));
    String transactionJSON = Convert.emptyToNull(req.getParameter("transactionJSON"));
    Transaction transaction = ParameterParser.parseTransaction(transactionBytes, transactionJSON);
    JSONObject response = new JSONObject();
    try {
        transaction.validate();
        Nxt.getTransactionProcessor().broadcast(transaction);
        response.put("transaction", transaction.getStringId());
        response.put("fullHash", transaction.getFullHash());
    } catch (NxtException.ValidationException|RuntimeException e) {
        Logger.logDebugMessage(e.getMessage(), e);
        response.put("errorCode", 4);
        response.put("errorDescription", "Incorrect transaction: " + e.toString());
        response.put("error", e.getMessage());
    }
    return response;

}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:BroadcastTransaction.java

示例11: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {

    String accountIdString = Convert.emptyToNull(req.getParameter("account"));
    long accountId = 0;

    if (accountIdString != null) {
        try {
            accountId = Convert.parseAccountId(accountIdString);
        } catch (RuntimeException e) {
            return INCORRECT_ACCOUNT;
        }
    }

    JSONArray transactions = new JSONArray();
    try (DbIterator<? extends Transaction> transactionsIterator = Nxt.getTransactionProcessor().getAllUnconfirmedTransactions()) {
        while (transactionsIterator.hasNext()) {
            Transaction transaction = transactionsIterator.next();
            if (accountId != 0 && !(accountId == transaction.getSenderId() || accountId == transaction.getRecipientId())) {
                continue;
            }
            transactions.add(JSONData.unconfirmedTransaction(transaction));
        }
    }

    JSONObject response = new JSONObject();
    response.put("unconfirmedTransactions", transactions);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:30,代码来源:GetUnconfirmedTransactions.java

示例12: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    String aliasName = Convert.emptyToNull(req.getParameter("aliasName"));
    String aliasURI = Convert.nullToEmpty(req.getParameter("aliasURI"));

    if (aliasName == null) {
        return MISSING_ALIAS_NAME;
    }

    aliasName = aliasName.trim();
    if (aliasName.length() == 0 || aliasName.length() > Constants.MAX_ALIAS_LENGTH) {
        return INCORRECT_ALIAS_LENGTH;
    }

    String normalizedAlias = aliasName.toLowerCase();
    for (int i = 0; i < normalizedAlias.length(); i++) {
        if (Constants.ALPHABET.indexOf(normalizedAlias.charAt(i)) < 0) {
            return INCORRECT_ALIAS_NAME;
        }
    }

    aliasURI = aliasURI.trim();
    if (aliasURI.length() > Constants.MAX_ALIAS_URI_LENGTH) {
        return INCORRECT_URI_LENGTH;
    }

    Account account = ParameterParser.getSenderAccount(req);

    Alias alias = Alias.getAlias(normalizedAlias);
    if (alias != null && alias.getAccountId() != account.getId()) {
        JSONObject response = new JSONObject();
        response.put("errorCode", 8);
        response.put("errorDescription", "\"" + aliasName + "\" is already used");
        return response;
    }

    Attachment attachment = new Attachment.MessagingAliasAssignment(aliasName, aliasURI);
    return createTransaction(req, account, attachment);

}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:41,代码来源:SetAlias.java

示例13: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {

    DigitalGoodsStore.Goods goods = ParameterParser.getGoods(req);
    if (goods.isDelisted()) {
        return UNKNOWN_GOODS;
    }

    int quantity = ParameterParser.getGoodsQuantity(req);
    if (quantity > goods.getQuantity()) {
        return INCORRECT_PURCHASE_QUANTITY;
    }

    long priceNQT = ParameterParser.getPriceNQT(req);
    if (priceNQT != goods.getPriceNQT()) {
        return INCORRECT_PURCHASE_PRICE;
    }

    String deliveryDeadlineString = Convert.emptyToNull(req.getParameter("deliveryDeadlineTimestamp"));
    if (deliveryDeadlineString == null) {
        return MISSING_DELIVERY_DEADLINE_TIMESTAMP;
    }
    int deliveryDeadline;
    try {
        deliveryDeadline = Integer.parseInt(deliveryDeadlineString);
        if (deliveryDeadline <= Nxt.getEpochTime()) {
            return INCORRECT_DELIVERY_DEADLINE_TIMESTAMP;
        }
    } catch (NumberFormatException e) {
        return INCORRECT_DELIVERY_DEADLINE_TIMESTAMP;
    }

    Account buyerAccount = ParameterParser.getSenderAccount(req);
    Account sellerAccount = Account.getAccount(goods.getSellerId());

    Attachment attachment = new Attachment.DigitalGoodsPurchase(goods.getId(), quantity, priceNQT,
            deliveryDeadline);
    return createTransaction(req, buyerAccount, sellerAccount.getId(), 0, attachment);

}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:41,代码来源:DGSPurchase.java

示例14: processRequest

import nxt.util.Convert; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {

    String accountIdString = Convert.emptyToNull(req.getParameter("account"));
    long accountId = 0;

    if (accountIdString != null) {
        try {
            accountId = Convert.parseAccountId(accountIdString);
        } catch (RuntimeException e) {
            return INCORRECT_ACCOUNT;
        }
    }

    JSONArray transactionIds = new JSONArray();
    try (DbIterator<? extends Transaction> transactionsIterator = Nxt.getTransactionProcessor().getAllUnconfirmedTransactions()) {
        while (transactionsIterator.hasNext()) {
            Transaction transaction = transactionsIterator.next();
            if (accountId != 0 && !(accountId == transaction.getSenderId() || accountId == transaction.getRecipientId())) {
                continue;
            }
            transactionIds.add(transaction.getStringId());
        }
    }

    JSONObject response = new JSONObject();
    response.put("unconfirmedTransactionIds", transactionIds);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:30,代码来源:GetUnconfirmedTransactionIds.java

示例15: getSellerId

import nxt.util.Convert; //导入方法依赖的package包/类
static long getSellerId(HttpServletRequest req) throws ParameterException {
    String sellerIdValue = Convert.emptyToNull(req.getParameter("seller"));
    try {
        return Convert.parseAccountId(sellerIdValue);
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_RECIPIENT);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:9,代码来源:ParameterParser.java


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