Example usage for org.apache.commons.lang StringUtils isEmpty

List of usage examples for org.apache.commons.lang StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isEmpty.

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:com.hangum.tadpole.rdb.core.editors.main.utils.SQLTextUtil.java

/**
 * cursor object arry//from  w  w  w  . j  a v a2 s .  co  m
 * 
 * @param strQuery
 * @param intPosition
 * @param startIndex
 * @param endIndex
 * @return
 */
private static String[] cusrsotObjectArry(String strQuery, int intPosition, int startIndex, int endIndex) {
    String[] arryCursor = { "", "" };

    String strPosTxt = StringUtils.trimToEmpty(StringUtils.substring(strQuery, startIndex, endIndex));
    //      if(logger.isDebugEnabled()) logger.debug("==> postion char : " + strPosTxt);
    if (StringUtils.isEmpty(strPosTxt))
        return arryCursor;

    String strBeforeTxt = strQuery.substring(0, startIndex);
    String[] strArryBeforeTxt = StringUtils.split(strBeforeTxt, ' ');

    //    ? ?  .
    String strAfterTxt = strQuery.substring(startIndex);
    String[] strArryAfterTxt = StringUtils.split(strAfterTxt, ' ');

    if (strArryBeforeTxt.length == 0) {
        arryCursor[0] = removeSpecialChar(strArryAfterTxt[0]);
        arryCursor[1] = "";
    } else {
        arryCursor[0] = removeSpecialChar(strArryBeforeTxt[strArryBeforeTxt.length - 1]);
        arryCursor[1] = removeSpecialChar(strArryAfterTxt[0]);
    }
    return arryCursor;
}

From source file:com.microsoft.alm.plugin.idea.ui.common.LookupHelper.java

public static void authenticateAndLoadTfsContexts(final LoginPageModel loginPageModel,
        final ServerContextLookupPageModel lookupPageModel, final AuthenticationProvider authenticationProvider,
        final ServerContextLookupListener lookupListener,
        final ServerContextLookupOperation.ContextScope scope) {
    loginPageModel.clearErrors();/* w  w w . j  a  v  a  2  s .  c  o m*/

    // Make sure we have a server url
    final String serverName = loginPageModel.getServerName();
    if (StringUtils.isEmpty(serverName)) {
        loginPageModel.addError(ModelValidationInfo.createWithResource(LoginPageModel.PROP_SERVER_NAME,
                TfPluginBundle.KEY_LOGIN_FORM_TFS_ERRORS_NO_SERVER_NAME));
        loginPageModel.setConnected(false);
        return;
    }

    //verify server url is a valid url
    if (!UrlHelper.isValidUrl(serverName)) {
        loginPageModel.addError(ModelValidationInfo.createWithResource(LoginPageModel.PROP_SERVER_NAME,
                TfPluginBundle.KEY_LOGIN_FORM_TFS_ERRORS_INVALID_SERVER_URL, serverName));
        loginPageModel.setConnected(false);
        return;
    }

    if (authenticationProvider.isAuthenticated()) {
        loadTfsContexts(loginPageModel, lookupPageModel, authenticationProvider, lookupListener, scope);
    } else {
        authenticationProvider.authenticateAsync(serverName, new AuthenticationListener() {
            @Override
            public void authenticating() {
                // Push this event back onto the UI thread
                IdeaHelper.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        // We are starting to authenticate, so set the boolean
                        loginPageModel.setAuthenticating(true);
                    }
                });
            }

            @Override
            public void authenticated(final AuthenticationInfo authenticationInfo, final Throwable throwable) {
                // Push this event back onto the UI thread
                IdeaHelper.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        // Authentication is over, so set the boolean
                        loginPageModel.setAuthenticating(false);

                        // Log exception
                        if (throwable != null) {
                            logger.warn("Connecting to TFS server failed", throwable);
                            if (throwable instanceof TeamServicesException) {
                                loginPageModel.addError(ModelValidationInfo.createWithMessage(
                                        LocalizationServiceImpl.getInstance().getExceptionMessage(throwable)));
                            } else {
                                loginPageModel.addError(
                                        ModelValidationInfo.createWithResource(LoginPageModel.PROP_SERVER_NAME,
                                                TfPluginBundle.KEY_LOGIN_PAGE_ERRORS_TFS_CONNECT_FAILED,
                                                loginPageModel.getServerName()));
                            }
                            loginPageModel.signOut();
                        } else {
                            // Try to load the contexts
                            loadTfsContexts(loginPageModel, lookupPageModel, authenticationProvider,
                                    lookupListener, scope);
                        }
                    }
                });
            }
        });
    }
}

From source file:com.netscape.certsrv.dbs.certdb.CertIdAdapter.java

public CertId unmarshal(String value) throws Exception {
    return StringUtils.isEmpty(value) ? null : new CertId(value);
}

From source file:info.magnolia.cms.security.AccessManagerImpl.java

/**
 * Check if the given path has specified permissions
 * @param path/*from   w w w.  ja va 2s  .  c  o  m*/
 * @param permissions
 * @return true if the given path has this permissions
 */
public boolean isGranted(String path, long permissions) {
    if (StringUtils.isEmpty(path)) {
        return (getPermissions("/") & permissions) == permissions; //$NON-NLS-1$
    }
    return (getPermissions(path) & permissions) == permissions;
}

From source file:lux.xml.QName.java

/**
 * @param localPart the local part of the QName to encode
 * @param namespaceURI the namespace (URI) of the QName to encode (may be null)
 * @return the QName encoded in a suitable form for indexing.  The namespace uri, if any,
 * is wrapped in {} and appended to the local-name.
 *//*from  ww w.j a  v a 2 s  .c o  m*/
public static String encode(String localPart, String namespaceURI) {
    if (StringUtils.isEmpty(namespaceURI)) {
        return localPart;
    }
    StringBuilder buf = new StringBuilder();
    buf.append(localPart).append('{').append(namespaceURI).append("}");
    return buf.toString();
}

From source file:com.haulmont.cuba.web.gui.icons.ThemeIconProvider.java

@Override
public Resource getIconResource(String iconPath) {
    if (StringUtils.isEmpty(iconPath)) {
        throw new IllegalArgumentException("Icon path should not be empty");
    }//from w  ww .j a  v  a2s  .  co m

    return new VersionedThemeResource(iconPath);
}

From source file:net.shopxx.BaseAttributeConverter.java

public Object convertToEntityAttribute(String dbData) {
    if (StringUtils.isEmpty(dbData)) {
        if (List.class.isAssignableFrom(javaType.getRawClass())) {
            return Collections.EMPTY_LIST;
        } else if (Set.class.isAssignableFrom(javaType.getRawClass())) {
            return Collections.EMPTY_SET;
        } else if (Map.class.isAssignableFrom(javaType.getRawClass())) {
            return Collections.EMPTY_MAP;
        } else {//  ww  w  .j  a  v a2 s  .  co  m
            return null;
        }
    }

    return JsonUtils.toObject(dbData, javaType);
}

From source file:com.lingxiang2014.controller.admin.ProfileController.java

@RequestMapping(value = "/check_current_password", method = RequestMethod.GET)
public @ResponseBody boolean checkCurrentPassword(String currentPassword) {
    if (StringUtils.isEmpty(currentPassword)) {
        return false;
    }/*from   ww w .  jav a  2  s. com*/
    Admin admin = adminService.getCurrent();
    if (StringUtils.equals(DigestUtils.md5Hex(currentPassword), admin.getPassword())) {
        return true;
    } else {
        return false;
    }
}

From source file:de.thischwa.pmcms.tool.connection.UploadTreeNode.java

protected static String[] splitPath(String path) {
    if (!path.contains("" + UploadTree.PATH_SEPARATOR) || StringUtils.isEmpty(path))
        return null;
    String[] keys = new String[2];
    keys[0] = path.substring(0, path.indexOf(UploadTree.PATH_SEPARATOR));
    keys[1] = path.substring(path.indexOf(UploadTree.PATH_SEPARATOR) + 1, path.length());
    return keys;/* w  ww .  j av  a2  s.  c  om*/
}

From source file:com.huasoft.entity.ErrorBean.java

/**
 * /* w  w  w  .  j  a  v a2 s. co  m*/
 * 
 * @param errorCode
 *            ?
 * @param errorDes
 *            ??
 */
public ErrorBean(String errorCode, String errorDes) {
    errorCode = StringUtils.strip(errorCode);
    errorDes = StringUtils.strip(errorDes);
    // ?jackson?json
    if (StringUtils.isEmpty(errorCode) || StringUtils.isEmpty(errorDes)) {
        this.errorCode = "99999";
        this.errorDes = "Uknow Exception";
    } else {
        this.errorCode = errorCode;
        this.errorDes = errorDes;
    }
}