Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

In this page you can find the example usage for java.lang Integer intValue.

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:com.bdx.rainbow.service.jc.impl.DrugService.java

public Drc findDrcFromCFDA(String jgmCode) throws Exception {
    if (StringUtils.isBlank(jgmCode))
        throw new Exception("?");

    Drc drc = selectDrcByCode(jgmCode);/*w  ww. j  a  v a 2s. com*/
    if (drc != null)
        return drc;

    String url = "http://mobile.cfda.gov.cn/services/code/codeQueryCFDA?code=" + jgmCode
            + "&phone=EC03E7D2-7AEF-46AE-AD0D-F6F0B1804A5A";

    logger.debug(url);

    Map<String, String> header = new HashMap<String, String>(0);

    String json = HttpClientUtil.getStringResponse(url, "get", header, null, null, "utf-8");

    //      String json = HttpClientUtil.getStringResponseByProxy(url, "get", header, null, null, "10.10.10.78",8080,"utf-8");
    System.out.println("#########################");
    System.out.println("json" + json);
    System.out.println("#########################");

    if (StringUtils.isBlank(json) == false) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            Map map = (Map) mapper.readValue(json, Map.class);
            Map infoMap = (Map) map.get("info");

            Integer retcode = (Integer) infoMap.get("retcode");

            if (infoMap != null && retcode != null && retcode.intValue() == 0) {
                drc = new Drc();
                drc.setLicenseNumber(
                        infoMap.get("license_number") == null ? "" : infoMap.get("license_number").toString());
                drc.setLastTime(infoMap.get("last_time") == null ? "" : infoMap.get("last_time").toString());
                drc.setFlow(infoMap.get("flow") == null ? "" : infoMap.get("flow").toString());
                drc.setPkgSpec(infoMap.get("pkg_spec") == null ? "" : infoMap.get("pkg_spec").toString());
                drc.setSaleTime(infoMap.get("sale_time") == null ? "" : infoMap.get("sale_time").toString());
                drc.setTitle(infoMap.get("title") == null ? "" : infoMap.get("title").toString());
                drc.setPrepnType(infoMap.get("prepn_type") == null ? "" : infoMap.get("prepn_type").toString());
                drc.setPrepnUnit(infoMap.get("prepn_unit") == null ? "" : infoMap.get("prepn_unit").toString());
                drc.setPkgUnit(infoMap.get("pkg_unit") == null ? "" : infoMap.get("pkg_unit").toString());
                drc.setIssueExpiry(
                        infoMap.get("issue_expiry") == null ? "" : infoMap.get("issue_expiry").toString());
                drc.setFirstQuery(
                        infoMap.get("first_query") == null ? "" : infoMap.get("first_query").toString());
                drc.setLastEnt(infoMap.get("last_ent") == null ? "" : infoMap.get("last_ent").toString());
                drc.setProductionBatch(infoMap.get("production_batch") == null ? ""
                        : infoMap.get("production_batch").toString());
                drc.setStatus(infoMap.get("status") == null ? "" : infoMap.get("status").toString());
                drc.setSaleEn(infoMap.get("sale_ent") == null ? "" : infoMap.get("sale_ent").toString());
                drc.setThumbUrl(infoMap.get("thumb_url") == null ? "" : infoMap.get("thumb_url").toString());
                drc.setJgmCode(jgmCode);
                drc.setProductionDate(infoMap.get("production_date") == null ? ""
                        : infoMap.get("production_date").toString());
                drc.setSpecifications(
                        infoMap.get("specifications") == null ? "" : infoMap.get("specifications").toString());
                drc.setCategory(infoMap.get("category") == null ? "" : infoMap.get("category").toString());
                drc.setManufacturer(
                        infoMap.get("manufacturer") == null ? "" : infoMap.get("manufacturer").toString());
                drc.setExpiryDate(
                        infoMap.get("expiry_date") == null ? "" : infoMap.get("expiry_date").toString());
                logger.debug("drc ?:" + mapper.writeValueAsString(drc));
            }

        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

    }

    if (drc != null) {

        saveDrc(drc);
    }

    return drc;

}

From source file:org.springmodules.validation.bean.conf.loader.xml.handler.SizeRuleElementHandler.java

protected AbstractValidationRule createValidationRule(Element element) {

    String minText = element.getAttribute(MIN_ATTR);
    String maxText = element.getAttribute(MAX_ATTR);

    Integer min = (StringUtils.hasText(minText)) ? new Integer(minText) : null;
    Integer max = (StringUtils.hasText(maxText)) ? new Integer(maxText) : null;

    if (min != null && max != null) {
        return new SizeValidationRule(min.intValue(), max.intValue());
    }/* w  w w. j  a v a  2s. c om*/

    if (min != null) {
        return new MinSizeValidationRule(min.intValue());
    }

    if (max != null) {
        return new MaxSizeValidationRule(max.intValue());
    }

    throw new ValidationConfigurationException(
            "Element '" + ELEMENT_NAME + "' must have either 'min' attribute, 'max' attribute, or both");

}

From source file:com.clustercontrol.sql.util.JdbcDriverUtil.java

public JdbcDriverUtil() {
    m_log.debug("initializing configuration for sql monitoring...");

    //JDBC??//  w ww .  j  a  v  a  2  s.  co m
    Integer count = HinemosPropertyUtil.getHinemosPropertyNum(JDBC_DRIVER, Long.valueOf(3)).intValue();
    m_log.debug("use " + count + " jdbc drivers for sql monitoring.");

    for (int i = 1; i <= count.intValue(); i++) {
        String name = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_NAME + i, "");
        if ("".equals(name)) {
            continue;
        }
        String classname = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_CLASSNAME + i, "");
        if ("".equals(classname)) {
            continue;
        }
        Long loginTimeout = HinemosPropertyUtil.getHinemosPropertyNum(JDBC_DRIVER_LOGINTIMEOUT + i, null);
        if (loginTimeout == null) {
            continue;
        }
        String properties = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_PROPERTIES + i, "");
        // JDBC_DRIVER_PROPERTIES???

        m_log.debug("setting jdbc driver " + i + " : " + name + "(classname = " + classname
                + ", login_timeout = " + loginTimeout + ")");
        jdbcProperties.put(classname,
                new JdbcDriverProperties(classname, name, loginTimeout.intValue(), properties, i));
    }
}

From source file:com.alibaba.sample.petstore.dal.dao.ibatis.IbatisProductItemDao.java

public ProductItem getItemById(String itemId) {
    Integer i = (Integer) getSqlMapClientTemplate().queryForObject("getInventoryQuantity", itemId);
    ProductItem item = (ProductItem) getSqlMapClientTemplate().queryForObject("getItem", itemId);

    if (item != null && i != null) {
        item.setQuantity(i.intValue());
    }/*from  w  ww  .jav a2  s.  c o m*/

    return item;
}

From source file:com.aurel.track.admin.customize.category.filter.execute.FilterLinkAction.java

/**
 * Generates an encoded filter URL/*w  w  w .  ja v  a  2 s  . c  o m*/
 * @return
 */
@Override
public String execute() {
    final String ENCODING_TYPE = "UTF-8";
    CategoryTokens categoryTokens = CategoryTokens.decodeNode(node);
    Integer filterID = categoryTokens.getObjectID();
    String baseUrlReport = Constants.getBaseURL() + "/encodedQuery.action?query=";
    String baseUrlMaven = Constants.getBaseURL() + "/xml/report?query=";
    Map<String, String> mapParams = new HashMap<String, String>();
    mapParams.put("queryID", filterID.toString());
    String queryIDEncoded = ReportQueryBL.a(ReportQueryBL.encodeMapAsUrl(mapParams));
    try {
        queryIDEncoded = URLEncoder.encode(queryIDEncoded, ENCODING_TYPE);
    } catch (UnsupportedEncodingException e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    mapParams.put("user", personBean.getLoginName());
    mapParams.put("pswd", personBean.getPasswd());
    String paramsEncoded = ReportQueryBL.a(ReportQueryBL.encodeMapAsUrl(mapParams));
    try {
        paramsEncoded = URLEncoder.encode(paramsEncoded, ENCODING_TYPE);
    } catch (UnsupportedEncodingException e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    //keep logged
    mapParams.put("keepMeLogged", "true");
    String paramsKeepEncoded = ReportQueryBL.a(ReportQueryBL.encodeMapAsUrl(mapParams));
    try {
        paramsKeepEncoded = URLEncoder.encode(paramsKeepEncoded, ENCODING_TYPE);
    } catch (UnsupportedEncodingException e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    TQueryRepositoryBean queryRepositoryBean = (TQueryRepositoryBean) TreeFilterFacade.getInstance()
            .getByKey(filterID);
    Integer queryType = queryRepositoryBean.getQueryType();
    String filterParams = null;
    if (queryType != null && queryType.intValue() == QUERY_PURPOSE.TREE_FILTER) {
        QNode extendedRootNode = FilterBL.loadNode(queryRepositoryBean);
        FilterUpperTO filterUpperTO = FilterUpperFromQNodeTransformer.getFilterSelectsFromTree(extendedRootNode,
                true, true, personBean, locale, true);
        List<IntegerStringBean> parametrizedFields = FilterSelectsParametersUtil
                .getParameterizedFields(filterUpperTO);
        if (parametrizedFields != null && !parametrizedFields.isEmpty()) {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < parametrizedFields.size(); i++) {
                if (i > 0) {
                    sb.append("&");
                }
                sb.append(parametrizedFields.get(i).getLabel());
                sb.append("=");
            }
            filterParams = sb.toString();
        }
    }
    String encodedFilterUrlIssueNavigatorNoUser = baseUrlReport + queryIDEncoded;
    String encodedFilterUrlIssueNavigator = baseUrlReport + paramsEncoded;
    String encodedFilterUrlIssueNavigatorKeep = baseUrlReport + paramsKeepEncoded;
    String encodedFilterUrlMavenPlugin = baseUrlMaven + paramsEncoded;
    JSONUtility.encodeJSON(servletResponse,
            FilterJSON.getFilterLinkJSON(encodedFilterUrlIssueNavigatorNoUser, encodedFilterUrlIssueNavigator,
                    encodedFilterUrlIssueNavigatorKeep, encodedFilterUrlMavenPlugin, filterParams));
    return null;
}

From source file:com.aurel.track.exchange.msProject.exchange.MsProjectExchangeBL.java

/**
 * Creates a new MsProjectImporterBean/*from w  ww. j  ava 2 s.  c o m*/
 *
 * @param projectOrReleaseID
 * @param personBean
 * @param file
 * @param locale
 * @return
 * @throws MSProjectImportException
 */
private static MsProjectExchangeDataStoreBean createMsProjectExchangeBean(Integer projectOrReleaseID,
        TPersonBean personBean, File file, Locale locale) throws MSProjectImportException {

    MsProjectExchangeDataStoreBean msProjectExchangeDataStoreBean = new MsProjectExchangeDataStoreBean(
            personBean, locale);
    Integer entityID = null;
    Integer entityType = null;
    Integer projectID = null;
    if (projectOrReleaseID != null) {
        if (projectOrReleaseID.intValue() < 0) {
            entityID = Integer.valueOf(-projectOrReleaseID.intValue());
            entityType = SystemFields.PROJECT;
            projectID = entityID;
            msProjectExchangeDataStoreBean.setProjectID(entityID);
        } else {
            entityID = projectOrReleaseID;
            entityType = SystemFields.RELEASE;
            msProjectExchangeDataStoreBean.setReleaseScheduledID(entityID);
            TReleaseBean releaseBean = LookupContainer.getReleaseBean(entityID);
            if (releaseBean != null) {
                projectID = releaseBean.getProjectID();
                msProjectExchangeDataStoreBean.setProjectID(releaseBean.getProjectID());
                // get the previous resource to person mappings if exists
                msProjectExchangeDataStoreBean.setResourceUIDToPersonIDMap(
                        MsProjectExchangeBL.transformResourceMappingsToMap(PropertiesHelper.getProperty(
                                releaseBean.getMoreProps(), TReleaseBean.MOREPPROPS.RESOURCE_PERSON_MAPPINGS)));
            }
        }
    }
    msProjectExchangeDataStoreBean.setEntityID(entityID);
    if (entityType != null) {
        msProjectExchangeDataStoreBean.setEntityType(entityType);
    }
    msProjectExchangeDataStoreBean.setFile(file);

    if (projectID != null) {
        TProjectBean projectBean = LookupContainer.getProjectBean(projectID);
        if (projectBean != null) {
            msProjectExchangeDataStoreBean.setProjectBean(projectBean);
            // do not set from track+ project but from msProject later
            // get the previous resource to person mappings if exists
            if (entityType == SystemFields.PROJECT) {
                msProjectExchangeDataStoreBean.setResourceUIDToPersonIDMap(
                        MsProjectExchangeBL.transformResourceMappingsToMap(PropertiesHelper.getProperty(
                                projectBean.getMoreProps(), TProjectBean.MOREPPROPS.RESOURCE_PERSON_MAPPINGS)));
            }
        }
    }
    Integer issueType = getIssueType();
    if (issueType == null) {
        throw new MSProjectImportException("admin.actions.importMSProject.err.noTasktypeFound");
    }
    msProjectExchangeDataStoreBean.setIssueType(issueType);
    return msProjectExchangeDataStoreBean;
}

From source file:com.phonegap.camera.CapturePhotoAction.java

/**
 * Capture a photo using device camera.  The camera is invoked using native APIs.
 * The photo is captured by listening to file system changes, and sent back by 
 * invoking the appropriate JS callback.
 *
 * @param args JSONArray formatted as [ cameraArgs ]
 *        cameraArgs:      /*from w w w .  jav a2 s . c o m*/
  *          [ 80,                                    // quality (ignored)
  *            Camera.DestinationType.DATA_URL,       // destinationType
  *            Camera.PictureSourceType.PHOTOLIBRARY  // sourceType (ignored)]
 * @return A CommandResult object with the INPROGRESS state for taking a photo.
 */
public PluginResult execute(JSONArray args) {
    // get the camera options, if supplied
    if (args != null && args.length() > 1) {
        // determine the desired destination type: data or file URI
        Integer destType = (Integer) args.opt(1);
        this.destinationType = (destType != null && destType.intValue() == FILE_URI) ? FILE_URI : DATA_URL;
    }

    // MMAPI interface doesn't use the native Camera application or interface
    // (we would have to replicate it).  So, we invoke the native Camera application,
    // which doesn't allow us to set any options.
    synchronized (UiApplication.getEventLock()) {
        UiApplication.getUiApplication().addFileSystemJournalListener(this);
        Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
    }

    // We invoked the native camera application, which runs in a separate
    // process, and must now wait for the listener to retrieve the photo taken. 
    // Return NO_RESULT status so plugin manager does not invoke a callback,
    // but set keep callback to true so we can invoke the callback later.
    PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
    result.setKeepCallback(true);
    return result;
}

From source file:com.glaf.core.dao.MyBatisEntityDAO.java

public int getCount(String statementId, Object parameterObject) {
    int totalCount = 0;
    SqlSession session = getSqlSession();

    Object object = null;//from  w  w w.j a  v  a 2s .  co  m
    if (parameterObject != null) {
        object = session.selectOne(statementId, parameterObject);
    } else {
        object = session.selectOne(statementId);
    }

    if (object instanceof Integer) {
        Integer iCount = (Integer) object;
        totalCount = iCount.intValue();
    } else if (object instanceof Long) {
        Long iCount = (Long) object;
        totalCount = iCount.intValue();
    } else if (object instanceof BigDecimal) {
        BigDecimal bg = (BigDecimal) object;
        totalCount = bg.intValue();
    } else if (object instanceof BigInteger) {
        BigInteger bi = (BigInteger) object;
        totalCount = bi.intValue();
    } else {
        String value = object.toString();
        totalCount = Integer.parseInt(value);
    }
    return totalCount;
}

From source file:com.stgmastek.birt.report.ReportService.java

/**
 * Initializes the service./*ww w .  j  a  v  a  2s.  co m*/
 * @param config
 * @throws ReportServiceException
 */
private void initialize(EngineConfigWrapper configWrapper) {
    //// Create Executor Service to hold ReportService Instance
    Integer size = new Integer((String) configWrapper.getEngineConfig().getProperty("threadPoolSize"));
    this.service = Executors.newFixedThreadPool(size.intValue());
    try {
        Platform.startup(configWrapper.getEngineConfig());
    } catch (BirtException e) {
        throw new ReportServiceException(e.getMessage(), e);
    }

    //// Engine Object Pool
    pool = new GenericObjectPool(new BIRTEngineFactory(configWrapper.getEngineConfig()));
    pool.setMaxActive(size);
    pool.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES.toMillis(5));
    initialized = true;
    logger.debug("ReportService pool initialized !! Total Pool size : [" + size + "]");
}

From source file:com.acc.core.suggestion.dao.impl.DefaultSimpleSuggestionDao.java

@Override
public List<ProductModel> findProductsRelatedToPurchasedProductsByCategory(final CategoryModel category,
        final List<ProductReferenceTypeEnum> referenceTypes, final UserModel user,
        final boolean excludePurchased, final Integer limit) {
    Assert.notNull(category);//from   w  ww . j a v a 2s.c  o m
    Assert.notNull(user);

    final int maxResultCount = limit == null ? DEFAULT_LIMIT : limit.intValue();

    final Map<String, Object> params = new HashMap<String, Object>();
    final StringBuilder builder = new StringBuilder(REF_QUERY_CATEGORY_START);
    if (excludePurchased) {
        builder.append(REF_QUERY_SUB);
    }
    if (CollectionUtils.isNotEmpty(referenceTypes)) {
        builder.append(REF_QUERY_TYPES);
        params.put(REF_QUERY_PARAM_TYPES, referenceTypes);
    }
    builder.append(REF_QUERY_CATEGORY_ORDER);

    params.put(REF_QUERY_PARAM_USER, user);
    params.put(REF_QUERY_PARAM_CATEGORY, category);

    final FlexibleSearchQuery query = new FlexibleSearchQuery(builder.toString());
    query.addQueryParameters(params);
    query.setNeedTotal(false);
    query.setCount(maxResultCount);

    final SearchResult<ProductModel> result = getFlexibleSearchService().search(query);
    return result.getResult();
}