Java String Quote quote(final String str)

Here you can find the source of quote(final String str)

Description

quote

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static final String quote(final String str) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String STR_EMP = "";

    /**/*www  .  ja  va2  s. c o m*/
     * 
     * @param str
     * @return
     */
    public static final String quote(final String str) {
        return (str == null || str.length() == 0 || (str.charAt(0) == '`' && str.charAt(str.length() - 1) == '`'))
                ? str
                : new StringBuilder(str.length() + 2).append('`').append(str).append('`').toString();
    }

    /**
     * 
     * @param objs
     * @return
     */
    public static String toString(final Object[] objs) {
        if (objs == null) {
            return STR_EMP;
        }
        final int len = objs.length;
        if (len == 0) {
            return STR_EMP;
        }
        final StringBuilder buf = new StringBuilder(len * 12);
        for (int i = 0; i < len - 1; i++) {
            buf.append(objs[i]).append(", ");
        }
        return buf.append(objs[len - 1]).toString();
    }
}

Related

  1. quote(CharSequence value)
  2. quote(final CharSequence original)
  3. quote(final CharSequence phrase)
  4. quote(final String s)
  5. quote(final String str)
  6. quote(final String str)
  7. quote(final String sValue)
  8. quote(final String value)
  9. quote(final String value)