List of usage examples for java.math BigInteger ZERO
BigInteger ZERO
To view the source code for java.math BigInteger ZERO.
Click Source Link
From source file:com.amazon.carbonado.repo.jdbc.LoggingPreparedStatement.java
public void clearParameters() throws SQLException { mParams = null; mSetParams = BigInteger.ZERO; ps().clearParameters(); }
From source file:com.spotify.reaper.unit.service.SegmentRunnerTest.java
@Test public void timeoutTest() throws InterruptedException, ReaperException, ExecutionException { final AppContext context = new AppContext(); context.storage = new MemoryStorage(); RepairUnit cf = context.storage//from www .j av a 2s .c o m .addRepairUnit(new RepairUnit.Builder("reaper", "reaper", Sets.newHashSet("reaper"))); RepairRun run = context.storage.addRepairRun( new RepairRun.Builder("reaper", cf.getId(), DateTime.now(), 0.5, 1, RepairParallelism.PARALLEL)); context.storage.addRepairSegments(Collections.singleton( new RepairSegment.Builder(run.getId(), new RingRange(BigInteger.ONE, BigInteger.ZERO), cf.getId())), run.getId()); final long segmentId = context.storage.getNextFreeSegment(run.getId()).get().getId(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final MutableObject<Future<?>> future = new MutableObject<>(); context.jmxConnectionFactory = new JmxConnectionFactory() { @Override public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host) { JmxProxy jmx = mock(JmxProxy.class); when(jmx.getClusterName()).thenReturn("reaper"); when(jmx.isConnectionAlive()).thenReturn(true); when(jmx.tokenRangeToEndpoint(anyString(), any(RingRange.class))) .thenReturn(Lists.newArrayList("")); when(jmx.triggerRepair(any(BigInteger.class), any(BigInteger.class), anyString(), Matchers.<RepairParallelism>any(), Sets.newHashSet(anyString()))) .then(new Answer<Integer>() { @Override public Integer answer(InvocationOnMock invocation) { assertEquals(RepairSegment.State.NOT_STARTED, context.storage.getRepairSegment(segmentId).get().getState()); future.setValue(executor.submit(new Thread() { @Override public void run() { handler.get().handle(1, ActiveRepairService.Status.STARTED, "Repair command 1 has started"); assertEquals(RepairSegment.State.RUNNING, context.storage .getRepairSegment(segmentId).get().getState()); } })); return 1; } }); return jmx; } }; RepairRunner rr = mock(RepairRunner.class); RepairUnit ru = mock(RepairUnit.class); SegmentRunner sr = new SegmentRunner(context, segmentId, Collections.singleton(""), 100, 0.5, RepairParallelism.PARALLEL, "reaper", ru, rr); sr.run(); future.getValue().get(); executor.shutdown(); assertEquals(RepairSegment.State.NOT_STARTED, context.storage.getRepairSegment(segmentId).get().getState()); assertEquals(1, context.storage.getRepairSegment(segmentId).get().getFailCount()); }
From source file:org.owasp.jbrofuzz.core.FuzzerBigInteger.java
/** * <p>This constructor is available through the factory method, * createFuzzerBigInteger(), available in the Database class.</p> * /*from w w w. j a v a2s . c o m*/ * <p>The length specifies the number of digits, in terms of characters that * the Fuzzer will be used for. This is required for recursive and zero fuzzers, * where an iteration is taking place.</p> * * @see Database.createFuzzerBigInteger(String id, int length) * * @param prototype The prototype id, as read from the fuzzers.jbrf file * e.g. "031-B16-HEX" for the hexadecimal alphabet * * @param len The length of the fuzzer, required for recursive and zero * fuzzers. This should always be a positive integer. * * @throws NoSuchFuzzerException * * @author subere@uncon.org * @version 2.4 * @since 1.2 */ protected FuzzerBigInteger(final Prototype prototype, final int len) throws NoSuchFuzzerException { this.prototype = prototype; if (prototype == null) { maxValue = BigInteger.ZERO; } else { payloads = this.prototype.getPayloads(); if (this.prototype.isRecursive()) { maxValue = BigInteger.valueOf(payloads.size()); maxValue = maxValue.pow(len < 0 ? 0 : len); } else { maxValue = BigInteger.valueOf(payloads.size()); } } cValue = BigInteger.ZERO; this.len = len; }
From source file:org.openestate.io.examples.FilemakerWritingExample.java
/** * Create a {@link DatabaseType} with some example data. * * @return/*from w w w . j av a 2s . c om*/ * created example object */ protected static DatabaseType createDatabase() { DatabaseType database = FACTORY.createDatabaseType(); database.setNAME("example database"); database.setLAYOUT("fmmedia2universal"); database.setDATEFORMAT("D.m.yyyy"); database.setTIMEFORMAT("k:mm:ss"); database.setRECORDS(BigInteger.ZERO); return database; }
From source file:utilities.itext.Turnover.java
private static Paragraph createTablesWithDetails(ArrayList<PaymentPosition> data) throws DocumentException { Paragraph paragraph = new Paragraph(); PdfPTable expense = new PdfPTable(2); float[] colWidths = { 5f, 1f }; expense.setWidths(colWidths);// www. ja v a 2s . c o m int lastPaymentID = 0; for (PaymentPosition pp : data) { if (lastPaymentID != pp.getPayment().getId()) { //new Payment Paragraph p1 = new Paragraph(pp.getPayment().getPayee().getName()); PdfPCell c1 = new PdfPCell(p1); //add next cell with price //calc price BigDecimal totalPrice = new BigDecimal(BigInteger.ZERO); for (PaymentPosition payPos : data) { if (payPos.getPayment().getId() == pp.getPayment().getId()) { totalPrice = totalPrice.add(payPos.getTotalPrice()); } } Paragraph p2 = new Paragraph(totalPrice.toPlainString()); PdfPCell c2 = new PdfPCell(p2); c1.setBorder(Rectangle.NO_BORDER); c1.setBorderWidthTop(0.5f); c2.setBorder(Rectangle.NO_BORDER); c2.setBorderWidthTop(0.5f); expense.addCell(c1); expense.addCell(c2); } //payment position Paragraph p1 = new Paragraph(" " + pp.getQuantity() + "x: " + pp.getArticle().getName()); PdfPCell c1 = new PdfPCell(p1); //add next cell with price Paragraph p2 = new Paragraph(pp.getTotalPriceAsString()); PdfPCell c2 = new PdfPCell(p2); c1.setBorder(Rectangle.NO_BORDER); c2.setBorder(Rectangle.NO_BORDER); expense.addCell(c1); expense.addCell(c2); lastPaymentID = pp.getPayment().getId(); } paragraph.add(expense); paragraph.setSpacingBefore(10f); return paragraph; }
From source file:com.dnsoft.inmobiliaria.controllers.ConsultaCCPropietariosController.java
void saldos() { DecimalFormat formatter = new DecimalFormat("###,###,###.00"); BigDecimal saldoPesos = new BigDecimal(BigInteger.ZERO); BigDecimal saldoDolares = new BigDecimal(BigInteger.ZERO); ;//w w w . j av a 2 s . c om for (Propietario propietario : listPropietarios) { CCPropietario ccPesos = cCPropietarioDAO.findUltimoMovimiento(Moneda.PESOS, propietario); if (ccPesos != null) { saldoPesos = saldoPesos.add(ccPesos.getSaldo()); } CCPropietario ccDolares = cCPropietarioDAO.findUltimoMovimiento(Moneda.DOLARES, propietario); if (ccDolares != null) { saldoDolares = saldoDolares.add(ccDolares.getSaldo()); } } view.txtDolares.setText(formatter.format(saldoDolares)); view.txtPesos.setText(formatter.format(saldoPesos)); }
From source file:com.docd.purefm.utils.PFMFileUtils.java
@NonNull public static String byteCountToDisplaySize(@NonNull final BigInteger size) { String displaySize;/*from w w w . j ava 2 s.co m*/ if (size.divide(FileUtils.ONE_GB_BI).compareTo(BigInteger.ZERO) > 0) { displaySize = String.valueOf(size.divide(FileUtils.ONE_GB_BI)) + " GiB"; } else if (size.divide(FileUtils.ONE_MB_BI).compareTo(BigInteger.ZERO) > 0) { displaySize = String.valueOf(size.divide(FileUtils.ONE_MB_BI)) + " MiB"; } else if (size.divide(FileUtils.ONE_KB_BI).compareTo(BigInteger.ZERO) > 0) { displaySize = String.valueOf(size.divide(FileUtils.ONE_KB_BI)) + " KiB"; } else { displaySize = String.valueOf(size) + " B"; } return displaySize; }
From source file:com.redhat.lightblue.metadata.types.StringTypeTest.java
@Test public void testCompareNotEqual() { assertEquals(stringType.compare((Object) BigInteger.ZERO, (Object) BigInteger.ONE), -1); }
From source file:nl.strohalm.cyclos.entities.ads.AdCategory.java
/** * returns a BigInteger indicating the global order index of the category. In the global order, whenever an item with children is encountered, all * child nodes are first handled before going on with the next item/node on the same level.<br> * Note that this method only works correctly with a maximum of 999 subcategories for a certain category. * @author rinke/* w w w .j av a 2 s. co m*/ */ public BigInteger getGlobalOrder() { if (globalOrder == null) { final int correctedLevel = AdCategory.MAX_LEVEL - getLevel(); final BigInteger levelFactor = new BigInteger("1000").pow(correctedLevel); // specified indexes are always > 0. Unspecified indexes of 0 mess up the calculation, so... final Integer index = (getOrder() == 0) ? 1 : getOrder(); final BigInteger parentGlobalOrder = (getParent() == null) ? BigInteger.ZERO : getParent().getGlobalOrder(); globalOrder = parentGlobalOrder.add(levelFactor.multiply(new BigInteger(index.toString()))); } return globalOrder; }
From source file:eu.dety.burp.joseph.attacks.bleichenbacher_pkcs1.BleichenbacherPkcs1DecryptionAttackExecutor.java
@Override // Fire prepared request and return responses as IHttpRequestResponse protected Integer doInBackground() throws Exception { int i = 0;//from w w w.ja v a 2s. c o m boolean solutionFound = false; this.c0 = BigInteger.ZERO; this.si = BigInteger.ZERO; this.m = null; this.blockSize = this.pubKey.getModulus().bitLength() / 8; this.httpService = this.requestResponse.getHttpService(); // b computation int tmp = this.pubKey.getModulus().bitLength(); while (tmp % 8 != 0) { tmp++; } tmp = ((tmp / 8) - 2) * 8; this.bigB = BigInteger.valueOf(2).pow(tmp); loggerInstance.log(getClass(), "B computed: " + this.bigB.toString(16), Logger.LogLevel.INFO); loggerInstance.log(getClass(), "Blocksize: " + blockSize + " bytes", Logger.LogLevel.INFO); String[] components = Decoder.getComponents(this.parameter.getJoseValue()); encryptedKey = Base64.decodeBase64(components[1]); loggerInstance.log(getClass(), "Step 1: Blinding", Logger.LogLevel.INFO); if (this.msgIsPkcs) { loggerInstance.log(getClass(), "Step skipped --> " + "Message is considered as PKCS compliant.", Logger.LogLevel.INFO); this.s0 = BigInteger.ONE; this.c0 = new BigInteger(1, this.encryptedKey); this.m = new Interval[] { new Interval(BigInteger.valueOf(2).multiply(this.bigB), (BigInteger.valueOf(3).multiply(this.bigB)).subtract(BigInteger.ONE)) }; } else { stepOne(); } i++; while (!solutionFound) { // Check if user has cancelled the worker if (isCancelled()) { loggerInstance.log(getClass(), "Decryption Attack Executor Worker cancelled by user", Logger.LogLevel.INFO); return 0; } loggerInstance.log(getClass(), "Step 2: Searching for PKCS conforming messages.", Logger.LogLevel.INFO); try { stepTwo(i); } catch (Exception e) { loggerInstance.log(getClass(), "Error in stepTwo: " + e.getMessage(), Logger.LogLevel.INFO); } loggerInstance.log(getClass(), "Step 3: Narrowing the set of soultions.", Logger.LogLevel.INFO); stepThree(i); loggerInstance.log(getClass(), "Step 4: Computing the solution.", Logger.LogLevel.INFO); solutionFound = stepFour(); i++; } return 1; }