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.streamreduce.util.HashtagUtil.java

public static boolean isValidTag(String tag) {
    return tag != null && !tag.isEmpty() && (tag.trim().charAt(0) == '#');
}

From source file:com.github.pires.hazelcast.HazelcastDiscoveryController.java

private static String getEnvOrDefault(String var, String def) {
    final String val = System.getenv(var);
    return (val == null || val.isEmpty()) ? def : val;
}

From source file:com.flipkart.phantom.task.utils.StringUtils.java

public static boolean isNullOrEmpty(String string) {
    if (string != null) {
        return string.isEmpty();
    }//from ww  w  .j a v a2 s. c  om
    return true;
}

From source file:com.linkedin.pinot.core.segment.index.loader.LoaderUtils.java

/**
 * Get string list from segment properties.
 * <p>//from  w w w . jav a2s  .c  o m
 * NOTE: When the property associated with the key is empty, {@link PropertiesConfiguration#getList(String)} will
 * return an empty string singleton list. Using this method will return an empty list instead.
 *
 * @param key property key.
 * @return string list value for the property.
 */
public static List<String> getStringListFromSegmentProperties(String key,
        PropertiesConfiguration segmentProperties) {
    List<String> stringList = new ArrayList<>();
    List propertyList = segmentProperties.getList(key);
    if (propertyList != null) {
        for (Object value : propertyList) {
            String stringValue = value.toString();
            if (!stringValue.isEmpty()) {
                stringList.add(stringValue);
            }
        }
    }
    return stringList;
}

From source file:Main.java

public static boolean matches(String s, String key, boolean matchNullOrEmpty, boolean ignoreCase) {
    if (key == null || key.isEmpty())
        return true;

    if (s == null || s.isEmpty())
        return matchNullOrEmpty;

    return containsWildCard(key) ? compilePattern(key, ignoreCase).matcher(s).matches()
            : ignoreCase ? key.equalsIgnoreCase(s) : key.equals(s);
}

From source file:Main.java

private static Vector<String> getSubTag(String source, String tag) {
    Vector<String> sSubTag = new Vector<String>();
    if (source == null || source.isEmpty() || tag == null || tag.isEmpty())
        return sSubTag;

    String subString, sTemp;/*  w w  w  . j  a  va 2  s .  c om*/
    int start, end;

    subString = source;
    sTemp = "<" + tag;

    start = subString.indexOf(sTemp);
    while (start >= 0) {
        subString = subString.substring(start);
        sTemp = "/>";
        end = subString.indexOf(sTemp);
        if (end < 0)
            break;

        end += sTemp.length();
        sSubTag.add(subString.substring(0, end));

        subString = subString.substring(end);
        sTemp = "<" + tag;
        start = subString.indexOf(sTemp);
    }
    return sSubTag;
}

From source file:Main.java

private static String getStringOfClassList(Map<String, Integer> classes) {
    String result = "";
    for (String className : classes.keySet()) {
        Integer occurences = classes.get(className);
        if (!result.isEmpty())
            result += ", ";
        result += className + ": " + occurences;
    }//from   w  ww .  ja v a2s. com

    return result;

}

From source file:org.eel.kitchen.jsonschema.ref.JsonFragment.java

/**
 * The only static factory method to obtain a fragment
 *
 * <p>Depending on the situation, this method will either return a
 * {@link JsonPointer}, an {@link IdFragment} or {@link #EMPTY}.</p>
 *
 * @param fragment the fragment as a string
 * @return the fragment//  w  w w  .  ja  va2  s .com
 */
public static JsonFragment fromFragment(final String fragment) {
    if (fragment.isEmpty())
        return EMPTY;

    try {
        return new JsonPointer(fragment);
    } catch (JsonSchemaException ignored) {
        // Not a valid JSON Pointer: it is an id
        return new IdFragment(fragment);
    }
}

From source file:org.jboss.jdf.stacks.StacksFactory.java

private static void configureProxy(final DefaultHttpClient client, final StacksConfiguration stacksConfig) {
    if (stacksConfig.getProxyHost() != null) {
        final String proxyHost = stacksConfig.getProxyHost();
        final int proxyPort = stacksConfig.getProxyPort();
        final HttpHost proxy = new HttpHost(proxyHost, proxyPort);
        client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        final String proxyUsername = stacksConfig.getProxyUser();
        if (proxyUsername != null && !proxyUsername.isEmpty()) {
            final String proxyPassword = stacksConfig.getProxyPassword();
            final AuthScope authScope = new AuthScope(proxyHost, proxyPort);
            final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(proxyUsername,
                    proxyPassword);//from ww  w.  j av  a 2  s  . c o m
            client.getCredentialsProvider().setCredentials(authScope, credentials);
        }
    }
}

From source file:Main.java

/**
 * Reads the first non-empty line from a file.
 *
 * @param file the file from which the line is to be read. This argument
 *   cannot be {@code null}.//from   w w w .  ja  v  a 2  s  .  c o m
 * @return the first non-empty line in the given file or {@code null} if
 *   there is no such line in the specified file
 *
 * @throws IOException thrown if there was an error while reading the
 *   specified file (e.g.: it does not exist)
 */
private static String readFirstLine(Path file) throws IOException {
    try (InputStream input = Files.newInputStream(file)) {
        LineNumberReader reader = new LineNumberReader(new InputStreamReader(input, DEFAULT_CHARSET));
        String line = reader.readLine();
        while (line != null) {
            line = line.trim();
            if (!line.isEmpty()) {
                return line;
            }
            line = reader.readLine();
        }
    }

    return null;
}