List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:net.shopxx.controller.shop.GoodsController.java
@RequestMapping(value = "/compare", method = RequestMethod.GET) public String compare(Long[] goodsIds, ModelMap model) { if (ArrayUtils.isEmpty(goodsIds) || goodsIds.length > MAX_COMPARE_GOODS_COUNT) { return ERROR_VIEW; }// w w w .j ava2 s . com List<Goods> goodsList = goodsService.findList(goodsIds); if (CollectionUtils.isEmpty(goodsList)) { return ERROR_VIEW; } model.addAttribute("goodsList", goodsList); return "/shop/${theme}/goods/compare"; }
From source file:cn.gov.icon.base.util.Assert.java
/** * Assert that an array has elements; that is, it must not be * <code>null</code> and must have at least one element. * /* w ww.j a v a2 s. co m*/ * <pre class="code"> * Assert.notEmpty(array, "The array must have elements"); * </pre> * * @param array * the array to check * @param message * the exception message to use if the assertion fails * @throws IllegalArgumentException * if the object array is <code>null</code> or has no elements */ public static void notEmpty(Object[] array, String message) { if (ArrayUtils.isEmpty(array)) { throw new IllegalArgumentException(message); } }
From source file:com.hs.mail.imap.dao.MySqlMessageDao.java
private void setUserFlags(long messageID, String[] flags, boolean replace, boolean set) { if (replace) { String sql = "DELETE FROM keyword WHERE messageid = ?"; getJdbcTemplate().update(sql, new Object[] { new Long(messageID) }); }//w ww . j a va 2 s . c om if (!ArrayUtils.isEmpty(flags)) { String sql = (replace || set) ? "INSERT INTO keyword (messageid, keyword) VALUES(?, ?)" : "DELETE FROM keyword WHERE messageid = ? AND keyword = ?"; for (int i = 0; i < flags.length; i++) { if (!(set && hasUserFlag(messageID, flags[i]))) { getJdbcTemplate().update(sql, new Object[] { new Long(messageID), flags[i] }); } } } }
From source file:de.codesourcery.eve.skills.ui.components.impl.ItemChooserComponent.java
protected List<ItemWithQuantity> getSelectedValues() { final List<ItemWithQuantity> result = new ArrayList<ItemWithQuantity>(); final int[] selectedRows = itemTable.getSelectedRows(); if (!ArrayUtils.isEmpty(selectedRows)) { for (int viewRow : selectedRows) { final int modelRow = itemTable.convertRowIndexToModel(viewRow); result.add(selectedItemsModel.getRow(modelRow)); }//from w w w .j av a 2 s . c om } return result; }
From source file:com.lyh.licenseworkflow.dao.EnhancedHibernateDaoSupport.java
/** * ?//from w ww . j av a 2 s. c o m * * @param propertyNames ??? * @param values ??? * @param start ? - 0 * @param pageSize * @return */ @SuppressWarnings("unchecked") public List<T> getPagingEntitiesByPropName(final String[] propertyNames, final Object[] values, final int start, final int pageSize) { if (ArrayUtils.isEmpty(propertyNames) || ArrayUtils.isEmpty(values) || propertyNames.length != values.length) { throw new IllegalArgumentException("Invalid arguments to execute sql query."); } return (List<T>) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(getEntityName()); for (int i = 0; i < propertyNames.length; i++) { if (values[i] == null) criteria.add(Restrictions.isNull(propertyNames[i])); else if (values[i].toString().indexOf("%") != -1) {// ,?value?% criteria.add(Restrictions.like(propertyNames[i], values[i])); } else { criteria.add(Restrictions.eq(propertyNames[i], values[i])); } } criteria.setFirstResult(start); criteria.setMaxResults(pageSize); return criteria.list(); } }); }
From source file:com.etcc.csc.datatype.PaymentDetailUtil.java
public static OLC_VB_INVOICES_REC[] invoicesToOLC_VB_INVOICES_RECs(Invoice[] invoices) throws Exception { if (ArrayUtils.isEmpty(invoices)) { return null; }/*from w w w . j a v a 2 s .c o m*/ OLC_VB_INVOICES_REC[] OLC_VB_INVOICES_RECs = new OLC_VB_INVOICES_REC[invoices.length]; for (int i = 0; i < invoices.length; i++) { OLC_VB_INVOICES_REC rec = invoiceToOLC_VB_INVOICES_REC(invoices[i]); // rec.setARR_INDEX(new BigDecimal(i + 1)); OLC_VB_INVOICES_RECs[i] = rec; } return OLC_VB_INVOICES_RECs; }
From source file:com.mindcognition.mindraider.ui.swing.trash.TrashJPanel.java
/** * Build tree. This method is called on startup and tree refresh in order to * reload disc content. Adding/removing of particular nodes during the * program run is performed on individual nodes. *//*from w w w .j a v a 2 s . c om*/ void buildTree() { discardedNotebooksDescriptors = MindRaider.labelCustodian.getDiscardedOutlineDescriptors(); if (!ArrayUtils.isEmpty(discardedNotebooksDescriptors)) { for (int i = 0; i < discardedNotebooksDescriptors.length; i++) { addDiscardedNotebookNode(discardedNotebooksDescriptors[i].getLabel(), discardedNotebooksDescriptors[i].getUri()); } // now expland all rows for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } } tree.setSelectionRow(0); enableDisableToolbarButtons(0); }
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
/** * Checks whether a mouse-click event should trigger a context-sensitive * popup menu and renders the menu if so. * // w w w .ja v a 2 s .c om * @param e */ private void maybeShowPopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } final int[] selectedRows = table.getSelectedRows(); if (ArrayUtils.isEmpty(selectedRows)) { final int row = table.rowAtPoint(e.getPoint()); if (row < 0) { if (log.isDebugEnabled()) { log.debug("maybeShowPopup(): Outside of table."); } return; } table.getSelectionModel().setSelectionInterval(row, row); } // translate row indices for (int i = 0; i < selectedRows.length; i++) { selectedRows[i] = table.getRowSorter().convertRowIndexToModel(selectedRows[i]); } if (populatePopupMenu(e, selectedRows)) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:com.dianping.wed.cache.redis.biz.WeddingRedisServiceImpl.java
@Override public long rPush(WeddingRedisKeyDTO redisKey, final String... values) { if (ArrayUtils.isEmpty(values)) { return 0; }//from ww w.j a v a2s. co m final String finalKey = wcsWeddingRedisKeyCfgService.generateKey(redisKey); return JedisHelper.doJedisOperation(new JedisCallback<Long>() { @Override public Long doWithJedis(Jedis jedis) { return jedis.rpush(finalKey, values); } }, finalKey, RedisActionType.WRITE); }
From source file:com.photon.phresco.framework.impl.ProjectManagerImpl.java
public List<ProjectInfo> discover() throws PhrescoException { if (isDebugEnabled) { S_LOGGER.debug("Entering Method ProjectManagerImpl.discover()"); }//from w w w . j a v a2 s. c o m File projectsHome = new File(Utility.getProjectHome()); if (isDebugEnabled) { S_LOGGER.debug("discover( ) projectHome = " + projectsHome); } if (!projectsHome.exists()) { return null; } List<ProjectInfo> projectInfos = new ArrayList<ProjectInfo>(); File[] appDirs = projectsHome.listFiles(); for (File appDir : appDirs) { if (appDir.isDirectory()) { File[] split_phresco = null; File[] split_src = null; File[] dotPhrescoFolders = null; dotPhrescoFolders = appDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO)); if (ArrayUtils.isEmpty(dotPhrescoFolders)) { File dotAppDir = new File(appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO); split_phresco = dotAppDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO)); if (ArrayUtils.isEmpty(split_phresco)) { File srcAppDir = new File(appDir + File.separator + appDir.getName()); split_src = srcAppDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO)); if (ArrayUtils.isEmpty(split_src)) { continue; } } } if (!ArrayUtils.isEmpty(dotPhrescoFolders)) { File[] dotProjectFiles = dotPhrescoFolders[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(dotProjectFiles)) { fillProjects(dotProjectFiles[0], projectInfos); } } if (!ArrayUtils.isEmpty(split_phresco)) { File[] splitDotProjectFiles = split_phresco[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitDotProjectFiles)) { fillProjects(splitDotProjectFiles[0], projectInfos); } } if (!ArrayUtils.isEmpty(split_src)) { File[] splitSrcDotProjectFiles = split_src[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitSrcDotProjectFiles)) { fillProjects(splitSrcDotProjectFiles[0], projectInfos); } } } } return projectInfos; }