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

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

Introduction

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

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:fm.pattern.valex.Reportable.java

private static Class<? extends ReportableException> getException(String key) {
    String className = ValexConfiguration.getException(key);
    if (StringUtils.isBlank(className)) {
        return null;
    }/*from  ww w .  j  a va2s  .c  o m*/

    try {
        return (Class<? extends ReportableException>) Class.forName(className);
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.autentia.bcbp.items.Item.java

public String getEncoded() {
    if (padding == PaddingType.Number && StringUtils.isBlank(original)) {
        return StringUtils.leftPad("", size).substring(0, size);
    }//from www.  ja  v  a  2 s .co m

    if (padding == PaddingType.Number) {
        return StringUtils.leftPad(original, size, "0").substring(0, size);
    }

    if (padding == PaddingType.NumberFollowedByAlpha && StringUtils.isBlank(original))
        return StringUtils.leftPad(original, size - 1, "0").substring(0, size - 1) + " ";

    if (padding == PaddingType.NumberFollowedByAlpha) {
        int lastPosition = original.length() - 1;
        if (StringUtils.isAlpha(original.substring(lastPosition))) {
            String number = original.substring(0, lastPosition);
            return StringUtils.leftPad(number, size - 1, "0").substring(0, size - 1)
                    + original.substring(lastPosition);
        } else {
            return StringUtils.leftPad(original, size - 1, "0").substring(0, size - 1) + " ";
        }
    }
    if (padding == PaddingType.String) {
        return StringUtils.rightPad(original, size).substring(0, size);
    }

    return "";
}

From source file:com.lynn.controller.LoginAction.java

@RequestMapping(value = "/login.do", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
@ResponseBody//w  w w  .  ja  va2 s  .  c  o m
public String loginAction(HttpServletRequest request, UserBean user) throws IOException {
    System.out.println("" + user);
    String username = user.getUsername();
    String password = user.getPassword();
    ResultBean result = null;
    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
        result = new ResultBean("error", "????");
        return new ObjectMapper().writeValueAsString(result);
    }
    //        UserBean tempUser = userDaoI.getByName(username);
    //        if(tempUser != null){
    //            if(!username.equalsIgnoreCase(tempUser.getUsername()) || !password.equalsIgnoreCase(tempUser.getPassword())){
    //            result = new ResultBean("error", "????!");
    //            }else{
    //                result = new ResultBean("ok", "1");
    //                request.getSession().setAttribute("user", user);
    //            }
    //        }
    return new ObjectMapper().writeValueAsString(result);
}

From source file:com.elemenopy.backupcopy.filesystem.RootFolderSynchronizer.java

public RootFolderSynchronizer(String defaultDestination, RootFolder sourceRootFolder) {
    this.destination = fileSystem
            .getPath(!StringUtils.isBlank(sourceRootFolder.getRemotePath()) ? sourceRootFolder.getRemotePath()
                    : defaultDestination);
    if (!Files.isDirectory(destination)) {
        throw new IllegalArgumentException("Destination path " + destination + " is not a directory");
    }/*ww w  .  j  a  va  2 s  .  c  om*/
    this.sourceRootFolder = sourceRootFolder;
}

From source file:com.trenako.web.editors.DeliveryDatePropertyEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (allowEmpty && StringUtils.isBlank(text)) {
        setValue(null);/*  w w  w  . ja v a2 s.c om*/
        return;
    }

    try {
        DeliveryDate dd = DeliveryDate.parseString(text);
        setValue(dd);
    } catch (DeliveryDateFormatException e) {
        throw new IllegalArgumentException("'" + text + "' is not a valid delivery date");
    }
}

From source file:de.romankreisel.faktotum.FaktotumContextListener.java

/**
 * @return the version/*  ww w  .j a va 2 s  .  c om*/
 */
public static String getVersion() {
    String projectVersion = FaktotumContextListener.version;
    if (StringUtils.isBlank(projectVersion)) {
        projectVersion = FaktotumContextListener.DEVELOPMENT_VERSION;
    }
    return projectVersion;
}

From source file:com.gammalabs.wifianalyzer.vendor.model.RemoteCall.java

@Override
protected RemoteResult doInBackground(String... params) {
    if (params == null || params.length < 1 || StringUtils.isBlank(params[0])) {
        return RemoteResult.EMPTY;
    }//from   www  . j  a  v a  2  s. c  o m
    String macAddress = params[0];
    String request = String.format(MAC_VENDOR_LOOKUP, macAddress.substring(0, macAddress.length() / 2));
    BufferedReader bufferedReader = null;
    try {
        URLConnection urlConnection = getURLConnection(request);
        bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        StringBuilder response = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            response.append(line);
        }
        String vendorName = VendorNameUtils.cleanVendorName(response.toString().trim());
        if (StringUtils.isNotBlank(vendorName)) {
            return new RemoteResult(macAddress, vendorName);
        }
        return RemoteResult.EMPTY;
    } catch (Exception e) {
        return RemoteResult.EMPTY;
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:com.msopentech.odatajclient.engine.data.ODataLinkType.java

/**
 * Gets//  w ww . ja v a  2 s. co m
 * <code>ODataLinkType</code> instance from the given rel and type.
 *
 * @param client OData client.
 * @param rel rel.
 * @param type type.
 * @return <code>ODataLinkType</code> object.
 */
public static ODataLinkType fromString(final ODataClient client, final String rel, final String type) {
    if (StringUtils.isNotBlank(rel) && rel
            .startsWith(client.getWorkingVersion().getNamespaceMap().get(ODataVersion.MEDIA_EDIT_LINK_REL))) {

        return MEDIA_EDIT.setType(StringUtils.isBlank(type) ? "*/*" : type);
    }

    if (ODataLinkType.ENTITY_NAVIGATION.type.equals(type)) {
        return ENTITY_NAVIGATION;
    }

    if (ODataLinkType.ENTITY_SET_NAVIGATION.type.equals(type)) {
        return ENTITY_SET_NAVIGATION;
    }

    if (ODataLinkType.ASSOCIATION.type.equals(type)) {
        return ASSOCIATION;
    }

    throw new IllegalArgumentException("Invalid link type: " + type);
}

From source file:gov.va.vinci.leo.tools.XmlFilter.java

/**
 * @see gov.va.vinci.leo.tools.TextFilter#filter(java.lang.String)
 * @param text The text to filter for non XML-1.0 characters.
 * @return the text filtered. Non XML-1.0 characters become spaces.
 *///from   ww  w  .j ava  2s .c  om
@Override
public String filter(String text) {
    if (StringUtils.isBlank(text)) {
        return text;
    } //if
    return XmlFilter.toXml10(text);
}

From source file:com.github.yongchristophertang.database.guice.provider.MongoTemplateFactory.java

/**
 * Transfer an annotation to a T object.
 *
 * @param anno Mongo annotation/*from w ww . ja v  a2 s.c  o  m*/
 */
@Override
protected MongoTemplate createClient(Mongo anno) {
    if (StringUtils.isBlank(anno.database()) || StringUtils.isBlank(anno.host())) {
        throw new IllegalArgumentException("Mongo annotation must has database argument configured");
    }
    try {
        return new MongoTemplate(new MongoClient(anno.host(), anno.port()), anno.database());
    } catch (UnknownHostException e) {
        e.printStackTrace();
        return null;
    }
}