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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

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

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

NOTE: This method changed in Lang version 2.0.

Usage

From source file:de.yaio.services.webshot.client.WebshotClient.java

public static WebshotClient createClient(final String webshoturl, final String webshotusername,
        final String webshotpassword) {
    if (StringUtils.isEmpty(webshoturl)) {
        throw new IllegalArgumentException("cant create webshotclient: webshoturl must not be empty");
    }//w  ww  .j  a  va2s .c  om
    if (StringUtils.isEmpty(webshotusername)) {
        throw new IllegalArgumentException("cant create webshotclient: webshotusername must not be empty");
    }
    if (StringUtils.isEmpty(webshotpassword)) {
        throw new IllegalArgumentException("cant create webshotclient: webshotpassword must not be empty");
    }
    return new WebshotClient(webshoturl, webshotusername, webshotpassword);
}

From source file:com.esri.geoevent.test.performance.utils.MessageUtils.java

public static String unescapeNewLineCharacters(String data) {
    if (StringUtils.isEmpty(data))
        return null;

    String replacedData = data.replace(CRNL_SEPERATOR, DEFAULT_CRNL_SEPERATOR);
    replacedData = replacedData.replace(CR_SEPERATOR, DEFAULT_CR_SEPERATOR);
    replacedData = replacedData.replace(NL_SEPERATOR, DEFAULT_NL_SEPERATOR);

    return replacedData;
}

From source file:com.thruzero.common.core.locator.LocatorUtils.java

/**
 * Return the required initialization parameter and if empty, throw an InitializationException.
 *
 * @param params the parameters read from the InitializationStrategy.
 * @param sectionName the section the params were read from (used only for error reporting).
 * @param key the parameter key used to read the value.
 * @param initStrategy the initialization strategy that was the source of the params (used only for error reporting).
 *///from   ww w. j  a v  a 2  s  .c  o m
public static String getRequiredParam(final StringMap params, final String sectionName, final String key,
        final InitializationStrategy initStrategy) {
    String result = params.get(key);

    if (StringUtils.isEmpty(result)) {
        throw InitializationException.createMissingKeyInitializationException(sectionName, key, initStrategy);
    }

    return result;
}

From source file:de.knightsoftnet.validators.shared.util.RegExUtil.java

/**
 * get all allowed characters which can be part of a String which matches a given regular
 * expression. TODO: this is a first feature incomplete implementation, has to be improved.
 *
 * @param pregEx string contains a regular expression pattern
 * @return string with all characters that can be part of a string that matches the regex
 *///  w w  w .j av  a2s .c  o  m
public static String getAllowedCharactersForRegEx(final String pregEx) {
    if (StringUtils.isEmpty(pregEx)) {
        return null;
    }
    final StringBuilder regExCheck = new StringBuilder();
    final StringBuilder regExCheckOut = new StringBuilder();
    boolean inSequence = false;
    boolean isNegativeSequence = false;
    boolean inSize = false;
    boolean isMasked = false;

    regExCheck.append("([");
    for (final char character : pregEx.toCharArray()) {
        switch (character) {
        case '\\':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            if (!inSequence) {
                isMasked = !isMasked;
            }
            break;
        case '^':
            if (inSequence) {
                if (isMasked) {
                    regExCheck.append(character);
                } else {
                    isNegativeSequence = true;
                }
            }
            isMasked = false;
            break;
        case '$':
        case '*':
        case '+':
        case '?':
        case '|':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        case '[':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSequence = true;
                isNegativeSequence = false;
            }
            isMasked = false;
            break;
        case ']':
            if (isMasked) {
                regExCheck.append(character);
            } else {
                inSequence = false;
                isNegativeSequence = false;
            }
            isMasked = false;
            break;
        case '{':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSize = true;
            }
            isMasked = false;
            break;
        case '}':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSize = false;
            }
            isMasked = false;
            break;
        case '(':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        case ')':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        default:
            if (inSize) {
                if (character != ',' && (character < '0' || character > '9')) {
                    regExCheck.append(character);
                }
            } else if (!isNegativeSequence) {
                if (isMasked) {
                    if (regExCheckOut.length() > 1) {
                        regExCheckOut.append('|');
                    }
                    regExCheckOut.append('\\');
                    regExCheckOut.append(character);
                } else {
                    regExCheck.append(character);
                }
            }
            isMasked = false;
            break;
        }
    }
    if (regExCheck.length() < 3) {
        regExCheck.delete(1, regExCheck.length());
    } else {
        regExCheck.append(']');
        if (regExCheckOut.length() > 0) {
            regExCheck.append('|');
        }
    }
    regExCheck.append(regExCheckOut);
    regExCheck.append(')');
    final RegExp regEx = RegExp.compile(regExCheck.toString());
    final StringBuilder result = new StringBuilder();
    for (int count = Character.MIN_VALUE; count < Character.MAX_VALUE; count++) {
        if (regEx.exec(String.valueOf((char) count)) != null) {
            result.append((char) count);
        }
    }
    return result.toString();
}

From source file:jp.junoe.confluence.plugins.precure.macro.Heading.java

@Override
public String execute(Map<String, String> params, String body, ConversionContext context)
        throws MacroExecutionException {
    String serise = params.get("series");
    if (StringUtils.isEmpty(serise)) {
        serise = "MaxHeart";
    }/*  ww w.jav a2  s  .  co m*/
    return "<div class=\"precure-heading ph-" + serise + "\">" + body + "</div>";
}

From source file:costumetrade.common.akka.ActorSystemContext.java

public static <T> ActorRef createActor(Props props, String name) {
    ActorSystem system = ActorSystemContext.get();
    if (StringUtils.isEmpty(name)) {
        return system.actorOf(props);
    }/*  w  ww.ja v a  2  s.  c o  m*/
    return system.actorOf(props, name);
}

From source file:io.cloudslang.content.utils.CollectionUtilities.java

/**
 * Splits the stringArray by the delimiter into an array of strings without ignoring the escaped delimiters
 *
 * @param stringArray the string to be split
 * @param delimiter   the delimiter by which to split the stringArray
 * @return an array of Strings/*from  w  ww.  ja va 2  s.  c  om*/
 */
@NotNull
public static String[] toArrayWithEscaped(@Nullable final String stringArray, @NotNull final String delimiter) {
    if (StringUtils.isEmpty(stringArray)) {
        return new String[0];
    }
    return StringUtils.splitByWholeSeparatorPreserveAllTokens(stringArray, delimiter);
}

From source file:ir.iais.utilities.javautils.utils.xml.DateAdapter.java

@Override
public Date unmarshal(String v) throws Exception {
    return StringUtils.isEmpty(v) ? null : dateFormat.parse(v);
}

From source file:fr.penet.servlet.ResumeCrawlServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String runIdString = req.getParameter("id");
    if (StringUtils.isEmpty(runIdString)) {
        resp.getWriter().println("Error : empty id parameter");
        return;//from   w  w w .ja  va2 s .  c  o  m
    }
    if (!StringUtils.isNumeric(runIdString)) {
        resp.getWriter().println("Error : id parameter is not an integer");
        return;
    }
    int runId = Integer.parseInt(runIdString);

    String threads = req.getParameter("threads");
    int threadInt = 5;
    if (StringUtils.isNumeric(threads)) {
        threadInt = Integer.parseInt(threads);
    }
    CustomCrawler crawler = new CustomCrawler();
    crawler.resumeCollectUrls(runId, threadInt);
    resp.getWriter().println("Crawler run with id " + runId + " resumed with " + threadInt + " threads");
}

From source file:com.casker.portfolio.common.DateConverter.java

@Override
public Date convert(String source) {
    if (StringUtils.isEmpty(source)) {
        return null;
    }// w  w  w.j a va 2  s. c om

    try {
        return formatter.parse(source);
    } catch (ParseException e) {
        log.error("?  ", e);
        return null;
    }
}