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:gov.nih.nci.cagrid.gts.service.ProxyPathValidator.java

protected int getCAPathConstraint(TBSCertificateStructure crt) throws IOException {
    X509Extensions extensions = crt.getExtensions();
    if (extensions == null) {
        return -1;
    }/*  w  ww  . jav a2 s  .c om*/
    X509Extension ext = extensions.getExtension(X509Extensions.BasicConstraints);
    if (ext != null) {
        BasicConstraints basicExt = BouncyCastleUtil.getBasicConstraints(ext);
        if (basicExt.isCA()) {
            BigInteger pathLen = basicExt.getPathLenConstraint();
            return (pathLen == null) ? Integer.MAX_VALUE : pathLen.intValue();
        } else {
            return -1;
        }
    }
    return -1;
}

From source file:org.emmanet.controllers.requestsUpdateInterfaceFormController.java

@Override
protected Object formBackingObject(HttpServletRequest request) {

    if (request.getParameter("Edit") != null) {

        subFile = "req_";
        setBaseURL((String) this.getBaseURL());
        wrd = wr.getReqByID(request.getParameter("Edit").toString());
        String date = wrd.getTimestamp();

        HttpSession session = request.getSession(true);
        session.setAttribute("BASEURL", BASEURL);

        session.setAttribute("reqID", wrd.getId_req());

        StrainsManager sm = new StrainsManager();
        int str_id_str = Integer.parseInt(request.getParameter("strainID").toString());
        ProjectsStrainsDAO psd = new ProjectsStrainsDAO();
        psd = sm.getProjectsByID(str_id_str);
        session.setAttribute("projectID", psd.getProject_id());
        //changes made to use rtools id=9 to determine eucomm strains as project id (3 for eucomm) is now used differently
        BigInteger iRTOOLS = sm.getRToolsCount(str_id_str);
        StrainsDAO sd = new StrainsDAO();
        RToolsDAO rtd = new RToolsDAO();
        int irtoolsID = 0;
        int iRtools = iRTOOLS.intValue();
        if (iRtools > 1) {

            List dupRtools = sm.getRToolsByID(str_id_str);
            String arr = dupRtools.toArray().toString();
            //  Object[] obj = (Object[]) dupRtools.get(0);
            System.out.println("RTOOLS LIST SIZE IS " + dupRtools.size());
            for (Iterator it = dupRtools.listIterator(); it.hasNext();) {
                // Object[] obj = (Object[]) it.next();
                RToolsDAO returnRTD = (RToolsDAO) it.next();
                // Object obj = (Object) it.next();

                irtoolsID = returnRTD.getRtls_id();
            }/*from  www  .jav a  2  s  . com*/

            // rtd=sm.get()RTOOLSByID(irtoolsID);

        } else if (iRtools == 1) {
            List rtool = sm.getRToolsByID(str_id_str);
            for (Iterator it = rtool.listIterator(); it.hasNext();) {
                rtd = (RToolsDAO) it.next();
            }
            //TODO SCREEN FOR STRAINS WITH NO ENTRY IN RTOOLS_STRAINS TABLE
            irtoolsID = rtd.getRtls_id();

        } else {
            irtoolsID = 8;
        }

        sd = sm.getStrainByID(str_id_str);
        if (sd.getRtoolsDAO().size() != 0) {
            System.out.println("project/rtools id=" + rtd.getRtls_id());
            session.setAttribute("projectID", irtoolsID);//rtd.getRtls_id());
        } else {
            session.setAttribute("projectID", 8);
        }
        return wr.getReqByID(request.getParameter("Edit").toString());
    }

    return wr;
}

From source file:com.ephesoft.dcma.tablefinder.share.TableRowFinderUtility.java

/**
 * Algorithm for comparison: if old span's y coordinate's mid lies within range of new span's y coordinates or not.
 * /*from w  w w .  j  av  a2  s. co m*/
 * @param spanList {@link List}<{@link Span}>
 * @param span {@link Span}
 * @return boolean
 */
private static boolean isSameLineSpan(final List<Span> spanList, final Span span) {
    final Span lastSpan = spanList.get(spanList.size() - 1);
    final BigInteger s1Y0 = span.getCoordinates().getY0();
    final BigInteger s1Y1 = span.getCoordinates().getY1();
    final BigInteger s2Y0 = lastSpan.getCoordinates().getY0();
    final BigInteger s2Y1 = lastSpan.getCoordinates().getY1();
    final BigInteger s2Y = s2Y1.add(s2Y0);
    final int oldSpanMid = s2Y.intValue() / 2;
    boolean isSameLineSpan = oldSpanMid >= s1Y0.intValue() && oldSpanMid <= s1Y1.intValue();
    return isSameLineSpan;
}

From source file:org.openxdata.server.service.impl.FormServiceImpl.java

@Override
@Transactional(readOnly = true)//from w ww . j  av a 2  s  . c om
public ExportedFormDataList getFormDataList(String formBinding, String[] questionBindings, int offset,
        int limit, String sortField, boolean ascending) {
    // find out the total size
    BigInteger count = studyDAO.getNumberOfResponses(formBinding);
    log.debug("total number of responses " + count + " for form " + formBinding);

    // create sql statement
    List<Object[]> data = studyDAO.getResponseData(formBinding, questionBindings, offset, limit, sortField,
            ascending);
    log.debug("loading exported form data. #items:" + data.size());

    // process results
    ExportedFormDataList dataList = new ExportedFormDataList();
    if (data != null) {
        dataList.setFromIndex(offset);
        int requestedToIndex = offset + limit;
        dataList.setToIndex(requestedToIndex > data.size() ? data.size() : requestedToIndex);
        dataList.setTotalSize(count.intValue());
        List<ExportedFormData> exportedFormData = getExportedFormData(questionBindings, data);
        dataList.setExportedFormData(exportedFormData);
    }

    return dataList;
}

From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.TestWfsSource.java

/**
 * Given 10 features (and metacards) exist that match search criteria, since page size=4 and
 * startIndex=0, should get 4 results back - metacards 1 thru 4.
 *
 * @throws WfsException,                     SecurityServiceException
 * @throws TransformerConfigurationException
 * @throws UnsupportedQueryException/*from  www  .ja v a 2s  . co  m*/
 */
@Test
public void testPagingStartIndexZero() throws WfsException, SecurityServiceException,
        TransformerConfigurationException, UnsupportedQueryException {

    //Setup
    int pageSize = 4;
    int startIndex = 0;

    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(),
            Wfs20Constants.EPSG_4326_URN, 10, false);
    Filter filter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
    Query query = new QueryImpl(filter, startIndex, pageSize, null, false, 0);

    //Execute
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    BigInteger startIndexGetFeature = featureType.getStartIndex();
    BigInteger countGetFeature = featureType.getCount();

    //Verify
    assertThat(countGetFeature.intValue(), is(pageSize));
    assertThat(startIndexGetFeature.intValue(), is(startIndex));
}

From source file:org.alfresco.wcm.client.impl.UgcServiceCmisImpl.java

private VisitorFeedbackImpl buildFeedbackObject(QueryResult queryResult) {
    BigInteger rating = (BigInteger) queryResult.getPropertyValueById(PROP_RATING);
    VisitorFeedbackImpl feedback = buildFeedbackObject((String) queryResult.getPropertyValueById(PROP_ARTICLE),
            (String) queryResult.getPropertyValueById(PROP_NAME),
            (String) queryResult.getPropertyValueById(PROP_EMAIL),
            (String) queryResult.getPropertyValueById(PROP_WEBSITE),
            (String) queryResult.getPropertyValueById(PROP_FEEDBACK_TYPE),
            (String) queryResult.getPropertyValueById(PROP_SUBJECT),
            (String) queryResult.getPropertyValueById(PROP_COMMENT),
            (Boolean) queryResult.getPropertyValueById(PROP_COMMENT_FLAGGED),
            rating == null ? null : rating.intValue());

    feedback.setId((String) queryResult.getPropertyValueById(PropertyIds.OBJECT_ID));
    feedback.setPostTime(((Calendar) queryResult.getPropertyValueById(PropertyIds.CREATION_DATE)).getTime());
    return feedback;
}

From source file:org.deegree.services.wps.provider.jrxml.contentprovider.map.MapContentProvider.java

List<OrderedDatasource<?>> anaylizeRequestOrder(List<AbstractDatasourceType> datasources) {

    List<OrderedDatasource<?>> orderedDatasources = new ArrayList<OrderedDatasource<?>>();
    for (AbstractDatasourceType datasource : datasources) {

        if (datasource instanceof WMSDatasource) {
            WMSDatasource wmsDatasource = (WMSDatasource) datasource;
            List<Layer> layers = wmsDatasource.getLayers().getLayer();
            int index = 0;
            for (Layer layer : layers) {
                BigInteger position = layer.getPosition();
                if (position != null) {
                    int intPos = position.intValue();

                    WMSOrderedDatasource contains = contains(orderedDatasources, wmsDatasource, intPos);
                    // splitten! wenn position zwischen zwei
                    if (contains != null) {
                        List<Layer> orderedLayers = contains.layers;
                        int i = 0;
                        for (Layer orderedLayer : orderedLayers) {
                            if (orderedLayer.getPosition().intValue() < intPos) {
                                i++;//from   w  ww.  ja  va2  s  . c om
                            }
                        }
                        contains.layers.add(i, layer);
                        contains.min = contains.min < intPos ? contains.min : intPos;
                        contains.max = contains.max > intPos ? contains.max : intPos;
                    } else {
                        List<Layer> newLayerList = new ArrayList<Layer>();
                        newLayerList.add(layer);
                        int indexToAdd = getIndexToAdd(orderedDatasources, intPos);
                        orderedDatasources.add(indexToAdd,
                                new WMSOrderedDatasource(wmsDatasource, newLayerList, intPos, intPos));
                    }
                } else {
                    WMSOrderedDatasource contains = contains(orderedDatasources, wmsDatasource);
                    if (contains != null) {
                        contains.layers.add(layer);
                    } else {
                        List<Layer> newLayerList = new ArrayList<Layer>();
                        newLayerList.add(layer);
                        orderedDatasources.add(new WMSOrderedDatasource(wmsDatasource, newLayerList));
                    }
                }
                index++;
            }
        } else if (datasource instanceof WFSDatasource) {
            WFSDatasource wfsDatasource = (WFSDatasource) datasource;
            WFSOrderedDatasource newDatasource = new WFSOrderedDatasource(wfsDatasource);
            if (wfsDatasource.getPosition() != null) {
                int indexToAdd = getIndexToAdd(orderedDatasources, wfsDatasource.getPosition().intValue());
                orderedDatasources.add(indexToAdd, newDatasource);
            } else {
                orderedDatasources.add(newDatasource);
            }

        }
    }
    return orderedDatasources;
}

From source file:com.ephesoft.dcma.tablefinder.share.TableRowFinderUtility.java

/**
 * Gets sorted list of spans of the page.
 * /*from ww  w .  j  a  v  a  2  s.c  o  m*/
 * @param spans {@link Spans}
 * @return {@link List}<{@link Span}>
 */
private static List<Span> getSortedSpanList(final Spans spans) {
    final List<Span> spanList = spans.getSpan();
    final Set<Span> set = new TreeSet<Span>(new Comparator<Span>() {

        public int compare(final Span firstSpan, final Span secSpan) {
            BigInteger s1Y0 = firstSpan.getCoordinates().getY0();
            BigInteger s1Y1 = firstSpan.getCoordinates().getY1();
            final BigInteger s2Y0 = secSpan.getCoordinates().getY0();
            final BigInteger s2Y1 = secSpan.getCoordinates().getY1();
            int halfOfSecSpan = (s2Y1.intValue() - s2Y0.intValue()) / 2;
            int y1 = s2Y1.intValue() + halfOfSecSpan;
            int y0 = s2Y0.intValue() - halfOfSecSpan;

            // following if else code is to handle abnormal(out of synch) value y0 or y1 coordinate of new span.
            if (isApproxEqual(s1Y0.intValue(), s2Y0.intValue()) && s1Y1.intValue() > y1) {
                s1Y1 = BigInteger.valueOf(y1);
                firstSpan.getCoordinates().setY1(s1Y1);
            } else if (isApproxEqual(s1Y1.intValue(), s2Y1.intValue()) && s1Y0.intValue() < y0) {
                s1Y0 = BigInteger.valueOf(y0);
                firstSpan.getCoordinates().setY0(s1Y0);
            }
            final BigInteger s1Y = s1Y1.add(s1Y0);
            final BigInteger s2Y = s2Y1.add(s2Y0);

            // calculating middle of old span.
            final int oldSpanMid = s2Y.intValue() / 2;
            int returnValue = 0;

            // if old span's y coordinate's middle lies within range of new span's y coordinates or not. if true, the two spans
            // belong to same line compare them further on their x coordinates, else they belong to two different lines.
            if (oldSpanMid >= s1Y0.intValue() && oldSpanMid <= s1Y1.intValue()) {
                final BigInteger s1X1 = firstSpan.getCoordinates().getX1();
                final BigInteger s2X1 = secSpan.getCoordinates().getX1();
                returnValue = s1X1.compareTo(s2X1);
            } else {
                returnValue = s1Y.compareTo(s2Y);
            }
            return returnValue;
        }

    });

    set.addAll(spanList);

    final List<Span> linkedList = new LinkedList<Span>();
    linkedList.addAll(set);

    // TODO add the clear method to remove all elements of set since it not required after adding it to linked list.
    // set.clear();

    return linkedList;
}

From source file:com.zl.bgec.basicapi.shop.service.impl.ShopServiceImpl.java

@Override
@Transactional(readOnly = true)// ww  w  .j av  a  2s .com
public PageFinder<Map<String, Object>> queryShopSummary(ShopVo shopVo) throws Exception {
    int pageNo = shopVo.getPageNo();
    int pageSize = shopVo.getPageSize();
    String shopType = shopVo.getShopTypeNo();
    String shopNo = shopVo.getShopNo();
    String sql = "select tsi.shop_no shopNo,tsi.shop_summary shopSummary,tsi.shop_name shopName from tbl_shop_info tsi where 1=1 ";
    String sqlCount = "select count(*) from tbl_shop_info tsi where 1=1 ";
    if (shopType != null && !shopType.equals("")) {
        sql = sql + " and tsi.shop_Type_No=:shopTypeNo ";
        sqlCount = sqlCount + " and tsi.shop_Type_No=:shopTypeNo ";
    }
    if (shopNo != null && !shopNo.equals("")) {
        sql = sql + " and tsi.shop_No=:shopNo ";
        sqlCount = sqlCount + " and tsi.shop_No=:shopNo ";
    }
    Query query = shopDao.createSQLQuery(sql);
    Query queryCount = shopDao.createSQLQuery(sqlCount.toString());
    if (shopType != null && !shopType.equals("")) {
        query.setParameter("shopTypeNo", shopType);
        queryCount.setParameter("shopTypeNo", shopType);
    }
    if (shopNo != null && !shopNo.equals("")) {
        query.setParameter("shopNo", shopNo);
        queryCount.setParameter("shopNo", shopNo);
    }
    query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    BigInteger totalRows = (BigInteger) queryCount.uniqueResult();
    if (totalRows.intValue() == 0) {
        return new PageFinder<Map<String, Object>>(pageNo, pageSize, 0);
    }
    PageFinder<Map<String, Object>> pageFinder = new PageFinder<Map<String, Object>>(pageNo, pageSize,
            totalRows.intValue());
    query.setMaxResults(pageFinder.getPageSize());
    query.setFirstResult(pageFinder.getStartOfPage());
    pageFinder.setData(query.list());
    return pageFinder;
}

From source file:com.zl.bgec.basicapi.shop.service.impl.ShopServiceImpl.java

@Override
@Transactional(readOnly = true)//from ww  w. j  av a2s.co  m
public PageFinder<Map<String, Object>> pagedProduct(Map<String, String> map) throws Exception {
    String shopNo = String.valueOf(map.get("shopNo"));
    int pageNo = Integer.parseInt(map.get("pageNo"));
    int pageSize = Integer.parseInt(map.get("pageSize"));
    String catNo = String.valueOf(map.get("catNo") == null ? "" : map.get("catNo"));
    String sqlProduct = "select IF(tp.prod_name is null,'',tp.prod_name) prodName,"
            + " IF(tp.default_pic is null,'',tp.default_pic) prodPic," + " tp.price prodPrice,"
            + " tp.prod_no prodNo," + " ifnull(tp.stock,0) stock,"
            + " ifnull(tp.stock_preemption,0) stockPreemption,"
            + " IF(tp.sell_num is null,0,tp.sell_num) sellNum ," + " tc.is_recommend isRecommend "
            + " from tbl_product tp left join tbl_commodity tc on tc.commo_no = tp.commo_no"
            + " where tc.seller_no = :shopNo and tc.publish_state ='1' and tp.is_groupbuy !='2' ";
    if (catNo != null && !catNo.isEmpty()) {
        sqlProduct = sqlProduct + " and tc.cat_no=:catNo ";
    }
    sqlProduct = sqlProduct
            + " and tp.delete_flag ='0' order by ifnull(tp.sort,2147483647) asc, tp.sell_num desc,tc.publish_time desc";
    String countSql = "select count(*) "
            + " from tbl_product tp left join tbl_commodity tc on tc.commo_no = tp.commo_no"
            + " where tc.seller_no = :shopNo and tc.publish_state ='1' and tp.delete_flag ='0' ";
    if (catNo != null && !catNo.isEmpty()) {
        countSql = countSql + " and tc.cat_no=:catNo ";
    }
    Query query = shopDao.createSQLQuery(sqlProduct);
    query = productDao.createSQLQuery(sqlProduct);
    query.setParameter("shopNo", shopNo);
    if (catNo != null && !catNo.isEmpty()) {
        query.setParameter("catNo", catNo);
    }
    query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    Query queryCount = shopDao.createSQLQuery(countSql.toString());
    queryCount.setParameter("shopNo", shopNo);
    if (catNo != null && !catNo.isEmpty()) {
        queryCount.setParameter("catNo", catNo);
    }
    BigInteger totalRows = (BigInteger) queryCount.uniqueResult();
    if (totalRows.intValue() == 0) {
        return new PageFinder<Map<String, Object>>(pageNo, pageSize, 0);
    }
    PageFinder<Map<String, Object>> pageFinder = new PageFinder<Map<String, Object>>(pageNo, pageSize,
            totalRows.intValue());
    query.setMaxResults(pageFinder.getPageSize());
    query.setFirstResult(pageFinder.getStartOfPage());
    pageFinder.setData(query.list());
    return pageFinder;
}