Example usage for java.math BigInteger ZERO

List of usage examples for java.math BigInteger ZERO

Introduction

In this page you can find the example usage for java.math BigInteger ZERO.

Prototype

BigInteger ZERO

To view the source code for java.math BigInteger ZERO.

Click Source Link

Document

The BigInteger constant zero.

Usage

From source file:com.kactech.otj.Utils.java

public static String base62Encode(BigInteger number) {
    if (number.compareTo(BigInteger.ZERO) == -1) { // number < 0
        throw new IllegalArgumentException("number must not be negative");
    }/*from   ww w . j  a v a 2  s. c  o m*/
    StringBuilder result = new StringBuilder();
    while (number.compareTo(BigInteger.ZERO) == 1) { // number > 0
        BigInteger[] divmod = number.divideAndRemainder(B62_BASE);
        number = divmod[0];
        int digit = divmod[1].intValue();
        result.insert(0, B62_DIGITS.charAt(digit));
    }
    return (result.length() == 0) ? B62_DIGITS.substring(0, 1) : result.toString();
}

From source file:org.apache.blur.command.BaseCommandManager.java

protected void lookForCommandsToRegisterInClassPath() throws IOException {
    Enumeration<URL> systemResources = ClassLoader
            .getSystemResources(META_INF_SERVICES_ORG_APACHE_BLUR_COMMAND_COMMANDS);
    loadCommandClasses(systemResources, getClass().getClassLoader(), BigInteger.ZERO);
}

From source file:org.egov.pgr.dashboard.service.DashboardService.java

public Map<String, Object> topComplaints() {
    DateTime currentDate = new DateTime();

    List<Object> dataHolderNumber = constructListOfMonthPlaceHolder(currentDate.minusMonths(5),
            currentDate.plusMonths(1), "MM");
    List<Object> dataHolderString = constructListOfMonthPlaceHolder(currentDate.minusMonths(5),
            currentDate.plusMonths(1), "MMM");
    List<Object[]> topFiveCompTypeData = dashboardRepository.fetchTopComplaintsBetween(
            startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(),
            endOfGivenDate(currentDate).toDate());
    List<Object[]> topFiveCompTypeCurrentMonth = dashboardRepository.fetchTopComplaintsForCurrentMonthBetween(
            startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(),
            endOfGivenDate(currentDate).toDate());
    Map<Object, Object> constructResultPlaceholder = new LinkedHashMap<>();
    Map<Object, Object> actualdata = new LinkedHashMap<>();
    for (Object complaintType : topFiveCompTypeCurrentMonth)
        for (Object month : dataHolderNumber)
            constructResultPlaceholder.put(month + "-" + complaintType, BigInteger.ZERO);
    for (Object[] top5CompType : topFiveCompTypeData)
        actualdata.put(top5CompType[0] + "-" + top5CompType[2], top5CompType[1]);
    Map<Object, Object> newdata = new LinkedHashMap<>();
    for (Object placeholderMapKey : constructResultPlaceholder.keySet())
        if (actualdata.get(placeholderMapKey) == null)
            newdata.put(placeholderMapKey, BigInteger.ZERO);
        else/*from w  ww.  j av  a  2  s  . c om*/
            newdata.put(placeholderMapKey, actualdata.get(placeholderMapKey));
    Map<String, Object> topFiveCompDataHolder = new LinkedHashMap<>();

    List<Object> dataHolder = new LinkedList<>();
    List<Object> compCount = new ArrayList<>();
    Iterator<Entry<Object, Object>> entries = newdata.entrySet().iterator();
    int index = 0;
    while (entries.hasNext()) {
        Map<String, Object> tmpdata = new LinkedHashMap<>();
        Entry<Object, Object> entry = entries.next();
        if (index < 5) {
            compCount.add(entry.getValue());
            index++;
        } else if (index == 5) {
            compCount.add(entry.getValue());
            String[] parts = entry.getKey().toString().split("-");
            tmpdata.put("name", parts[1]);
            tmpdata.put("data", new LinkedList<Object>(compCount));
            HashMap<String, Object> ctypeCountMap = new LinkedHashMap<>();
            ctypeCountMap.putAll(tmpdata);
            dataHolder.add(ctypeCountMap);
            index = 0;
            compCount.clear();
            tmpdata.clear();
        }
    }
    topFiveCompDataHolder.put("year", dataHolderString);
    topFiveCompDataHolder.put("series", dataHolder);

    return topFiveCompDataHolder;
}

From source file:io.instacount.appengine.counter.service.ShardedCounterServiceImpl.java

@Override
public Counter createCounter(final String counterName) {
    final CounterData counterData = this.createCounterData(counterName);
    // No need to call call #getCounter here. The count will be zero, and so we don't need to perform any cache
    // warm-up (this will be performed on the first read) and performing #getCounter here will load all counter
    // shards, which is wasteful since they're likely 0. This will be extra wasteful for large-shard counters.
    return new CounterBuilder(counterData).withCount(BigInteger.ZERO).build();
}

From source file:com.ar.dev.tierra.api.controller.DetalleFacturaController.java

@RequestMapping(value = "/delete/discount", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteDiscount(@RequestParam("dni") int dni, @RequestParam("password") String password,
        @RequestBody DetalleFactura detalleFactura) {
    Usuarios user = facadeService.getUsuariosDAO().findUsuarioByDNI(dni);
    boolean permiso = passwordEncoder.matches(password, user.getPassword());
    if (permiso) {
        if (user.getRoles().getIdRol() == 1 || user.getRoles().getIdRol() == 6) {
            detalleFactura.setDescuentoDetalle(BigDecimal.ZERO);
            BigDecimal monto = detalleFactura.getProducto().getPrecioVenta()
                    .multiply(BigDecimal.valueOf(detalleFactura.getCantidadDetalle()));
            detalleFactura.setTotalDetalle(monto);
            facadeService.getDetalleFacturaDAO().update(detalleFactura);
            List<DetalleFactura> detallesFactura = facadeService.getDetalleFacturaDAO()
                    .facturaDetalle(detalleFactura.getFactura().getIdFactura());
            BigDecimal sumMonto = new BigDecimal(BigInteger.ZERO);
            Factura factura = facadeService.getFacturaDAO()
                    .searchById(detalleFactura.getFactura().getIdFactura());
            for (DetalleFactura detailList : detallesFactura) {
                sumMonto = sumMonto.add(detailList.getTotalDetalle());
            }/*from  ww  w .j av a2 s.co  m*/
            factura.setTotal(sumMonto);
            factura.setFechaModificacion(new Date());
            factura.setUsuarioModificacion(user.getIdUsuario());
            facadeService.getFacturaDAO().update(factura);
            JsonResponse msg = new JsonResponse("Success", "Descuento eliminado con exito.");
            return new ResponseEntity<>(msg, HttpStatus.OK);
        } else {
            JsonResponse msg = new JsonResponse("Error",
                    "No tienes los permisos necesarios para realizar esta operacion.");
            return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST);
        }
    } else {
        JsonResponse msg = new JsonResponse("Error",
                "No tienes los permisos necesarios para realizar esta operacion.");
        return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST);
    }
}

From source file:org.openhim.mediator.denormalization.ATNAAuditingActor.java

protected String generateForPNRResponse(ATNAAudit audit) throws JAXBException {
    AuditMessage res = new AuditMessage();

    EventIdentificationType eid = new EventIdentificationType();
    eid.setEventID(ATNAUtil.buildCodedValueType("DCM", "110106", "Export"));
    eid.setEventActionCode("R");
    eid.setEventDateTime(ATNAUtil.newXMLGregorianCalendar());
    eid.getEventTypeCode().add(/*from  w ww . jav a 2 s .  co  m*/
            ATNAUtil.buildCodedValueType("IHE Transactions", "ITI-41", "Provide and Register Document Set-b"));
    eid.setEventOutcomeIndicator(audit.getOutcome() ? BigInteger.ZERO : new BigInteger("4"));
    res.setEventIdentification(eid);

    String xdsRepositoryHost = config.getProperty("xds.repository.host");
    res.getActiveParticipant().add(ATNAUtil.buildActiveParticipant(ATNAUtil.WSA_REPLYTO_ANON,
            ATNAUtil.getProcessID(), true, ATNAUtil.getHostIP(), (short) 2, "DCM", "110153", "Source"));
    res.getActiveParticipant().add(ATNAUtil.buildActiveParticipant(xdsRepositoryHost, false, xdsRepositoryHost,
            (short) 1, "DCM", "110152", "Destination"));

    res.getAuditSourceIdentification().add(ATNAUtil.buildAuditSource("openhim"));

    // Only one is allowed
    Identifier id = audit.getParticipantIdentifiers().get(0);
    if (id != null) {
        res.getParticipantObjectIdentification().add(ATNAUtil.buildParticipantObjectIdentificationType(
                id.toCX(), (short) 1, (short) 1, "RFC-3881", "2", "PatientNumber", null));
    }

    res.getParticipantObjectIdentification()
            .add(ATNAUtil.buildParticipantObjectIdentificationType(audit.getUniqueId(), (short) 2, (short) 20,
                    "IHE XDS Metadata", "urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd",
                    "submission set classificationNode", audit.getMessage()));

    return ATNAUtil.marshallATNAObject(res);
}

From source file:com.google.uzaygezen.core.hbase.HBaseQueryTest.java

private List<FilteredIndexRange<Object, BigIntegerRange>> query(MockHTable table, List<BigIntegerRange> region,
        SpaceFillingCurve sfc, int maxRanges,
        Map<Pow2LengthBitSetRange, NodeValue<BigIntegerContent>> rolledupMap) {
    List<? extends List<BigIntegerRange>> x = ImmutableList.of(region);
    BigIntegerContent zero = new BigIntegerContent(BigInteger.ZERO);
    Object filter = "";
    BigIntegerContent one = new BigIntegerContent(BigInteger.ONE);
    RegionInspector<Object, BigIntegerContent> simpleRegionInspector = SimpleRegionInspector.create(x, one,
            Functions.constant(filter), BigIntegerRangeHome.INSTANCE, zero);
    final RegionInspector<Object, BigIntegerContent> regionInspector;
    if (rolledupMap == null) {
        regionInspector = simpleRegionInspector;
    } else {/*from ww  w . ja v  a 2  s  .c o m*/
        regionInspector = MapRegionInspector.create(rolledupMap, simpleRegionInspector, false, zero, one);
    }
    // Not using using sub-ranges here.
    PlainFilterCombiner<Object, BigInteger, BigIntegerContent, BigIntegerRange> combiner = new PlainFilterCombiner<>(
            filter);
    QueryBuilder<Object, BigIntegerRange> queryBuilder = BacktrackingQueryBuilder.create(regionInspector,
            combiner, maxRanges, true, BigIntegerRangeHome.INSTANCE, zero);
    sfc.accept(new ZoomingSpaceVisitorAdapter(sfc, queryBuilder));
    Query<Object, BigIntegerRange> query = queryBuilder.get();
    return query.getFilteredIndexRanges();
}

From source file:com.kactech.otj.Utils.java

public static BigInteger base62Decode(final String string) {
    if (string.length() == 0) {
        throw new IllegalArgumentException("string must not be empty");
    }/*  ww w .j  a va  2 s.  co m*/
    BigInteger result = BigInteger.ZERO;
    int digits = string.length();
    for (int index = 0; index < digits; index++) {
        int digit = B62_DIGITS.indexOf(string.charAt(digits - index - 1));
        result = result.add(BigInteger.valueOf(digit).multiply(B62_BASE.pow(index)));
    }
    return result;
}

From source file:jp.aegif.nemaki.cmis.aspect.impl.CompileServiceImpl.java

@Override
public <T extends Content> ObjectList compileObjectDataList(CallContext callContext, String repositoryId,
        List<T> contents, String filter, Boolean includeAllowableActions,
        IncludeRelationships includeRelationships, String renditionFilter, Boolean includeAcl,
        BigInteger maxItems, BigInteger skipCount, boolean folderOnly, String orderBy) {
    if (CollectionUtils.isEmpty(contents)) {
        //Empty list
        ObjectListImpl list = new ObjectListImpl();
        list.setObjects(new ArrayList<ObjectData>());
        list.setNumItems(BigInteger.ZERO);
        list.setHasMoreItems(false);//from w  ww.j  a va 2s  .  com
        return list;
    } else {
        List<ObjectData> ods = new ArrayList<ObjectData>();
        for (T c : contents) {
            //Filter by folderOnly
            if (folderOnly && !c.isFolder()) {
                continue;
            }

            //Get each ObjectData
            ObjectData _od;
            ObjectData v = nemakiCachePool.get(repositoryId).getObjectDataCache().get(c.getId());
            if (v == null) {
                _od = compileObjectDataWithFullAttributes(callContext, repositoryId, c);
            } else {
                _od = (ObjectDataImpl) v;
            }

            ObjectData od = filterObjectDataInList(callContext, repositoryId, _od, filter,
                    includeAllowableActions, includeRelationships, renditionFilter, includeAcl);
            if (od != null) {
                ods.add(od);
            }
        }

        //Sort
        sortUtil.sort(repositoryId, ods, orderBy);

        //Set metadata
        ObjectListImpl list = new ObjectListImpl();
        Integer _skipCount = skipCount.intValue();
        Integer _maxItems = maxItems.intValue();

        if (_skipCount >= ods.size()) {
            list.setHasMoreItems(false);
            list.setObjects(new ArrayList<ObjectData>());
        } else {
            //hasMoreItems
            Boolean hasMoreItems = _skipCount + _maxItems < ods.size();
            list.setHasMoreItems(hasMoreItems);
            //paged list
            Integer toIndex = Math.min(_skipCount + _maxItems, ods.size());
            list.setObjects(new ArrayList<>(ods.subList(_skipCount, toIndex)));
        }
        //totalNumItem
        list.setNumItems(BigInteger.valueOf(ods.size()));

        return list;
    }
}

From source file:org.estatio.api.Api.java

@ActionSemantics(Of.IDEMPOTENT)
public void putProperty(@Named("reference") final String reference, @Named("name") final String name,
        @Named("countryCode") final String countryCode, @Named("city") final String city,
        @Named("type") final String type, @Named("acquireDate") @Optional final LocalDate acquireDate,
        @Named("disposalDate") @Optional final LocalDate disposalDate,
        @Named("openingDate") @Optional final LocalDate openingDate,
        @Named("ownerReference") @Optional final String ownerReference,
        @Named("numeratorFormat") @Optional final String numeratorFormat,
        @Named("externalReference") @Optional final String externalReference,
        @Named("atPath") final String countryAtPath) {
    final Party owner = fetchParty(ownerReference);
    final Country country = fetchCountry(countryCode);
    final ApplicationTenancy countryAppTenancy = fetchApplicationTenancy(countryAtPath);
    final Property property = fetchProperty(reference, countryAppTenancy, true);
    property.setName(name);//from   ww  w .  j a v a2s.  c  om
    property.setCountry(country);
    property.setCity(city);
    property.setType(PropertyType.valueOf(type));
    property.setAcquireDate(acquireDate);
    property.setDisposalDate(disposalDate);
    property.setOpeningDate(openingDate);
    property.setExternalReference(externalReference);
    property.addRoleIfDoesNotExist(owner, FixedAssetRoleType.PROPERTY_OWNER, null, null);
    if (numeratorFormat != null)
        collectionNumerators.createInvoiceNumberNumerator(property, numeratorFormat, BigInteger.ZERO);
}