private static int getSaveTokenType(String s, boolean functionsAsKeywords) { return ParserUtil.getSaveTokenType(s, functionsAsKeywords); }
private boolean isKeyword(String s) { if (!identifiersToUpper) { // if not yet converted to uppercase, do it now s = StringUtils.toUpperEnglish(s); } return ParserUtil.isKeyword(s); }
/** * @param identifier * identifier to check * @return is specified identifier may be used without quotes */ @Override public boolean isSimpleIdentifier(String identifier) throws SQLException { return ParserUtil.isSimpleIdentifier(identifier, true); }
switch (s.charAt(0)) { case 'A': return getKeywordOrIdentifier(s, "ALL", KEYWORD); case 'C': if ("CHECK".equals(s)) { return getKeywordOrIdentifier(s, "DISTINCT", KEYWORD); case 'E': if ("EXCEPT".equals(s)) { return KEYWORD; return getKeywordOrIdentifier(s, "EXISTS", KEYWORD); case 'F': if ("FETCH".equals(s)) { return getKeywordOrIdentifier(s, "FALSE", FALSE); case 'G': return getKeywordOrIdentifier(s, "GROUP", KEYWORD); case 'H': return getKeywordOrIdentifier(s, "HAVING", KEYWORD); case 'I': if ("INNER".equals(s)) { return getKeywordOrIdentifier(s, "IS", KEYWORD); case 'J': return getKeywordOrIdentifier(s, "JOIN", KEYWORD); case 'L': if ("LIMIT".equals(s)) { return KEYWORD;
if ("SET".equals(alias) || ParserUtil.isKeyword(alias)) { return s;
/** * Checks if this string is a SQL keyword. * * @param s the token to check * @return true if it is a keyword */ public static boolean isKeyword(String s) { if (s == null || s.length() == 0) { return false; } return getSaveTokenType(s, false) != IDENTIFIER; }
/** * Add double quotes around an identifier if required. * * @param s the identifier * @return the quoted identifier */ public static String quoteIdentifier(String s) { if (s == null) { return "\"\""; } if (ParserUtil.isSimpleIdentifier(s, false)) { return s; } return StringUtils.quoteIdentifier(s); }
if (ParserUtil.isKeyword(alias)) { break;
/** * Is this a simple identifier (in the JDBC specification sense). * * @param s identifier to check * @param functionsAsKeywords treat system functions as keywords * @return is specified identifier may be used without quotes * @throws NullPointerException if s is {@code null} */ public static boolean isSimpleIdentifier(String s, boolean functionsAsKeywords) { if (s.length() == 0) { return false; } char c = s.charAt(0); // lowercase a-z is quoted as well if ((!Character.isLetter(c) && c != '_') || Character.isLowerCase(c)) { return false; } for (int i = 1, length = s.length(); i < length; i++) { c = s.charAt(i); if ((!Character.isLetterOrDigit(c) && c != '_') || Character.isLowerCase(c)) { return false; } } return getSaveTokenType(s, functionsAsKeywords) == IDENTIFIER; }