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


Java Convert.parseUnsignedLong方法代码示例

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


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

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

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

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

示例4: DigitalGoodsPurchase

import nxt.util.Convert; //导入方法依赖的package包/类
DigitalGoodsPurchase(JSONObject attachmentData) {
    super(attachmentData);
    this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
    this.quantity = ((Long)attachmentData.get("quantity")).intValue();
    this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
    this.deliveryDeadlineTimestamp = ((Long)attachmentData.get("deliveryDeadlineTimestamp")).intValue();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:8,代码来源:Attachment.java

示例5: parseBlock

import nxt.util.Convert; //导入方法依赖的package包/类
static BlockImpl parseBlock(JSONObject blockData) throws NxtException.ValidationException {
	try {
		int version = ((Long)blockData.get("version")).intValue();
        int timestamp = ((Long)blockData.get("timestamp")).intValue();
        Long previousBlock = Convert.parseUnsignedLong((String) blockData.get("previousBlock"));
        long totalAmountNQT = Convert.parseLong(blockData.get("totalAmountNQT"));
        long totalFeeNQT = Convert.parseLong(blockData.get("totalFeeNQT"));
        int payloadLength = ((Long)blockData.get("payloadLength")).intValue();
        byte[] payloadHash = Convert.parseHexString((String) blockData.get("payloadHash"));
        byte[] generatorPublicKey = Convert.parseHexString((String) blockData.get("generatorPublicKey"));
        byte[] generationSignature = Convert.parseHexString((String) blockData.get("generationSignature"));
        byte[] blockSignature = Convert.parseHexString((String) blockData.get("blockSignature"));
        byte[] previousBlockHash = version == 1 ? null : Convert.parseHexString((String) blockData.get("previousBlockHash"));
        Long nonce = Convert.parseUnsignedLong((String)blockData.get("nonce"));
        
        SortedMap<Long, TransactionImpl> blockTransactions = new TreeMap<>();
        JSONArray transactionsData = (JSONArray)blockData.get("transactions");
        for (Object transactionData : transactionsData) {
            TransactionImpl transaction = TransactionImpl.parseTransaction((JSONObject) transactionData);
            if (blockTransactions.put(transaction.getId(), transaction) != null) {
                throw new NxtException.NotValidException("Block contains duplicate transactions: " + transaction.getStringId());
            }
        }
        byte[] blockATs = Convert.parseHexString( (String) blockData.get("blockATs") );
        return new BlockImpl(version, timestamp, previousBlock, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash, generatorPublicKey,
                generationSignature, blockSignature, previousBlockHash, new ArrayList<>(blockTransactions.values()), nonce , blockATs);
	} catch (NxtException.ValidationException|RuntimeException e) {
		Logger.logDebugMessage("Failed to parse block: " + blockData.toJSONString());
		throw e;
	}
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:32,代码来源:BlockImpl.java

示例6: processRequest

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

    long accountId = ParameterParser.getAccount(req).getId();
    long assetId = 0;
    try {
        assetId = Convert.parseUnsignedLong(req.getParameter("asset"));
    } catch (RuntimeException e) {
        // ignore
    }
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);

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

示例7: processRequest

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

    String transactionValue = req.getParameter("transaction");
    if (transactionValue == null) {
        return MISSING_TRANSACTION;
    }

    long transactionId;
    Transaction transaction;
    try {
        transactionId = Convert.parseUnsignedLong(transactionValue);
    } catch (RuntimeException e) {
        return INCORRECT_TRANSACTION;
    }

    transaction = Nxt.getBlockchain().getTransaction(transactionId);
    JSONObject response = new JSONObject();
    if (transaction == null) {
        transaction = Nxt.getTransactionProcessor().getUnconfirmedTransaction(transactionId);
        if (transaction == null) {
            return UNKNOWN_TRANSACTION;
        }
    } else {
        response.put("confirmations", Nxt.getBlockchain().getHeight() - transaction.getHeight());
    }
    response.put("transactionBytes", Convert.toHexString(transaction.getBytes()));
    response.put("unsignedTransactionBytes", Convert.toHexString(transaction.getUnsignedBytes()));
    return response;

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

示例8: processRequest

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

    long accountId = ParameterParser.getAccount(req).getId();
    long assetId = 0;
    try {
        assetId = Convert.parseUnsignedLong(req.getParameter("asset"));
    } catch (RuntimeException e) {
        // ignore
    }
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);

    DbIterator<Order.Ask> askOrders;
    if (assetId == 0) {
        askOrders = Order.Ask.getAskOrdersByAccount(accountId, firstIndex, lastIndex);
    } else {
        askOrders = Order.Ask.getAskOrdersByAccountAsset(accountId, assetId, firstIndex, lastIndex);
    }
    JSONArray orderIds = new JSONArray();
    try {
        while (askOrders.hasNext()) {
            orderIds.add(Convert.toUnsignedLong(askOrders.next().getId()));
        }
    } finally {
        askOrders.close();
    }
    JSONObject response = new JSONObject();
    response.put("askOrderIds", orderIds);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:32,代码来源:GetAccountCurrentAskOrderIds.java

示例9: processRequest

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

    JSONObject response = new JSONObject();

    List<Block> nextBlocks = new ArrayList<>();
    int totalLength = 0;
    long blockId = Convert.parseUnsignedLong((String) request.get("blockId"));
    List<? extends Block> blocks = Nxt.getBlockchain().getBlocksAfter(blockId, 1440);

    for (Block block : blocks) {
        int length = Constants.BLOCK_HEADER_LENGTH + block.getPayloadLength();
        if (totalLength + length > 1048576) {
            break;
        }
        nextBlocks.add(block);
        totalLength += length;
    }

    JSONArray nextBlocksArray = new JSONArray();
    for (Block nextBlock : nextBlocks) {
        nextBlocksArray.add(nextBlock.getJSONObject());
    }
    response.put("nextBlocks", nextBlocksArray);

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

示例10: MessagingVoteCasting

import nxt.util.Convert; //导入方法依赖的package包/类
MessagingVoteCasting(JSONObject attachmentData) {
    super(attachmentData);
    this.pollId = Convert.parseUnsignedLong((String)attachmentData.get("pollId"));
    JSONArray vote = (JSONArray)attachmentData.get("vote");
    this.pollVote = new byte[vote.size()];
    for (int i = 0; i < pollVote.length; i++) {
        pollVote[i] = ((Long) vote.get(i)).byteValue();
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:10,代码来源:Attachment.java

示例11: getCommonMilestoneBlockId

import nxt.util.Convert; //导入方法依赖的package包/类
private long getCommonMilestoneBlockId(Peer peer) {

			String lastMilestoneBlockId = null;

			while (true) {
				JSONObject milestoneBlockIdsRequest = new JSONObject();
				milestoneBlockIdsRequest.put("requestType", "getMilestoneBlockIds");
				if (lastMilestoneBlockId == null) {
					milestoneBlockIdsRequest.put("lastBlockId", blockchain.getLastBlock().getStringId());
				} else {
					milestoneBlockIdsRequest.put("lastMilestoneBlockId", lastMilestoneBlockId);
				}

				JSONObject response = peer.send(JSON.prepareRequest(milestoneBlockIdsRequest));
				if (response == null) {
					return 0;
				}
				JSONArray milestoneBlockIds = (JSONArray) response.get("milestoneBlockIds");
				if (milestoneBlockIds == null) {
					return 0;
				}
				if (milestoneBlockIds.isEmpty()) {
					return Genesis.GENESIS_BLOCK_ID;
				}
				// prevent overloading with blockIds
				if (milestoneBlockIds.size() > 20) {
					Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many milestoneBlockIds, blacklisting");
					peer.blacklist();
					return 0;
				}
				if (Boolean.TRUE.equals(response.get("last"))) {
					peerHasMore = false;
				}
				for (Object milestoneBlockId : milestoneBlockIds) {
					long blockId = Convert.parseUnsignedLong((String) milestoneBlockId);
					if (BlockDb.hasBlock(blockId)) {
						if (lastMilestoneBlockId == null && milestoneBlockIds.size() > 1) {
							peerHasMore = false;
						}
						return blockId;
					}
					lastMilestoneBlockId = (String) milestoneBlockId;
				}
			}

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

示例12: ColoredCoinsOrderCancellation

import nxt.util.Convert; //导入方法依赖的package包/类
private ColoredCoinsOrderCancellation(JSONObject attachmentData) {
    super(attachmentData);
    this.orderId = Convert.parseUnsignedLong((String) attachmentData.get("order"));
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:5,代码来源:Attachment.java

示例13: DigitalGoodsQuantityChange

import nxt.util.Convert; //导入方法依赖的package包/类
DigitalGoodsQuantityChange(JSONObject attachmentData) {
    super(attachmentData);
    this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
    this.deltaQuantity = ((Long)attachmentData.get("deltaQuantity")).intValue();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:6,代码来源:Attachment.java

示例14: AdvancedPaymentEscrowSign

import nxt.util.Convert; //导入方法依赖的package包/类
AdvancedPaymentEscrowSign(JSONObject attachmentData) {
	super(attachmentData);
	this.escrowId = Convert.parseUnsignedLong((String)attachmentData.get("escrowId"));
	this.decision = Escrow.stringToDecision((String)attachmentData.get("decision"));
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:6,代码来源:Attachment.java

示例15: AdvancedPaymentSubscriptionCancel

import nxt.util.Convert; //导入方法依赖的package包/类
AdvancedPaymentSubscriptionCancel(JSONObject attachmentData) {
	super(attachmentData);
	this.subscriptionId = Convert.parseUnsignedLong((String)attachmentData.get("subscriptionId"));
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:5,代码来源:Attachment.java


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