Code example for SpannableStringBuilder

Methods: append, charAt, length

0
        return Integer.parseInt(nm.substring(index), base) * sign;
    } 
 
 
    private static void handleP(SpannableStringBuilder text) {
        int len = text.length();
 
        if (len >= 1 && text.charAt(len - 1) == '\n') {
            if (len >= 2 && text.charAt(len - 2) == '\n') {
                return; 
            } 
 
            text.append("\n");
            return; 
        } 
 
        if (len != 0) {
            text.append("\n\n");
        } 
    } 
 
    private static void handleBr(SpannableStringBuilder text) {
        text.append("\n");
    } 
 
    private static Object getLast(Spanned text, Class kind) {
        /* 
         * This knows that the last returned object from getSpans() 
         * will be the most recently added. 
         */ 
        Object[] objs = text.getSpans(0, text.length(), kind);
 
        if (objs.length == 0) {
            return null; 
        } else { 
            return objs[objs.length - 1];
        } 
    } 
 
    private static void start(SpannableStringBuilder text, Object mark) {
        int len = text.length();
        text.setSpan(mark, len, len, Spannable.SPAN_MARK_MARK);
    } 
 
    private static void end(SpannableStringBuilder text, Class kind,
                            Object repl) {