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:net.ecfirm.ec.ec1.net.EcNetHelper.java

public static HashMap<String, String> getApiHttp(String nameCom, String nameKey, String task, String[] keys,
        String[] values) {/*from   w w w  .jav  a  2 s. co  m*/
    ////////FIXME
    if (task.equals("getItems")) {
        nameKey = nameKey + "s";
        task = "display";
    }
    ////////
    HashMap<String, String> box = new HashMap<>();
    box.put(EcConst.NET_API_HTTP_1, "?option=com_ec" + nameCom + "&format=json&task=" + nameKey + "." + task);
    int i = 0;
    for (String value : values) {
        if (!value.isEmpty())
            box.put(keys[i], value);
        i++;
    }
    return box;
}

From source file:com.nabla.wapp.server.xml.Util.java

public static String extractFieldName(final PersistenceException e) {
    final String message = e.getMessage();
    if (message != null && !message.isEmpty()) {
        // looking for ...'field name'...
        final String[] matches = e.getMessage().split("'");
        if (matches.length > 2)
            return matches[1];
    }/*  ww w  .jav a  2 s. com*/
    return null;
}

From source file:net.diogobohm.timed.api.domain.Tag.java

private static String removeFormatting(String originalString, String regex) {
    if (!originalString.isEmpty()) {
        return originalString.replaceAll(regex, "");
    }//from w w  w  .j a v a  2  s  .c o  m

    return originalString;
}

From source file:Main.java

public static String[] split(String s, char delim) {
    if (s == null || s.isEmpty())
        return EMPTY_STRING;

    int count = 1;
    int delimPos = -1;
    while ((delimPos = s.indexOf(delim, delimPos + 1)) >= 0)
        count++;/* w  w  w.  j  ava  2s .  c  o m*/

    if (count == 1)
        return new String[] { s };

    String[] ss = new String[count];
    int delimPos2 = s.length();
    while (--count >= 0) {
        delimPos = s.lastIndexOf(delim, delimPos2 - 1);
        ss[count] = s.substring(delimPos + 1, delimPos2);
        delimPos2 = delimPos;
    }
    return ss;
}

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

public static boolean contains(String string, String subString) {
    return string != null && !string.isEmpty() && string.indexOf(subString) >= 0;
}

From source file:Main.java

@NonNull
public static Calendar getCalendar(String date) {
    //Date should be in the format YYYY/MM/DD if not return
    if (date != null && !date.isEmpty() && date.length() == 10) {
        int year = Integer.parseInt(date.substring(0, 4));
        int month = Integer.parseInt(date.substring(5, 7));
        int day = Integer.parseInt(date.substring(8, 10));
        Calendar startingTime = Calendar.getInstance();
        startingTime.set(year, month - 1, day, 0, 0, 0);
        return startingTime;
    }//w  ww. j a v a  2  s  . c o m
    return null;
}

From source file:Main.java

/**
 * Returns the attribute value or {@code null} if it does not exist.
 *//*from w  w  w . j a  v a2s  .c o m*/
public static String getAttribute(Element element, Enum<?> attribute) {
    final String attName = getXmlName(attribute);
    final String attValue = element.getAttribute(attName);
    return attValue == null || attValue.isEmpty() ? null : attValue;
}

From source file:com.francetelecom.clara.cloud.commons.FqdnHelper.java

/**
 * Takes a candidate fqdn and removes all invalid parts. if this becomes empty, it returns the default.
 * When too long, trims by removing chars at beginning
 * @param candidateFqdn//  w ww .  j a  v  a 2 s. c o m
 * @param defaultOnEmpty a valid default domain name, otherwise an exception is thrown.
 * @return
 */
public static String truncateUnsupportedCharsToValidHost(String candidateFqdn, String defaultOnEmpty) {
    if (defaultOnEmpty == null || defaultOnEmpty.isEmpty() || !InternetDomainName.isValid(defaultOnEmpty)) {
        throw new IllegalArgumentException("invalid default (" + defaultOnEmpty + ")");
    }
    String trimmed;
    if (candidateFqdn == null || candidateFqdn.isEmpty()) {
        return defaultOnEmpty;
    }
    trimmed = InternetDomainNameCleaner.from(candidateFqdn).name();
    if (trimmed.isEmpty()) {
        return defaultOnEmpty;
    }
    return trimmed;
}

From source file:Main.java

/**
 * Return all values associated with attributeName inside element specified by tag
 * @param document doc we work with/*from w ww  .  ja v a  2 s.  c om*/
 * @param elementTag element containing desired attribute
 * @param attributeName name of attribute
 * @return List of values specified in XML array
 */
public static List<String> getListOfTagAttributeValues(Document document, String elementTag,
        String attributeName) {
    NodeList usesPermissionList = document.getElementsByTagName(elementTag);

    List<String> result = new ArrayList<String>();
    for (int i = 0; i < usesPermissionList.getLength(); i++) {
        Node nNode = usesPermissionList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element eElement = (Element) nNode;
            String value = eElement.getAttribute(attributeName);
            if (value != null && !value.isEmpty()) {
                result.add(value);
            }
        }
    }
    return result;
}

From source file:Main.java

public static String SearchForElementText(Element element, String name, String defaultValue) {
    if (element != null && name != null && !name.isEmpty()) {
        NodeList nodes = element.getElementsByTagName(name);

        if (nodes != null && nodes.getLength() > 0) {
            return nodes.item(0).getTextContent();
        }/*from   w  ww  .ja v  a  2s  .  c  om*/
    }

    return defaultValue;
}