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 String buildIdentificationNumberWithDecimalSeparator(CharSequence number) {
    if (number.length() == 0) {
        return number.toString();
    }/* www. ja  va  2  s  . co m*/
    try {
        Long value = Long.valueOf(number.toString());
        Locale.setDefault(Locale.GERMAN);
        return String.format("%,d", value);
    } catch (NumberFormatException e) {
        return "";
    }
}

From source file:Main.java

public static final int parseUnsignedIntAttribute(CharSequence charSeq) {
    String value = charSeq.toString();

    int index = 0;
    int len = value.length();
    int base = 10;

    if ('0' == value.charAt(index)) {
        // Quick check for zero by itself
        if (index == len - 1) {
            return 0;
        }/* ww w .  jav  a  2  s.  com*/

        char c = value.charAt(index + 1);

        if ('x' == c || 'X' == c) { // check for hex
            index += 2;
            base = 16;
        } else { // check for octal
            index++;
            base = 8;
        }
    } else if ('#' == value.charAt(index)) {
        index++;
        base = 16;
    }

    return (int) Long.parseLong(value.substring(index), base);
}

From source file:Main.java

public static double getDoubleFrom(CharSequence chars) {
    double val = 0;

    if (!"".equals(chars.toString())) {
        val = Double.parseDouble(chars.toString());
    }/*from  ww w.  j ava 2s  . co m*/

    return val;
}

From source file:Main.java

public static int parseUnsignedIntAttribute(CharSequence charSeq) {
    String value = charSeq.toString();

    long bits;/*from  w w w.  j av a2s.  c o m*/
    int index = 0;
    int len = value.length();
    int base = 10;

    if ('0' == value.charAt(index)) {
        //  Quick check for zero by itself
        if (index == (len - 1))
            return 0;

        char c = value.charAt(index + 1);

        if ('x' == c || 'X' == c) { //  check for hex
            index += 2;
            base = 16;
        } else { //  check for octal
            index++;
            base = 8;
        }
    } else if ('#' == value.charAt(index)) {
        index++;
        base = 16;
    }

    return (int) Long.parseLong(value.substring(index), base);
}

From source file:Main.java

public static String checkField(CharSequence text) {
    String str = null;//  ww  w .  j  a  v  a2  s.co m
    if (text != null) {
        str = text.toString();
        if (str != null && str.length() > 0 && !str.equals("null")) {
            return str;
        }
    }
    return null;
}

From source file:Main.java

public static String safeCharSeqToString(CharSequence cs) {
    if (cs == null)
        return "[null]";
    else// www. ja  v a  2 s. c  om
        return cs.toString();
}

From source file:com.mattbertolini.statusboard.view.graph.Units.java

public static Units prefix(final CharSequence prefix) {
    return new Units(prefix.toString(), null);
}

From source file:Main.java

public static int parseUnsignedIntAttribute(CharSequence charSeq) {
    String value = charSeq.toString();

    int index = 0;
    int len = value.length();
    int base = 10;

    if ('0' == value.charAt(index)) {
        //  Quick check for zero by itself
        if (index == (len - 1))
            return 0;

        char c = value.charAt(index + 1);

        if ('x' == c || 'X' == c) { //  check for hex
            index += 2;/*  w  w  w  .ja  va2 s . c  om*/
            base = 16;
        } else { //  check for octal
            index++;
            base = 8;
        }
    } else if ('#' == value.charAt(index)) {
        index++;
        base = 16;
    }

    return (int) Long.parseLong(value.substring(index), base);
}

From source file:Main.java

public static final int parseUnsignedIntAttribute(CharSequence charSeq) {
    String value = charSeq.toString();

    long bits;//from w  ww. ja va2 s.  com
    int index = 0;
    int len = value.length();
    int base = 10;

    if ('0' == value.charAt(index)) {
        //  Quick check for zero by itself
        if (index == (len - 1))
            return 0;

        char c = value.charAt(index + 1);

        if ('x' == c || 'X' == c) { //  check for hex
            index += 2;
            base = 16;
        } else { //  check for octal
            index++;
            base = 8;
        }
    } else if ('#' == value.charAt(index)) {
        index++;
        base = 16;
    }

    return (int) Long.parseLong(value.substring(index), base);
}

From source file:com.mattbertolini.statusboard.view.graph.Units.java

public static Units suffix(final CharSequence suffix) {
    return new Units(null, suffix.toString());
}