本文整理汇总了Java中nxt.util.Convert.parseAccountId方法的典型用法代码示例。如果您正苦于以下问题:Java Convert.parseAccountId方法的具体用法?Java Convert.parseAccountId怎么用?Java Convert.parseAccountId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nxt.util.Convert
的用法示例。
在下文中一共展示了Convert.parseAccountId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
if(account != null) {
response.put("balanceNQT", Convert.toUnsignedLong(account.getBalanceNQT()));
}
else {
response.put("balanceNQT", "0");
}
}
catch(Exception e) {
}
return response;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
}
示例8: getBuyerId
import nxt.util.Convert; //导入方法依赖的package包/类
static long getBuyerId(HttpServletRequest req) throws ParameterException {
String buyerIdValue = Convert.emptyToNull(req.getParameter("buyer"));
try {
return Convert.parseAccountId(buyerIdValue);
} catch (RuntimeException e) {
throw new ParameterException(INCORRECT_RECIPIENT);
}
}