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.glaf.activiti.util.ExtensionUtils.java

public static List<Object> getValues(Map<String, Object> paramMap, ExtensionEntity extension) {
    java.util.Date now = new java.util.Date();
    List<Object> values = new java.util.ArrayList<Object>();
    List<ExtensionParamEntity> x_params = extension.getParams();
    Iterator<ExtensionParamEntity> iterator = x_params.iterator();
    while (iterator.hasNext()) {
        ExtensionParamEntity param = iterator.next();
        String key = param.getValue();
        Object value = param.getValue();
        if (key != null && value != null) {
            String tmp = param.getValue();
            if (StringUtils.isNotEmpty(tmp)) {
                if (tmp.equals("now()")) {
                    value = new java.sql.Date(now.getTime());
                } else if (tmp.equals("date()")) {
                    value = new java.sql.Date(now.getTime());
                } else if (tmp.equals("time()")) {
                    value = new java.sql.Time(now.getTime());
                } else if (tmp.equals("timestamp()")) {
                    value = new java.sql.Timestamp(now.getTime());
                } else if (tmp.equals("dateTime()")) {
                    value = new java.sql.Timestamp(now.getTime());
                } else if (tmp.equals("currentTimeMillis()")) {
                    value = Long.valueOf(System.currentTimeMillis());
                } else if (tmp.equals("#{businessKey}")) {
                    value = ParamUtils.getString(paramMap, "businessKey");
                } else if (tmp.equals("#{processInstanceId}")) {
                    value = ParamUtils.getString(paramMap, "processInstanceId");
                } else if (tmp.equals("#{processName}")) {
                    value = ParamUtils.getString(paramMap, "processName");
                } else if (tmp.equals("#{status}")) {
                    value = paramMap.get("status");
                } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) {
                    tmp = StringTools.replaceIgnoreCase(tmp, "#P{", "");
                    tmp = StringTools.replaceIgnoreCase(tmp, "}", "");
                    value = paramMap.get(tmp);
                } else if (tmp.startsWith("#{") && tmp.endsWith("}")) {
                    value = Mvel2ExpressionEvaluator.evaluate(tmp, paramMap);
                }/*  ww  w  .  j  a  v a 2s . c o m*/
            }
        }
        values.add(value);
    }
    return values;
}

From source file:de.hasait.genesis.base.model.AbstractJNamed.java

AbstractJNamed(final @Nonnull String pName) {
    super();
    GenesisUtils.assertTrue(StringUtils.isNotEmpty(pName));

    _name = pName;
}

From source file:com.wedian.site.common.template.method.CurrencyMethod.java

@SuppressWarnings("rawtypes")
public Object exec(List arguments) throws TemplateModelException {
    if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null
            && StringUtils.isNotEmpty(arguments.get(0).toString())) {
        boolean showSign = false;
        boolean showUnit = false;
        if (arguments.size() == 2) {
            if (arguments.get(1) != null) {
                showSign = Boolean.valueOf(arguments.get(1).toString());
            }/*from w w w  .  ja va2 s  .  c  o m*/
        } else if (arguments.size() > 2) {
            if (arguments.get(1) != null) {
                showSign = Boolean.valueOf(arguments.get(1).toString());
            }
            if (arguments.get(2) != null) {
                showUnit = Boolean.valueOf(arguments.get(2).toString());
            }
        }
        Setting setting = SettingUtils.get();
        BigDecimal amount = new BigDecimal(arguments.get(0).toString());
        String price = setting.setScale(amount).toString();
        if (showSign) {
            price = setting.getCurrencySign() + price;
        }
        if (showUnit) {
            price += setting.getCurrencyUnit();
        }
        return new SimpleScalar(price);
    }
    return null;
}

From source file:com.dgtlrepublic.anitomyj.StringHelper.java

/** Returns whether or not the {@code string} is mostly a latin string. */
public static boolean isMostlyLatinString(String string) {
    double length = StringUtils.isNotEmpty(string) ? 1.0 : string.length();
    return IntStream.range(0, StringUtils.isEmpty(string) ? 0 : string.length())
            .filter(value -> isLatinChar(string.charAt(value))).count() / length >= 0.5;
}

From source file:com.pontorural.pedidovenda.converter.CicloConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    if (StringUtils.isNotEmpty(value.toString())) {
        Ciclo classe = (Ciclo) value;// w  w w .  j a va  2s .  com
        this.addAttribute(component, classe);
        Integer codigo = classe.getCodigo();
        if (codigo != null) {
            return String.valueOf(codigo);
        }
    }
    return (String) value;
}

From source file:com.mirth.connect.connectors.tcp.SocketUtil.java

/**
 * Creates a socket and connects it to the specified remote host on the specified remote port.
 * // w  w w  .  jav a2s .  c om
 * @param host
 *            - The remote host to connect on.
 * @param port
 *            - The remote port to connect on.
 * @param localAddr
 *            - The local address to bind the socket to.
 * @param localPort
 *            - The local port to bind the socket to.
 * @param timeout
 *            - The socket timeout to use when connecting.
 * @return The bound and connected Socket.
 * @throws UnknownHostException
 *             if the IP address of the host could not be determined
 * @throws IOException
 *             if an I/O error occurs when creating the socket
 */
public static Socket createSocket(TcpConfiguration configuration, String localAddr, int localPort)
        throws UnknownHostException, IOException {
    Socket socket = configuration.createSocket();

    if (StringUtils.isNotEmpty(localAddr)) {
        InetAddress localAddress = InetAddress.getByName(TcpUtil.getFixedHost(localAddr));
        socket.bind(new InetSocketAddress(localAddress, localPort));
    }

    return socket;
}

From source file:com.oliveira.pedidovenda.converter.GrupoConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Grupo retorno = null;/* www  .jav a 2s  .  c o  m*/

    if (StringUtils.isNotEmpty(value)) {
        Long id = new Long(value);
        retorno = grupos.porId(id);
    }

    return retorno;
}

From source file:com.pontorural.pedidovenda.converter.ProdutoConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Produto retorno = null;/*from  w  w  w. ja v a  2  s  .co m*/

    if (StringUtils.isNotEmpty(value)) {
        String codigo;
        codigo = value;
        retorno = produtos.porId(codigo);
    }

    return retorno;
}

From source file:com.glaf.activiti.executionlistener.factory.ExecutionListenerFactory.java

public static void notify(String key, DelegateExecution execution) {
    String executionListenerType = "spring";
    if (StringUtils.isNotEmpty(SystemProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE))) {
        executionListenerType = SystemProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE);
    }/*from www .j  a v a  2s .co m*/
    if (StringUtils.isNotEmpty(CustomProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE))) {
        executionListenerType = CustomProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE);
    }

    key = key.trim();

    ExecutionListener executionListener = null;
    if (StringUtils.equals(executionListenerType, "spring")) {
        executionListener = (ExecutionListener) ExecutionListenerBeanFactory.getBean(key);
        if (executionListener != null) {
            try {
                executionListener.notify(execution);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    } else {
        try {
            executionListener = (ExecutionListener) pool.borrowObject(key);
            if (executionListener != null) {
                executionListener.notify(execution);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        } finally {
            if (executionListener != null) {
                try {
                    pool.returnObject(key, executionListener);
                } catch (Exception ex) {
                    if (LogUtils.isDebug()) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    }
}

From source file:br.com.bb.intranet.supermt.governo.sbg.converter.SitesPrefeiturasConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    SitesPrefeituras retorno = null;/*from  w ww. j a  va  2s .  c o  m*/

    if (value != null && StringUtils.isNotEmpty(value)) {
        retorno = this.repositorio.porCodigoIBGE(value);
    }

    return retorno;

}