Java String Quote quoteIfNeeded(String value)

Here you can find the source of quoteIfNeeded(String value)

Description

quote If Needed

License

Apache License

Declaration

public static String quoteIfNeeded(String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final String SPACE = " ";

    public static String quoteIfNeeded(String value) {
        if (value == null) {
            return null;
        }//from   w ww . ja v  a2 s. c om
        return value.contains(SPACE) ? String.format("'%s'", value) : value;
    }
}

Related

  1. quoteIdentifier(String s)
  2. quoteIfCeylonKeyword(String name)
  3. quoteIfNeeded(String id)
  4. quoteIfNeeded(String input)
  5. quoteIfNeeded(String source)
  6. quoteIfNeeded(StringBuilder buf, String str, String delim)
  7. quoteIfNotNull(String str)
  8. quoteIfNotNull(String text)
  9. quoteIfNotNull(StringBuilder sb, String val)