Example usage for java.math BigInteger intValue

List of usage examples for java.math BigInteger intValue

Introduction

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

Prototype

public int intValue() 

Source Link

Document

Converts this BigInteger to an int .

Usage

From source file:schemareader.Element.java

/**
 * Default Element constructor/* w  w w . j a va  2  s .  c om*/
 *
 * @param element Element as a <code>XSElementDecl</code>
 * @param path Path as a <code>String</code>
 * @param minOccurs Minimum occurences as a <code>BigInteger</code>
 * @param maxOccurs Maximum occurences as a <code>BigInteger</code>
 */
public Element(XSElementDecl element, String path, BigInteger minOccurs, BigInteger maxOccurs) {

    this.name = path.substring(path.lastIndexOf("/") + 1, path.length());
    String type = element.getType().getName();

    if (type == null) {
        this.type = element.getType().getBaseType().getName();
    } else {

        this.type = type;

    }
    this.fullPath = path;
    this.minOccurs = minOccurs.intValue();
    this.maxOccurs = maxOccurs.intValue();

}

From source file:org.openvpms.component.system.common.jxpath.OpenVPMSTypeConverter.java

/**
 * Convert a {@link BigInteger} to another type
 * /*from w  ww. ja va  2 s.  co m*/
 * @param type
 *            the class to convert too
 * @param value
 *            the value to convert
 * @return Number
 *            the converted number of null.
 *            
 */
protected Number allocateNumber(Class type, BigInteger value) {
    if (type == Byte.class || type == byte.class) {
        return new Byte(value.byteValue());
    }
    if (type == Short.class || type == short.class) {
        return new Short(value.shortValue());
    }
    if (type == Integer.class || type == int.class) {
        return new Integer(value.intValue());
    }
    if (type == Long.class || type == long.class) {
        return new Long(value.longValue());
    }
    if (type == Float.class || type == float.class) {
        return new Float(value.floatValue());
    }
    if (type == Double.class || type == double.class) {
        return new Double(value.doubleValue());
    }
    if (type == BigDecimal.class) {
        return new BigDecimal(value);
    }
    if (type == BigInteger.class) {
        return value;
    }

    return null;
}

From source file:com.tremolosecurity.proxy.filter.PostProcess.java

public CloseableHttpClient getHttp(String finalURL, HttpServletRequest request, ConfigManager cfgMgr) {
    HttpSession session = request.getSession();
    PoolingHttpClientConnectionManager phcm = (PoolingHttpClientConnectionManager) session
            .getAttribute("TREMOLO_HTTP_POOL");
    CloseableHttpClient http = (CloseableHttpClient) session.getAttribute("TREMOLO_HTTP_CLIENT");
    if (http == null) {
        //create a new connection manager and client
        phcm = new PoolingHttpClientConnectionManager(cfgMgr.getHttpClientSocketRegistry());
        BigInteger num = cfgMgr.getCfg().getThreadsPerRoute();
        if (num == null) {
            phcm.setDefaultMaxPerRoute(6);
        } else {/*w  ww  .j  av a 2 s .co  m*/
            phcm.setDefaultMaxPerRoute(num.intValue());
        }
        phcm.setDefaultSocketConfig(SocketConfig.custom().setSoKeepAlive(true).build());
        http = HttpClients.custom().setConnectionManager(phcm)
                .setDefaultRequestConfig(cfgMgr.getGlobalHttpClientConfig()).build();

        session.setAttribute("TREMOLO_HTTP_POOL", phcm);
        session.setAttribute("TREMOLO_HTTP_CLIENT", http);

        LogoutUtil.insertFirstLogoutHandler(request, new CloseHttpConnectionsOnLogout(http, phcm));

    }

    return http;
}

From source file:eu.europa.esig.dss.tsl.service.TSLParser.java

private int getSequenceNumber(TrustStatusListType tsl) {
    BigInteger tslSequenceNumber = tsl.getSchemeInformation().getTSLSequenceNumber();
    if (tslSequenceNumber != null) {
        return tslSequenceNumber.intValue();
    }//from  w  w w.  jav  a2s . c o m
    return -1;
}

From source file:at.tfr.securefs.ui.CopyFilesServiceBean.java

@Audit
@RolesAllowed(Role.ADMIN)/*from ww w  .java  2 s  . c o  m*/
public void runCombine() {
    if (processFilesData.isProcessActive()) {
        throw new SecureFSError("Process already active!");
    }

    combined = false;
    ValidationData validationData = processFilesData.getValidationData();
    List<UiShare> badShares = validationData.getUiShares().stream()
            .filter(s -> s.getIndex() <= 0 || s.getShare() == null).collect(Collectors.toList());
    if (!badShares.isEmpty()) {
        throw new SecureFSError("Found " + badShares.size() + " invalid Shares");
    }
    List<UiShare> shares = validationData.getUiShares();
    BigInteger tmpSecret = new Shamir().combine(validationData.getNrOfShares(), validationData.getThreshold(),
            validationData.getModulus(), shares);
    if (tmpSecret == null || tmpSecret.intValue() == 0) {
        throw new SecureFSError("Generated invalid Secret");
    }
    newSecret = tmpSecret;
    combined = true;
}

From source file:org.trnltk.numeral.DigitsToTextConverter.java

private String convertNaturalNumberToWords(BigInteger naturalNumber) {
    Validate.isTrue(naturalNumber.compareTo(ZERO) >= 0);
    Validate.isTrue(naturalNumber.compareTo(MAX_NATURAL_NUMBER_SUPPORTED) <= 0, "Given number " + naturalNumber
            + " is larger than maximum supported natural number " + MAX_NATURAL_NUMBER_SUPPORTED);

    StringBuilder result = new StringBuilder();

    if (naturalNumber.compareTo(BigInteger.TEN) < 0) {
        result.append(NUMERAL_SYMBOL_NAMES.get(naturalNumber.intValue()));

    } else if (naturalNumber.compareTo(ONE_HUNDRED) < 0) {
        final BigInteger tensDigit = naturalNumber.divide(TEN);
        final BigInteger onesDigit = naturalNumber.mod(TEN);
        final String strTensDigit = TENS_MULTIPLES_NAMES.get(tensDigit.intValue());
        final String strOnesDigit = onesDigit.compareTo(ZERO) > 0 ? convertNaturalNumberToWords(onesDigit)
                : StringUtils.EMPTY;//www.jav  a2s .  c o  m
        result.append(strTensDigit).append(" ").append(strOnesDigit);

    } else if (naturalNumber.compareTo(ONE_THOUSAND) < 0) {
        final BigInteger hundredsDigit = naturalNumber.divide(ONE_HUNDRED);
        final BigInteger rest = naturalNumber.mod(ONE_HUNDRED);
        final String strHundredsDigit;
        if (hundredsDigit.equals(ZERO)) {
            strHundredsDigit = StringUtils.EMPTY;
        } else if (hundredsDigit.equals(ONE)) {
            strHundredsDigit = StringUtils.EMPTY;
        } else {
            strHundredsDigit = convertNaturalNumberToWords(hundredsDigit);
        }

        final String restStr = rest.compareTo(ZERO) > 0 ? convertNaturalNumberToWords(rest) : StringUtils.EMPTY;

        result.append(strHundredsDigit).append(" ").append(HUNDRED_NAME).append(" ").append(restStr);

    } else {
        int mostSignificantGroupBase = this.findMostSignificantGroupBase(naturalNumber);
        for (int i = mostSignificantGroupBase / 3; i > 0; i--) {
            int groupNumber = this.getNthGroupNumber(naturalNumber, i);
            //noinspection StatementWithEmptyBody
            if (groupNumber == 0) {
                // don't write 'sifir milyon'
            } else if (groupNumber == 1 && i == 1) {
                // don't write 'bir bin', but write 'bir milyon'(below)
                result.append(" ").append(THOUSAND_NAME);
            } else {
                final String strGroupNumber = this.convertNaturalNumberToWords(BigInteger.valueOf(groupNumber));
                result.append(" ").append(strGroupNumber).append(" ").append(THOUSAND_POWER_NAMES.get(i));
            }

            result = new StringBuilder(result.toString().trim());
        }

        final BigInteger lastGroupNumber = naturalNumber.mod(ONE_THOUSAND);
        if (lastGroupNumber.compareTo(ZERO) > 0)
            result.append(" ").append(convertNaturalNumberToWords(lastGroupNumber));
    }

    return result.toString().trim();
}

From source file:com.healthcit.cacure.dao.FormElementDao.java

/**
 * @return Next Ord Number in ordered entities.
 *///  ww  w.j  av a 2  s  .  c o m
@Transactional(propagation = Propagation.SUPPORTS)
public Integer calculateNextOrdNumber(Long formId) {
    String sql = "select max(ord +1) from form_element where form_id = :formId";
    Query query = em.createNativeQuery(sql);
    query.setParameter("formId", formId);
    BigInteger o = (BigInteger) query.getSingleResult();
    if (o == null) {
        o = BigInteger.valueOf(1l);
    }

    return o == null ? null : Integer.valueOf(o.intValue());
}

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 www. ja  v a 2s .  co 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:com.sourcesense.opencmis.server.TypeManager.java

/**
 * CMIS getTypesDescendants.//w  w  w  .  ja  v  a2s  .  c o m
 */
public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth,
        Boolean includePropertyDefinitions) {
    List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();

    // check depth
    int d = (depth == null ? -1 : depth.intValue());
    if (d == 0) {
        throw new CmisInvalidArgumentException("Depth must not be 0!");
    }

    // set property definition flag to default value if not set
    boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());

    if (typeId == null) {
        result.add(getTypesDescendants(d, fTypes.get(FOLDER_TYPE_ID), ipd));
        result.add(getTypesDescendants(d, fTypes.get(DOCUMENT_TYPE_ID), ipd));
        // result.add(getTypesDescendants(depth,
        // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions));
        // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID),
        // includePropertyDefinitions));
    } else {
        TypeDefinitionContainer tc = fTypes.get(typeId);
        if (tc != null) {
            result.add(getTypesDescendants(d, tc, ipd));
        }
    }

    return result;
}

From source file:com.siapa.managedbean.DetalleMuestreoManagedBean.java

@Override
public void saveNew(ActionEvent event) {
    DetalleMuestreo detallemuestreo = getDetallemuestreo();
    detallemuestreo.setIdMuestreo(muestreo);
    detallemuestreoService.save(detallemuestreo);
    BigInteger cant = detallemuestreoService.cantidad(muestreo.getIdMuestreo());

    BigDecimal dividir = new BigDecimal(cant);
    List<DetalleMuestreo> q = detallemuestreoService.findAll();
    BigDecimal suma = BigDecimal.ZERO;
    BigDecimal promedio = BigDecimal.ZERO;

    for (DetalleMuestreo detalle : q) {
        if (detalle.getIdMuestreo().getIdMuestreo() == muestreo.getIdMuestreo()) {
            suma = suma.add(detalle.getPesoDetalleMuestreo());
        }/*from ww w .  j  av  a  2  s .c  o  m*/
    }
    int sumaint = suma.intValue();
    int cantint = cant.intValue();
    //int prom=sumaint/cantint;
    //  promedio=new BigDecimal(prom);
    //  System.out.println(prom);
    promedio = suma.divide(dividir);
    Muestreo newMuestreo = getMuestreo();
    newMuestreo.setPesoPromedioMuestreo(suma.divide(dividir));
    //  muestreo.setPesoPromedioMuestreo(suma);
    System.out.println(promedio);
    muestreoService.merge(newMuestreo);

    loadLazyModels();
    FacesContext context = FacesContext.getCurrentInstance();
    context.addMessage(null, new FacesMessage("Successful"));
    try {
        FacesContext context1 = FacesContext.getCurrentInstance();
        context1.getExternalContext().redirect("/siapa/views/detalleMuestreo/index.xhtml");
    } catch (IOException e) {

    }

}