List of usage examples for java.math BigInteger longValue
public long longValue()
From source file:com.cinnober.msgcodec.json.JsonValueHandler.java
static boolean isJavaScriptSafeSigned(BigInteger value) { int bitlen = value.bitLength(); return bitlen <= 52 || (bitlen == 53 && isJavaScriptSafeSigned(value.longValue())); }
From source file:burstcoin.jminer.core.checker.task.OCLCheckerFindAllBelowTargetTask.java
@Override public void run() { int[] lowestNonces; synchronized (oclChecker) { // todo not working?! lowestNonces = oclChecker.findTarget(generationSignature, scoops, targetDeadline); }//from w ww . j a v a2s. c om if (lowestNonces != null) { List<DevPoolResult> devPoolResults = new ArrayList<>(); for (int lowestNonce : lowestNonces) { long nonce = chunkPartStartNonce + lowestNonce; BigInteger result = calculateResult(scoops, generationSignature, lowestNonce); BigInteger deadline = result.divide(BigInteger.valueOf(baseTarget)); long calculatedDeadline = deadline.longValue(); devPoolResults.add(new DevPoolResult(blockNumber, calculatedDeadline, nonce, chunkPartStartNonce)); } publisher.publishEvent(new CheckerDevResultEvent(blockNumber, chunkPartStartNonce, devPoolResults)); } else { publisher.publishEvent(new CheckerDevResultEvent(blockNumber, chunkPartStartNonce, null)); } }
From source file:net.maritimecloud.identityregistry.controllers.CertificateController.java
private byte[] handleOCSP(byte[] input) throws IOException { OCSPReq ocspreq = new OCSPReq(input); if (ocspreq.isSigned()) { // TODO: verify signature - needed? }//from www .j a v a 2 s .c om BasicOCSPRespBuilder respBuilder = certUtil.initOCSPRespBuilder(ocspreq); Req[] requests = ocspreq.getRequestList(); for (Req req : requests) { BigInteger sn = req.getCertID().getSerialNumber(); Certificate cert = this.certificateService.getCertificateById(sn.longValue()); if (cert == null) { // Throw exception? continue; } // Check if certificate has been revoked if (cert.isRevoked()) { respBuilder.addResponse(req.getCertID(), new RevokedStatus(cert.getRevokedAt(), certUtil.getCRLReasonFromString(cert.getRevokeReason()))); } else { // Certificate is valid respBuilder.addResponse(req.getCertID(), CertificateStatus.GOOD); } } OCSPResp response = certUtil.generateOCSPResponse(respBuilder); return response.getEncoded(); }
From source file:py.una.pol.karaku.dao.entity.interceptors.UriInterceptor.java
protected String getNextSequence(String sequenceName) { BigInteger nextVal = (BigInteger) getSession() .createSQLQuery(String.format("select nextval('%s');", sequenceName)).uniqueResult(); return "" + nextVal.longValue(); }
From source file:org.springframework.cloud.consul.bus.EventService.java
public List<Event> watch(BigInteger lastIndex) { // TODO: parameterized or configurable watch time long index = -1; if (lastIndex != null) { index = lastIndex.longValue(); }// ww w .j a v a 2s. c om Response<List<Event>> watch = consul.eventList(new QueryParams(2, index)); return filterEvents(readEvents(watch), lastIndex); }
From source file:burstcoin.address.generator.core.GenerateWorkActor.java
/** * Full hash to id./* w w w .j a v a 2 s . c om*/ * * @param hash the hash * @return the long */ public Long fullHashToId(byte[] hash) { if (hash == null || hash.length < 8) { throw new IllegalArgumentException("Invalid hash: " + Arrays.toString(hash)); } BigInteger bigInteger = new BigInteger(1, new byte[] { hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0] }); return bigInteger.longValue(); }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
public boolean existsFaturaCartao(Conta conta) { boolean result = true; String sqlLancamento = "select count(id) from faturacartao where idConta = " + conta.getId(); Query queryLancamento = getSession().createSQLQuery(sqlLancamento); BigInteger queryResultLancamento = (BigInteger) queryLancamento.uniqueResult(); if (queryResultLancamento.longValue() == 0) { return false; }//from ww w .ja v a2 s . c o m return result; }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
public boolean existsFaturaCartaoByContaAndDataVencimento(Conta conta, Date dataVencimento) { boolean result = true; String sqlLancamento = "select count(id) from faturacartao where idConta = " + conta.getId() + " and dataVencimento = '" + Util.formataDataHora(dataVencimento, Util.DATABASE) + "'"; Query queryLancamento = getSession().createSQLQuery(sqlLancamento); BigInteger queryResultLancamento = (BigInteger) queryLancamento.uniqueResult(); if (queryResultLancamento.longValue() == 0) { return false; }/*from w w w.j a va2 s . c o m*/ return result; }
From source file:net.sf.jasperreports.data.cache.BigIntegerStore.java
protected ColumnValues createPrimitiveValues(boolean useOffset) { if (primitiveStore == null) { primitiveStore = new LongArrayStore(rawStore.size(), true); } else {/*from ww w. ja v a 2s . c o m*/ primitiveStore.resetValues(); } int count = rawStore.count(); Object[] values = rawStore.valuesBuffer(); for (int i = 0; i < count; i++) { BigInteger value = (BigInteger) values[i]; if (useOffset) { value = value.subtract(min); } primitiveStore.add(value.longValue()); } ColumnValues primitiveValues = primitiveStore.createValues(); return primitiveValues; }
From source file:org.egov.wtms.web.controller.reports.DefaultersWTReportController.java
public String getDuePeriodFrom(final BigInteger demandId) { final List<EgDemandDetails> demandDetList = new ArrayList<>( egDemandDao.findById(demandId.longValue(), false).getEgDemandDetails()); final List<EgDemandDetails> demandDetFinalList = new ArrayList<>(); for (final EgDemandDetails egDemandTemp : demandDetList) if (!egDemandTemp.getAmount().equals(egDemandTemp.getAmtCollected())) demandDetFinalList.addAll(egDemandTemp.getEgDemand().getEgDemandDetails()); if (demandDetFinalList.isEmpty()) return ""; else {/*ww w.j a va 2s. c o m*/ Collections.sort(demandDetFinalList, new DemandComparatorByInstallmentOrder()); return demandDetFinalList.get(0).getEgDemandReason().getEgInstallmentMaster().getDescription(); } }