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


Java DbIterator.hasNext方法代码示例

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


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

示例1: processRequest

import nxt.db.DbIterator; //导入方法依赖的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

示例2: getEscrowTransactionsByParticipent

import nxt.db.DbIterator; //导入方法依赖的package包/类
public static Collection<Escrow> getEscrowTransactionsByParticipent(Long accountId) {
	List<Escrow> filtered = new ArrayList<>();
	DbIterator<Decision> it = decisionTable.getManyBy(new DbClause.LongClause("account_id", accountId), 0, -1);
	while(it.hasNext()) {
		Decision decision = it.next();
		Escrow escrow = escrowTable.get(escrowDbKeyFactory.newKey(decision.escrowId));
		if(escrow != null) {
			filtered.add(escrow);
		}
	}
	return filtered;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:13,代码来源:Escrow.java

示例3: processRequest

import nxt.db.DbIterator; //导入方法依赖的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

示例4: processRequest

import nxt.db.DbIterator; //导入方法依赖的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 orders = new JSONArray();
    try {
        while (askOrders.hasNext()) {
            orders.add(JSONData.askOrder(askOrders.next()));
        }
    } finally {
        askOrders.close();
    }
    JSONObject response = new JSONObject();
    response.put("askOrders", orders);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:32,代码来源:GetAccountCurrentAskOrders.java

示例5: processRequest

import nxt.db.DbIterator; //导入方法依赖的package包/类
@Override
   JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
	JSONObject response = new JSONObject();
	
	Account targetAccount = ParameterParser.getAccount(req);
	
	long height = Nxt.getBlockchain().getLastBlock().getHeight();
	
	JSONArray accounts = new JSONArray();
	/*for(Account account : Account.getAllAccounts()) {
		long recip;
		if(account.getRewardRecipientFrom() > height + 1) {
			recip = 0L; // this api is intended for pools, so drop changing users a few blocks early to avoid overpaying
		}
		else {
			recip = account.getRewardRecipient();
		}
		if(targetAccount.getId() == recip) {
			accounts.add(Convert.toUnsignedLong(account.getId()));
		}
	}*/
	DbIterator<Account.RewardRecipientAssignment> assignments = Account.getAccountsWithRewardRecipient(targetAccount.getId());
	while(assignments.hasNext()) {
		Account.RewardRecipientAssignment assignment = assignments.next();
		accounts.add(Convert.toUnsignedLong(assignment.accountId));
	}
	if(targetAccount.getRewardRecipientAssignment() == null) {
		accounts.add(Convert.toUnsignedLong(targetAccount.getId()));
	}
	
	response.put("accounts", accounts);
	
	return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:35,代码来源:GetAccountsWithRewardRecipient.java

示例6: processRequest

import nxt.db.DbIterator; //导入方法依赖的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 orders = new JSONArray();
    try {
        while (bidOrders.hasNext()) {
            orders.add(JSONData.bidOrder(bidOrders.next()));
        }
    } finally {
        bidOrders.close();
    }
    JSONObject response = new JSONObject();
    response.put("bidOrders", orders);
    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:32,代码来源:GetAccountCurrentBidOrders.java

示例7: processRequest

import nxt.db.DbIterator; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    long sellerId = ParameterParser.getSellerId(req);
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    boolean inStockOnly = !"false".equalsIgnoreCase(req.getParameter("inStockOnly"));

    JSONObject response = new JSONObject();
    JSONArray goodsJSON = new JSONArray();
    response.put("goods", goodsJSON);

    DbIterator<DigitalGoodsStore.Goods> goods = null;
    try {
        if (sellerId == 0) {
            if (inStockOnly) {
                goods = DigitalGoodsStore.getGoodsInStock(firstIndex, lastIndex);
            } else {
                goods = DigitalGoodsStore.getAllGoods(firstIndex, lastIndex);
            }
        } else {
            goods = DigitalGoodsStore.getSellerGoods(sellerId, inStockOnly, firstIndex, lastIndex);
        }
        while (goods.hasNext()) {
            DigitalGoodsStore.Goods good = goods.next();
            goodsJSON.add(JSONData.goods(good));
        }
    } finally {
        DbUtils.close(goods);
    }

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

示例8: processRequest

import nxt.db.DbIterator; //导入方法依赖的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: checkComplete

import nxt.db.DbIterator; //导入方法依赖的package包/类
private DecisionType checkComplete() {
	Decision senderDecision = decisionTable.get(decisionDbKeyFactory.newKey(id, senderId));
	if(senderDecision.getDecision() == DecisionType.RELEASE) {
		return DecisionType.RELEASE;
	}
	Decision recipientDecision = decisionTable.get(decisionDbKeyFactory.newKey(id, recipientId));
	if(recipientDecision.getDecision() == DecisionType.REFUND) {
		return DecisionType.REFUND;
	}
	
	int countRelease = 0;
	int countRefund = 0;
	int countSplit = 0;
	
	DbIterator<Decision> decisions = decisionTable.getManyBy(new DbClause.LongClause("escrow_id", id), 0, -1);
	while(decisions.hasNext()) {
		Decision decision = decisions.next();
		if(decision.getAccountId().equals(senderId) ||
		   decision.getAccountId().equals(recipientId)) {
			continue;
		}
		switch(decision.getDecision()) {
		case RELEASE:
			countRelease++;
			break;
		case REFUND:
			countRefund++;
			break;
		case SPLIT:
			countSplit++;
			break;
		default:
			break;
		}
	}
	
	if(countRelease >= requiredSigners) {
		return DecisionType.RELEASE;
	}
	if(countRefund >= requiredSigners) {
		return DecisionType.REFUND;
	}
	if(countSplit >= requiredSigners) {
		return DecisionType.SPLIT;
	}
	
	return DecisionType.UNDECIDED;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:49,代码来源:Escrow.java


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