Example usage for org.apache.commons.lang3 StringUtils isNotEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:com.cognifide.qa.bb.aem.ui.DialogFieldProvider.java

/**
 * Looks for DialogField annotation, reads locator data from the annotation instance
 * and asks AemDialogFieldResolver to produce a dialog field instance for the class field.
 *///from  w w  w .j a  va 2s .c  om
@Override
public Optional<Object> provideValue(Object pageObject, Field field, PageObjectContext context) {
    AemDialogFieldResolver aemDialogFieldResolver = fieldResolverProvider.get();
    DialogField dialogFieldAnnotation = field.getAnnotation(DialogField.class);

    String searchBy;
    Class<?> type = field.getType();
    Object dialogField = null;
    if (StringUtils.isNotEmpty(dialogFieldAnnotation.label())) {
        searchBy = dialogFieldAnnotation.label();
        dialogField = aemDialogFieldResolver.getField(searchBy, type);
    } else if (StringUtils.isNotEmpty(dialogFieldAnnotation.css())) {
        searchBy = dialogFieldAnnotation.css();
        dialogField = aemDialogFieldResolver.getFieldByCss(searchBy, type);
    } else if (StringUtils.isNotEmpty(dialogFieldAnnotation.name())) {
        searchBy = dialogFieldAnnotation.name();
        dialogField = aemDialogFieldResolver.getFieldByName(searchBy, type);
    } else if (StringUtils.isNotEmpty(dialogFieldAnnotation.xpath())) {
        searchBy = dialogFieldAnnotation.xpath();
        dialogField = aemDialogFieldResolver.getFieldByXpath(searchBy, type);
    }
    return Optional.ofNullable(dialogField);
}

From source file:com.ec2box.manage.db.UserThemeDB.java

/**
 * saves user theme//  ww  w  .  j a v a 2s  .  c o m
 * 
 * @param userId object
 */
public static void saveTheme(Long userId, UserSettings theme) {

    Connection con = null;
    try {
        con = DBUtils.getConn();
        PreparedStatement stmt = con.prepareStatement("delete from user_theme where user_id=?");
        stmt.setLong(1, userId);
        stmt.execute();
        DBUtils.closeStmt(stmt);

        if (StringUtils.isNotEmpty(theme.getPlane()) || StringUtils.isNotEmpty(theme.getTheme())) {

            stmt = con.prepareStatement(
                    "insert into user_theme(user_id, bg, fg, d1, d2, d3, d4, d5, d6, d7, d8, b1, b2, b3, b4, b5, b6, b7, b8) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            stmt.setLong(1, userId);
            stmt.setString(2, theme.getBg());
            stmt.setString(3, theme.getFg());
            //if contains all 16 theme colors insert
            if (theme.getColors() != null && theme.getColors().length == 16) {
                for (int i = 0; i < 16; i++) {
                    stmt.setString(i + 4, theme.getColors()[i]);
                }
                //else set to null
            } else {
                for (int i = 0; i < 16; i++) {
                    stmt.setString(i + 4, null);
                }
            }
            stmt.execute();
            DBUtils.closeStmt(stmt);
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DBUtils.closeConn(con);
    }

}

From source file:com.glaf.report.web.springmvc.MxReportFileController.java

@RequestMapping("/delete")
public ModelAndView delete(HttpServletRequest request, ModelMap modelMap) {

    Map<String, Object> params = RequestUtils.getParameterMap(request);
    String reportFileId = ParamUtils.getString(params, "reportFileId");
    String reportFileIds = request.getParameter("reportFileIds");
    if (StringUtils.isNotEmpty(reportFileIds)) {
        StringTokenizer token = new StringTokenizer(reportFileIds, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                ReportFile reportFile = reportFileService.getReportFile(x);
                if (reportFile != null) {

                    reportFileService.save(reportFile);
                }/* w ww.j a  v a 2  s.  c o  m*/
            }
        }
    } else if (StringUtils.isNotEmpty(reportFileId)) {
        ReportFile reportFile = reportFileService.getReportFile(reportFileId);
        if (reportFile != null) {

            reportFileService.save(reportFile);
        }
    }

    return this.list(request, modelMap);
}

From source file:com.gdo.stencils.cond.LinkCondition.java

public static <C extends _StencilContext, S extends _PStencil<C, S>> boolean isWithoutLinksCondition(
        C stclContext, S link, StencilCondition<C, S> cond) {
    if (cond instanceof PathCondition) {
        String path = ((PathCondition<C, S>) cond).getCondition();
        if (PathUtils.isExpContained(path)) {
            String exp = PathUtils.getExpContained(path);
            return (StringUtils.isNotEmpty(exp) && exp.equals("$!"));
        }/*from w ww .j  a  v a2s . co m*/
    }
    return false;
}

From source file:com.glaf.activiti.web.springmvc.ActivitiProcessImageController.java

@RequestMapping("/image")
@ResponseBody/*w w  w . j ava 2s  .  co m*/
public byte[] image(@RequestParam("deploymentId") String deploymentId) throws IOException {
    ProcessDefinition processDefinition = null;
    logger.debug("deploymentId:" + deploymentId);
    if (StringUtils.isNotEmpty(deploymentId)) {
        processDefinition = activitiProcessQueryService.getProcessDefinitionByDeploymentId(deploymentId);
    }
    if (processDefinition != null) {
        byte[] bytes = null;
        try {
            bytes = ProcessUtils.getImage(processDefinition.getId());
        } catch (Exception e) {
        }
        return bytes;
    }

    return null;
}

From source file:com.inkubator.hrm.web.recruitment.RecruitAdvertisementMediaFormController.java

@PostConstruct
@Override//from w  w w. ja  v a  2 s. c o  m
public void initialization() {
    super.initialization();
    try {
        String recruitAdvertisementMediaId = FacesUtil.getRequestParameter("recruitmentId");
        model = new RecruitAdvertisementMediaModel();
        isUpdate = Boolean.FALSE;
        if (StringUtils.isNotEmpty(recruitAdvertisementMediaId)) {
            RecruitAdvertisementMedia recruitAdvertisementMedia = recruitAdvertisementMediaService
                    .getEntiyByPK(Long.parseLong(recruitAdvertisementMediaId));
            if (recruitAdvertisementMedia != null) {
                model = getModelFromEntity(recruitAdvertisementMedia);
                isUpdate = Boolean.TRUE;
            }
        }
        listAdvertisementCategory = recruitAdvertisementCategoryService.getAllData();
        for (RecruitAdvertisementCategory advCategory : listAdvertisementCategory) {
            dropDownAdvCategory.put(advCategory.getName(), advCategory.getId());
        }
    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:com.glaf.oa.traveladdress.web.springmvc.TraveladdressController.java

@ResponseBody
@RequestMapping("/delete")
public void delete(HttpServletRequest request, ModelMap modelMap) {
    Long addressid = RequestUtils.getLong(request, "addressid");
    String addressids = request.getParameter("addressids");
    if (StringUtils.isNotEmpty(addressids)) {
        StringTokenizer token = new StringTokenizer(addressids, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                Traveladdress traveladdress = traveladdressService.getTraveladdress(Long.valueOf(x));
                /**/*from w  w  w . j a v  a2s. c om*/
                 * 
                 */
                if (traveladdress != null) {
                    // traveladdress.setDeleteFlag(1);
                    traveladdressService.deleteById(Long.valueOf(x));
                }
            }
        }
    } else if (addressid != null) {
        Traveladdress traveladdress = traveladdressService.getTraveladdress(Long.valueOf(addressid));
        /**
         * 
         */
        if (traveladdress != null) {
            // traveladdress.setDeleteFlag(1);
            traveladdressService.deleteById(addressid);
        }
    }
}

From source file:io.cloudslang.lang.cli.SlangBootstrap.java

private static String replacePropertyReferences(String value, Set<String> variableNames) {
    for (String variableName : variableNames) {
        String variableValue = System.getProperty(variableName);
        if (StringUtils.isNotEmpty(variableValue)) {
            value = value.replace("${" + variableName + "}", variableValue);
        }/*from  w w  w.  java2 s.c  o m*/
    }
    return value;
}

From source file:de.hybris.platform.chineseprofile.controllers.pages.ChineseEmailPageController.java

@Override
@RequestMapping(value = "", method = RequestMethod.POST, params = "emailLanguage")
@RequireHardLogIn/* w w  w  .ja v  a  2s.  c o  m*/
public String updateEmail(final UpdateEmailForm updateEmailForm, final BindingResult bindingResult,
        final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException {
    final HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
            .getRequest();
    final String emailLanguage = request.getParameter("emailLanguage");
    if (StringUtils.isNotEmpty(emailLanguage)) {
        chineseCustomerFacade.saveEmailLanguageForCurrentUser(emailLanguage);
    }
    return super.updateEmail(updateEmailForm, bindingResult, model, redirectAttributes);
}

From source file:com.glaf.core.config.SystemProperties.java

/**
 * ?//from   w  w w.  j  av a 2  s .  c  o m
 * 
 * @return
 */
public static String getFileStorageRootPath() {
    if (StringUtils.isNotEmpty(conf.get("fs_storage_path"))) {
        String path = conf.get("fs_storage_path");
        if (StringUtils.startsWith(path, "${webapp.root}")) {
            path = StringTools.replaceIgnoreCase(path, "${webapp.root}", getAppPath());
        }
        if (StringUtils.startsWith(path, "${webapp.root.config}")) {
            path = StringTools.replaceIgnoreCase(path, "${webapp.root.config}", getConfigRootPath());
        }
        return path;
    }
    return getConfigRootPath();
}