Example usage for java.lang CharSequence toString

List of usage examples for java.lang CharSequence toString

Introduction

In this page you can find the example usage for java.lang CharSequence toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:Main.java

/**
 * Returns just the numbers of a String/*from ww  w. j  a  va 2 s .  c o m*/
 * @param s Charsequence to analyze
 * @return String, containing only numbers
 */
public static String keepNumbersOnly(CharSequence s) {
    try {
        return s.toString().replaceAll("[^0-9]", "");
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

public static boolean isEmpty2(CharSequence str) {

    return (isEmpty(str) || str.toString().trim().equalsIgnoreCase("null"));
}

From source file:Main.java

public static boolean isBlank(CharSequence charSequence) {
    return null == charSequence || charSequence.toString().trim().length() <= 0;
}

From source file:Main.java

public static String toString(CharSequence charSequence) {
    return charSequence != null ? charSequence.toString() : "";
}

From source file:Main.java

public static ArrayList<String> toStringArrayList(CharSequence[] strings) {
    ArrayList<String> list = new ArrayList<>();
    for (CharSequence string : strings) {
        list.add(string.toString());
    }/*  w w  w.  j a  v  a  2  s .com*/
    return list;
}

From source file:Main.java

public static String emptyToNull(CharSequence name) {
    return TextUtils.isEmpty(name) ? null : name.toString();
}

From source file:Main.java

public static String trim(CharSequence charSequence) {
    return null == charSequence ? null : charSequence.toString().trim();
}

From source file:Main.java

public static boolean isEmpty3(CharSequence str) {

    return (isEmpty2(str) || "0".equals(str.toString().trim()));
}

From source file:Main.java

/**
 * Determine whether it is a valid charSequence
 * /*from   ww w. j  a v a  2  s.  c o m*/
 * @param value
 * @return {@code true} if not {@code null} and the value's length is over 0
 *         (not include the blank), or {@code false}
 */
public static boolean isValidText(CharSequence value) {
    return value != null && value.toString().trim().length() > 0;
}

From source file:com.amazon.ion.plugin.intellij.helpers.ContentCorrectnessHelper.java

/**
 * Validate Base64 value for BLOB data type
 *
 * @param text Input value/*www  . ja va 2  s  . c  o m*/
 * @return true if the value is a valid base64 encoded blob
 */
public static boolean isValidBase64(CharSequence text) {
    final String input = text.toString();
    final String decoded = new String(Base64.decodeBase64(input));
    final String encoded = Base64.encodeBase64String(decoded.getBytes());
    return encoded.equals(input);
}