org.jooq.util.mariadb.MariaDBDSL Maven / Gradle / Ivy
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.util.mariadb;
import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
/**
* The {@link SQLDialect#MARIADB} specific DSL.
*
* @author Lukas Eder
*/
public class MariaDBDSL extends DSL {
/**
* No instances
*/
protected MariaDBDSL() {
}
// -------------------------------------------------------------------------
// MariaDB-specific compression and encryption functions
// -------------------------------------------------------------------------
/**
* Get the MariaDB-specific DECODE()
function
*
* Don't mix this up with the various {@link DSL#decode()} methods!
*/
public static Field decode(String cryptString, String keyString) {
return decode(val(cryptString), val(keyString));
}
/**
* Get the MariaDB-specific DECODE()
function
*
* Don't mix this up with the various {@link DSL#decode()} methods!
*/
public static Field decode(Field cryptString, Field keyString) {
return function("decode", String.class, cryptString, keyString);
}
/**
* Get the MariaDB-specific ENCODE()
function
*/
public static Field encode(String string, String keyString) {
return encode(val(string), val(keyString));
}
/**
* Get the MariaDB-specific ENCODE()
function
*/
public static Field encode(Field string, Field keyString) {
return function("encode", String.class, string, keyString);
}
/**
* Get the MariaDB-specific AES_DECRYPT()
function
*/
public static Field aesDecrypt(String cryptString, String keyString) {
return aesDecrypt(val(cryptString), val(keyString));
}
/**
* Get the MariaDB-specific AES_DECRYPT()
function
*/
public static Field aesDecrypt(Field cryptString, Field keyString) {
return function("aes_decrypt", String.class, cryptString, keyString);
}
/**
* Get the MariaDB-specific AES_ENCRYPT()
function
*/
public static Field aesEncrypt(String string, String keyString) {
return aesEncrypt(val(string), val(keyString));
}
/**
* Get the MariaDB-specific AES_ENCRYPT()
function
*/
public static Field aesEncrypt(Field string, Field keyString) {
return function("aes_encrypt", String.class, string, keyString);
}
/**
* Get the MariaDB-specific DES_DECRYPT()
function
*/
public static Field desDecrypt(String cryptString) {
return desDecrypt(val(cryptString));
}
/**
* Get the MariaDB-specific DES_DECRYPT()
function
*/
public static Field desDecrypt(Field cryptString) {
return function("des_decrypt", String.class, cryptString);
}
/**
* Get the MariaDB-specific DES_DECRYPT()
function
*/
public static Field desDecrypt(String cryptString, String keyString) {
return desDecrypt(val(cryptString), val(keyString));
}
/**
* Get the MariaDB-specific DES_DECRYPT()
function
*/
public static Field desDecrypt(Field cryptString, Field keyString) {
return function("des_decrypt", String.class, cryptString, keyString);
}
/**
* Get the MariaDB-specific DES_ENCRYPT()
function
*/
public static Field desEncrypt(String string) {
return desEncrypt(val(string));
}
/**
* Get the MariaDB-specific DES_ENCRYPT()
function
*/
public static Field desEncrypt(Field string) {
return function("des_encrypt", String.class, string);
}
/**
* Get the MariaDB-specific DES_ENCRYPT()
function
*/
public static Field desEncrypt(String string, String keyString) {
return desEncrypt(val(string), val(keyString));
}
/**
* Get the MariaDB-specific DES_ENCRYPT()
function
*/
public static Field desEncrypt(Field string, Field keyString) {
return function("des_encrypt", String.class, string, keyString);
}
/**
* Get the MariaDB-specific COMPRESS()
function
*/
public static Field compress(String string) {
return compress(val(string));
}
/**
* Get the MariaDB-specific COMPRESS()
function
*/
public static Field compress(Field string) {
return function("compress", String.class, string);
}
/**
* Get the MariaDB-specific UNCOMPRESS()
function
*/
public static Field uncompress(String string) {
return uncompress(val(string));
}
/**
* Get the MariaDB-specific UNCOMPRESS()
function
*/
public static Field uncompress(Field string) {
return function("uncompress", String.class, string);
}
/**
* Get the MariaDB-specific UNCOMPRESSED_LENGTH()
function
*/
public static Field uncompressedLength(String string) {
return uncompressedLength(val(string));
}
/**
* Get the MariaDB-specific UNCOMPRESSED_LENGTH()
function
*/
public static Field uncompressedLength(Field string) {
return function("uncompressed_length", Integer.class, string);
}
/**
* Get the MariaDB-specific SHA1()
function
*/
public static Field sha1(String string) {
return sha1(val(string));
}
/**
* Get the MariaDB-specific SHA1()
function
*/
public static Field sha1(Field string) {
return function("sha1", String.class, string);
}
/**
* Get the MariaDB-specific PASSWORD()
function
*/
public static Field password(String string) {
return password(val(string));
}
/**
* Get the MariaDB-specific PASSWORD()
function
*/
public static Field password(Field string) {
return function("password", String.class, string);
}
// -------------------------------------------------------------------------
// Other utilities
// -------------------------------------------------------------------------
/**
* Get a field based {@link EnumType} by its MariaDB-specific index.
*
* If your MariaDB 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()}
* MariaDB index
*
*
* null
* -
* 0
*
*
* A
* 0
* 1
*
*
* B
* 1
* 2
*
*
* C
* 2
* 3
*
*
*
* 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];
}
}