• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Convert类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: processRequest

import nxt.util.Convert; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(JSONObject request, Peer peer) {

    JSONObject response = new JSONObject();

    JSONArray nextBlockIds = new JSONArray();
    long blockId = Convert.parseUnsignedLong((String) request.get("blockId"));
    List<Long> ids = Nxt.getBlockchain().getBlockIdsAfter(blockId, 1440);

    for (Long id : ids) {
        nextBlockIds.add(Convert.toUnsignedLong(id));
    }

    response.put("nextBlockIds", nextBlockIds);

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


示例2: applyUnconfirmed

import nxt.util.Convert; //导入依赖的package包/类
final boolean applyUnconfirmed(Transaction transaction, Account senderAccount) {
    long totalAmountNQT = Convert.safeAdd(transaction.getAmountNQT(), transaction.getFeeNQT());
    if (transaction.getReferencedTransactionFullHash() != null
            && transaction.getTimestamp() > Constants.REFERENCED_TRANSACTION_FULL_HASH_BLOCK_TIMESTAMP) {
        totalAmountNQT = Convert.safeAdd(totalAmountNQT, Constants.UNCONFIRMED_POOL_DEPOSIT_NQT);
    }
    if (senderAccount.getUnconfirmedBalanceNQT() < totalAmountNQT) {
        return false;
    }
    senderAccount.addToUnconfirmedBalanceNQT(-totalAmountNQT);
    if (!applyAttachmentUnconfirmed(transaction, senderAccount)) {
        senderAccount.addToUnconfirmedBalanceNQT(totalAmountNQT);
        return false;
    }
    return true;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:TransactionType.java


示例3: buildLinks

import nxt.util.Convert; //导入依赖的package包/类
private static String buildLinks(HttpServletRequest req) {
    StringBuilder buf = new StringBuilder();
    String requestTag = Convert.nullToEmpty(req.getParameter("requestTag"));
    buf.append("<li");
    if (requestTag.equals("")) {
        buf.append(" class=\"active\"");
    }
    buf.append("><a href=\"/test\">All</a></li>");
    for (APITag apiTag : APITag.values()) {
        if (requestTags.get(apiTag.name()) != null) {
        	buf.append("<li");
         if (requestTag.equals(apiTag.name())) {
	            buf.append(" class=\"active\"");
    	    }
        	buf.append("><a href=\"/test?requestTag=").append(apiTag.name()).append("\">");
        	buf.append(apiTag.getDisplayName()).append("</a></li>").append(" ");
        }
    }
    return buf.toString();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:APITestServlet.java


示例4: validateAttachment

import nxt.util.Convert; //导入依赖的package包/类
@Override
void validateAttachment(Transaction transaction) throws NxtException.ValidationException {
    Attachment.MessagingAliasAssignment attachment = (Attachment.MessagingAliasAssignment) transaction.getAttachment();
    if (attachment.getAliasName().length() == 0
            || Convert.toBytes(attachment.getAliasName()).length > Constants.MAX_ALIAS_LENGTH
            || attachment.getAliasURI().length() > Constants.MAX_ALIAS_URI_LENGTH) {
        throw new NxtException.NotValidException("Invalid alias assignment: " + attachment.getJSONObject());
    }
    String normalizedAlias = attachment.getAliasName().toLowerCase();
    for (int i = 0; i < normalizedAlias.length(); i++) {
        if (Constants.ALPHABET.indexOf(normalizedAlias.charAt(i)) < 0) {
            throw new NxtException.NotValidException("Invalid alias name: " + normalizedAlias);
        }
    }
    Alias alias = Alias.getAlias(normalizedAlias);
    if (alias != null && alias.getAccountId() != transaction.getSenderId()) {
        throw new NxtException.NotCurrentlyValidException("Alias already owned by another account: " + normalizedAlias);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:TransactionType.java


示例5: processRequest

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

    String poll = req.getParameter("poll");
    if (poll == null) {
        return MISSING_POLL;
    }

    Poll pollData;
    try {
        pollData = Poll.getPoll(Convert.parseUnsignedLong(poll));
        if (pollData == null) {
            return UNKNOWN_POLL;
        }
    } catch (RuntimeException e) {
        return INCORRECT_POLL;
    }

    return JSONData.poll(pollData);

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


示例6: doValidateAttachment

import nxt.util.Convert; //导入依赖的package包/类
@Override
void doValidateAttachment(Transaction transaction) throws NxtException.ValidationException {
    Attachment.DigitalGoodsDelivery attachment = (Attachment.DigitalGoodsDelivery) transaction.getAttachment();
    DigitalGoodsStore.Purchase purchase = DigitalGoodsStore.getPendingPurchase(attachment.getPurchaseId());
    if (attachment.getGoods().getData().length > Constants.MAX_DGS_GOODS_LENGTH
            || attachment.getGoods().getData().length == 0
            || attachment.getGoods().getNonce().length != 32
            || attachment.getDiscountNQT() < 0 || attachment.getDiscountNQT() > Constants.MAX_BALANCE_NQT
            || (purchase != null &&
            (purchase.getBuyerId() != transaction.getRecipientId()
                    || transaction.getSenderId() != purchase.getSellerId()
                    || attachment.getDiscountNQT() > Convert.safeMultiply(purchase.getPriceNQT(), purchase.getQuantity())))) {
        throw new NxtException.NotValidException("Invalid digital goods delivery: " + attachment.getJSONObject());
    }
    if (purchase == null || purchase.getEncryptedGoods() != null) {
        throw new NxtException.NotCurrentlyValidException("Purchase does not exist yet, or already delivered: "
                + attachment.getJSONObject());
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:TransactionType.java


示例7: applyAttachment

import nxt.util.Convert; //导入依赖的package包/类
@Override
final void applyAttachment(Transaction transaction, Account senderAccount, Account recipientAccount) {
	Attachment.AdvancedPaymentEscrowCreation attachment = (Attachment.AdvancedPaymentEscrowCreation) transaction.getAttachment();
	Long totalAmountNQT = Convert.safeAdd(attachment.getAmountNQT(), attachment.getTotalSigners() * Constants.ONE_NXT);
	senderAccount.addToBalanceNQT(-totalAmountNQT);
	Collection<Long> signers = attachment.getSigners();
	for(Long signer : signers) {
		Account.addOrGetAccount(signer).addToBalanceAndUnconfirmedBalanceNQT(Constants.ONE_NXT);
	}
	Escrow.addEscrowTransaction(senderAccount,
								recipientAccount,
								transaction.getId(),
								attachment.getAmountNQT(),
								attachment.getRequiredSigners(),
								attachment.getSigners(),
								transaction.getTimestamp() + attachment.getDeadline(),
								attachment.getDeadlineAction());
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:19,代码来源:TransactionType.java


示例8: notify

import nxt.util.Convert; //导入依赖的package包/类
@Override
public void notify(Peer peer) {
    JSONObject response = new JSONObject();
    JSONArray removedActivePeers = new JSONArray();
    JSONObject removedActivePeer = new JSONObject();
    removedActivePeer.put("index", Users.getIndex(peer));
    removedActivePeers.add(removedActivePeer);
    response.put("removedActivePeers", removedActivePeers);
    JSONArray removedKnownPeers = new JSONArray();
    JSONObject removedKnownPeer = new JSONObject();
    removedKnownPeer.put("index", Users.getIndex(peer));
    removedKnownPeers.add(removedKnownPeer);
    response.put("removedKnownPeers", removedKnownPeers);
    JSONArray addedBlacklistedPeers = new JSONArray();
    JSONObject addedBlacklistedPeer = new JSONObject();
    addedBlacklistedPeer.put("index", Users.getIndex(peer));
    addedBlacklistedPeer.put("address", peer.getPeerAddress());
    addedBlacklistedPeer.put("announcedAddress", Convert.truncate(peer.getAnnouncedAddress(), "-", 25, true));
    if (peer.isWellKnown()) {
        addedBlacklistedPeer.put("wellKnown", true);
    }
    addedBlacklistedPeer.put("software", peer.getSoftware());
    addedBlacklistedPeers.add(addedBlacklistedPeer);
    response.put("addedBlacklistedPeers", addedBlacklistedPeers);
    Users.sendNewDataToAll(response);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:27,代码来源:Users.java


示例9: processRequest

import nxt.util.Convert; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(JSONObject request, Peer peer) {
	
	JSONObject response = new JSONObject();
	
	try {
		Long accountId = Convert.parseAccountId((String)request.get("account"));
		Account account = Account.getAccount(accountId);
		JSONArray transactions = new JSONArray();
		if(account != null) {
			DbIterator<? extends Transaction> iterator = Nxt.getBlockchain().getTransactions(account, 0, (byte)-1, (byte)0, 0, 0, 9);
			while(iterator.hasNext()) {
				Transaction transaction = iterator.next();
				transactions.add(nxt.http.JSONData.transaction(transaction));
			}
		}
		response.put("transactions", transactions);
	}
	catch(Exception e) {
	}
	
	return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:24,代码来源:GetAccountRecentTransactions.java


示例10: getAT

import nxt.util.Convert; //导入依赖的package包/类
static AT getAT(HttpServletRequest req) throws ParameterException {
    String atValue = Convert.emptyToNull(req.getParameter("at"));
    if (atValue == null) {
        throw new ParameterException(MISSING_AT);
    }
    AT at;
    try {
        Long atId = Convert.parseUnsignedLong(atValue);
        at = AT.getAT( atId );
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_AT);
    }
    if (at == null) {
        throw new ParameterException(UNKNOWN_AT);
    }
    return at;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:ParameterParser.java


示例11: processRequest

import nxt.util.Convert; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
    String accountValue = Convert.emptyToNull(req.getParameter("account"));
    if (accountValue == null) {
        return MISSING_ACCOUNT;
    }
    try {
        long accountId = Convert.parseAccountId(accountValue);
        if (accountId == 0) {
            return INCORRECT_ACCOUNT;
        }
        JSONObject response = new JSONObject();
        JSONData.putAccount(response, "account", accountId);
        return response;
    } catch (RuntimeException e) {
        return INCORRECT_ACCOUNT;
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:19,代码来源:RSConvert.java


示例12: processRequest

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

    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);

    JSONArray pollIds = new JSONArray();
    try (DbIterator<Poll> polls = Poll.getAllPolls(firstIndex, lastIndex)) {
        while (polls.hasNext()) {
            pollIds.add(Convert.toUnsignedLong(polls.next().getId()));
        }
    }
    JSONObject response = new JSONObject();
    response.put("pollIds", pollIds);
    return response;

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


示例13: processRequest

import nxt.util.Convert; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
	JSONObject response = new JSONObject();
	
	response.put("height", Long.toString(Nxt.getBlockchain().getHeight() + 1));
	
	Block lastBlock = Nxt.getBlockchain().getLastBlock();
	byte[] lastGenSig = lastBlock.getGenerationSignature();
	Long lastGenerator = lastBlock.getGeneratorId();
	
	ByteBuffer buf = ByteBuffer.allocate(32 + 8);
	buf.put(lastGenSig);
	buf.putLong(lastGenerator);
	
	Shabal256 md = new Shabal256();
	md.update(buf.array());
	byte[] newGenSig = md.digest();
	
	response.put("generationSignature", Convert.toHexString(newGenSig));
	response.put("baseTarget", Long.toString(lastBlock.getBaseTarget()));
	
	return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:24,代码来源:GetMiningInfo.java


示例14: processRequest

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

    Asset asset = ParameterParser.getAsset(req);
    long priceNQT = ParameterParser.getPriceNQT(req);
    long quantityQNT = ParameterParser.getQuantityQNT(req);
    long feeNQT = ParameterParser.getFeeNQT(req);
    Account account = ParameterParser.getSenderAccount(req);

    try {
        if (Convert.safeAdd(feeNQT, Convert.safeMultiply(priceNQT, quantityQNT)) > account.getUnconfirmedBalanceNQT()) {
            return NOT_ENOUGH_FUNDS;
        }
    } catch (ArithmeticException e) {
        return NOT_ENOUGH_FUNDS;
    }

    Attachment attachment = new Attachment.ColoredCoinsBidOrderPlacement(asset.getId(), quantityQNT, priceNQT);
    return createTransaction(req, account, attachment);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:PlaceBidOrder.java


示例15: processRequest

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

    long assetId = ParameterParser.getAsset(req).getId();
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);

    JSONArray orderIds = new JSONArray();
    try (DbIterator<Order.Bid> bidOrders = Order.Bid.getSortedOrders(assetId, firstIndex, lastIndex)) {
        while (bidOrders.hasNext()) {
            orderIds.add(Convert.toUnsignedLong(bidOrders.next().getId()));
        }
    }
    JSONObject response = new JSONObject();
    response.put("bidOrderIds", orderIds);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:GetBidOrderIds.java


示例16: processRequest

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

    String[] assets = req.getParameterValues("assets");

    JSONObject response = new JSONObject();
    JSONArray assetsJSONArray = new JSONArray();
    response.put("assets", assetsJSONArray);
    for (String assetIdString : assets) {
        if (assetIdString == null || assetIdString.equals("")) {
            continue;
        }
        try {
            Asset asset = Asset.getAsset(Convert.parseUnsignedLong(assetIdString));
            if (asset == null) {
                return UNKNOWN_ASSET;
            }
            assetsJSONArray.add(JSONData.asset(asset));
        } catch (RuntimeException e) {
            return INCORRECT_ASSET;
        }
    }
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:GetAssets.java


示例17: 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


示例18: getGoods

import nxt.util.Convert; //导入依赖的package包/类
static DigitalGoodsStore.Goods getGoods(HttpServletRequest req) throws ParameterException {
    String goodsValue = Convert.emptyToNull(req.getParameter("goods"));
    if (goodsValue == null) {
        throw new ParameterException(MISSING_GOODS);
    }
    DigitalGoodsStore.Goods goods;
    try {
        long goodsId = Convert.parseUnsignedLong(goodsValue);
        goods = DigitalGoodsStore.getGoods(goodsId);
        if (goods == null) {
            throw new ParameterException(UNKNOWN_GOODS);
        }
        return goods;
    } catch (RuntimeException e) {
        throw new ParameterException(INCORRECT_GOODS);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:ParameterParser.java


示例19: AdvancedPaymentEscrowCreation

import nxt.util.Convert; //导入依赖的package包/类
AdvancedPaymentEscrowCreation(JSONObject attachmentData) throws NxtException.NotValidException {
	super(attachmentData);
	this.amountNQT = Convert.parseUnsignedLong((String)attachmentData.get("amountNQT"));
	this.deadline = ((Long)attachmentData.get("deadline")).intValue();
	this.deadlineAction = Escrow.stringToDecision((String)attachmentData.get("deadlineAction"));
	this.requiredSigners = ((Long)attachmentData.get("requiredSigners")).byteValue();
	int totalSigners = ((JSONArray)attachmentData.get("signers")).size();
	if(totalSigners > 10 || totalSigners <= 0) {
		throw new NxtException.NotValidException("Invalid number of signers listed on create escrow transaction");
	}
	//this.signers.addAll((JSONArray)attachmentData.get("signers"));
	JSONArray signersJson = (JSONArray)attachmentData.get("signers");
	for(int i = 0; i < signersJson.size(); i++) {
		this.signers.add(Convert.parseUnsignedLong((String)signersJson.get(i)));
	}
	if(this.signers.size() != ((JSONArray)attachmentData.get("signers")).size()) {
		throw new NxtException.NotValidException("Duplicate signer on escrow creation");
	}
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:Attachment.java


示例20: getTimestamp

import nxt.util.Convert; //导入依赖的package包/类
static int getTimestamp(HttpServletRequest req) throws ParameterException {
    String timestampValue = Convert.emptyToNull(req.getParameter("timestamp"));
    if (timestampValue == null) {
        return 0;
    }
    int timestamp;
    try {
        timestamp = Integer.parseInt(timestampValue);
    } catch (NumberFormatException e) {
        throw new ParameterException(INCORRECT_TIMESTAMP);
    }
    if (timestamp < 0) {
        throw new ParameterException(INCORRECT_TIMESTAMP);
    }
    return timestamp;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:ParameterParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RxLifecycleAndroid类代码示例发布时间:2022-05-22
下一篇:
Java TimeDefinition类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap