Example usage for java.lang Appendable append

List of usage examples for java.lang Appendable append

Introduction

In this page you can find the example usage for java.lang Appendable append.

Prototype

Appendable append(char c) throws IOException;

Source Link

Document

Appends the specified character to this Appendable .

Usage

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*from   ww w.j av  a 2  s  .  c  om*/
 *
 * @param sb _more_
 * @param comp _more_
 * @param attrs _more_
 *
 * @return _more_
 */
public static Appendable open(Appendable sb, String comp, String... attrs) {
    try {
        sb.append("<");
        sb.append(comp);
        if (attrs.length == 1) {
            sb.append(" ");
            sb.append(attrs[0]);
            sb.append(" ");
        } else {
            attrs(sb, attrs);
        }
        sb.append(">");
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return sb;
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//from  ww w  .j av a2  s .c om
 *
 * @param sb _more_
 * @param function _more_
 * @param args _more_
 *
 * @return _more_
 */
public static String call(Appendable sb, String function, String... args) {
    try {
        sb.append("(");
        for (int i = 0; i < args.length; i++) {
            if (i > 0) {
                sb.append(",");
            }
            sb.append(args[i]);
        }
        sb.append(");");

        return sb.toString();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//w  w  w.  j  av a2s  .c  o m
 *
 * @param sb _more_
 * @param name _more_
 * @param value _more_
 * @param encodeArg _more_
 */
public static void arg(Appendable sb, Object name, Object value, boolean encodeArg) {
    try {
        sb.append(name.toString());
        sb.append("=");
        sb.append((encodeArg ? java.net.URLEncoder.encode(value.toString(), "UTF-8") : value.toString()));
    } catch (Exception exc) {
        System.err.println("error encoding arg(2):" + value + " " + exc);
        exc.printStackTrace();
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//from   ww w  .j a v  a 2 s .c  om
 *
 * @param sb _more_
 * @param s _more_
 *
 * @return _more_
 */
public static Appendable pad(Appendable sb, String s) {
    try {
        String space = space(1);
        sb.append(space);
        sb.append(s);
        sb.append(space);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return sb;
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*w  ww  .jav  a2s. c om*/
 *
 * @param sb _more_
 * @param args _more_
 */
public static void concat(Appendable sb, String... args) {
    try {
        for (String s : args) {
            sb.append(s);
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*from  w w w .j  ava  2s . c  o  m*/
 *
 * @param sb _more_
 * @param cols _more_
 */
public static void cols(Appendable sb, String... cols) {
    try {
        for (int i = 0; i < cols.length; i++) {
            sb.append(tag(TAG_TD, "", cols[i]));
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*from w  w w  .ja  v a2 s.  c  o  m*/
 *
 * @param sb _more_
 * @param path _more_
 * @param args _more_
 * @param encodeArgs _more_
 */
public static void url(Appendable sb, String path, String[] args, boolean encodeArgs) {
    try {
        sb.append(path);
        if (args.length == 0) {
            return;
        }
        boolean addAmpersand = false;
        if (path.indexOf("?") >= 0) {
            if (!path.endsWith("?")) {
                addAmpersand = true;
            }
        } else {
            sb.append("?");
        }

        for (int i = 0; i < args.length; i += 2) {
            if (addAmpersand) {
                sb.append("&");
            }
            try {
                arg(sb, args[i], args[i + 1], encodeArgs);
            } catch (Exception exc) {
                if (i < args.length) {
                    System.err.println("error encoding arg(1):" + args[i + 1] + " " + exc);
                }
                exc.printStackTrace();

                throw new RuntimeException(exc);
            }
            addAmpersand = true;
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//from w w w .  j  a  v  a 2 s. co  m
 *
 * @param sb _more_
 * @param tag _more_
 * @param attrs _more_
 * @param inner _more_
 *
 * @return _more_
 */
public static Appendable tag(Appendable sb, String tag, String attrs, String inner) {
    try {
        open(sb, tag, attrs);
        sb.append(inner);
        close(sb, tag);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return sb;
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*  w  w  w.  j ava  2s .  c  om*/
 *
 * @param sb _more_
 * @param tag _more_
 * @param inner _more_
 * @param attrs _more_
 *
 * @return _more_
 */
public static Appendable makeTag(Appendable sb, String tag, String inner, String... attrs) {
    try {
        open(sb, tag, attrs);
        sb.append(inner);
        close(sb, tag);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return sb;
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_/*from  w w  w .jav  a 2  s  .c  o m*/
 *
 * @param sb _more_
 * @param s _more_
 */
public static void comma(Appendable sb, String... s) {
    try {
        for (int i = 0; i < s.length; i++) {
            if (i > 0) {
                sb.append(",");
            }
            sb.append(s[i]);
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}