All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jooq.util.mysql.MySQLDSL Maven / Gradle / Ivy

There is a newer version: 3.19.9
Show newest version
/*
 * 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Other licenses:
 * -----------------------------------------------------------------------------
 * Commercial licenses for this work are available. These replace the above
 * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
 * database integrations.
 *
 * For more information, please visit: http://www.jooq.org/licenses
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package org.jooq.util.mysql;

import static org.jooq.SQLDialect.MYSQL;

import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.SQLDialect;
import org.jooq.Support;
import org.jooq.impl.DSL;

/**
 * The {@link SQLDialect#MYSQL} specific DSL.
 *
 * @author Lukas Eder
 */
public class MySQLDSL extends DSL {

    /**
     * No instances
     */
    protected MySQLDSL() {
    }

    // -------------------------------------------------------------------------
    // MySQL-specific compression and encryption functions
    // -------------------------------------------------------------------------

    /**
     * Get the MySQL-specific DECODE() function.
     * 

* Don't mix this up with the various {@link DSL#decode()} methods! */ @Support({ MYSQL }) public static Field decode(String cryptString, String keyString) { return decode(val(cryptString), val(keyString)); } /** * Get the MySQL-specific DECODE() function. *

* Don't mix this up with the various {@link DSL#decode()} methods! */ @Support({ MYSQL }) public static Field decode(byte[] cryptString, byte[] keyString) { return decode(val(cryptString), val(keyString)); } /** * Get the MySQL-specific DECODE() function. *

* Don't mix this up with the various {@link DSL#decode()} methods! */ @Support({ MYSQL }) public static Field decode(Field cryptString, Field keyString) { return function("decode", cryptString.getType(), cryptString, keyString); } /** * Get the MySQL-specific ENCODE() function. */ @Support({ MYSQL }) public static Field encode(String string, String keyString) { return encode(val(string), val(keyString)); } /** * Get the MySQL-specific ENCODE() function. */ @Support({ MYSQL }) public static Field encode(byte[] string, byte[] keyString) { return encode(val(string), val(keyString)); } /** * Get the MySQL-specific ENCODE() function. */ @Support({ MYSQL }) public static Field encode(Field string, Field keyString) { return function("encode", string.getType(), string, keyString); } /** * Get the MySQL-specific AES_DECRYPT() function. */ @Support({ MYSQL }) public static Field aesDecrypt(String cryptString, String keyString) { return aesDecrypt(val(cryptString), val(keyString)); } /** * Get the MySQL-specific AES_DECRYPT() function. */ @Support({ MYSQL }) public static Field aesDecrypt(byte[] cryptString, byte[] keyString) { return aesDecrypt(val(cryptString), val(keyString)); } /** * Get the MySQL-specific AES_DECRYPT() function. */ @Support({ MYSQL }) public static Field aesDecrypt(Field cryptString, Field keyString) { return function("aes_decrypt", cryptString.getType(), cryptString, keyString); } /** * Get the MySQL-specific AES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field aesEncrypt(String string, String keyString) { return aesEncrypt(val(string), val(keyString)); } /** * Get the MySQL-specific AES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field aesEncrypt(byte[] string, byte[] keyString) { return aesEncrypt(val(string), val(keyString)); } /** * Get the MySQL-specific AES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field aesEncrypt(Field string, Field keyString) { return function("aes_encrypt", string.getType(), string, keyString); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(String cryptString) { return desDecrypt(val(cryptString)); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(byte[] cryptString) { return desDecrypt(val(cryptString)); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(Field cryptString) { return function("des_decrypt", cryptString.getType(), cryptString); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(String cryptString, String keyString) { return desDecrypt(val(cryptString), val(keyString)); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(byte[] cryptString, byte[] keyString) { return desDecrypt(val(cryptString), val(keyString)); } /** * Get the MySQL-specific DES_DECRYPT() function. */ @Support({ MYSQL }) public static Field desDecrypt(Field cryptString, Field keyString) { return function("des_decrypt", cryptString.getType(), cryptString, keyString); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(String string) { return desEncrypt(val(string)); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(byte[] string) { return desEncrypt(val(string)); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(Field string) { return function("des_encrypt", string.getType(), string); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(String string, String keyString) { return desEncrypt(val(string), val(keyString)); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(byte[] string, byte[] keyString) { return desEncrypt(val(string), val(keyString)); } /** * Get the MySQL-specific DES_ENCRYPT() function. */ @Support({ MYSQL }) public static Field desEncrypt(Field string, Field keyString) { return function("des_encrypt", string.getType(), string, keyString); } /** * Get the MySQL-specific COMPRESS() function. */ @Support({ MYSQL }) public static Field compress(String string) { return compress(val(string)); } /** * Get the MySQL-specific COMPRESS() function. */ @Support({ MYSQL }) public static Field compress(byte[] string) { return compress(val(string)); } /** * Get the MySQL-specific COMPRESS() function. */ @Support({ MYSQL }) public static Field compress(Field string) { return function("compress", string.getType(), string); } /** * Get the MySQL-specific UNCOMPRESS() function. */ @Support({ MYSQL }) public static Field uncompress(String string) { return uncompress(val(string)); } /** * Get the MySQL-specific UNCOMPRESS() function. */ @Support({ MYSQL }) public static Field uncompress(byte[] string) { return uncompress(val(string)); } /** * Get the MySQL-specific UNCOMPRESS() function. */ @Support({ MYSQL }) public static Field uncompress(Field string) { return function("uncompress", string.getType(), string); } /** * Get the MySQL-specific UNCOMPRESSED_LENGTH() function. */ @Support({ MYSQL }) public static Field uncompressedLength(String string) { return uncompressedLength(val(string)); } /** * Get the MySQL-specific UNCOMPRESSED_LENGTH() function. */ @Support({ MYSQL }) public static Field uncompressedLength(byte[] string) { return uncompressedLength(val(string)); } /** * Get the MySQL-specific UNCOMPRESSED_LENGTH() function. */ @Support({ MYSQL }) public static Field uncompressedLength(Field string) { return function("uncompressed_length", Integer.class, string); } /** * Get the MySQL-specific SHA1() function. */ @Support({ MYSQL }) public static Field sha1(String string) { return sha1(val(string)); } /** * Get the MySQL-specific SHA1() function. */ @Support({ MYSQL }) public static Field sha1(byte[] string) { return sha1(val(string)); } /** * Get the MySQL-specific SHA1() function. */ @Support({ MYSQL }) public static Field sha1(Field string) { return function("sha1", string.getType(), string); } /** * Get the MySQL-specific SHA2() function. */ @Support({ MYSQL }) public static Field sha2(String string, int hashLength) { return sha2(val(string), val(hashLength)); } /** * Get the MySQL-specific SHA2() function. */ @Support({ MYSQL }) public static Field sha2(byte[] string, int hashLength) { return sha2(val(string), val(hashLength)); } /** * Get the MySQL-specific SHA2() function. */ @Support({ MYSQL }) public static Field sha2(Field string, Field hashLength) { return function("sha2", string.getType(), string, hashLength); } /** * Get the MySQL-specific PASSWORD() function. */ @Support({ MYSQL }) public static Field password(String string) { return password(val(string)); } /** * Get the MySQL-specific PASSWORD() function. */ @Support({ MYSQL }) public static Field password(byte[] string) { return password(val(string)); } /** * Get the MySQL-specific PASSWORD() function. */ @Support({ MYSQL }) public static Field password(Field string) { return function("password", string.getType(), string); } // ------------------------------------------------------------------------- // Other functions // ------------------------------------------------------------------------- /** * Get the MySQL-specific VALUES() function for use with * INSERT .. ON DUPLICATE KEY UPDATE statements. * * @see * http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html# * function_values */ @Support({ MYSQL }) public static Field values(Field values) { return function("values", values.getDataType(), values); } // ------------------------------------------------------------------------- // Other utilities // ------------------------------------------------------------------------- /** * Get a field based {@link EnumType} by its MySQL-specific index. *

* If your MySQL enum type contains these three values: A, B, C * , then this will be the mapping of indexes to values: *

* * * * * * * * * * * * * * * * * * * * * * * * * *
Enum literal as in {@link Enum#name()}Enum ordinal as in {@link Enum#ordinal()}MySQL index
null-0
A01
B12
C23
*

* See dev.mysql.com/doc/ * refman/5.5/en/enum.html for more details about MySQL enum types */ public static & org.jooq.EnumType> E enumType(Class type, int index) { if (index <= 0) { return null; } E[] values = type.getEnumConstants(); if (index > values.length) { return null; } return values[index - 1]; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy