List of usage examples for java.math BigInteger intValue
public int intValue()
From source file:com.glaf.core.db.mybatis2.SqlMapClientDAOImpl.java
public int getCount(String statementId, Object parameterObject) { int totalCount = 0; Object object = null;/*from w w w . j a v a 2s.co m*/ if (parameterObject != null) { object = getSqlMapClientTemplate().queryForObject(statementId, parameterObject); } else { object = getSqlMapClientTemplate().queryForObject(statementId, null); } 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(); } return totalCount; }
From source file:com.ephesoft.dcma.tablefinder.share.TableExtractionResultModifierUtility.java
/** * Checks if new column data is in same alignment with previous column data * /* w w w . ja v a 2 s. c om*/ * @param prevColumnX0 {@link BigInteger} * @param prevColumnX1 {@link BigInteger} * @param columnX0 {@link BigInteger} * @param columnX1 {@link BigInteger} * @return {@code boolean} True if new column data value coordinates. */ private static boolean isColumnValidWithPrevColumnCoordinate(final BigInteger prevColumnX0, final BigInteger prevColumnX1, final BigInteger columnX0, final BigInteger columnX1) { LOGGER.trace("Entering method isColumnValidWithPrevColumnCoordinate....."); boolean isValid = false; LOGGER.debug("New Column Coordinates: X0=", columnX0, " ,X1=", columnX1); LOGGER.debug("Previous column Coordinates: X0=", prevColumnX0, " ,X1=", prevColumnX1); if (prevColumnX0 != null && prevColumnX1 != null && columnX0 != null && columnX0 != null) { if ((columnX0.compareTo(prevColumnX0) == 1 && columnX0.compareTo(prevColumnX1) == -1) || (columnX1.compareTo(prevColumnX0) == 1 && columnX1.compareTo(prevColumnX1) == -1) || (columnX0.compareTo(prevColumnX0) == -1 && columnX1.compareTo(prevColumnX1) == 1) || columnX0.compareTo(prevColumnX0) == 0 || columnX1.compareTo(prevColumnX1) == 0 || TableRowFinderUtility.isApproxEqual(columnX1.intValue(), prevColumnX0.intValue()) || TableRowFinderUtility.isApproxEqual(columnX0.intValue(), prevColumnX1.intValue())) { isValid = true; } } LOGGER.info("Is value coordinates valid with column coordinates : ", isValid); LOGGER.trace("Exiting method isColumnValidWithColCoord....."); return isValid; }
From source file:com.glaf.jbpm.db.mybatis2.SqlMapClientDAOImpl.java
public Paging getPage(int pageNo, int pageSize, SqlExecutor countExecutor, SqlExecutor queryExecutor) { Paging page = new Paging(); if (pageSize <= 0) { pageSize = Paging.DEFAULT_PAGE_SIZE; }/*from ww w.j av a2s. c o m*/ if (pageNo <= 0) { pageNo = 1; } Object params = countExecutor.getParameter(); Object object = null; int totalCount = 0; if (params != null) { object = getSqlMapClientTemplate().queryForObject(countExecutor.getStatementId(), params); } else { object = getSqlMapClientTemplate().queryForObject(countExecutor.getStatementId(), null); } 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(); } if (totalCount == 0) { page.setRows(new java.util.ArrayList<Object>()); page.setCurrentPage(0); page.setPageSize(0); page.setTotal(0); return page; } page.setTotal(totalCount); int maxPageNo = (page.getTotal() + (pageSize - 1)) / pageSize; if (pageNo > maxPageNo) { pageNo = maxPageNo; } List<Object> rows = null; Object queryParams = queryExecutor.getParameter(); int begin = (pageNo - 1) * pageSize + 1; if (queryParams != null) { rows = getSqlMapClientTemplate().queryForList(queryExecutor.getStatementId(), queryParams, begin, pageSize); } else { rows = getSqlMapClientTemplate().queryForList(queryExecutor.getStatementId(), null, begin, pageSize); } page.setRows(rows); page.setPageSize(pageSize); page.setCurrentPage(pageNo); return page; }
From source file:com.glaf.core.db.mybatis2.SqlMapClientDAOImpl.java
public Paging getPage(int pageNo, int pageSize, SqlExecutor countExecutor, SqlExecutor queryExecutor) { if (LogUtils.isDebug()) { logger.debug("count executor:" + countExecutor); logger.debug("query executor:" + queryExecutor); }//from w w w .j a v a 2s . c om Paging page = new Paging(); if (pageSize <= 0) { pageSize = Paging.DEFAULT_PAGE_SIZE; } if (pageNo <= 0) { pageNo = 1; } Object params = countExecutor.getParameter(); Object object = null; int totalCount = 0; if (params != null) { object = getSqlMapClientTemplate().queryForObject(countExecutor.getStatementId(), params); } else { object = getSqlMapClientTemplate().queryForObject(countExecutor.getStatementId(), null); } 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(); } if (totalCount == 0) { page.setRows(new java.util.concurrent.CopyOnWriteArrayList<Object>()); page.setCurrentPage(0); page.setPageSize(0); page.setTotal(0); return page; } page.setTotal(totalCount); int maxPageNo = (page.getTotal() + (pageSize - 1)) / pageSize; if (pageNo > maxPageNo) { pageNo = maxPageNo; } List<Object> rows = null; Object queryParams = queryExecutor.getParameter(); int begin = (pageNo - 1) * pageSize + 1; if (queryParams != null) { rows = getSqlMapClientTemplate().queryForList(queryExecutor.getStatementId(), queryParams, begin, pageSize); } else { rows = getSqlMapClientTemplate().queryForList(queryExecutor.getStatementId(), null, begin, pageSize); } page.setRows(rows); page.setPageSize(pageSize); page.setCurrentPage(pageNo); if (LogUtils.isDebug()) { logger.debug("params:" + params); logger.debug("rows size:" + rows.size()); } return page; }
From source file:org.apereo.portal.io.xml.portlet.ExternalPortletDefinitionUnmarshaller.java
IPortletDefinition unmarshall(ExternalPortletDefinition epd) { final PortletDescriptor portletDescriptor = epd.getPortletDescriptor(); final Boolean isFramework = portletDescriptor.isIsFramework(); if (isFramework != null && isFramework && "UPGRADED_CHANNEL_IS_NOT_A_PORTLET".equals(portletDescriptor.getPortletName())) { if (errorOnChannel) { throw new IllegalArgumentException(epd.getFname() + " is not a portlet. It was likely an IChannel from a previous version of uPortal and cannot be imported."); }//from w w w . j a va2 s. co m logger.warn(epd.getFname() + " is not a portlet. It was likely an IChannel from a previous version of uPortal and will not be imported."); return null; } // get the portlet type final IPortletType portletType = portletTypeRegistry.getPortletType(epd.getType()); if (portletType == null) { throw new IllegalArgumentException("No portlet type registered for: " + epd.getType()); } final String fname = epd.getFname(); IPortletDefinition rslt = portletDefinitionDao.getPortletDefinitionByFname(fname); if (rslt == null) { rslt = new PortletDefinitionImpl(portletType, fname, epd.getName(), epd.getTitle(), portletDescriptor.getWebAppName(), portletDescriptor.getPortletName(), isFramework != null ? isFramework : false); } else { final IPortletDescriptorKey portletDescriptorKey = rslt.getPortletDescriptorKey(); portletDescriptorKey.setPortletName(portletDescriptor.getPortletName()); if (isFramework != null && isFramework) { portletDescriptorKey.setFrameworkPortlet(true); portletDescriptorKey.setWebAppName(null); } else { portletDescriptorKey.setFrameworkPortlet(false); portletDescriptorKey.setWebAppName(portletDescriptor.getWebAppName()); } rslt.setName(epd.getName()); rslt.setTitle(epd.getTitle()); rslt.setType(portletType); } rslt.setDescription(epd.getDesc()); final BigInteger timeout = epd.getTimeout(); if (timeout != null) { rslt.setTimeout(timeout.intValue()); } final BigInteger actionTimeout = epd.getActionTimeout(); if (actionTimeout != null) { rslt.setActionTimeout(actionTimeout.intValue()); } final BigInteger eventTimeout = epd.getEventTimeout(); if (eventTimeout != null) { rslt.setEventTimeout(eventTimeout.intValue()); } final BigInteger renderTimeout = epd.getRenderTimeout(); if (renderTimeout != null) { rslt.setRenderTimeout(renderTimeout.intValue()); } final BigInteger resourceTimeout = epd.getResourceTimeout(); if (resourceTimeout != null) { rslt.setResourceTimeout(resourceTimeout.intValue()); } unmarshallLifecycle(epd.getLifecycle(), rslt); final Set<IPortletDefinitionParameter> parameters = new LinkedHashSet<>(); for (ExternalPortletParameter param : epd.getParameters()) { parameters.add(new PortletDefinitionParameterImpl(param.getName(), param.getValue())); } rslt.setParameters(parameters); final ArrayList<IPortletPreference> preferenceList = new ArrayList<>(); for (ExternalPortletPreference pref : epd.getPortletPreferences()) { final List<String> valueList = pref.getValues(); final String[] values = valueList.toArray(new String[valueList.size()]); final Boolean readOnly = pref.isReadOnly(); preferenceList .add(new PortletPreferenceImpl(pref.getName(), readOnly != null ? readOnly : false, values)); } rslt.setPortletPreferences(preferenceList); return rslt; }
From source file:org.openxdata.server.dao.hibernate.HibernateEditableDAO.java
@Override @Secured("Perm_View_Form_Data") public Integer getFormDataCount(Integer formDefId) { Session session = getSession();//from w ww .j a v a 2s.c om BigInteger count = (BigInteger) session .createSQLQuery("select count(*) from form_data where form_definition_version_id = " + formDefId) .uniqueResult(); return count.intValue(); }
From source file:com.glaf.core.entity.mybatis.MyBatisEntityDAOImpl.java
public Paging getPage(int pageNo, int pageSize, SqlExecutor countExecutor, SqlExecutor queryExecutor) { if (pageNo < 1) { pageNo = 1;/*from w ww . j a v a2s .c om*/ } if (pageSize <= 0) { pageSize = Paging.DEFAULT_PAGE_SIZE; } Object object = null; int totalCount = 0; Paging page = new Paging(); SqlSession session = getSqlSession(); Object parameter = countExecutor.getParameter(); if (parameter != null) { object = session.selectOne(countExecutor.getStatementId(), parameter); } else { object = session.selectOne(countExecutor.getStatementId()); } 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); } if (totalCount == 0) { page.setRows(new java.util.ArrayList<Object>()); page.setCurrentPage(0); page.setPageSize(0); page.setTotal(0); return page; } page.setTotal(totalCount); int maxPageNo = (page.getTotal() + (pageSize - 1)) / pageSize; if (pageNo > maxPageNo) { pageNo = maxPageNo; } List<Object> rows = null; Object queryParams = queryExecutor.getParameter(); int begin = (pageNo - 1) * pageSize; logger.debug("begin:" + begin); logger.debug("pageSize:" + pageSize); RowBounds rowBounds = new RowBounds(begin, pageSize); if (queryParams != null) { rows = session.selectList(queryExecutor.getStatementId(), queryParams, rowBounds); } else { rows = session.selectList(queryExecutor.getStatementId(), null, rowBounds); } page.setRows(rows); page.setPageSize(pageSize); page.setCurrentPage(pageNo); if (LogUtils.isDebug()) { logger.debug("params:" + queryParams); logger.debug("rows size:" + rows.size()); } return page; }
From source file:com.acmemotors.obd2.OBD2Controller.java
private int decodePercentage(String response) { String[] respsonseLines = response.split("\n"); StringBuilder pidString = new StringBuilder(); String[] elements = respsonseLines[1].split(" "); BigInteger a = new BigInteger(elements[7], 16); return a.intValue() * 100 / 255; }
From source file:com.acmemotors.obd2.OBD2Controller.java
protected double decodeFuelPercent(String response) { String[] respsonseLines = response.split("\n"); StringBuilder pidString = new StringBuilder(); String[] elements = respsonseLines[1].split(" "); BigInteger a = new BigInteger(elements[7], 16); return a.intValue() - 40; }
From source file:com.acmemotors.obd2.OBD2Controller.java
protected int decodeCoolantTemp(String response) { String[] respsonseLines = response.split("\n"); StringBuilder pidString = new StringBuilder(); String[] elements = respsonseLines[1].split(" "); BigInteger a = new BigInteger(elements[7], 16); return a.intValue() - 40; }