Here you can find the source of quote(String value)
Parameter | Description |
---|---|
value | value to be quoted |
Parameter | Description |
---|---|
IllegalArgumentException | if no unused quote char can be found |
private static String quote(String value)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w. j a v a2 s. co m*/ * Surrounds a value with quote characters that are not contained in the value itself. * * @param value value to be quoted * @return quoted value * @throws IllegalArgumentException if no unused quote char can be found */ private static String quote(String value) { String quoteChar = "\""; if (value.contains(quoteChar)) { quoteChar = "\'"; } if (value.contains(quoteChar)) { throw new IllegalArgumentException(String.format( "Could not find quote char for expression: %s", value)); } return String.format("%s%s%s", quoteChar, value, quoteChar); } }