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:staff.cashier.CashierController.java
@FXML private void onClickGetPayment(ActionEvent e) throws SQLException, IOException, ClassNotFoundException, DocumentException, DecoderException { PendingBill currBill = cashierView.getSelectionModel().getSelectedItem(); System.out.println(currBill.getCusName() + " " + currBill.getOrderID() + " " + currBill.getBill()); int orderid = currBill.getOrderID(); int bill_status = 1; Statement st = conn.createStatement(); Statement st1 = conn.createStatement(); Statement st2 = conn.createStatement(); // set bill status 1 in order_info table. String query = "update order_info set bill_paid='" + bill_status + "' where order_id='" + currBill.getOrderID() + "'"; st.executeUpdate(query);// www .j ava2s.co m // set cus_id=0 in corrosponding table. String query1 = "select * from order_info where order_id='" + currBill.getOrderID() + "'"; ResultSet rs = st1.executeQuery(query1); rs.next(); BigInteger cus_id = new BigInteger(Long.toString(rs.getLong("c_id"))); BigInteger new_cid = BigInteger.ZERO; String query2 = "update table_info set c_id='" + new_cid + "',order_taken=0 where c_id='" + cus_id + "'"; st2.executeUpdate(query2); //deleting the row ObservableList<PendingBill> billSelected, allBill; allBill = cashierView.getItems(); allBill.remove((currBill)); //Inserting into `bill` schema int counter = 0; //fetching the bill_id of the last order query = "select * from bill"; rs = st.executeQuery(query); while (rs.next()) { counter = rs.getInt("bill_id"); } counter++; String query3 = "insert into bill values(" + counter + "," + currBill.bill + ")"; st.executeUpdate(query3); //Updating the bill_generation schema String query4 = "insert into bill_generation values(" + currBill.orderID + ",'" + caid + "'," + counter + ")"; st.executeUpdate(query4); //GENERATING THE BILL IN PDF FORM String query5 = "select * from order_info where order_id=" + orderid + " "; ResultSet rs1 = st.executeQuery(query5); rs1.next(); String itemList = rs1.getString("list"); int tis = rs1.getInt("table_id"); float cc = rs1.getFloat("cost"); //String itemDetails=rs1.getString("item_qty"); int coupon = rs1.getInt("coupon_id"); float disc_p = 0; //FETCHING THE DISCOUNT PERCENT CORRESPONDING TO THAT COUPON if (coupon != 0) { Statement st4 = conn.createStatement(); String q4 = "select discount_percent from coupon where coupon_id=" + coupon; ResultSet rs4 = st4.executeQuery(q4); rs4.next(); disc_p = rs4.getFloat("discount_percent"); } //FETCHING CUSTOMER NAME String query6 = "select * from customer where c_id=" + cus_id + ""; ResultSet rs2 = st.executeQuery(query6); rs2.next(); String cusname = rs2.getString("c_name"); String email = rs2.getString("c_email"); String itemsInfo = ""; /*----------------DESERIALIZATION ByteArrayInputStream in = new ByteArrayInputStream(Hex.decodeHex(itemList.toCharArray())); String[] aa= (String[]) (new ObjectInputStream(in).readObject()); //System.out.println(Arrays.toString(); try{ for (String aa1 : aa) { if(aa1!=null){ int i; String tmp=""; for( i=0;i<(aa1.length()-1);i++) { tmp+=aa1.charAt(i); } int qty=Integer.parseInt(""+aa1.charAt(i)); itemsInfo+="Item name: "+tmp+" Qty:"+qty+"\n\n"; } } } catch(Exception ee){} -----------------------------------------*/ //EXTRACTING INFORMATION ABOUT ORDERED ITEMS String tmp = ""; for (int i = 0; i < (itemList.length() - 1); i++) { if (itemList.charAt(i + 1) == '-') { int qty = Integer.parseInt("" + itemList.charAt(i)); Statement st3 = conn.createStatement(); String q3 = "Select price from menu where d_name='" + tmp + "'"; ResultSet rs3 = st3.executeQuery(q3); rs3.next(); float p = rs3.getFloat("price"); itemsInfo += "Item name:" + tmp + " Qty:" + qty + " Price:+" + p + " Total:" + (qty * p) + "\n\n"; tmp = ""; i++; } else tmp += itemList.charAt(i); } itemsInfo += "Total Cost :" + cc + "\n\n"; if (coupon != 0) { float tprice = cc - ((disc_p * cc) / 100); itemsInfo += "You have been given a discount of " + disc_p + "%\n\nFinal Cost : Rs." + tprice + "\n\n"; } System.out.println("Item info:" + itemsInfo); //WRITING TO PDF Document doc = new Document(); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("Order" + orderid + ".pdf")); doc.open(); doc.addTitle("CENTRICO RESTAURANT"); doc.addCreationDate(); doc.addSubject("BILL"); //System.out.println(itemDetails); doc.add(new Paragraph(" CENTRICO RESTAURANT\n\nORDER ID : " + orderid + "\n\nTABLE ID : " + tis + "\n\nCUSTOMER NAME : " + cusname + "\n\nEMAIL ID : " + email + "\n\n" + itemsInfo + "\n\n")); doc.close(); writer.close(); //SENDING THE BILL IN MAIL TO THE CUSTOMER GmailQuickstart a = new GmailQuickstart(); a.setCusemail(email); a.setCusmessage("Thankyou so much " + cusname + " for coming here.Please visit us again :) \n Please find your bill attached below\n"); a.setCussubject("Bill for order number " + orderid); a.setFileName("Order" + orderid + ".pdf"); Thread t = new Thread(a); t.start(); //alert Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Information dialog"); alert.setHeaderText(null); alert.setContentText(" Payment has Received Successfully"); alert.showAndWait(); }
From source file:com.emergya.siradmin.invest.InvestmentUpdater.java
public List<LlaveBean> getExistingKeysInChileindica(Integer ano, Integer codigoRegion) { LOGGER.info("Obteniendo llaves para del ao " + ano + " y la regin " + codigoRegion); try {//from w ww. ja va 2 s . c o m List<LlaveBean> keys = null; ConsultaLlavesResponse response = wsConsultaLlaves.getWSConsultaLlavesPort().WSConsultaLlaves( BigInteger.valueOf(ano.longValue()), BigInteger.valueOf(codigoRegion.longValue())); Respuesta respuesta = response.getRespuesta(); if (!BigInteger.ZERO.equals(respuesta.getCodigoRespuesta())) { LOGGER.error( "El servicio web Consulta de llaves " + wsConsultaLlaves.getWSConsultaLlavesPortAddress() + " ha devuelto un cdigo de error " + respuesta.getCodigoRespuesta() + ". El mensaje de error fue: " + respuesta.getTextoRespuesta()); throw new WSCallException(respuesta.getCodigoRespuesta(), respuesta.getTextoRespuesta()); } if (response.getLlavesInversion() != null) { keys = new ArrayList<LlaveBean>(response.getLlavesInversion().length); for (LlavesInversionData projectKey : response.getLlavesInversion()) { LlaveBean key = new LlaveBean(); key.setAno(projectKey.getAno().intValue()); key.setRegion(codigoRegion); key.setcFicha(projectKey.getC_Ficha().intValue()); key.setcInstitucion(projectKey.getC_Institucion().intValue()); key.setcPreinversion(projectKey.getC_Preinversion().intValue()); BigInteger fechaRegistro = projectKey.getFechaRegistro(); if (fechaRegistro != null) { key.setFechaRegistro(fechaRegistro.intValue()); } boolean updatable = service.checkIfProjectMustBeUpdated(key.getRegion(), key.getAno(), key.getcInstitucion(), key.getcPreinversion(), key.getcFicha(), key.getFechaRegistro()); key.setUpdatable(updatable); keys.add(key); } return keys; } else { if (LOGGER.isInfoEnabled()) { LOGGER.info("El WS de consulta de llaves no ha devuelto datos para el ao " + ano + " y la regin " + codigoRegion); } return new ArrayList<LlaveBean>(); } } catch (RemoteException e) { LOGGER.error("Error llamando al servicio web " + wsConsultaLlaves.getWSConsultaLlavesPortAddress(), e); throw new WSCallException(e); } catch (ServiceException e) { LOGGER.error("Error llamando al servicio web " + wsConsultaLlaves.getWSConsultaLlavesPortAddress(), e); throw new WSCallException(e); } }
From source file:net.ripe.rpki.commons.crypto.util.Asn1Util.java
/** * IPAddress ::= BIT STRING/* w w w . j a va 2 s.co m*/ */ public static IpAddress parseIpAddress(IpResourceType type, ASN1Encodable der, boolean padWithOnes) { expect(der, DERBitString.class); DERBitString derBitString = (DERBitString) der; byte[] bytes = derBitString.getBytes(); BigInteger value = new BigInteger(1, bytes); int usedBits = bytes.length * Byte.SIZE; int neededBits = type.getBitSize(); int padBits = derBitString.getPadBits(); if (padBits > 0) { byte lastByte = bytes[bytes.length - 1]; byte mask = (byte) ((1 << padBits) - 1); Validate.isTrue((lastByte & mask) == 0, "pad bits not zero"); } BigInteger upperBits = value.shiftLeft(neededBits - usedBits); BigInteger lowerBits = BigInteger.ZERO; if (padWithOnes) { lowerBits = BigInteger.ONE.shiftLeft(neededBits - usedBits + padBits).subtract(BigInteger.ONE); } return (IpAddress) type.fromBigInteger(upperBits.or(lowerBits)); }
From source file:com.mothsoft.alexis.engine.numeric.TopicActivityDataSetImporter.java
private void importTopicDataForUser(final Long userId, final Date startDate, final Date endDate) { logger.debug(String.format("Importing topic activity for user: %d between %s and %s", userId, startDate.toString(), endDate.toString())); final List<Long> topicIds = this.transactionTemplate.execute(new TransactionCallback<List<Long>>() { @SuppressWarnings("unchecked") @Override//from w w w. j a v a 2 s . c o m public List<Long> doInTransaction(TransactionStatus txStatus) { final Query query = TopicActivityDataSetImporter.this.em .createQuery("SELECT id FROM Topic WHERE userId = :userId ORDER BY id ASC"); query.setParameter("userId", userId); return query.getResultList(); } }); BigInteger total = BigInteger.ZERO; for (final Long topicId : topicIds) { BigInteger count = importTopicDataForTopic(topicId, startDate, endDate); total = total.add(count); } recordAggregateTopicActivity(userId, startDate, total); }
From source file:net.ripe.ipresource.IpRange.java
private boolean canBeDividedByThePowerOfTwo(BigInteger number, int power) { return number.remainder(BigInteger.valueOf(2).pow(power)).equals(BigInteger.ZERO); }
From source file:com.netflix.imfutility.cpl._2016.Cpl2016ContextBuilderStrategy.java
@Override public BigFraction getCompositionTimecodeRate() { if (cpl2016.getCompositionTimecode() == null) { return null; }/*from w w w. ja v a 2s . c om*/ BigInteger rate = cpl2016.getCompositionTimecode().getTimecodeRate(); boolean isDropFrame = cpl2016.getCompositionTimecode().isTimecodeDropFrame(); if (rate == null || BigInteger.ZERO.equals(rate)) { return null; } // return as-is if non-drop if (!isDropFrame) { return new BigFraction(rate); } // return as 30000/1001 for 30 if drop frame return new BigFraction(rate.multiply(BigInteger.valueOf(1000)), BigInteger.valueOf(1001)); }
From source file:com.netflix.imfutility.cpl._2013.Cpl2013ContextBuilderStrategy.java
@Override public BigFraction getCompositionTimecodeRate() { if (cpl2013.getCompositionTimecode() == null) { return null; }//from w ww . j a v a 2 s.c o m BigInteger rate = cpl2013.getCompositionTimecode().getTimecodeRate(); boolean isDropFrame = cpl2013.getCompositionTimecode().isTimecodeDropFrame(); if (rate == null || BigInteger.ZERO.equals(rate)) { return null; } // return as-is if non-drop if (!isDropFrame) { return new BigFraction(rate); } // return as 30000/1001 for 30 if drop frame return new BigFraction(rate.multiply(BigInteger.valueOf(1000)), BigInteger.valueOf(1001)); }
From source file:org.jcryptool.visual.verifiablesecretsharing.views.ReconstructionChartComposite.java
private XYDataset createDataset() { final XYSeries playerAndSharesSeries = new XYSeries("Shares"); final XYSeries reconstructionSeries = new XYSeries("Reconstructed Polynom"); final XYSeries secretSeries = new XYSeries("Secret"); BigInteger[] coef = reconstructedPolynom.getCoef(); BigInteger y = BigInteger.ZERO; for (int i = 0; i < playerID.length && playerID[i] != 0; i++) { playerAndSharesSeries.add(playerID[i], shares[i]); }//from www .j a v a 2 s. com for (int i = 0; i <= playerID[playerID.length - 1]; i++) { for (int j = 0; j < coef.length; j++) { y = y.add(coef[j].multiply(new BigInteger(i + "").pow(j))); } reconstructionSeries.add(i, y); y = BigInteger.ZERO; } secretSeries.add(0, secret); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(playerAndSharesSeries); dataset.addSeries(reconstructionSeries); dataset.addSeries(secretSeries); return dataset; }
From source file:com.redhat.lightblue.crud.ldap.translator.ResultTranslatorTest.java
@Test public void testTranslate_SimpleField_BigIntegerType() throws JSONException { SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[] { new Attribute("key", BigInteger.ZERO.toString()) }); EntityMetadata md = fakeEntityMetadata("fakeMetadata", new SimpleField("key", BigIntegerType.TYPE)); DocCtx document = new ResultTranslator(factory, md, new TrivialLdapFieldNameTranslator()).translate(result); assertNotNull(document);// www . jav a 2 s . c om JSONAssert.assertEquals("{\"key\":" + BigInteger.ZERO + ",\"dn\":\"uid=john.doe,dc=example,dc=com\"}", document.getOutputDocument().toString(), true); }
From source file:com.tps.ttorrent.bcodec.BDecoder.java
/** * Returns the next b-encoded value on the stream and makes sure it is a * number.// w ww . j a v a2 s .c om * * @throws InvalidBEncodingException If it is not a number. */ public BEValue bdecodeNumber() throws IOException { int c = this.getNextIndicator(); if (c != 'i') { throw new InvalidBEncodingException("Expected 'i', not '" + (char) c + "'"); } this.indicator = 0; c = this.read(); if (c == '0') { c = this.read(); if (c == 'e') return new BEValue(BigInteger.ZERO); else throw new InvalidBEncodingException("'e' expected after zero," + " not '" + (char) c + "'"); } // We don't support more the 255 char big integers char[] chars = new char[256]; int off = 0; if (c == '-') { c = this.read(); if (c == '0') throw new InvalidBEncodingException("Negative zero not allowed"); chars[off] = (char) c; off++; } if (c < '1' || c > '9') throw new InvalidBEncodingException("Invalid Integer start '" + (char) c + "'"); chars[off] = (char) c; off++; c = this.read(); int i = c - '0'; while (i >= 0 && i <= 9) { chars[off] = (char) c; off++; c = read(); i = c - '0'; } if (c != 'e') throw new InvalidBEncodingException("Integer should end with 'e'"); String s = new String(chars, 0, off); return new BEValue(new BigInteger(s)); }