Java String Quote quoteMonetDbIdentifier(String ident)

Here you can find the source of quoteMonetDbIdentifier(String ident)

Description

Quote and make the identifier MonetDB-proof by making lowercase and removing special characters.

License

Apache License

Declaration

public static String quoteMonetDbIdentifier(String ident) 

Method Source Code

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

public class Main {
    /**// w  ww .  jav  a 2s.com
     * Quote and make the identifier MonetDB-proof by making lowercase and removing
     * special characters.
     */
    public static String quoteMonetDbIdentifier(String ident) {
        // prepare identifier
        ident = prepareMonetDbIdentifier(ident);

        // make sure identifier is actually quoted
        ident = "\"" + ident + "\"";

        return ident;
    }

    /**
     * Make the identifier MonetDB-proof by making lowercase and removing special
     * characters.
     */
    public static String prepareMonetDbIdentifier(String ident) {
        // MonetDB only supports lowercase identifiers
        ident = ident.toLowerCase();

        // MonetDB doesn't support any special characters so replace with underscore
        ident = ident.replaceAll("[^a-zA-Z0-9]+", "_");

        return ident;
    }
}

Related

  1. quoteLocation(String location)
  2. quoteMdxIdentifier(String ident)
  3. quoteMe(String unquoted)
  4. quoteMeta(String s)
  5. quotemeta(String s)
  6. quoteMonetDbValue(String value)
  7. quoteNameIfNecessary(String name)
  8. quoteNcName(String ncName)
  9. quotEncode(String txt)