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:gobblin.util.FileListUtils.java
private static List<FileStatus> listMostNestedPathRecursivelyHelper(FileSystem fs, List<FileStatus> files, FileStatus fileStatus, PathFilter fileFilter) throws IOException { if (fileStatus.isDirectory()) { FileStatus[] curFileStatus = fs.listStatus(fileStatus.getPath()); if (ArrayUtils.isEmpty(curFileStatus)) { files.add(fileStatus);/*from w w w.jav a2 s . com*/ } else { for (FileStatus status : curFileStatus) { listMostNestedPathRecursivelyHelper(fs, files, status, fileFilter); } } } else if (fileFilter.accept(fileStatus.getPath())) { files.add(fileStatus); } return files; }
From source file:com.etcc.csc.datatype.PaymentDetailUtil.java
public static Violation[] convertToViolations(OLC_VIOLATION_REC[] violationRecs) throws Exception { if (ArrayUtils.isEmpty(violationRecs)) { return null; }/*from w w w. j a va 2 s.co m*/ Violation[] violations = new Violation[violationRecs.length]; for (int i = 0; i < violationRecs.length; i++) { violations[i] = convertToViolation(violationRecs[i]); } return violations; }
From source file:edu.cornell.med.icb.goby.alignments.TestAlignmentReader.java
/** * Validate that the method/*from ww w .jav a 2 s.c om*/ * {@link AlignmentReaderImpl#getBasenames(String[])} * produces the proper results. */ @Test public void basenames() { assertTrue("Basename array should be empty", ArrayUtils.isEmpty(AlignmentReaderImpl.getBasenames())); final String[] nullArray = { null }; assertArrayEquals("Basename array should contain a single null element", nullArray, AlignmentReaderImpl.getBasenames((String) null)); final String[] emptyStringArray = { "" }; assertArrayEquals("Basename array should contain a single empty string element", emptyStringArray, AlignmentReaderImpl.getBasenames("")); final String[] foobarArray = { "foobar" }; assertArrayEquals("Basenames should be unchanged", foobarArray, AlignmentReaderImpl.getBasenames("foobar")); final String[] foobarTxtArray = { "foobar.txt" }; assertArrayEquals("Basenames should be unchanged", foobarTxtArray, AlignmentReaderImpl.getBasenames("foobar.txt")); assertArrayEquals("Basenames should be unchanged", ArrayUtils.addAll(foobarArray, foobarTxtArray), AlignmentReaderImpl.getBasenames("foobar", "foobar.txt")); final String basename = "mybasename"; final String[] basenameArray = { basename }; final String[] filenames = new String[FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS.length]; for (int i = 0; i < FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS.length; i++) { filenames[i] = basename + FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS[i]; } assertArrayEquals("Basename not stripped properly from " + ArrayUtils.toString(filenames), basenameArray, AlignmentReaderImpl.getBasenames(filenames)); }
From source file:com.hs.mail.imap.message.response.FetchResponseBuilder.java
private BodyFetchItem getBodyFetchItem(FetchProfile fp) { FetchProfile.Item[] items = fp.getItems(); BodyFetchItem result = null;/*from www. ja v a 2s . c o m*/ if (!ArrayUtils.isEmpty(items)) { for (int i = 0; i < items.length; i++) { if (items[i] instanceof BodyFetchItem) { result = (BodyFetchItem) items[i]; break; } } } return result; }
From source file:com.nec.harvest.service.impl.PettyCashServiceImpl.java
/** {@inheritDoc} */ @Override/*from w w w . ja v a2s . c o m*/ public List<PettyCash> findCurrentUpdateNo(String... recordIds) throws ServiceException { if (ArrayUtils.isEmpty(recordIds)) { throw new IllegalArgumentException("The list of petty cash's Id must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<PettyCash> pettyCashes = new ArrayList<PettyCash>(); try { tx = session.beginTransaction(); Query query = pettyCashRepository .getNamedQuery(session, SqlConstants.SQL_FIND_PETTY_CASH_PRESENT_UPDATE_NO) .setParameterList("recordIDs", recordIds) .setResultTransformer(Transformers.aliasToBean(PettyCash.class)); pettyCashes = pettyCashRepository.findByQuery(query); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("Hibernate runtime exception occur when get petty cash update number", ex); } finally { HibernateSessionManager.closeSession(session); } return pettyCashes; }
From source file:io.fabric8.utils.cxf.WebClients.java
public static void configureClientCert(WebClient webClient, String clientCertData, File clientCertFile, String clientKeyData, File clientKeyFile, String clientKeyAlgo, char[] clientKeyPassword) { try {/*w w w . j a v a2 s . c o m*/ KeyStore keyStore = createKeyStore(clientCertData, clientCertFile, clientKeyData, clientKeyFile, clientKeyAlgo, clientKeyPassword); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, clientKeyPassword); KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit(); TLSClientParameters params = conduit.getTlsClientParameters(); if (params == null) { params = new TLSClientParameters(); conduit.setTlsClientParameters(params); } KeyManager[] existingKeyManagers = params.getKeyManagers(); if (!ArrayUtils.isEmpty(existingKeyManagers)) { keyManagers = (KeyManager[]) ArrayUtils.addAll(existingKeyManagers, keyManagers); } params.setKeyManagers(keyManagers); } catch (Exception e) { LOG.error("Could not create key manager for " + clientCertFile + " (" + clientKeyFile + ")", e); } }
From source file:net.lmxm.ute.configuration.ConfigurationReader.java
/** * Parses the files.// w ww. ja v a 2s. c om * * @param task the task * @param filesType the files type */ private void parseFiles(final FilesTask task, final FilesType filesType) { final String prefix = "parseFiles() :"; LOGGER.debug("{} entered", prefix); if (filesType == null) { LOGGER.debug("{} filesType is null, exiting", prefix); return; } final List<FileReference> files = task.getFiles(); final FileType[] fileTypeArray = filesType.getFileArray(); if (ArrayUtils.isEmpty(fileTypeArray)) { LOGGER.debug("{} fileArray is empty is null, exiting", prefix); return; } LOGGER.debug("{} parsing {} file types", prefix, fileTypeArray.length); for (final FileType fileType : fileTypeArray) { final FileReference file = parseFile(fileType); if (file != null) { files.add(file); } } LOGGER.debug("{} exiting", prefix); }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public BigDecimal getAuthorizedInvSecondNoticeAdminFee() { BigDecimal total = new BigDecimal(0.0); if (!ArrayUtils.isEmpty(invoices)) { for (int i = 0; i < invoices.length; i++) { if (invoices[i].isAuthorized()) { total = total.add(BigDecimalUtil.nullSafe(invoices[i].getInvSecondNoticeAdminFee())); }//from w w w. jav a2s . com } } return total; }
From source file:com.etcc.csc.dao.OraclePaymentDAO.java
public PaymentDetail getPaymentDetail(String dbSessionId, String ipAddress, String loginId, long docId, String docType, String licPlate, String licState, BigDecimal transactionId) throws EtccErrorMessageException, Exception { PaymentDetail paymentDetail = null;/*from w w w . j a v a2 s . c om*/ try { setConnection(Util.getDbConnection()); OLC_ACCOUNT_TAG_ARR[] P_ACCOUNT_TAG_ARR = new OLC_ACCOUNT_TAG_ARR[] { new OLC_ACCOUNT_TAG_ARR() }; String[] P_FORCE_PMT = new String[] { "" }; BigDecimal[] P_PMT_AMT = new BigDecimal[] { new BigDecimal(0) }; BigDecimal[] P_DEP_AMT = new BigDecimal[] { new BigDecimal(0) }; BigDecimal[] P_RTL_TRXN_ID = new BigDecimal[] { transactionId }; OLC_VPS_INVOICES_ARR[] O_VPS_INVOICES_ARR = new OLC_VPS_INVOICES_ARR[] { new OLC_VPS_INVOICES_ARR() }; OLC_UNINVOICED_VIOLS_ARR[] O_UNINVOICED_VIOLS_ARR = new OLC_UNINVOICED_VIOLS_ARR[] { new OLC_UNINVOICED_VIOLS_ARR() }; OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() }; int result = new OLCSC_INV(conn).GET_PMT_INFO(dbSessionId, ipAddress, loginId, new BigDecimal(docId), docType, licPlate, licState, P_ACCOUNT_TAG_ARR, P_FORCE_PMT, P_PMT_AMT, P_DEP_AMT, P_RTL_TRXN_ID, O_VPS_INVOICES_ARR, O_UNINVOICED_VIOLS_ARR, O_ERROR_MSG_ARR, true).intValue(); if (result == 1) { paymentDetail = new PaymentDetail(); if (P_ACCOUNT_TAG_ARR[0] != null && !ArrayUtils.isEmpty(P_ACCOUNT_TAG_ARR[0].getArray())) { OLC_ACCOUNT_TAG_REC[] accountTagRecs = P_ACCOUNT_TAG_ARR[0].getArray(); TagDTO[] tags = new TagDTO[accountTagRecs.length]; for (int i = 0; i < accountTagRecs.length; i++) { tags[i] = new TagDTO(); tags[i].setLicPlate(accountTagRecs[i].getLIC_PLATE()); tags[i].setLicState(accountTagRecs[i].getLIC_STATE()); tags[i].setVehicleYear(accountTagRecs[i].getVEHICLE_YEAR()); tags[i].setVehicleColor(accountTagRecs[i].getVEHICLE_COLOR()); tags[i].setVehicleMake(accountTagRecs[i].getVEHICLE_MAKE()); tags[i].setVehicleModel(accountTagRecs[i].getVEHICLE_MODEL()); } paymentDetail.setTags(tags); } if (!ArrayUtils.isEmpty(P_FORCE_PMT)) { paymentDetail.setForcePayment(P_FORCE_PMT[0]); } if (!ArrayUtils.isEmpty(P_PMT_AMT)) { paymentDetail.setTagAmount(P_PMT_AMT[0]); } if (!ArrayUtils.isEmpty(P_DEP_AMT)) { paymentDetail.setDepAmount(P_DEP_AMT[0]); } if (!ArrayUtils.isEmpty(P_RTL_TRXN_ID)) { paymentDetail.setTransactionId(P_RTL_TRXN_ID[0]); } if (O_VPS_INVOICES_ARR[0] != null && !ArrayUtils.isEmpty(O_VPS_INVOICES_ARR[0].getArray())) { OLC_VPS_INVOICES_REC[] vpsInvoicesRecs = O_VPS_INVOICES_ARR[0].getArray(); Invoice[] invoices = new Invoice[vpsInvoicesRecs.length]; for (int i = 0; i < vpsInvoicesRecs.length; i++) { invoices[i] = PaymentDetailUtil.convertToInvoice(vpsInvoicesRecs[i]); } paymentDetail.setInvoices(invoices); } if (O_UNINVOICED_VIOLS_ARR[0] != null && !ArrayUtils.isEmpty(O_UNINVOICED_VIOLS_ARR[0].getArray())) { OLC_UNINVOICED_VIOLS_REC[] uninvoicedViolsRecs = O_UNINVOICED_VIOLS_ARR[0].getArray(); Violation[] violations = new Violation[uninvoicedViolsRecs.length]; for (int i = 0; i < uninvoicedViolsRecs.length; i++) { violations[i] = PaymentDetailUtil.convertToViolation(uninvoicedViolsRecs[i]); } paymentDetail.setViolations(violations); } System.out.println(paymentDetail.toString()); } else { throw new EtccException("PaymentWS::getPaymentDetail fatal error"); } } finally { closeConnection(); } return paymentDetail; }
From source file:com.hs.mail.imap.message.responder.AbstractImapResponder.java
protected void flags(Flags flags) { if (flags.contains(Flags.Flag.ANSWERED)) { message("\\Answered"); }/*w w w. j a v a 2s. c o m*/ if (flags.contains(Flags.Flag.DELETED)) { message("\\Deleted"); } if (flags.contains(Flags.Flag.DRAFT)) { message("\\Draft"); } if (flags.contains(Flags.Flag.FLAGGED)) { message("\\Flagged"); } if (flags.contains(Flags.Flag.RECENT)) { message("\\Recent"); } if (flags.contains(Flags.Flag.SEEN)) { message("\\Seen"); } String[] ufs = flags.getUserFlags(); if (!ArrayUtils.isEmpty(ufs)) { for (String uf : ufs) { message(uf); } } skipNextSpace = false; }