Example usage for org.apache.commons.lang3 StringUtils isBlank

List of usage examples for org.apache.commons.lang3 StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isBlank.

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is whitespace, empty ("") or null.

 StringUtils.isBlank(null)      = true StringUtils.isBlank("")        = true StringUtils.isBlank(" ")       = true StringUtils.isBlank("bob")     = false StringUtils.isBlank("  bob  ") = false 

Usage

From source file:jfix.zk.Combobox.java

public boolean isEmpty() {
    return StringUtils.isBlank(getValue());
}

From source file:com.netsteadfast.greenstep.util.Pivot4JUtils.java

public static String getHtmlCss() throws Exception {
    if (!StringUtils.isBlank(_htmlCss)) {
        return _htmlCss;
    }//w w  w .  jav a 2 s  .c  o  m
    InputStream is = Pivot4JUtils.class.getClassLoader().getResource(PIVOT4J_HTML_CSS).openStream();
    _htmlCss = IOUtils.toString(is, Constants.BASE_ENCODING);
    is.close();
    is = null;
    return _htmlCss;
}

From source file:info.magnolia.vaadin.periscope.result.SupplierUtil.java

/**
 * Highlight (using HTML tags) all occurrences of a query string, ignoring case.
 *
 * @param text Text in which parts should be highlighted
 * @param query Parts to highlight/*www. ja v  a2s .c o  m*/
 * @return Highlighted string
 */
public static String highlight(final String text, final String query) {
    if (StringUtils.isBlank(query)) {
        return text;
    }

    final List<Integer> startIndices = allIndicesOf(text, query);
    final List<Integer> endIndices = startIndices.stream().map(i -> i + query.length()).collect(toList());

    // we run back to front to not mess up indices when inserting tags
    Collections.reverse(startIndices);
    Collections.reverse(endIndices);
    Queue<Integer> startQueue = new LinkedList<>(startIndices);
    Queue<Integer> endQueue = new LinkedList<>(endIndices);

    StringBuilder highlighted = new StringBuilder(text);
    while (!startQueue.isEmpty() || !endQueue.isEmpty()) {
        final Integer startCandidate = startQueue.peek();
        final Integer endCandidate = endQueue.peek();

        if (startCandidate != null && (endCandidate == null || startCandidate > endCandidate)) {
            highlighted.insert(startCandidate, "<strong>");
            startQueue.poll();
        } else {
            highlighted.insert(endCandidate, "</strong>");
            endQueue.poll();
        }
    }

    return highlighted.toString();
}

From source file:ch.cyberduck.ui.comparator.GroupComparator.java

@Override
protected int compareFirst(final Path p1, final Path p2) {
    if (StringUtils.isBlank(p1.attributes().getGroup()) && StringUtils.isBlank(p2.attributes().getGroup())) {
        return 0;
    }/*w  w  w.  j  ava  2  s.  c om*/
    if (StringUtils.isBlank(p1.attributes().getGroup())) {
        return -1;
    }
    if (StringUtils.isBlank(p2.attributes().getGroup())) {
        return 1;
    }
    if (ascending) {
        return p1.attributes().getGroup().compareToIgnoreCase(p2.attributes().getGroup());
    }
    return -p1.attributes().getGroup().compareToIgnoreCase(p2.attributes().getGroup());
}

From source file:cherry.sqlapp.controller.sqltool.ParamMapUtil.java

public Map<String, ?> getParamMap(String pmap) {
    if (StringUtils.isBlank(pmap)) {
        return new HashMap<>();
    }/*from   w  ww .j a  v  a  2  s .c  o m*/
    try {
        JavaType type = TypeFactory.defaultInstance().constructMapType(Map.class, String.class, Object.class);
        return objectMapper.readValue(pmap, type);
    } catch (IOException ex) {
        return new HashMap<>();
    }
}

From source file:ch.cyberduck.ui.comparator.OwnerComparator.java

@Override
protected int compareFirst(final Path p1, final Path p2) {
    if (StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) {
        return 0;
    }/*  w  w w .  j av  a2s.  c  om*/
    if (StringUtils.isBlank(p1.attributes().getOwner())) {
        return -1;
    }
    if (StringUtils.isBlank(p2.attributes().getOwner())) {
        return 1;
    }
    if (ascending) {
        return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner());
    }
    return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner());
}

From source file:ch.cyberduck.ui.comparator.RegionComparator.java

@Override
protected int compareFirst(final Path p1, final Path p2) {
    if (StringUtils.isBlank(p1.attributes().getRegion()) && StringUtils.isBlank(p2.attributes().getRegion())) {
        return 0;
    }//from w  w  w . j  a  v  a 2s. co  m
    if (StringUtils.isBlank(p1.attributes().getRegion())) {
        return -1;
    }
    if (StringUtils.isBlank(p2.attributes().getRegion())) {
        return 1;
    }
    if (ascending) {
        return p1.attributes().getRegion().compareToIgnoreCase(p2.attributes().getRegion());
    }
    return -p1.attributes().getRegion().compareToIgnoreCase(p2.attributes().getRegion());
}

From source file:gov.va.vinci.leo.tools.AutoCompile.java

/**
 * Compile the files in the list.  Optionally provide a destination directory where the
 * compiled files should be placed./*ww  w.j a  v  a 2s .  c o  m*/
 *
 * @param files           List of java files to be compiled
 * @param outputDirectory Optional, output directory where the compiled files will be written
 * @throws Exception If there are errors compiling the files or we are unable to get a compiler
 */
public static void compileFiles(File[] files, String outputDirectory) throws Exception {
    //If the list is null there is nothing to do
    if (files == null) {
        return;
    }

    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    if (compiler == null) {
        throw new Exception("Unable to get a Compiler from the ToolProvider");
    }
    StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, null, null);
    Iterable<String> compilationOptions = (StringUtils.isBlank(outputDirectory)) ? null
            : Arrays.asList(new String[] { "-d", outputDirectory });
    try {
        Iterable<? extends JavaFileObject> compilationUnits = stdFileManager
                .getJavaFileObjectsFromFiles(Arrays.asList(files));
        compiler.getTask(null, stdFileManager, null, compilationOptions, null, compilationUnits).call();
    } finally {
        stdFileManager.close();
    } //finally

}

From source file:ch.cyberduck.ui.comparator.VersionComparator.java

@Override
protected int compareFirst(final Path p1, final Path p2) {
    if (StringUtils.isBlank(p1.attributes().getVersionId())
            && StringUtils.isBlank(p2.attributes().getVersionId())) {
        return 0;
    }//w  ww. ja  v a  2 s .co m
    if (StringUtils.isBlank(p1.attributes().getVersionId())) {
        return -1;
    }
    if (StringUtils.isBlank(p2.attributes().getVersionId())) {
        return 1;
    }
    if (ascending) {
        return p1.attributes().getVersionId().compareToIgnoreCase(p2.attributes().getVersionId());
    }
    return -p1.attributes().getVersionId().compareToIgnoreCase(p2.attributes().getVersionId());
}

From source file:com.jci.utils.CommonUtils.java

/**
 * String to date./*from  w w w .  j  a  v  a  2 s .  c o  m*/
 *
 * @param dateStr the date str
 * @return the date
 */
public static Date stringToDate(String dateStr) { // NO_UCD (unused code)
    if (StringUtils.isBlank(dateStr) || "null".equals(dateStr)) {
        return null;
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date convertedCurrentDate = null;
    try {
        convertedCurrentDate = sdf.parse(dateStr);
    } catch (ParseException e) {
        LOG.error("### Exception in   ####", e);

    }
    return convertedCurrentDate;
}