List of usage examples for java.math BigInteger valueOf
private static BigInteger valueOf(int val[])
From source file:com.crimelab.service.PolygraphServiceImpl.java
@Override public XWPFDocument create(Polygraph polygraph, HttpSession session) { XWPFDocument document = null;//from w w w .j a v a 2s.c o m //Insert into dbase // polygraphDAO.polygraphInfo(polygraph); try { //Blank Document InputStream inpDocx = session.getServletContext() .getResourceAsStream("/WEB-INF/templates/Polygraph.docx"); document = new XWPFDocument(inpDocx); //create Paragraph XWPFParagraph subjectNo = document.createParagraph(); XWPFRun r1 = subjectNo.createRun(); r1.setText("POLYGRAPH SUBJECT NO: " + polygraph.getSubjectNo()); subjectNo.setAlignment(ParagraphAlignment.CENTER); r1.setBold(true); ; //create table XWPFTable table = document.createTable(); //width CTTbl tableFix = table.getCTTbl(); CTTblPr pr = tableFix.getTblPr(); CTTblWidth tblW = pr.getTblW(); tblW.setW(BigInteger.valueOf(4800)); tblW.setType(STTblWidth.PCT); pr.setTblW(tblW); tableFix.setTblPr(pr); //create first row XWPFTableRow tableRowOne = table.getRow(0); XWPFTableCell headerCell = tableRowOne.getCell(0); XWPFParagraph headerParagraph = headerCell.getParagraphs().get(0); XWPFRun hRun = headerParagraph.createRun(); headerCell.setColor("CDCDB4"); hRun.setText("PERSONAL INFORMATION"); tableRowOne.addNewTableCell().setText(null); headerParagraph.setAlignment(ParagraphAlignment.CENTER); XWPFTableCell photoHeaderCell = tableRowOne.getCell(1); XWPFParagraph photoHeaderParagraph = photoHeaderCell.getParagraphs().get(0); XWPFRun pRun = photoHeaderParagraph.createRun(); photoHeaderCell.setColor("CDCDB4"); pRun.setText("PHOTO"); photoHeaderParagraph.setAlignment(ParagraphAlignment.CENTER); XWPFTableRow tableRowTwo = table.createRow(); XWPFTableCell cell = tableRowTwo.getCell(0); XWPFParagraph personalInfo = cell.getParagraphs().get(0); XWPFRun r2 = personalInfo.createRun(); r2.setText("Name"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getName()); r2.addBreak(); r2.setText("Gender"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getGender()); r2.addBreak(); r2.setText("Age"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getAge()); r2.addBreak(); r2.setText("Date of Birth"); r2.addTab(); r2.setText(": " + polygraph.getBirthdate()); r2.addBreak(); r2.setText("Civil Status"); r2.addTab(); r2.setText(": " + polygraph.getCivilStatus()); r2.addBreak(); r2.setText("ID Presented"); r2.addTab(); r2.setText(": " + polygraph.getIdPresented()); r2.addBreak(); r2.setText("Address"); r2.addTab(); r2.setText(": " + polygraph.getAddress()); //Adding the picture XWPFTableCell pictureCell = tableRowTwo.getCell(1); XWPFParagraph pictureHolder = pictureCell.getParagraphs().get(0); XWPFRun pictureRun = pictureHolder.createRun(); FileInputStream getPhoto = new FileInputStream(polygraph.getPhotoLocation()); FileInputStream getImage = new FileInputStream(polygraph.getPhotoLocation()); ImageInputStream imageInput = ImageIO.createImageInputStream(getPhoto); BufferedImage bi = ImageIO.read(imageInput); pictureHolder.setAlignment(ParagraphAlignment.RIGHT); pictureRun.addPicture(getImage, XWPFDocument.PICTURE_TYPE_JPEG, null, Units.toEMU(120), Units.toEMU(120)); XWPFParagraph spacing = document.createParagraph(); XWPFRun spacingRun = spacing.createRun(); //create table XWPFTable otherTable = document.createTable(); //width CTTbl tableFixTwo = otherTable.getCTTbl(); CTTblPr prTwo = tableFixTwo.getTblPr(); CTTblWidth tblWTwo = prTwo.getTblW(); tblWTwo.setW(BigInteger.valueOf(4800)); tblWTwo.setType(STTblWidth.PCT); prTwo.setTblW(tblWTwo); tableFixTwo.setTblPr(prTwo); XWPFTableRow examInfoHeader = otherTable.createRow(); XWPFTableCell cellInfo = examInfoHeader.getCell(0); XWPFParagraph examInfo = cellInfo.getParagraphs().get(0); XWPFRun r3 = examInfo.createRun(); cellInfo.setColor("CDCDB4"); r3.setText("EXAM INFORMATION"); examInfo.setAlignment(ParagraphAlignment.CENTER); XWPFTableRow examInfoRow = otherTable.createRow(); XWPFTableCell cellRowInfo = examInfoRow.getCell(0); XWPFParagraph examInfoRowP = cellRowInfo.getParagraphs().get(0); XWPFRun examRun = examInfoRowP.createRun(); examRun.setText("Case Number"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getCaseNo()); examRun.addBreak(); examRun.setText("Requesting Party"); examRun.addTab(); examRun.setText(": " + polygraph.getRequestingParty()); examRun.addBreak(); examRun.setText("Time/Date Received"); examRun.addTab(); examRun.setText(": " + polygraph.getTimeDateReceived()); examRun.addBreak(); examRun.setText("Nature of Case"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getNatureOfCase()); examRun.addBreak(); examRun.setText("Exam Location"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getExamLocation()); examRun.addBreak(); examRun.setText("Exam Date"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getExamDate()); otherTable.removeRow(0); XWPFParagraph purposeOfExamination = document.createParagraph(); XWPFRun r4 = purposeOfExamination.createRun(); r4.setUnderline(UnderlinePatterns.SINGLE); r4.addBreak(); r4.setText("SECTION 1: PURPOSE OF EXAMINATION"); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); XWPFParagraph purposeOfExaminationContents = document.createParagraph(); XWPFRun r4Contents = purposeOfExaminationContents.createRun(); r4Contents.setText(polygraph.getPurpose()); XWPFParagraph preTestInterview = document.createParagraph(); XWPFRun r5 = preTestInterview.createRun(); r5.setUnderline(UnderlinePatterns.SINGLE); r5.setText("SECTION 2: PRE-TEST INTERVIEW"); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); XWPFParagraph preTestInterviewContents = document.createParagraph(); XWPFRun r5Contents = preTestInterviewContents.createRun(); r5Contents.setText(polygraph.getPreTest()); XWPFParagraph inTestPhase = document.createParagraph(); XWPFRun r6 = inTestPhase.createRun(); r6.setUnderline(UnderlinePatterns.SINGLE); r6.setText("SECTION 3: IN-TEST PHASE"); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); XWPFParagraph inTestPhaseContents = document.createParagraph(); XWPFRun r6Contents = inTestPhaseContents.createRun(); r6Contents.setText(polygraph.getInTest()); XWPFParagraph result = document.createParagraph(); XWPFRun r7 = result.createRun(); r7.setUnderline(UnderlinePatterns.SINGLE); r7.setText("SECTION 4: RESULT"); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); XWPFParagraph resultContents = document.createParagraph(); XWPFRun r7Contents = resultContents.createRun(); r7Contents.setText(polygraph.getResult()); XWPFParagraph postTestInterview = document.createParagraph(); XWPFRun r8 = postTestInterview.createRun(); r8.setUnderline(UnderlinePatterns.SINGLE); r8.setText("SECTION 5: POST-TEST INTERVIEW"); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); XWPFParagraph postTestInterviewContents = document.createParagraph(); XWPFRun r8Contents = postTestInterviewContents.createRun(); r8Contents.setText(polygraph.getPostTest()); XWPFParagraph remarks = document.createParagraph(); XWPFRun r9 = remarks.createRun(); r9.setUnderline(UnderlinePatterns.SINGLE); r9.setText("REMARKS:"); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); XWPFParagraph remarksContents = document.createParagraph(); XWPFRun r9Contents = remarksContents.createRun(); r9Contents.setText(polygraph.getRemarks()); XWPFParagraph timeDateCompleted = document.createParagraph(); XWPFRun r10 = timeDateCompleted.createRun(); r10.setUnderline(UnderlinePatterns.SINGLE); r10.setText("TIME AND DATE COMPLETED:"); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); XWPFParagraph timeDateCompletedContents = document.createParagraph(); XWPFRun r10Contents = timeDateCompletedContents.createRun(); r10Contents.setText(polygraph.getTimeDateCompleted()); XWPFParagraph examinedBy = document.createParagraph(); XWPFRun r11 = examinedBy.createRun(); r11.setUnderline(UnderlinePatterns.SINGLE); r11.setText("EXAMINED BY:"); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); XWPFParagraph examinedByContents = document.createParagraph(); XWPFRun r11Contents = examinedByContents.createRun(); r11Contents.setText(polygraph.getExaminerName()); r11Contents.addBreak(); r11Contents.setText(polygraph.getExaminerRank()); r11Contents.addBreak(); r11Contents.setText(polygraph.getExaminerPosition()); XWPFParagraph approvedBy = document.createParagraph(); XWPFRun r12 = approvedBy.createRun(); r12.setUnderline(UnderlinePatterns.SINGLE); r12.setText("APPROVED BY:"); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); XWPFParagraph approvedByContents = document.createParagraph(); XWPFRun r12Contents = approvedByContents.createRun(); // r12Contents.setText(polygraph.getApprovedName()); // r12Contents.addBreak(); // r12Contents.setText(polygraph.getApprovedRank()); // r12Contents.addBreak(); // r12Contents.setText(polygraph.getApprovedPosition()); // r12Contents.addBreak(); XWPFParagraph notedBy = document.createParagraph(); XWPFRun r13 = notedBy.createRun(); r13.setUnderline(UnderlinePatterns.SINGLE); r13.setText("NOTED BY:"); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); XWPFParagraph notedByContents = document.createParagraph(); XWPFRun r13Contents = notedByContents.createRun(); r13Contents.setText(polygraph.getNotedName()); r13Contents.addBreak(); r13Contents.setText(polygraph.getNotedRank()); r13Contents.addBreak(); r13Contents.setText(polygraph.getNotedPosition()); r13Contents.addBreak(); table.setInsideVBorder(XWPFTable.XWPFBorderType.NIL, 0, 0, "white"); document.getXWPFDocument(); } catch (Exception e) { e.printStackTrace(); } return document; }
From source file:co.rsk.remasc.RemascStorageProviderTest.java
@Test public void setSaveRetrieveAndGetBurnedBalance() throws IOException { String accountAddress = randomAddress(); Repository repository = new RepositoryImplForTesting(); RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress); provider.setBurnedBalance(BigInteger.valueOf(255)); provider.save();/* w w w. j av a 2 s . c o m*/ RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress); Assert.assertEquals(BigInteger.valueOf(255), newProvider.getBurnedBalance()); }
From source file:co.rsk.remasc.Remasc.java
/** * Implements the actual Remasc distribution logic *//*from w w w . ja v a2s .co m*/ void processMinersFees() { if (!(executionTx instanceof RemascTransaction)) { //Detect // 1) tx to remasc that is not the latest tx in a block // 2) invocation to remasc from another contract (ie call opcode) throw new RemascInvalidInvocationException("Invoked Remasc outside last tx of the block"); } this.addNewSiblings(); long blockNbr = executionBlock.getNumber(); long processingBlockNumber = blockNbr - remascConstants.getMaturity(); if (processingBlockNumber < 1) { logger.debug("First block has not reached maturity yet, current block is {}", blockNbr); return; } BlockHeader processingBlockHeader = blockStore .getBlockByHashAndDepth(executionBlock.getParentHash(), remascConstants.getMaturity() - 1) .getHeader(); // Adds current block fees to accumulated rewardBalance BigInteger processingBlockReward = BigInteger.valueOf(processingBlockHeader.getPaidFees()); BigInteger rewardBalance = provider.getRewardBalance(); rewardBalance = rewardBalance.add(processingBlockReward); provider.setRewardBalance(rewardBalance); if (processingBlockNumber - remascConstants.getSyntheticSpan() < 0) { logger.debug("First block has not reached maturity+syntheticSpan yet, current block is {}", executionBlock.getNumber()); return; } // Takes from rewardBalance this block's height reward. BigInteger fullBlockReward = rewardBalance.divide(BigInteger.valueOf(remascConstants.getSyntheticSpan())); rewardBalance = rewardBalance.subtract(fullBlockReward); provider.setRewardBalance(rewardBalance); // Pay RSK labs cut BigInteger payToRskLabs = fullBlockReward.divide(BigInteger.valueOf(remascConstants.getRskLabsDivisor())); transfer(remascConstants.getRskLabsAddress(), payToRskLabs); fullBlockReward = fullBlockReward.subtract(payToRskLabs); List<Sibling> siblings = provider.getSiblings().get(processingBlockNumber); if (CollectionUtils.isNotEmpty(siblings)) { // Block has siblings, reward distribution is more complex boolean previousBrokenSelectionRule = provider.getBrokenSelectionRule(); this.payWithSiblings(processingBlockHeader, fullBlockReward, siblings, previousBrokenSelectionRule); boolean brokenSelectionRule = this.isBrokenSelectionRule(processingBlockHeader, siblings); provider.setBrokenSelectionRule(brokenSelectionRule); } else { if (provider.getBrokenSelectionRule()) { // broken selection rule, apply punishment, ie burn part of the reward. BigInteger punishment = fullBlockReward .divide(BigInteger.valueOf(remascConstants.getPunishmentDivisor())); fullBlockReward = fullBlockReward.subtract(punishment); provider.setBurnedBalance(provider.getBurnedBalance().add(punishment)); } transfer(processingBlockHeader.getCoinbase(), fullBlockReward); provider.setBrokenSelectionRule(Boolean.FALSE); } this.removeUsedSiblings(processingBlockHeader); }
From source file:gov.nih.nci.cabig.caaers.grid.service.StudyServiceImpl.java
public gov.nih.nci.cabig.caaers.grid.beans.StudyParticipantAssignment assignParticipant( gov.nih.nci.cabig.caaers.grid.beans.Study studyBean, gov.nih.nci.cabig.caaers.grid.beans.Participant participantBean, gov.nih.nci.cabig.caaers.grid.beans.Site siteBean) throws RemoteException { gov.nih.nci.cabig.caaers.grid.beans.StudyParticipantAssignment assignmentBean = new gov.nih.nci.cabig.caaers.grid.beans.StudyParticipantAssignment(); try {// ww w .j av a2 s . c om BigInteger studyId = studyBean.getId(); if (studyId == null) { throw new IllegalArgumentException("Study ID is null"); } BigInteger siteId = siteBean.getId(); if (siteId == null) { throw new IllegalArgumentException("Site ID is null"); } Study study = new Study(); study.setId(studyId.intValue()); Organization site = new Organization(); site.setId(siteId.intValue()); BigInteger participantId = participantBean.getId(); Participant participant = new Participant(); if (participantId != null) { participant.setId(participantId.intValue()); } else { participant.setFirstName(participantBean.getFirstName()); participant.setMiddleName(participantBean.getMiddleName()); participant.setLastName(participantBean.getLastName()); participant.setMaidenName(participantBean.getMaidenName()); participant.setInstitution(participantBean.getInstitution()); participant.setInstitutionalPatientNumber(participantBean.getInstitutionalPatientNumber()); participant.setDateOfBirth(participantBean.getDateOfBirth()); participant.setRace(participantBean.getRace()); participant.setGender(participantBean.getGender()); } StudyService svc = (StudyService) this.ctx.getBean(STUDY_SERVICE_BEAN_NAME); StudyParticipantAssignment assignment = svc.assignParticipant(study, participant, site, ""); //TODO: Switch to using grid id when that is reader assignmentBean.setId(BigInteger.valueOf(assignment.getId().longValue())); } catch (Exception ex) { String msg = "Error assigning participant: " + ex.getMessage(); logger.debug(msg, ex); throw new RuntimeException(msg, ex); } return assignmentBean; }
From source file:cn.dsgrp.field.stock.functional.rest.TaskRestFT.java
@Test public void invalidInput() { // create/*from w w w .j av a2 s .c om*/ Task titleBlankTask = new Task(); try { restTemplate.postForLocation(resourceUrl, titleBlankTask); fail("Create should fail while title is blank"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); Map messages = jsonMapper.fromJson(e.getResponseBodyAsString(), Map.class); assertThat(messages).hasSize(1); assertThat(messages.get("title")).isIn("may not be empty", "?"); } // update titleBlankTask.setId(BigInteger.valueOf(1)); try { restTemplate.put(resourceUrl + "/1", titleBlankTask); fail("Update should fail while title is blank"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); Map messages = jsonMapper.fromJson(e.getResponseBodyAsString(), Map.class); assertThat(messages).hasSize(1); assertThat(messages.get("title")).isIn("may not be empty", "?"); } }
From source file:de.tudarmstadt.ukp.teaching.uima.nounDecompounding.ranking.TotalFreqAmout.java
/** * Adds all frequency values for a special directory * @return// ww w . j a v a2s. c om * @throws IOException */ protected BigInteger countFreq(FSDirectory dir) throws IOException { BigInteger count = BigInteger.valueOf(0); IndexReader reader = IndexReader.open(dir); for (int i = 0; i < reader.maxDoc(); i++) { if (reader.isDeleted(i)) { continue; } Document doc = reader.document(i); count = count.add(new BigInteger(doc.get("freq"))); } return count; }
From source file:com.baasbox.BBConfiguration.java
public static BigInteger getDBSizeThreshold() { if (!isDBSizeThresholdOverridden && configuration.getLong(DB_SIZE_THRESHOLD) != null) return BigInteger.valueOf(configuration.getLong(DB_SIZE_THRESHOLD)); return dbSizeThreshold; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.databasecomponents.ModifyListenerForDBComp.java
/** * The Function will compare bigInteger values * @param value1// ww w .j a va 2 s . c o m * @param value2 * @return */ private int compareBigIntegerValue(String value1, String value2) { BigInteger int1 = BigInteger.valueOf(Long.parseLong(value1)); BigInteger int2 = BigInteger.valueOf(Long.parseLong(value2)); return int1.compareTo(int2); }
From source file:io.stallion.services.SecureTempTokens.java
public String idToRandomString(Long id) { SecureRandom random = new SecureRandom(); Integer rand = random.nextInt(); Long n = rand * 1000000000 + id; return Base64.getEncoder().encodeToString(BigInteger.valueOf(n).toByteArray()); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsUserWriterTest.java
@Test public void test() throws Exception { final Operation op = sequenceOf( insertInto("mantis_project_table").columns("id", "name").values(1, "project_1").build(), insertInto("mantis_user_table").columns("id", "name").values(1, "old_user_1").build(), insertInto("mantis_project_user_list_table").columns("user_id", "project_id").values(1, 1).build()); lauchOperation(op);// w w w . j av a2 s.co m projectUsersWriter.write(buildItems()); final List<AccountData> results = getJdbcTemplate() .query("SELECT usr.id, usr.name" + " FROM mantis_user_table usr" + " INNER JOIN mantis_project_user_list_table pul ON pul.user_id = usr.id" + " WHERE pul.project_id = 1", new BeanPropertyRowMapper<AccountData>(AccountData.class)); assertEquals(2, results.size()); for (final AccountData item : results) { if (item.getId() == BigInteger.ONE) { assertEquals("new_user_1", item.getName()); } else { assertEquals(BigInteger.valueOf(2), item.getId()); assertEquals("new_user_2", item.getName()); } } }