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

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

Introduction

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

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:net.erdfelt.android.sdkfido.util.PropertyExpander.java

public String expand(String str) {
    if (StringUtils.isEmpty(str)) {
        // Empty string. Fail fast.
        return str;
    }//from  w w w .  ja v a2  s . c  o m

    if (str.indexOf("@") < 0) {
        // Contains no potential expressions. Fail fast.
        return str;
    }

    Matcher mat = pat.matcher(str);
    int offset = 0;
    String expression;
    String value;
    StringBuffer expanded = new StringBuffer();

    while (mat.find(offset)) {
        expression = mat.group(1);

        expanded.append(str.substring(offset, mat.start(1)));
        value = props.get(mat.group(2));
        if (value != null) {
            expanded.append(value);
        } else {
            expanded.append(expression);
        }
        offset = mat.end(1);
    }

    expanded.append(str.substring(offset));

    if (expanded.indexOf("@@") >= 0) {
        // Special case for escaped content.
        return expanded.toString().replaceAll("\\@\\@", "\\@");
    } else {
        // return expanded
        return expanded.toString();
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.export.sqlresult.composite.AbstractExportComposite.java

public boolean isValidate() {
    if (StringUtils.isEmpty(textTargetName.getText())) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning,
                Messages.get().AbstractExportCompositeFileEmpty);
        textTargetName.setFocus();// ww w.  j  a va2  s. c o  m
        return false;
    }
    if (StringUtils.isEmpty(comboEncoding.getText())) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning,
                Messages.get().AbstractExportCompositeEncoding);
        comboEncoding.setFocus();
        return false;
    }
    return true;
}

From source file:info.magnolia.cms.util.PathUtil.java

public static String getFolder(String path) {
    String res;/*from  www  . j  a  v a  2 s  . co  m*/
    res = StringUtils.substringBeforeLast(path, "/"); //$NON-NLS-1$
    if (StringUtils.isEmpty(res)) {
        return "/"; //$NON-NLS-1$
    }
    return res;
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.ReviewValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final ReviewForm reviewForm = (ReviewForm) object;
    final String headLine = reviewForm.getHeadline();
    final String comment = reviewForm.getComment();
    final Double rating = reviewForm.getRating();

    if (StringUtils.isEmpty(headLine) || StringUtils.length(headLine) > 255) {
        errors.rejectValue("headline", "review.headline.invalid");
    }/*from ww w .ja v  a  2  s  . c  o m*/

    if (StringUtils.isEmpty(comment) || StringUtils.length(comment) > 4000) {
        errors.rejectValue("comment", "review.comment.invalid");
    }

    if (rating == null || rating.doubleValue() < 0.5 || rating.doubleValue() > 5) {
        errors.rejectValue("rating", "review.rating.invalid");
    }
}

From source file:com.daveayan.rjson.utils.RjsonUtil.java

public static Object getJsonObject(String json) throws JSONException {
    log.debug("getJsonObject for " + json);
    if (StringUtils.isEmpty(json)) {
        return "";
    }//from   ww w  .j av a  2s .  c o  m
    JSONTokener tokener = new JSONTokener(json);
    char firstChar = tokener.nextClean();
    if (firstChar == '\"') {
        return tokener.nextString('\"');
    }
    if (firstChar == '{') {
        tokener.back();
        return new JSONObject(tokener);
    }
    if (firstChar == '[') {
        tokener.back();
        return new JSONArray(tokener);
    }
    if (Character.isDigit(firstChar)) {
        tokener.back();
        return tokener.nextValue();
    }
    tokener.back();
    return tokener.nextValue();
}

From source file:com.dp2345.controller.admin.TemplateController.java

/**
 * //from www . j  a  v  a2 s  .c om
 */
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String edit(String id, ModelMap model) {
    if (StringUtils.isEmpty(id)) {
        return ERROR_VIEW;
    }
    model.addAttribute("template", templateService.get(id));
    model.addAttribute("content", templateService.read(id));
    return "/admin/template/edit";
}

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

/** {@inheritDoc} */
@Override// w  w w .ja  v  a  2  s  .c  o m
public int findByOrgCodeAndMonth(String strCode, String month) throws ServiceException {
    if (StringUtils.isEmpty(strCode)) {
        throw new IllegalArgumentException("Organization's code must not be null or empty");
    }
    if (StringUtils.isEmpty(month)) {
        throw new IllegalArgumentException("Month must not be null or empty");
    }

    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    int recordsNo = 0;

    try {
        tx = session.beginTransaction();
        Query namedQuery = repository.getNamedQuery(session,
                SqlConstants.SQL_FIND_MONTHLY_PURCHASE_BY_ORGANIZATION_AND_MONTH);
        namedQuery.setString("strCode", strCode);
        namedQuery.setString("getSudo", month);

        Long result = (Long) namedQuery.uniqueResult();
        recordsNo = result.intValue();
        tx.commit();
    } catch (HibernateException ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException("An exception occured while count purchase change for organization "
                + strCode + " month " + month, ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return recordsNo;
}

From source file:gov.nih.nci.cabig.caaers.dao.query.DeviceQuery.java

public void filterByCtepDbIdentifier(String ctepDbIdentifier) {
    if (StringUtils.isEmpty(ctepDbIdentifier)) {
        andWhere("d.ctepDbIdentifier is NULL OR d.ctepDbIdentifier = ''");
    } else {//  w ww. ja va 2 s. c  om
        andWhere("d.ctepDbIdentifier = :dbId");
        setParameter("dbId", ctepDbIdentifier);
    }
}

From source file:com.intel.cosbench.config.Operation.java

public void setType(String type) {
    if (StringUtils.isEmpty(type))
        throw new ConfigException("operation type cannot be empty");
    this.type = type;
}

From source file:com.pedra.storefront.forms.validation.ProfileValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final UpdateProfileForm profileForm = (UpdateProfileForm) object;
    final String title = profileForm.getTitleCode();
    final String firstName = profileForm.getFirstName();
    final String lastName = profileForm.getLastName();

    if (StringUtils.isEmpty(title)) {
        errors.rejectValue("titleCode", "profile.title.invalid");
    } else if (StringUtils.length(title) > 255) {
        errors.rejectValue("titleCode", "profile.title.invalid");
    }//  w ww.  j  a va2  s .  com

    if (StringUtils.isEmpty(firstName)) {
        errors.rejectValue("firstName", "profile.firstName.invalid");
    } else if (StringUtils.length(firstName) > 255) {
        errors.rejectValue("firstName", "profile.firstName.invalid");
    }

    if (StringUtils.isEmpty(lastName)) {
        errors.rejectValue("lastName", "profile.lastName.invalid");
    } else if (StringUtils.length(lastName) > 255) {
        errors.rejectValue("lastName", "profile.lastName.invalid");
    }
}