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.micromata.genome.gwiki.model.config.GWikiAbstractSpringContextBootstrapConfigLoader.java

public String getApplicationContextName() {
    if (StringUtils.isEmpty(fileName) == true) {

        fileName = "GWikiContext.xml";
    }
    return fileName;
}

From source file:$.MyWebService.java

@GET
    @Produces("text/plain; charset=utf8")
    public Response hello(@QueryParam("name") String name) {
        if (StringUtils.isEmpty(name)) {
            log.warn("No name given");
            // No name given? Invalid request.
            return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build();
        }//from w  w w  . ja v  a 2 s.co  m

        log.debug("Sending regards to {}", name);
        // Return the greeting.
        return Response.ok(myService.helloWorld(name)).build();
    }

From source file:de.micromata.genome.gwiki.plugin.vfolder_1_0.GWikiVFileSyncJob.java

@Override
public void call() {
    List<String> pages;
    String pageIds = args.get("PAGEIDS");
    if (StringUtils.isEmpty(pageIds) == true) {
        pages = new ArrayList<String>();
        for (GWikiElementInfo ei : wikiContext.getElementFinder()
                .getPageInfos(new GWikiElementMetatemplateMatcher(wikiContext,
                        GWikiVFolderLoadFilter.VFILE_METATEMPLATEID))) {
            pages.add(ei.getId());/* ww w .j a va2 s .c om*/
        }
    } else {
        pages = Converter.parseStringTokens(pageIds, ", ", false);
    }
    for (String page : pages) {
        check(page);
    }
}

From source file:io.cloudslang.content.httpclient.build.HeadersBuilder.java

public List<Header> buildHeaders() {
    ArrayList<Header> headersArr = new ArrayList<>();
    if (!StringUtils.isEmpty(headers)) {
        BufferedReader in = new BufferedReader(new StringReader(headers));

        String str;/* w  w w  . ja  v a 2 s.  c  o m*/
        try {
            while ((str = in.readLine()) != null) {
                CharArrayBuffer charArrayBuffer = new CharArrayBuffer(str.length());
                charArrayBuffer.append(str);
                headersArr.add(new BufferedHeader(charArrayBuffer));
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }

    if (entityContentType != null) {
        headersArr.add(entityContentType);
    } else if (contentType != null && !contentType.toString().isEmpty()) {
        headersArr.add(new BasicHeader("Content-Type", contentType.toString()));
    }
    return headersArr;
}

From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionComandChilds.java

protected boolean isChildOf(GWikiContext ctx, GWikiElementInfo parent, GWikiElementInfo child) {
    if (StringUtils.equals(child.getParentId(), parent.getId()) == true) {
        return true;
    }/*from ww  w.  j a  va 2 s . com*/
    if (StringUtils.isEmpty(child.getParentId()) == true) {
        return false;
    }
    GWikiElementInfo el = ctx.getWikiWeb().findElementInfo(child.getParentId());
    if (el == null)
        return false;
    return isChildOf(ctx, parent, el);
}

From source file:com.hg.ecommerce.util.MailUtil.java

/**
 * This method is used to send a Message with a pre-defined
 * mime-type./*from  w  w  w .  j  av a 2  s.  c  om*/
 *
 * @param from     e-mail address of sender
 * @param to       e-mail address(es) of recipients
 * @param subject  subject of e-mail
 * @param content  the body of the e-mail
 * @param mimeType type of message, i.e. text/plain or text/html
 * @throws MessagingException the exception to indicate failure
 */
public static void sendMessage(Session session, String from, String[] to, String[] cc, String[] bcc,
        String subject, String content, String mimeType) throws MessagingException {
    MimeMessage message = new MimeMessage(session);

    // n.b. any default from address is expected to be determined by caller.
    if (!StringUtils.isEmpty(from)) {
        InternetAddress sentFrom = new InternetAddress(from);
        message.setFrom(sentFrom);
        if (mLogger.isDebugEnabled()) {
            mLogger.debug("e-mail from: " + sentFrom);
        }
    }

    if (to != null) {
        InternetAddress[] sendTo = new InternetAddress[to.length];

        for (int i = 0; i < to.length; i++) {
            sendTo[i] = new InternetAddress(to[i]);
            if (mLogger.isDebugEnabled()) {
                mLogger.debug("sending e-mail to: " + to[i]);
            }
        }
        message.setRecipients(Message.RecipientType.TO, sendTo);
    }

    if (cc != null) {
        InternetAddress[] copyTo = new InternetAddress[cc.length];

        for (int i = 0; i < cc.length; i++) {
            copyTo[i] = new InternetAddress(cc[i]);
            if (mLogger.isDebugEnabled()) {
                mLogger.debug("copying e-mail to: " + cc[i]);
            }
        }
        message.setRecipients(Message.RecipientType.CC, copyTo);
    }

    if (bcc != null) {
        InternetAddress[] copyTo = new InternetAddress[bcc.length];

        for (int i = 0; i < bcc.length; i++) {
            copyTo[i] = new InternetAddress(bcc[i]);
            if (mLogger.isDebugEnabled()) {
                mLogger.debug("blind copying e-mail to: " + bcc[i]);
            }
        }
        message.setRecipients(Message.RecipientType.BCC, copyTo);
    }
    message.setSubject((subject == null) ? "(no subject)" : subject, "UTF-8");
    message.setContent(content, mimeType);
    message.setSentDate(new java.util.Date());

    // First collect all the addresses together.
    Address[] remainingAddresses = message.getAllRecipients();
    int nAddresses = remainingAddresses.length;
    boolean bFailedToSome = false;

    SendFailedException sendex = new SendFailedException("Unable to send message to some recipients");

    // Try to send while there remain some potentially good addresses
    do {
        // Avoid a loop if we are stuck
        nAddresses = remainingAddresses.length;

        try {
            // Send to the list of remaining addresses, ignoring the addresses attached to the message
            Transport.send(message, remainingAddresses);
        } catch (SendFailedException ex) {
            bFailedToSome = true;
            sendex.setNextException(ex);

            // Extract the remaining potentially good addresses
            remainingAddresses = ex.getValidUnsentAddresses();
        }
    } while (remainingAddresses != null && remainingAddresses.length > 0
            && remainingAddresses.length != nAddresses);

    if (bFailedToSome) {
        throw sendex;
    }
}

From source file:me.repository.office.OfficeDao.java

public List<Office> findOfficesBy(String id) {
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Office.class);
    if (!StringUtils.isEmpty(id)) {
        detachedCriteria.add(Restrictions.eq("parentId", Long.valueOf(id)));
    } else {//  w  ww.j  a v a2s  . co  m
        detachedCriteria.add(Restrictions.isNull("parentId"));
    }
    return find(detachedCriteria);
}

From source file:candr.yoclip.ParsedOption.java

/**
 * Creates an immutable error for a parsed parameter that does not have an {@link ParserOption} associated with it.
 *
 * @param error A description of the error.
 *//*  w ww  .  j  av a  2s .co  m*/
public ParsedOption(final String error) {
    if (StringUtils.isEmpty(error)) {
        throw new IllegalArgumentException("The parsed parameter error cannot be empty.");
    }
    this.error = error;
}

From source file:com.movies.bean.MovieDetailBean.java

@PostConstruct
private void init() {
    String param = JsfUtil.getRequestParameter(MovieConstants.ID_FIELD);
    if (StringUtils.isEmpty(param)) {
        movies = movieService.getAllMoviesWithActorsAndDirectors();
    } else {/*from   ww w  .  j a v a 2 s  . co  m*/
        movies = Arrays.asList(movieService.getMovieById(Integer.parseInt(param)));
    }
}

From source file:com.creditcloud.interestbearing.model.HuaAnFundAccountConfig.java

@JsonIgnore
public boolean isPlatformTradingPrivateKeyReady() {
    boolean isPlatformTradingPrivateKeyReady = !StringUtils.isEmpty(platformTradingPrivateKey);
    return isPlatformTradingPrivateKeyReady;
}