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.ec2box.manage.model.UserSettings.java

public void setPlane(String plane) {
    if (StringUtils.isNotEmpty(plane) && plane.split(",").length == 2) {
        this.setBg(plane.split(",")[0]);
        this.setFg(plane.split(",")[1]);
    }//from  w  w  w .j  av a2 s.  c o m
    this.plane = plane;
}

From source file:com.baifendian.swordfish.common.hive.service2.HiveService2PoolFactory.java

/**
 * ?/*w w  w  .jav a  2  s. c  om*/
 *
 * @param object
 * @return
 * @throws Exception
 */
@Override
public HiveConnection makeObject(Object object) throws Exception {
    // ? client 
    if (object != null) {
        HiveService2ConnectionInfo hiveService2ConnectionInfo = (HiveService2ConnectionInfo) object;
        Properties info = new Properties();

        if (StringUtils.isNotEmpty(hiveService2ConnectionInfo.getUser())) {
            info.put("user", hiveService2ConnectionInfo.getUser());
        }

        if (StringUtils.isNotEmpty(hiveService2ConnectionInfo.getPassword())) {
            info.put("password", hiveService2ConnectionInfo.getPassword());
        }

        try {
            HiveConnection connection = new HiveConnection(hiveService2ConnectionInfo.getUri(), info);
            return connection;
        } catch (SQLException e) {
            logger.error("Connection hive exception", e);
        }
    }

    return null;
}

From source file:de.micromata.genome.logging.LogSqlAttribute.java

@Override
public String getValue() {
    if (StringUtils.isNotEmpty(super.getValue()) == true) {
        return super.getValue();
    }/*  w  w  w .  j  a  v  a2s .c  o  m*/
    String formated = formatValue(sql, args);
    super.setValue(formated);
    return formated;
}

From source file:com.github.aynu.mosir.core.enterprise.persistence.SmartRepositoryProducer.java

/**
 * ???//from   w  w  w . j  a v a  2 s.  c  om
 * @return ?()
 */
@Produces
public SmartRepository<Testee, TesteeFilter> createTestee() {
    final SmartRepositoryListener<Testee, TesteeFilter> listener = new AbstractSmartRepositoryListener<Testee, TesteeFilter>() {
        @Override
        public CriteriaQuery<Testee> query(final CriteriaBuilder builder, final CriteriaQuery<Testee> query,
                final Root<Testee> root, final TesteeFilter filter) {
            query.select(root);
            if (StringUtils.isNotEmpty(filter.getCode())) {
                query.where(builder.equal(root.get("code"), filter.getCode()));
            }
            return query.orderBy(createOrders(builder, root, filter));
        }
    };
    return new SmartRepositoryImpl<>(Testee.class, manager, listener);
}

From source file:com.autsia.socialboot.businesslogic.nlp.processors.NLPProcessor.java

/**
 * Finds sentiment of a message//  ww w.j  a  va  2s.co m
 *
 * @param text Input text
 * @return Class of Sentiment
 */
public Sentiment findSentiment(String text) {
    int mainSentiment = 0;
    if (StringUtils.isNotEmpty(text)) {
        int longest = 0;
        Annotation annotation = pipeline.process(text);
        for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
            Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class);
            int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
            String partText = sentence.toString();
            if (partText.length() > longest) {
                mainSentiment = sentiment;
                longest = partText.length();
            }

        }
    }
    return Sentiment.valueOf(mainSentiment);
}

From source file:com.green.modules.sys.service.DictService.java

public Page<Dict> find(Page<Dict> page, Dict dict) {
    // MyBatis /*from ww w  .jav  a2  s . co  m*/
    //      dict.setPage(page);
    //      page.setList(myBatisDictDao.find(dict));
    //      return page;
    // Hibernate 
    DetachedCriteria dc = dictDao.createDetachedCriteria();
    if (StringUtils.isNotEmpty(dict.getType())) {
        dc.add(Restrictions.eq("type", dict.getType()));
    }
    if (StringUtils.isNotEmpty(dict.getDescription())) {
        dc.add(Restrictions.like("description", "%" + dict.getDescription() + "%"));
    }
    dc.add(Restrictions.eq(Dict.FIELD_DEL_FLAG, Dict.DEL_FLAG_NORMAL));
    dc.addOrder(Order.asc("type")).addOrder(Order.asc("sort")).addOrder(Order.desc("id"));
    return dictDao.find(page, dc);
}

From source file:me.j360.base.service.common.ResultService.java

public String toAjax(Result result) {
    int errorCode = result.getState();
    String errorMessage = StringUtils.isNotEmpty(result.getMessage()) ? result.getMessage() : "";
    JSONObject object = result.getData() != null ? JSONObject.fromObject(result.getData()) : null;

    Map<String, Object> mpMap = new HashMap<String, Object>();
    Map<String, Object> rsMap = new HashMap<String, Object>();
    rsMap.put("errorCode", errorCode);
    rsMap.put("errorMessage", errorMessage);
    mpMap.put("result", JSONObject.fromObject(rsMap));
    mpMap.put("data", object == null ? "" : object);
    return JSONObject.fromObject(mpMap).toString();
}

From source file:com.arvato.thoroughly.util.security.impl.AES128AttributeEncryptionStrategy.java

public String encrypt(final String s) throws Exception {
    if (StringUtils.isNotEmpty(s)) {
        final Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM);
        final SecretKeySpec keySpec = getKeySpec();
        cipher.init(1, keySpec);/*from ww w.j ava 2 s  .c  om*/

        final byte[] encrypted = cipher.doFinal(s.getBytes());
        final byte[] encoded = new Hex().encode(encrypted);
        return new String(encoded);
    }
    return s;
}

From source file:com.glaf.dts.web.springmvc.MxDtsSchedulerController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    String jx_view = request.getParameter("jx_view");
    RequestUtils.setRequestParameterToAttribute(request);
    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }// www  .j ava2  s  .c  om

    String x_view = ViewProperties.getString("dts_scheduler.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }
    return new ModelAndView("/bi/dts/scheduler/edit", modelMap);
}

From source file:com.msg.wmTestHelper.pojo.ProcessStep.java

/**
 * @return the first literal of the step name, per definition the technical name.
 *///  w w w .  j  av a  2 s  .  co m
public String cropStepLabel() {
    if (StringUtils.isNotEmpty(stepLabel)) {
        String[] strings = stepLabel.split(" ");
        String literal = strings[0];
        if (isTechnicalName(literal)) {
            return literal;
        } else {
            // There is no rule without exception :(
            for (String otherLiteral : strings) {
                if (isTechnicalName(otherLiteral)) {
                    return otherLiteral;
                }
            }
        }
    }

    return StringUtils.EMPTY;
}