Java String Escape escapeReservedWord(String input)

Here you can find the source of escapeReservedWord(String input)

Description

escape Reserved Word

License

Open Source License

Declaration

static String escapeReservedWord(String input) 

Method Source Code


//package com.java2s;
/*/*from  w w w.  j ava 2 s  . c  o  m*/
 * Copyright (c) 2016, Bui Nguyen Thang, thang.buinguyen@gmail.com, thangbui.net. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import java.util.Arrays;
import java.util.List;

public class Main {
    private final static List<String> RESERVED_KEYWORDS = Arrays.asList("ADD", "ALLOW", "ALTER", "AND", "ANY",
            "APPLY", "ASC", "AUTHORIZE", "BATCH", "BEGIN", "BY", "COLUMNFAMILY", "CREATE", "DELETE", "DESC", "DROP",
            "EACH_QUORUM", "FROM", "GRANT", "IN", "INDEX", "INET", "INSERT", "INTO", "KEYSPACE", "KEYSPACES",
            "LIMIT", "LOCAL_ONE", "LOCAL_QUORUM", "MODIFY", "NORECURSIVE", "OF", "ON", "ONE", "ORDER", "PASSWORD",
            "PRIMARY", "QUORUM", "RENAME", "REVOKE", "SCHEMA", "SELECT", "SET", "TABLE", "TO", "TOKEN", "THREE",
            "TRUNCATE", "TWO", "UNLOGGED", "UPDATE", "USE", "USING", "WHERE", "WITH");

    static String escapeReservedWord(String input) {
        return RESERVED_KEYWORDS.contains(input) ? "\"" + input + "\"" : input;
    }
}

Related

  1. escapeQuotes(String string)
  2. escapeRegex(String regex)
  3. escapeRegexChars(String str, char... ignores)
  4. escapeRegexp(final String str)
  5. escapeRegexpSymbol(String expr)
  6. escapeSelected(String str, String chars)
  7. escapeSolr(String value)
  8. escapeToFileName(String name)
  9. escapeUnicode(String s)