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:Main.java

public static HashMap<String, Element> buildIndex(Element element, String tagName, String idName) {
    NodeList nl = element.getElementsByTagName(tagName);
    HashMap<String, Element> index = new HashMap<>(nl.getLength());
    for (int i = 0; i < nl.getLength(); i++) {
        Element el = (Element) nl.item(i);
        String id = el.getAttribute(idName);
        if (!id.isEmpty())
            index.put(id, el);/*from  w  w w .  j av a 2s. c o m*/
    }
    return index;
}

From source file:Main.java

/**
 * Returns the set of ABIs associated with the given architecture.
 * @param arch The architecture to look up.
 * @return a new Set containing the ABIs.
 *//*from   www .j a va  2s. co  m*/
public static Set<String> getAbisForArch(String arch) {
    if (arch == null || arch.isEmpty() || !ARCH_TO_ABIS.containsKey(arch)) {
        return getAbisSupportedByCts();
    }
    return new HashSet<String>(ARCH_TO_ABIS.get(arch));
}

From source file:Main.java

/**
 * Decodes HEX representation of the string.
 *
 * @param data HEX//from  www .j  a v  a 2s .  c  o  m
 * @return String representation of the {@code data}
 * @throws IOException if some error occurs
 */
private static String decodeHex(String data) throws IOException {
    if (data == null || data.isEmpty()) {
        return data;
    }
    if (data.length() % 2 != 0) {
        throw new IOException("String is not in hexadecimal representation.");
    }
    byte[] bytes = new byte[data.length() / 2];
    for (int i = 0; i < data.length(); i += 2) {
        bytes[i / 2] = Integer.valueOf(data.substring(i, i + 2), 16).byteValue();
    }
    return new String(bytes, "UTF-8");
}

From source file:Main.java

public static HashMap<String, Element> createIndex(Element root, String tagName, String idName) {
    NodeList nodes = root.getElementsByTagName(tagName);
    HashMap<String, Element> index = new HashMap<>(nodes.getLength());
    for (int i = 0; i < nodes.getLength(); i++) {
        Element el = (Element) nodes.item(i);
        String key = el.getAttribute(idName);
        if (!key.isEmpty())
            index.put(key, el);/*from ww w . j  a  v  a2s  .  com*/
    }
    return index;
}

From source file:mojo.view.util.SpringUtils.java

public static boolean containsBean(String id) {
    if (id == null || id.isEmpty()) {
        return false;
    }//from  w ww. ja  va 2  s  .com

    return applicationContext.containsBean(id);
}

From source file:Main.java

static public int getIntegerTextContent(Element element) {
    String s = getTrimmedTextContent(element);
    return s == null || s.isEmpty() ? 0 : Integer.parseInt(getTrimmedTextContent(element));
}

From source file:Main.java

public static double[] readVectorDouble(String path) throws FileNotFoundException {
    ArrayList<Double> arr = new ArrayList<Double>();
    System.err.println("Load vector from " + path);
    Scanner sc = new Scanner(new BufferedReader(new FileReader(path)));
    while (sc.hasNext()) {
        String line = sc.nextLine();
        if (line.isEmpty()) {
            break;
        }//from  w w w .j  a va 2  s.c  o m
        if (line.startsWith("%%")) { // detect matrix market format
            System.err.println(line);
            while (sc.nextLine().startsWith("%"))
                ; // skip the comment line, and the dimension info.
            continue;
        }
        arr.add(Double.parseDouble(line));
    }
    System.err.println("Length: " + arr.size());
    double[] ret = new double[arr.size()];
    for (int i = 0; i < arr.size(); i++)
        ret[i] = arr.get(i);
    System.err.println("Done.");
    return ret;
}

From source file:Main.java

static public boolean getBooleanTextContent(Element element) {
    String s = getTrimmedTextContent(element);
    return s == null || s.isEmpty() ? false : Boolean.parseBoolean(s);
}

From source file:Main.java

/** @param text Text that should contain true or false
 *  @param default_value Value to use when text is empty
 *  @return Boolean value of text//  w  ww.  ja  va  2s.  c  o m
 */
public static boolean parseBoolean(final String text, final boolean default_value) {
    if (text == null || text.isEmpty())
        return default_value;
    return Boolean.parseBoolean(text);
}

From source file:Main.java

static public float getFloatTextContent(Element element) {
    String s = getTrimmedTextContent(element);
    return s == null || s.isEmpty() ? 0 : Float.parseFloat(s);
}