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 Map<String, String> parseOAuthResponse(String content) {
    Map<String, String> map = new HashMap<String, String>();
    if (content != null && !content.isEmpty()) {
        String[] items = content.split("&");
        for (String item : items) {
            int index = item.indexOf("=");
            String key = item.substring(0, index);
            String value = item.substring(index + 1);
            map.put(key, value);/* ww w. j  ava 2 s . c o  m*/
        }
    }
    return map;
}

From source file:com.streametry.json.JsonSerializer.java

@SuppressWarnings("unchecked")
public static Map<String, Object> parse(String jsonString) {
    try {/* w  w  w .ja v  a 2 s  .c o  m*/
        if (jsonString.isEmpty())
            return new LinkedHashMap<String, Object>();
        return serializer.readValue(jsonString, Map.class);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

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

public static Integer extractLine(final Exception e) {
    final String message = e.getMessage();
    if (message != null && !message.isEmpty()) {
        // looking for [row,col]:[x,x]
        int from = message.indexOf(ROW_COL);
        if (from >= 0) {
            from += ROW_COL.length();/*from   w  ww. j a va2s . com*/
            int to = message.indexOf(',', from);
            if (to > from) {
                final String row = message.substring(from, to);
                try {
                    return Integer.valueOf(row);
                } catch (Throwable x) {
                    log.warn("fail to convert " + row + " to a row", x);
                }
            }
        }
    }
    return null;
}

From source file:Main.java

public static void takePicture(Activity mActivity, String imagePath) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (null != imagePath && !imagePath.isEmpty()) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(imagePath)));
    }/*w  w w  . j a v  a2 s .  c o  m*/
    mActivity.startActivityForResult(intent, BBS_REQUEST_CAMERA);
}

From source file:com.gargoylesoftware.htmlunit.general.HostExtractor.java

private static void fillMDNJavaScriptGlobalObjects(final WebClient webClient, final Set<String> set)
        throws Exception {
    final HtmlPage page = webClient
            .getPage("https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects");
    for (final Object o : page.getByXPath("//*[name()='code']/text()")) {
        String value = o.toString();
        if (!value.isEmpty()) {
            if (value.endsWith("()")) {
                value = value.substring(0, value.length() - 2);
            }//from   w w  w  .  ja v a  2s  .c  o m

            set.add(value);
        }
    }
}

From source file:grails.plugins.sitemapper.ValidationUtils.java

public static void assertDataObjectType(String type) {
    if (type == null || type.isEmpty())
        throw new SitemapperException("Data object's type not specified");
}

From source file:grails.plugins.sitemapper.ValidationUtils.java

public static void assertDataObjectAttrName(String name) {
    if (name == null || name.isEmpty())
        throw new SitemapperException("Data object attr's name not specified");
}

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

public static Set<Tag> parseTagsFromString(String tagExpression) {
    String cleanTags = cleanExpression(tagExpression);
    Set<Tag> tagSet = Sets.newHashSet();

    for (String tagName : cleanTags.split("#")) {
        if (!tagName.isEmpty()) {
            tagSet.add(new Tag(tagName));
        }/*from  w w  w .  j a va 2s.  c  om*/
    }

    return tagSet;
}

From source file:Main.java

/**
 * Generate a Uri to launch Collector for ArcGIS App.
 *
 * @param mapItemId The web map item ID to open within Collector.
 * @param mapCenter Specified as a set of latitude, longitude (y,x) coordinates. Coordinates must be in WGS84 coordinates. (optional)
 * @return A properly formatted Uri to launch Collector
 * @throws IllegalArgumentException if the map item id passed in is null or empty
 *//*  w w w  .j a v a 2  s  . co m*/
public static Uri generateUri(String mapItemId, String mapCenter) {
    if (mapItemId == null || mapItemId.isEmpty()) {
        throw new IllegalArgumentException("You must pass in a valid map item id");
    }

    Uri.Builder uriBuilder = new Uri.Builder();

    uriBuilder.scheme(ARCGIS_COLLECTOR_SCHEME);
    uriBuilder.authority("");
    uriBuilder.appendQueryParameter(MAP_ITEM_ID, mapItemId);
    uriBuilder.appendQueryParameter(MAP_CENTER, mapCenter);

    return uriBuilder.build();
}

From source file:Main.java

/**
 * Get the last word (pure alphabet word) from a String
 * /*from   w ww. ja va 2s  . c  o  m*/
 * @param source
 *            the string where the last word is to be extracted
 * @return the extracted last word or null if there is no last word
 */
public static String getLastWord(String source) {
    if (source == null) {
        return null;
    }

    source = source.trim();

    if (source.isEmpty()) {
        return null;
    }

    if (containsSpace(source)) {
        final int LAST_WORD_GROUP = 1;
        String lastWordRegex = "\\s([A-z]+)[^A-z]*$";
        Pattern pattern = Pattern.compile(lastWordRegex);
        Matcher matcher = pattern.matcher(source);
        if (matcher.find()) {
            return matcher.group(LAST_WORD_GROUP);
        } else {
            return null;
        }

    } else {
        return source;
    }
}