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

public static boolean verifyLen(CharSequence s, int minLen) {
    if (s != null && !isEmpty(s.toString()) && s.toString().length() >= minLen) {
        return true;
    }//from  www  .  j  a  va2  s . c om
    return false;
}

From source file:Main.java

public static InputStream toInputStream(CharSequence input, Charset encoding) {
    return toInputStream(input.toString(), encoding);
}

From source file:Main.java

public static CharSequence[] split(CharSequence string, String pattern) {
    String[] parts = string.toString().split(pattern);
    List<CharSequence> res = new ArrayList<>();
    CharSequence temp = string;/*from   ww w.j  a va  2  s .  com*/
    int pos = 0;
    for (String part : parts) {
        res.add(string.subSequence(pos, pos + part.length()));
        pos += part.length();
    }
    return res.toArray(new CharSequence[res.size()]);
}

From source file:Main.java

/**
 * check the string is null or not//  w  ww. j a v  a  2  s.  co m
 *
 * @param text text to check
 * @return true null false !null
 */
public static boolean isNull(CharSequence text) {
    if (text == null || "".equals(text.toString().trim()) || "null".equals(text)) {
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean isEmpty(CharSequence value) {
    return value == null || isEmpty(value.toString());
}

From source file:Main.java

public static String unformatNum(CharSequence num) {
    String res = "";
    try {/*  ww  w  .j  a v  a  2 s  . c o m*/
        res = num.toString().replaceAll(",", "");
    } catch (Exception e) {

    }
    return res;
}

From source file:Main.java

public final static boolean isShellFriendly(CharSequence s) {
    String str = s instanceof String ? (String) s : s.toString();
    return str.matches("^[a-zA-Z0-9_]+$");
}

From source file:Main.java

public final static boolean isShellFriendlyPath(CharSequence s) {
    String str = s instanceof String ? (String) s : s.toString();
    return str.matches("^[/a-zA-Z0-9_.]+$");
}

From source file:Main.java

/**
 * Used by the lastIndexOf(CharSequence methods) as a green implementation of lastIndexOf
 *
 * @param cs the {@code CharSequence} to be processed
 * @param searchChar the {@code CharSequence} to be searched for
 * @param start the start index/*from w  ww.ja  v a2s.co m*/
 * @return the index where the search sequence was found
 */
static int lastIndexOf(final CharSequence cs, final CharSequence searchChar, final int start) {
    return cs.toString().lastIndexOf(searchChar.toString(), start);
}

From source file:Main.java

/**
 * Used by the indexOf(CharSequence methods) as a green implementation of indexOf.
 *
 * @param cs the {@code CharSequence} to be processed
 * @param searchChar the {@code CharSequence} to be searched for
 * @param start the start index/*w  w w  . ja  va  2  s  .  co  m*/
 * @return the index where the search sequence was found
 */
static int indexOf(final CharSequence cs, final CharSequence searchChar, final int start) {
    return cs.toString().indexOf(searchChar.toString(), start);
}