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:com.activecq.experiments.pageimage.impl.PageImageServletImpl.java
/** * Checks if the dimensions requested by the URL are * @param width/*www. ja va 2 s . c om*/ * @param height * @param imageResource * @return */ private boolean isAllowedDimension(final String width, final String height, final Resource imageResource) { final ResourceResolver resourceResolver = imageResource.getResourceResolver(); final PageManager pageManager = resourceResolver.adaptTo(PageManager.class); final Page page = pageManager.getContainingPage(imageResource); if (page == null) { return true; } final Designer designer = resourceResolver.adaptTo(Designer.class); final Design design = designer.getDesign(page); if (design == null) { return true; } final Style style = design.getStyle(imageResource); if (style == null) { return true; } final String[] dimensions = style.get(STYLE_PROPERTY_ALLOWED_DIMENSIONS, new String[] {}); if (ArrayUtils.isEmpty(dimensions)) { return true; } for (final String dimension : dimensions) { final String requestedDimension = width + "x" + height; if (StringUtils.equals(requestedDimension, dimension)) { return true; } } return false; }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public BigDecimal getAuthorizedViolationFeeAmount() { BigDecimal total = new BigDecimal(0.0); if (!ArrayUtils.isEmpty(violations)) { for (int i = 0; i < violations.length; i++) { if (violations[i].isAuthorized()) { total = total.add(BigDecimalUtil.nullSafe(violations[i].getOnlineFee())); }//from w w w . j av a 2 s . c om } } return total; }
From source file:com.nec.harvest.service.impl.PettyCashServiceImpl.java
/** {@inheritDoc} */ @Override//from w ww. j a v a 2 s . c o m public boolean updatePettyCashes(PettyCash... pettyCashes) throws ServiceException { if (ArrayUtils.isEmpty(pettyCashes)) { throw new IllegalArgumentException("The list of petty cash must not be null or empty"); } User user = AuthenticatedUserDetails.getUserPrincipal(); if (user == null) { logger.info("You must login to use this function"); // return false; } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; boolean isUpdated = false; try { StringBuilder sql = new StringBuilder(); sql.append(" UPDATE " + TblConstants.TBL_PETTY_CASH); sql.append(" SET SrDate=:srDate, CtgCode=:ctgCode, Naiyo=:naiyo, Kingaku=:kingaku, Shito=:shito, "); sql.append( " UpdNo=:updNo, DelKbn=:delKbn, TanCode=:tanCode, APInf2=:apInf2, StfCodeU=:stfCodeU, PrdNoU=:prdNoU "); sql.append(" WHERE RecID=:recId "); // tx = session.beginTransaction(); Query query = pettyCashRepository.getSQLQuery(session, sql.toString()); for (int i = 0; i < pettyCashes.length; i++) { PettyCash pettyCash = pettyCashes[i]; // Trying to build a query query.setDate("srDate", pettyCash.getSrDate()) .setString("ctgCode", pettyCash.getCategory().getCtgCode()) .setString("naiyo", pettyCash.getNaiyo()).setDouble("kingaku", pettyCash.getKingaku()) .setString("shito", pettyCash.getShito()) .setInteger("updNo", (pettyCash.getUpdNo() == null ? 1 : pettyCash.getUpdNo())) .setString("delKbn", pettyCash.getDelKbn()).setString("tanCode", user.getUsrCode()) .setString("apInf2", user.getUsrCode()).setString("stfCodeU", user.getUsrCode()) .setString("prdNoU", pettyCash.getPrdNoU()).setString("recId", pettyCash.getRecID()) .executeUpdate(); } isUpdated = true; tx.commit(); } catch (Exception ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("Hibernate runtime exception occur when update a list of petty cashes", ex); } return isUpdated; }
From source file:com.dianping.wed.cache.redis.biz.WeddingRedisKeyConfigurationServiceImpl.java
@Override public boolean clearMemoryCache(String... categories) { if (ArrayUtils.isEmpty(categories)) { return false; }// w w w . j a v a2 s. c o m if ("all".equals(categories[0])) { keyCfgCache.clear(); return true; } for (String category : categories) { keyCfgCache.remove(category); } return true; }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CalendarComponent.java
@Override protected JPanel createPanel() { addEntryButton.setEnabled(false);/*from w ww . j ava 2s. co m*/ addEntryButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewCalendarEntry(); } }); calendarWidget.addSelectionListener(new ISelectionListener<Date>() { @Override public void selectionChanged(Date selected) { addEntryButton.setEnabled(selected != null); tableModel.refresh(); } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() != 2 || e.isPopupTrigger()) { return; } final int viewRow = table.rowAtPoint(e.getPoint()); if (viewRow != -1) { editCalendarEntry(tableModel.getRow(table.convertRowIndexToModel(viewRow))); } } }); table.setFillsViewportHeight(true); table.setRowSorter(tableModel.getRowSorter()); table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final PopupMenuBuilder menuBuilder = new PopupMenuBuilder(); menuBuilder.addItem("Remove", new AbstractAction() { @Override public boolean isEnabled() { return !ArrayUtils.isEmpty(table.getSelectedRows()); } @Override public void actionPerformed(ActionEvent e) { final int[] viewRows = table.getSelectedRows(); if (ArrayUtils.isEmpty(viewRows)) { return; } final int[] modelRows = new int[viewRows.length]; int i = 0; for (int viewRow : viewRows) { modelRows[i++] = table.convertRowIndexToModel(viewRow); } final List<ICalendarEntry> removedEntries = new ArrayList<ICalendarEntry>(); for (int modelRow : modelRows) { removedEntries.add(tableModel.getRow(modelRow)); } for (ICalendarEntry toBeRemoved : removedEntries) { calendarManager.getCalendar().deleteEntry(toBeRemoved); } } }); menuBuilder.addItem("Edit...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final int modelRow = table.convertRowIndexToModel(table.getSelectedRows()[0]); editCalendarEntry(tableModel.getRow(modelRow)); } @Override public boolean isEnabled() { return !ArrayUtils.isEmpty(table.getSelectedRows()); } }); menuBuilder.attach(table); // controls panel final JPanel controlsPanel = new JPanel(); controlsPanel.setLayout(new GridBagLayout()); controlsPanel.add(addEntryButton, constraints(0, 0).noResizing().end()); // combine panels final JPanel subPanel = new JPanel(); subPanel.setLayout(new GridBagLayout()); subPanel.add(controlsPanel, constraints(0, 0).useRelativeWidth().weightY(0).end()); subPanel.add(new JScrollPane(table), constraints(0, 1).useRelativeWidth().useRemainingHeight().end()); final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT, calendarWidget, subPanel); splitPane.setDividerLocation(0.7); final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); result.add(splitPane, constraints(0, 0).resizeBoth().end()); return result; }
From source file:ee.ria.xroad.common.messagelog.archive.LogArchiveWriter.java
private static boolean filenameRandomUnique(String random) { String filenameEnd = String.format("-%s.zip", random); String[] fileNamesWithSameRandom = new File(getArchivePath()) .list((file, name) -> name.startsWith("mlog-") && name.endsWith(filenameEnd)); return ArrayUtils.isEmpty(fileNamesWithSameRandom); }
From source file:com.fiveamsolutions.nci.commons.mojo.copywebfiles.CopyWebFilesMojo.java
/** * {@inheritDoc}// w w w. j a v a 2 s . c om */ public void execute() throws MojoExecutionException, MojoFailureException { if (ArrayUtils.isEmpty(srcDirectories)) { getLog().info("No values given for srcDirectories, no files will be copied."); return; } if (deployDirectory == null || !deployDirectory.isDirectory()) { throw new MojoExecutionException( "The deployDirectory configuration parameter must be set to a directory."); } if (ArrayUtils.isEmpty(fileTypes)) { fileTypes = defaultFileTypes; } deployDirectoryPattern = StringUtils.trimToNull(deployDirectoryPattern); Collection<File> latestDeployDirectories = getLatestDeploymentDirectories(); for (File latestDeployDirectory : latestDeployDirectories) { IOFileFilter fileFilter = getFilefilter(latestDeployDirectory); copyFiles(latestDeployDirectory, fileFilter); } }
From source file:com.hs.mail.imap.message.responder.FetchResponder.java
void address(Address[] addresses) { if (ArrayUtils.isEmpty(addresses)) { nil();//w w w . j ava 2 s . co m } else { openParen("("); for (int i = 0; i < addresses.length; i++) { skipNextSpace(); openParen("("); nillableQuote(addresses[i].getPersonalName()); nillableQuote(addresses[i].getAtDomainList()); nillableQuote(addresses[i].getMailboxName()); nillableQuote(addresses[i].getHostName()); closeParen(")"); } closeParen(")"); } }
From source file:io.cloudslang.worker.management.services.WorkerManager.java
protected static String resolveDotNetVersion() { File dotNetHome = new File(DOTNET_PATH); if (dotNetHome.isDirectory()) { File[] versionFolders = dotNetHome.listFiles(new FileFilter() { @Override/*from ww w.jav a 2 s . co m*/ public boolean accept(File file) { return file.isDirectory() && file.getName().startsWith("v"); } }); if (!ArrayUtils.isEmpty(versionFolders)) { String maxVersion = max(versionFolders, on(File.class).getName()).substring(1); return maxVersion.substring(0, 1) + ".x"; } } return "N/A"; }
From source file:com.lxht.emos.data.cache.intf.HessianUtil.java
/** * ??,?,?????.// w w w .j a va2 s. c om * * @param objectFileDirectory ? * @param fileName ??????? * @return boolean ??, true:?,false:. */ public static boolean removeSerializeLikeFile(String objectFileDirectory, final String fileName) { if (StringUtils.isBlank(objectFileDirectory) || StringUtils.isBlank(fileName)) { return false; } // ?File. File objDirFile = getObjectFileDir(objectFileDirectory); // ???? File[] objFiles = objDirFile.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (StringUtils.isBlank(name)) { return false; } /** * ??. */ return StringUtils.startsWith(name, fileName); } }); if (ArrayUtils.isEmpty(objFiles)) { return false; } // ?. for (File file : objFiles) { boolean isDelSuc = file.delete(); if (!isDelSuc) { file.deleteOnExit(); logger.warn("removeSerializeLikeFile(),Delete the local cache file failed.[File:" + file + "]"); continue; } } return true; }