Here you can find the source of quote(String name)
Parameter | Description |
---|---|
name | The name to quote. |
public static String quote(String name)
//package com.java2s; /*// w ww .j av a 2 s. c o m * Hibernate, Relational Persistence for Idiomatic Java * * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. */ public class Main { /** * Return a representation of the given name ensuring quoting (wrapped with '`' characters). If already wrapped * return name. * * @param name The name to quote. * * @return The quoted version. */ public static String quote(String name) { if (isEmpty(name) || isQuoted(name)) { return name; } // Convert the JPA2 specific quoting character (double quote) to Hibernate's (back tick) else if (name.startsWith("\"") && name.endsWith("\"")) { name = name.substring(1, name.length() - 1); } return "`" + name + '`'; } public static boolean isEmpty(String string) { return string == null || string.length() == 0; } /** * Determine if the given string is quoted (wrapped by '`' characters at beginning and end). * * @param name The name to check. * * @return True if the given string starts and ends with '`'; false otherwise. */ public static boolean isQuoted(String name) { return name != null && name.length() != 0 && ((name.charAt(0) == '`' && name.charAt(name.length() - 1) == '`') || (name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"')); } }