Example usage for org.apache.commons.lang ArrayUtils isEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isEmpty.

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResultsUtils.java

private static List<VClass> buildListOfRequestedVClasses(VitroRequest vreq) throws Exception {
    String[] vitroClassIdStr = vreq.getParameterValues("vclassId");
    if (ArrayUtils.isEmpty(vitroClassIdStr)) {
        log.error("parameter vclassId URI parameter expected ");
        throw new Exception("parameter vclassId URI parameter expected ");
    }/*from  w  ww . ja  va2 s.  c  o m*/

    List<VClass> list = new ArrayList<>();
    for (String vclassId : vitroClassIdStr) {
        VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassId);
        if (vclass == null) {
            log.error("Couldn't retrieve vclass ");
            throw new Exception("Class " + vclassId + " not found");
        }
        list.add(vclass);
    }
    return list;
}

From source file:com.sunyue.util.calculator.impl.parser.AbstractExpressionParser.java

/**
 * Add elements into expression//ww w .j  a v  a2 s .  c o  m
 * 
 * @param elements
 *            atomic elements of expression
 */
protected void addToken(List<Object> result, Object... elements) {
    if (!ArrayUtils.isEmpty(elements)) {
        for (Object element : elements) {
            if (element != null && !"".equals(element.toString())) {
                result.add(element);
            }
        }
    }
}

From source file:ch.nydi.aop.interceptor.DebugInterceptor.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {

    if (this.logger.isTraceEnabled()) {
        return Interceptors.create(this.traceInterceptor, this.timerInterceptor, new MethodInterceptor() {

            @Override/*from w  w  w.  java  2 s.co  m*/
            public Object invoke(MethodInvocation invocation) throws Throwable {
                // TODO Verletzung DRY-Prinzip: gesamter Inhalt dieser Methode nahezu identisch mit TraceInterceptor
                final String prefix = "invocation arguments of " + invocation.getMethod().getName() + " ";
                final Object[] arguments = invocation.getArguments();
                if (ArrayUtils.isEmpty(arguments)) {
                    DebugInterceptor.this.logger.debug(prefix + "{no arguments}");
                } else {
                    final StringBuilder flattenArguments = new StringBuilder();
                    flattenArguments.append("{");
                    for (int i = 0; i < arguments.length; i++) {
                        if (i > 0) {
                            flattenArguments.append(" | ");
                        }
                        flattenArguments.append(DebugInterceptor.this.flattenArgument(arguments[i]));
                    }
                    flattenArguments.append("}");
                    DebugInterceptor.this.logger.debug(prefix + flattenArguments.toString());
                }
                // DebugInterceptor.this.logger.info("Greetings from a anonymous interceptor");
                return invocation.proceed();
            }
        }).invoke(invocation);
    }

    return invocation.proceed();
}

From source file:com.nec.harvest.service.impl.InventoryCategoryServiceImpl.java

/** {@inheritDoc} */
@Override//w ww  .  j  a  v a  2  s. com
public List<InventoryCategory> findByCategoryCodes(String... categories) throws ServiceException {
    if (ArrayUtils.isEmpty(categories)) {
        throw new ServiceException("Ids must not be null");
    }
    List<InventoryCategory> results = new ArrayList<>();
    for (String categoryCode : categories) {
        InventoryCategory category = findByCategoryCode(categoryCode);
        if (category != null) {
            results.add(category);
        }
    }
    return results;
}

From source file:fr.exanpe.t5.lib.services.impl.AuthorizeBusinessServiceImpl.java

public boolean applyNot(String[] not) {
    if (ArrayUtils.isEmpty(not)) {
        return true;
    }/*from   w  ww.  jav a  2 s  .  c om*/

    String[] roles = not;
    for (String r : roles) {
        if (r != null && request.getHTTPServletRequest().isUserInRole(r.trim())) {
            return false;
        }
    }

    return true;
}

From source file:com.etcc.csc.presentation.action.monthlyStatement.ProcessMonthlyStatementAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    DynaActionForm dynaForm = (DynaActionForm) form;
    String licensePlate = (String) dynaForm.get("licensePlate");
    HttpSession session = request.getSession();
    AccountLoginDTO accountLoginDTO = SessionUtil.getSessionAccountLogin(session);
    LicensePlateDTO[] licensePlates = accountLoginDTO.getLicensePlates();

    if (licensePlates == null || licensePlates.length == 0) {
        PaymentInterface pi = (PaymentInterface) DelegateFactory.create(DelegateEnum.PAYMENT_DELEGATE);
        //Task 2128_1 implementation. To display link to access Monthly Statements 
        List<LicensePlateDTO> licensePlateDTOList = pi.getAccountLicPlates(accountLoginDTO.getAcctId());
        accountLoginDTO/* w w w .j a  v a2s  . c o m*/
                .setLicensePlates(licensePlateDTOList.toArray(new LicensePlateDTO[licensePlateDTOList.size()]));

        licensePlates = accountLoginDTO.getLicensePlates();
        SessionUtil.setSessionAccountLogin(session, accountLoginDTO);
    }

    if (StringUtils.isEmpty(licensePlate) && !ArrayUtils.isEmpty(licensePlates)) {
        licensePlate = licensePlates[0].getDisplayLicPlateValue();
        dynaForm.set("licensePlate", licensePlate);
    }

    if (StringUtils.isNotEmpty(licensePlate)) {
        String[] licensePlateArr = licensePlate.split("~");
        accountLoginDTO.setLicPlate(licensePlateArr[0]);
        accountLoginDTO.setLicState(licensePlateArr[1]);
        accountLoginDTO.setViolatorId(Long.valueOf(licensePlateArr[2]));
        SessionUtil.setSessionAccountLogin(session, accountLoginDTO);
        return mapping.findForward("process.monthlyStatement");
    }
    return mapping.findForward("success");
}

From source file:br.msf.commons.netbeans.util.FileObjectUtils.java

public static Collection<FileObject> getFiles(final FileObject rootDir, final boolean recursive,
        final FileType... types) {
    assert rootDir != null && rootDir.isFolder() && !ArrayUtils.contains(types, FileType.OTHER);
    Collection<FileObject> fileObjects = new ArrayList<FileObject>();
    Enumeration<FileObject> entries = (Enumeration<FileObject>) rootDir.getChildren(recursive);
    while (entries.hasMoreElements()) {
        FileObject curr = entries.nextElement();
        if (curr.isData()) {
            FileType t = FileType.parse(curr.getExt());
            if (ArrayUtils.isEmpty(types) || ArrayUtils.contains(types, t)) {
                fileObjects.add(curr);/*from  ww w . j av a 2 s .  c om*/
            }
        }
    }
    return fileObjects;
}

From source file:com.kcs.action.GenerateXmlLtxAction.java

public String generateXml() throws Exception {
    logger.debug("generateXml : begin...");
    logger.debug("dataSetDate : " + tmpDataSetDate);

    byte[] xmlBytes = generateXmlService.generateXmlLtx(tmpDataSetDate, tmpTcb);

    if (ArrayUtils.isEmpty(xmlBytes)) {
        throw new RuntimeException("Can't generate xml.");
    } else {//www .  j av a2 s .  com
        inputStream = new ByteArrayInputStream(xmlBytes);
    }
    setCookieDownloadStatus("complete");
    fileName = Utility.createXmlFileName("LTX", tmpDataSetDate);

    logger.debug("generateXml : end...");
    return XML;
}

From source file:com.kcs.action.GenerateXmlDfFxmAction.java

public String generateXml() throws Exception {
    logger.debug("generateXml : begin...");
    logger.debug("dataSetDate : " + tmpDataSetDate);

    byte[] xmlBytes = generateXmlService.generateXmlFxm(tmpDataSetDate, tmpTcb);

    if (ArrayUtils.isEmpty(xmlBytes)) {
        //            throw new RuntimeException("Can't generate xml.");
        displayErrorMessage(new RuntimeException("Can't generate xml."));
    } else {/*www.  j a va2 s  . c  o m*/
        inputStream = new ByteArrayInputStream(xmlBytes);
    }
    setCookieDownloadStatus("complete");
    fileName = Utility.createXmlFileName("DF_FXM", tmpDataSetDate);

    logger.debug("generateXml : end...");
    return XML;
}

From source file:com.kcs.action.GenerateXmlPtxAction.java

public String generateXml() throws Exception {
    logger.debug("generateXml : begin...");
    logger.debug("dataSetDate : " + tmpDataSetDate);

    byte[] xmlBytes = generateXmlService.generateXmlPtx(tmpDataSetDate, tmpTcb);

    if (ArrayUtils.isEmpty(xmlBytes)) {
        throw new RuntimeException("Can't generate xml.");
    } else {// w w w .j a  v  a  2s.co  m
        inputStream = new ByteArrayInputStream(xmlBytes);
    }
    setCookieDownloadStatus("complete");
    fileName = Utility.createXmlFileName("PTX", tmpDataSetDate);

    logger.debug("generateXml : end...");
    return XML;
}