Example usage for java.lang String isEmpty

List of usage examples for java.lang String isEmpty

Introduction

In this page you can find the example usage for java.lang String isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if, and only if, #length() is 0 .

Usage

From source file:com.hubrick.vertx.s3.util.UrlEncodingUtils.java

public static String addParamsSortedToUrl(String url, Map<String, String> params) {
    checkNotNull(url, "url must not be null");
    checkNotNull(!url.isEmpty(), "url must not be empty");
    checkNotNull(params, "params must not be null");
    checkNotNull(!params.isEmpty(), "params must not be empty");

    final String baseUrl = extractBaseUrl(url);
    final String urlParams = baseUrl.equals(url) ? "" : url.replace(baseUrl + "?", "");
    final List<NameValuePair> nameValuePairs = URLEncodedUtils.parse(urlParams, Charsets.UTF_8);

    for (Map.Entry<String, String> paramToUrlEncode : params.entrySet().stream()
            .sorted(Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList())) {
        nameValuePairs.add(new BasicNameValuePair(paramToUrlEncode.getKey(), paramToUrlEncode.getValue()));
    }//  w  ww. ja  va  2  s  . co m

    return baseUrl + "?" + URLEncodedUtils.format(nameValuePairs, Charsets.UTF_8);
}

From source file:fr.shywim.antoinedaniel.utils.GcmUtils.java

public static String getRegistrationId(Context context) {
    final SharedPreferences prefs = context.getSharedPreferences(AppConstants.GOOGLE_PREFS,
            Context.MODE_PRIVATE);
    String registrationId = prefs.getString(AppConstants.GOOGLE_GCM_REGID, "");

    if (registrationId.isEmpty()) {
        return "";
    }// w  w w . j  a v a2  s. c om
    // Check if app was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // app version.
    int registeredVersion = prefs.getInt(AppConstants.GOOGLE_GCM_APPVER, Integer.MIN_VALUE);
    int currentVersion = Utils.getAppVersion(context);
    if (registeredVersion != currentVersion) {
        return "";
    }
    return registrationId;
}

From source file:com.amazonaws.codepipeline.jenkinsplugin.Validation.java

private static boolean projectNameIsValid(final String projectName) {
    return projectName != null && !projectName.isEmpty() && projectName.length() <= MAX_PROJECT_NAME_LENGTH;
}

From source file:com.github.nethad.clustermeister.provisioning.torque.TorqueConfiguration.java

private static String checkString(Configuration configuration, String configOption, String defaultValue,
        String logMessage) {/*  w  w w.  j a v a2  s. c  om*/
    String value = configuration.getString(configOption, "");
    if (value.isEmpty()) {
        logger.warn(loggerMessage(logMessage, configOption, defaultValue));
        return defaultValue;
    }
    return value;
}

From source file:keywhiz.utility.SecretTemplateCompiler.java

public static boolean validName(String name) {
    // "." is allowed at any position but the first.
    return !name.isEmpty() && !name.startsWith(".") && name.matches(VALID_NAME_PATTERN);
}

From source file:net.minecraftforge.common.command.SelectorHandlerManager.java

/**
 * Registers a new {@link SelectorHandler} for {@code prefix}.<br>
 *
 * @param prefix The domain the specified {@code handler} is registered for.
 * If you want to register just a single selector, {@code prefix} has the form '@{selectorName}'
 *///from  ww w.  j a  va 2s.  c  o  m
public static void register(final String prefix, final SelectorHandler handler) {
    if (prefix.isEmpty()) {
        throw new IllegalArgumentException("Prefix must not be empty");
    }

    final String modId = Loader.instance().activeModContainer().getModId();

    selectorHandlers.put(prefix, handler);
    registeringMods.put(prefix, modId);
}

From source file:Main.java

public static String parseToString(XmlPullParser parser, boolean skipXMLNS)
        throws XmlPullParserException, IOException {
    String tag = parser.getName();
    String ret = "<" + tag;

    // skipXMLNS for xmlns="jabber:client"

    String ns = parser.getNamespace();
    if (!skipXMLNS && ns != null && !ns.isEmpty()) {
        ret += " xmlns=\"" + ns + "\"";
    }/*from  w  w  w. ja va2  s  .co  m*/

    for (int i = 0; i < parser.getAttributeCount(); i++) {
        String attr = parser.getAttributeName(i);
        if ((!skipXMLNS || !attr.equals("xmlns")) && !attr.contains(":")) {
            ret += " " + attr + "=\"" + escape(parser.getAttributeValue(i)) + "\"";
        }
    }
    ret += ">";

    while (!(parser.next() == XmlPullParser.END_TAG && parser.getName().equals(tag))) {
        int event = parser.getEventType();
        if (event == XmlPullParser.START_TAG) {
            if (!parser.getName().contains(":")) {
                ret += parseToString(parser, false);
            } else {
                skip(parser);
            }
        } else if (event == XmlPullParser.TEXT) {
            ret += escape(parser.getText());
        }
    }

    ret += "</" + tag + ">";
    return ret;
}

From source file:adalid.util.i18n.Merger.java

private static boolean isNotTranslated(String string) {
    return string == null || string.isEmpty() || isMessageKey(string) || string.startsWith(TRAN_REQD);
}

From source file:com.platform.BRHTTPHelper.java

public static boolean handleSuccess(int code, byte[] body, Request baseRequest, HttpServletResponse resp,
        String contentType) {
    try {//from   w  w  w . ja  v a  2  s.com
        resp.setStatus(code);
        if (contentType != null && !contentType.isEmpty())
            resp.setContentType(contentType);
        if (body != null)
            resp.getOutputStream().write(body);
        baseRequest.setHandled(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:hot.swap.proxy.utils.PathUtils.java

/**
 * split path as list/*from ww  w  . j a  v  a 2 s  .c  om*/
 *
 * @param path
 * @return
 */
public static List<String> tokenize_path(String path) {
    String[] toks = path.split(SEPERATOR);
    java.util.ArrayList<String> rtn = new ArrayList<String>();
    for (String str : toks) {
        if (!str.isEmpty()) {
            rtn.add(str);
        }
    }
    return rtn;
}