List of usage examples for java.math BigInteger valueOf
private static BigInteger valueOf(int val[])
From source file:com.sun.honeycomb.admin.mgmt.server.HCCellAdapterBase.java
public BigInteger setCellProps(EventSender evt, HCCellProps value, Byte cellid) throws MgmtException { boolean updateSwitch = false; boolean updateSp = false; boolean isUpdateLocal = (localCellid == cellid.byteValue()) ? true : false; HashMap map = new HashMap(); if (!value.getAdminVIP().equals(MultiCellLib.getInstance().getAdminVIP())) { updateSp = true;/*from w w w . j av a 2s . com*/ updateSwitch = true; map.put(MultiCellLib.PROP_ADMIN_VIP, value.getAdminVIP()); } if (!value.getDataVIP().equals(MultiCellLib.getInstance().getDataVIP())) { updateSp = true; updateSwitch = true; map.put(MultiCellLib.PROP_DATA_VIP, value.getDataVIP()); } if (!value.getSpVIP().equals(MultiCellLib.getInstance().getSPVIP())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_SP_VIP, value.getSpVIP()); } if (!value.getSubnet().equals(MultiCellLib.getInstance().getSubnet())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_SUBNET, value.getSubnet()); } if (!value.getGateway().equals(MultiCellLib.getInstance().getGateway())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_GATEWAY, value.getGateway()); } if (map.size() != 0) { if (!isUpdateLocal) { // Update the of silo_info.xml properties on the local cell MultiCellLib.getInstance().updateProperties(cellid.byteValue(), map); try { evt.sendAsynchronousEvent( "successfully updated the " + "configuration [cell " + localCellid + "]"); } catch (MgmtException e) { logger.severe("failed to send synchronous event " + e); } // // Other cells-- on which no configuration change occur need to // notify Multicell about those changes. // Cell updatedCell = new Cell(cellid.byteValue(), value.getAdminVIP(), value.getDataVIP(), value.getSpVIP(), null, value.getSubnet(), value.getGateway()); // TODO: This code isn't valid for the emulator // Proxy calls don't seem to be supported. The // call to api.cahngeCellCfg() will fail with a class not // found exception. Need to fix for the emulator MultiCellIntf api = MultiCellIntf.Proxy.getMultiCellAPI(); if (api == null) { logger.severe("failed to grab multicellAPI"); if (MultiCellLib.getInstance().isCellMaster()) { throw new MgmtException("Internal error while " + "notifying services on master cell. Will " + " require a reboot of the master cell [cell " + localCellid + "]"); } else { return BigInteger.valueOf(-1); } } try { api.changeCellCfg(updatedCell); } catch (Exception e) { logger.log(Level.SEVERE, "failed to update Multicell service", e); if (MultiCellLib.getInstance().isCellMaster()) { throw new MgmtException("Internal error while " + "notifying services on master cell. Will " + " require a reboot of the master cell [cell " + localCellid + "]"); } else { return BigInteger.valueOf(-1); } } } else { // // We need to preform those config/update and any subsequent // operation in an async way because the dataVIP may be // reconfigured under our feet and the CLI gets screwed. // try { evt.sendAsynchronousEvent( "will update the configuration " + " and reboot the cell [cell " + localCellid + "]"); } catch (MgmtException e) { logger.severe("failed to send synchronous event " + e); } updatePropertiesAndRebootCell(map, updateSwitch, updateSp); } } return BigInteger.valueOf(0); }
From source file:org.mule.modules.quickbooks.windows.api.DefaultQuickBooksWindowsClient.java
/** * Returns the list of results pages from QB * //from www . jav a 2s. co m * @return List of pages with results */ @Override public Iterable findObjectsGetPages(final OAuthCredentials credentials, final WindowsEntityType type, final Object query) { Validate.notNull(type); return new PaginatedIterable<Object, List<Object>>() { private Integer countPage = 1; @Override protected List<Object> firstPage() { return askAnEspecificPage(countPage); } @Override protected boolean hasNextPage(List<Object> arg0) { return arg0.isEmpty(); } @Override protected List<Object> nextPage(List<Object> arg0) { countPage = countPage + 1; return askAnEspecificPage(countPage); } @Override protected Iterator<Object> pageIterator(List<Object> arg0) { return arg0.iterator(); } private List<Object> askAnEspecificPage(Integer pageNumber) { String str = String.format("%s/%s/v2/%s", credentials.getBaseUri(), type.getResouceName(), credentials.getRealmId()); HttpUriRequest httpRequest = new HttpPost(str); httpRequest.addHeader("Content-Type", "text/xml"); ((QueryBase) query).setStartPage(BigInteger.valueOf(pageNumber)); ((QueryBase) query).setChunkSize(getResultsPerPage()); prepareToPost(query, httpRequest); try { Object respObj = makeARequestToQuickbooks(httpRequest, credentials, false); if (respObj instanceof ErrorResponse) { throw new QuickBooksRuntimeException(new ErrorInfo(respObj)); } return getListFromIntuitResponse(respObj, type); } catch (QuickBooksRuntimeException e) { if (e.isAExpiredTokenFault()) { destroyAccessToken(credentials); return askAnEspecificPage(pageNumber); } else { throw e; } } } }; }
From source file:com.netflix.imfutility.cpl._2013.Cpl2013ContextBuilderStrategy.java
private void processResourceRepeat(TrackFileResourceType trackFileResource, long repeat) { // 1. init resource context ResourceUUID resourceId = ResourceUUID.create(trackFileResource.getId(), repeat); ResourceKey resourceKey = ResourceKey.create(currentSegmentUuid, currentSequenceUuid, currentSequenceType); contextProvider.getResourceContext().initResource(resourceKey, resourceId); // 2. Init essence parameter in Edit Units (as defined in CPL) // Check that we have a corresponding track file in assetmap // asset map already contains full absolute paths UUID trackId = UUID.create(trackFileResource.getTrackFileId()); String assetPath = assetMap.getAsset(trackId); if (assetPath == null) { throw new ConversionException( String.format("Resource track file '%s' isn't present in assetmap.xml", trackId)); }//from w ww. ja va 2 s. com assetMap.markAssetReferenced(trackId); contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.ESSENCE, assetPath); // 3. init edit rate parameter BigFraction editRate = ((trackFileResource.getEditRate() != null) && !trackFileResource.getEditRate().isEmpty()) ? ConversionHelper.parseEditRate(trackFileResource.getEditRate()) : compositionEditRate; contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.EDIT_RATE, ConversionHelper.toEditRate(editRate)); // 4. Init startTime parameter BigInteger startTimeEditUnit = trackFileResource.getEntryPoint() != null ? trackFileResource.getEntryPoint() : BigInteger.valueOf(0); contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.START_TIME_EDIT_UNIT, startTimeEditUnit.toString()); // 5. init duration parameter BigInteger durationEditUnit; if (trackFileResource.getSourceDuration() != null) { durationEditUnit = trackFileResource.getSourceDuration(); } else { durationEditUnit = trackFileResource.getIntrinsicDuration().subtract(startTimeEditUnit); } contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.DURATION_EDIT_UNIT, durationEditUnit.toString()); // 6. init endTime parameter BigInteger endTimeEditUnit = startTimeEditUnit.add(durationEditUnit); contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.END_TIME_EDIT_UNIT, endTimeEditUnit.toString()); // 7. init total repeat count parameter BigInteger repeatCount = trackFileResource.getRepeatCount() != null ? trackFileResource.getRepeatCount() : BigInteger.ONE; contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.REPEAT_COUNT, repeatCount.toString()); // 8. init trackFile ID contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.TRACK_FILE_ID, trackId.getUuid()); // 9. init essence descriptor ID String essenceDescId = trackFileResource.getSourceEncoding(); contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId, ResourceContextParameters.ESSENCE_DESC_ID, essenceDescId); }
From source file:co.rsk.blockchain.utils.BlockGenerator.java
private static Map<ByteArrayWrapper, InitialAddressState> generatePreMine(Map<byte[], BigInteger> alloc) { Map<ByteArrayWrapper, InitialAddressState> premine = new HashMap<>(); for (byte[] key : alloc.keySet()) { AccountState acctState = new AccountState(BigInteger.valueOf(0), alloc.get(key)); premine.put(wrap(key), new InitialAddressState(acctState, null)); }// ww w . j av a 2 s . co m return premine; }
From source file:Main.java
/** * Java runtime 1.5 is inconsistent with its handling of days in Duration objects. * @param duration A duration object to be normalised * @return A day-normalised duration, i.e. all years and months converted to days, * e.g. 1Y 3M 3D => 458 days//from w w w . j a v a 2 s .c o m */ private static javax.xml.datatype.Duration normaliseDays(javax.xml.datatype.Duration duration) { final long DAYS_PER_MONTH = 30; final long DAYS_PER_YEAR = 365; BigInteger days = (BigInteger) duration.getField(DatatypeConstants.DAYS); BigInteger months = (BigInteger) duration.getField(DatatypeConstants.MONTHS); BigInteger years = (BigInteger) duration.getField(DatatypeConstants.YEARS); BigInteger normalisedDays = years.multiply(BigInteger.valueOf(DAYS_PER_YEAR)); normalisedDays = normalisedDays.add(months.multiply(BigInteger.valueOf(DAYS_PER_MONTH))); normalisedDays = normalisedDays.add(days); BigInteger hours = (BigInteger) duration.getField(DatatypeConstants.HOURS); BigInteger minutes = (BigInteger) duration.getField(DatatypeConstants.MINUTES); BigDecimal seconds = (BigDecimal) duration.getField(DatatypeConstants.SECONDS); boolean positive = duration.getSign() >= 0; return FACTORY.newDuration(positive, BigInteger.ZERO, BigInteger.ZERO, normalisedDays, hours, minutes, seconds); }
From source file:jp.aegif.nemaki.cmis.service.impl.ObjectServiceImpl.java
private ContentStream getContentStreamInternal(String repositoryId, Content content, BigInteger rangeOffset, BigInteger rangeLength) { if (!content.isDocument()) { exceptionService.constraint(content.getId(), "getContentStream cannnot be invoked to other than document type."); }/*from www.j av a2 s . c o m*/ Document document = (Document) content; exceptionService.constraintContentStreamDownload(repositoryId, document); AttachmentNode attachment = contentService.getAttachment(repositoryId, document.getAttachmentNodeId()); attachment.setRangeOffset(rangeOffset); attachment.setRangeLength(rangeLength); // Set content stream BigInteger length = BigInteger.valueOf(attachment.getLength()); String name = attachment.getName(); String mimeType = attachment.getMimeType(); InputStream is = attachment.getInputStream(); ContentStream cs = new ContentStreamImpl(name, length, mimeType, is); return cs; }
From source file:gov.nih.nci.firebird.service.signing.DigitalSigningHelper.java
private X509V1CertificateGenerator buildX509V1CertificateGenerator(PublicKey publicKey, DigitalSigningDistinguishedName distinguishedName, long serialNumber, int validDays) { X509V1CertificateGenerator v1CertGen = new X509V1CertificateGenerator(); // Calculate Expiration Date Calendar notBeforeCal = Calendar.getInstance(); Date notBeforeDate = notBeforeCal.getTime(); Calendar notAfterCal = Calendar.getInstance(); notAfterCal.add(Calendar.DAY_OF_YEAR, validDays); Date notAfterDate = notAfterCal.getTime(); ///*from w w w. j a va 2 s. c om*/ // create the certificate - version 1 // v1CertGen.setSerialNumber(BigInteger.valueOf(serialNumber)); v1CertGen.setIssuerDN(new X509Principal(getAttributeOrder(), buildAttributes(distinguishedName))); v1CertGen.setNotBefore(notBeforeDate); v1CertGen.setNotAfter(notAfterDate); // subjects name - the same as we are self signed. v1CertGen.setSubjectDN(new X509Principal(getAttributeOrder(), buildAttributes(distinguishedName))); v1CertGen.setPublicKey(publicKey); v1CertGen.setSignatureAlgorithm("SHA256WithRSAEncryption"); return v1CertGen; }
From source file:com.aurel.track.exchange.docx.exporter.ImageUtil.java
/** * Creates the caption/bookmark/figure sequence for an image * add this (see caption markup in document.xml): * <w:p w:rsidR="00324188" w:rsidRDefault="00E8619E" w:rsidP="00E8619E"> <w:pPr>// w ww .j a v a 2s .c o m <w:pStyle w:val="Caption"/> </w:pPr> <w:r> <w:t xml:space="preserve">Figure </w:t> </w:r> <w:fldSimple w:instr=" SEQ Figure \* ARABIC "> <w:r> <w:rPr> <w:noProof/> </w:rPr> <w:t>1</w:t> </w:r> </w:fldSimple> <w:bookmarkStart w:id="2" w:name="_GoBack"/> <w:bookmarkEnd w:id="2"/> </w:p> * * @param figurePrefix * @param figureNumber * @param figureName * @param bookmarkID * @return */ private static P createCaption(String figurePrefix, int figureNumber, String figureName, String description, String captionStyleId, int bookmarkID) { ObjectFactory wmlObjectFactory = new ObjectFactory(); P p = wmlObjectFactory.createP(); if (figurePrefix != null) { // Create object for r R r = wmlObjectFactory.createR(); p.getContent().add(r); // Create object for t (wrapped in JAXBElement) Text text = wmlObjectFactory.createText(); JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text); r.getContent().add(textWrapped); text.setValue(figurePrefix + " "); text.setSpace("preserve"); } // Create object for fldSimple (wrapped in JAXBElement) CTSimpleField simplefield = wmlObjectFactory.createCTSimpleField(); JAXBElement<org.docx4j.wml.CTSimpleField> simplefieldWrapped = wmlObjectFactory .createPFldSimple(simplefield); p.getContent().add(simplefieldWrapped); // Create object for r R r2 = wmlObjectFactory.createR(); simplefield.getContent().add(r2); // Create object for t (wrapped in JAXBElement) Text text2 = wmlObjectFactory.createText(); JAXBElement<org.docx4j.wml.Text> textWrapped2 = wmlObjectFactory.createRT(text2); r2.getContent().add(textWrapped2); text2.setValue(Integer.valueOf(figureNumber).toString()); // Create object for rPr RPr rpr = wmlObjectFactory.createRPr(); r2.setRPr(rpr); // Create object for noProof BooleanDefaultTrue booleandefaulttrue = wmlObjectFactory.createBooleanDefaultTrue(); rpr.setNoProof(booleandefaulttrue); simplefield.setInstr(" SEQ " + figurePrefix + " \\* ARABIC "); if (description != null && !"".equals(description)) { // Create object for r R r4 = wmlObjectFactory.createR(); p.getContent().add(r4); // Create object for t (wrapped in JAXBElement) Text text4 = wmlObjectFactory.createText(); JAXBElement<org.docx4j.wml.Text> textWrapped4 = wmlObjectFactory.createRT(text4); r4.getContent().add(textWrapped4); text4.setValue(" - "); text4.setSpace("preserve"); // Create object for r R r5 = wmlObjectFactory.createR(); p.getContent().add(r5); // Create object for t (wrapped in JAXBElement) Text text5 = wmlObjectFactory.createText(); JAXBElement<org.docx4j.wml.Text> textWrapped5 = wmlObjectFactory.createRT(text5); r5.getContent().add(textWrapped5); text5.setValue(description); text5.setSpace("preserve"); // Create object for bookmarkStart (wrapped in JAXBElement) } CTBookmark bookmark = wmlObjectFactory.createCTBookmark(); JAXBElement<org.docx4j.wml.CTBookmark> bookmarkWrapped = wmlObjectFactory.createPBookmarkStart(bookmark); p.getContent().add(bookmarkWrapped); bookmark.setName(figurePrefix + figureName); bookmark.setId(BigInteger.valueOf(bookmarkID)); // Create object for bookmarkEnd (wrapped in JAXBElement) CTMarkupRange markuprange = wmlObjectFactory.createCTMarkupRange(); JAXBElement<org.docx4j.wml.CTMarkupRange> markuprangeWrapped = wmlObjectFactory .createPBookmarkEnd(markuprange); p.getContent().add(markuprangeWrapped); markuprange.setId(BigInteger.valueOf(bookmarkID)); // Create object for pPr PPr ppr = wmlObjectFactory.createPPr(); p.setPPr(ppr); if (captionStyleId != null) { // Create object for pStyle PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle(); ppr.setPStyle(pprbasepstyle); pprbasepstyle.setVal(captionStyleId); } // Create object for jc Jc jc = wmlObjectFactory.createJc(); ppr.setJc(jc); jc.setVal(org.docx4j.wml.JcEnumeration.LEFT); return p; }
From source file:org.osiam.client.ScimExtensionIT.java
@Test @DatabaseSetup(value = "/database_seeds/ScimExtensionIT/extensions.xml") public void updating_one_extension_field_doesnt_change_the_other_fields() { Map<String, Extension.Field> extensionDataToPatch = new HashMap<>(); extensionDataToPatch.put("gender", new Extension.Field(ExtensionFieldType.STRING, "male")); Extension extension = createExtensionWithData(URN, extensionDataToPatch); UpdateUser patchUser = new UpdateUser.Builder().updateExtension(extension).build(); User updatedUser = oConnector.updateUser(EXISTING_USER_UUID, patchUser, accessToken); Extension storedExtension = updatedUser.getExtension(URN); assertEquals(BigInteger.valueOf(28), storedExtension.getField("age", ExtensionFieldType.INTEGER)); }
From source file:jef.tools.DateUtils.java
/** * ?????//from w ww . j a va 2s.com * * @param d * @param unit * ?? * @param zone * ?? ??? * @return */ public static boolean isOnTime(Date d, TimeUnit unit, TimeZone zone) { BigInteger i = BigInteger.valueOf(d.getTime() + zone.getRawOffset()); long result = i.mod(BigInteger.valueOf(unit.ms)).longValue(); return result == 0; }