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.pontorural.pedidovenda.converter.PessoaConverter.java

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

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = pessoas.porId(codigo);
    }

    return retorno;
}

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

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

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = condicoes.porId(codigo);
    }

    return retorno;
}

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

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

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = operacoes.porId(codigo);
    }

    return retorno;
}

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

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

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = parceiros.porId(codigo);
    }

    return retorno;
}

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

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

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = empresas.porId(codigo);
    }

    return retorno;
}

From source file:io.wcm.wcm.ui.granite.util.GraniteUi.java

/**
 * Current content resource//from   ww w .  j  a  v a2  s  .  c o  m
 * @param request Request
 * @return Current content resource or null
 */
public static Resource getContentResource(HttpServletRequest request) {
    SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
    String contentPath = (String) request.getAttribute(Value.CONTENTPATH_ATTRIBUTE);
    if (contentPath != null) {
        return slingRequest.getResourceResolver().getResource(contentPath);
    }
    // fallback to suffix if CONTENTPATH_ATTRIBUTE is not set
    // (e.g. in inside a /libs/granite/ui/components/foundation/form/multifield component)
    contentPath = ((SlingHttpServletRequest) request).getRequestPathInfo().getSuffix();
    if (StringUtils.isNotEmpty(contentPath)) {
        return slingRequest.getResourceResolver().getResource(contentPath);
    }
    return null;
}

From source file:com.jkoolcloud.tnt4j.streams.utils.StreamsScriptingUtils.java

/**
 * Initiates default set of Java API imported packages.
 *//* www. j a va2 s  . c om*/
private static void initDefaultImportPackages() {
    try {
        Properties p = Utils.loadPropertiesResources("scripting.properties"); // NON-NLS

        for (String pName : p.stringPropertyNames()) {
            if (pName.endsWith(".scripting.import.packages")) { // NON-NLS
                String importPackages = p.getProperty(pName);

                if (StringUtils.isNotEmpty(importPackages)) {
                    String[] pArray = importPackages.split(";");

                    Collections.addAll(DEFAULT_IMPORT_PACKAGES, pArray);
                }
            }
        }
    } catch (Exception exc) {
    }
}

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

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Propriedade retorno = null;//from  w  ww.java2 s .  co  m

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = propriedades.porId(codigo);
    }

    return retorno;
}

From source file:io.wcm.caravan.io.http.impl.CaravanHttpServiceConfigValidator.java

/**
 * Checks if a valid configuration exists for the given service ID. This does not mean that the host
 * name is correct or returns correct responses, it only checks that the minimum required configuration
 * properties are set to a value./* w  ww .  ja  v  a 2s  . co  m*/
 * @param serviceId Service ID
 * @return true if configuration is valid
 */
public static boolean hasValidConfiguration(String serviceId) {
    Configuration archaiusConfig = ArchaiusConfig.getConfiguration();
    return StringUtils.isNotEmpty(archaiusConfig.getString(serviceId + RIBBON_PARAM_LISTOFSERVERS));
}

From source file:it.attocchi.utils.HtmlUtils.java

/**
 * /*  ww  w.  j  a  va 2s  . co m*/
 * @param uri
 * @return
 * @throws Exception
 */
// public static String readUrl(String uri) throws Exception {
// StringBuilder sb = new StringBuilder();
// URL url = new URL(uri);
// BufferedReader in = new BufferedReader(new
// InputStreamReader(url.openStream()));
//
// String inputLine;
// while ((inputLine = in.readLine()) != null) {
// sb.append(inputLine);
// }
// in.close();
//
// return sb.toString();
// }

public static String callUrl(String url) throws Exception {
    StringBuffer sb = new StringBuffer();

    // try {

    if (StringUtils.isNotEmpty(url)) {
        URL anUrl = new URL(url);
        BufferedReader in = new BufferedReader(new InputStreamReader(anUrl.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            // System.out.println(inputLine);
            sb.append(inputLine);
        }
        in.close();
    }

    // } catch (Exception ex) {
    // // logger.error("callProc", ex);
    // }

    return sb.toString();
}