Enum Class DefaultSqlFormatter
- All Implemented Interfaces:
de.calamanari.adl.cnv.tps.ArgValueFormatter,Serializable,Comparable<DefaultSqlFormatter>,Constable
Important: These formatters usually only come into play when debugging or logging because regularly all values are passed as parameters of
PreparedStatements, so there is no formatting required.
See also remarks at QueryParameterApplicator.applyUnsafe(StringBuilder, QueryParameter, int)
- Author:
- Karl Eilebrecht
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatSqlBit(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as a bit-value (0/1) if it is '0', '1', 'TRUE' or 'FALSE'static StringformatSqlBoolean(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as a boolean value (TRUE/FALSE) if it is '0', '1', 'TRUE' or 'FALSE'static StringformatSqlDateDefaultStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.static StringformatSqlDateMySqlStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.static StringformatSqlDateOracleStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.static StringformatSqlDatePlain(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.static StringformatSqlDateSqlServerStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.static StringformatSqlInteger(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 32-bit signed integer rangestatic StringformatSqlSmallInt(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 16-bit signed short rangestatic StringformatSqlTimestampDefaultStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.static StringformatSqlTimestampMySqlStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.static StringformatSqlTimestampOracleStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.static StringformatSqlTimestampPlain(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.static StringformatSqlTimestampSqlServerStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.static StringformatSqlTinyInt(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 8-bit unsigned byte rangestatic DefaultSqlFormatterReturns the enum constant of this class with the specified name.static DefaultSqlFormatter[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SQL_BIT
-
SQL_BIGINT
-
SQL_BOOLEAN
-
SQL_CHAR
-
SQL_DATE_PLAIN
-
SQL_DATE_DEFAULT
-
SQL_DATE_MYSQL
-
SQL_DATE_ORACLE
-
SQL_DATE_SQL_SERVER
-
SQL_DECIMAL
-
SQL_DOUBLE
-
SQL_FLOAT
-
SQL_INTEGER
-
SQL_LONGNVARCHAR
-
SQL_LONGVARCHAR
-
SQL_NCHAR
-
SQL_NUMERIC
-
SQL_NVARCHAR
-
SQL_REAL
-
SQL_SMALLINT
-
SQL_TIMESTAMP_PLAIN
-
SQL_TIMESTAMP_DEFAULT
-
SQL_TIMESTAMP_MYSQL
-
SQL_TIMESTAMP_ORACLE
-
SQL_TIMESTAMP_SQL_SERVER
-
SQL_TINYINT
-
SQL_VARCHAR
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
format
- Specified by:
formatin interfacede.calamanari.adl.cnv.tps.ArgValueFormatter
-
formatSqlBit
public static String formatSqlBit(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as a bit-value (0/1) if it is '0', '1', 'TRUE' or 'FALSE'- Parameters:
argName-argValue-operator-- Returns:
- 0 or 1
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- if the input does not match
-
formatSqlBoolean
public static String formatSqlBoolean(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as a boolean value (TRUE/FALSE) if it is '0', '1', 'TRUE' or 'FALSE'- Parameters:
argName-argValue-operator-- Returns:
- FALSE or TRUE
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- if the input does not match
-
formatSqlInteger
public static String formatSqlInteger(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 32-bit signed integer range- Parameters:
argName-argValue-operator-- Returns:
- int value as string
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- if the input does not match
-
formatSqlSmallInt
public static String formatSqlSmallInt(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 16-bit signed short range- Parameters:
argName-argValue-operator-- Returns:
- short value as string
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- if the input does not match
-
formatSqlTinyInt
public static String formatSqlTinyInt(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string as integer if it is in 8-bit unsigned byte range- Parameters:
argName-argValue-operator-- Returns:
- byte value as string (0-255)
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- if the input does not match
-
formatSqlTimestampPlain
public static String formatSqlTimestampPlain(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.Note: The compromise to support full time stamps was introduced to avoid confusion when specifying
FilterColumns, it should be irrelevant for regular fields (by default Audlang deals with date only).This plain format is accepted by SQLite.
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
'yyyy-MM-dd HH:mm:ss'
-
formatSqlTimestampDefaultStyle
public static String formatSqlTimestampDefaultStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.This "standard" format works with H2 and PostreSql but for example not with SQLite.
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TIMESTAMP '2024-12-12 00:00:00'
-
formatSqlTimestampOracleStyle
public static String formatSqlTimestampOracleStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.Should also work for PostgreSQL
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TO_TIMESTAMP('2024-12-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
-
formatSqlTimestampMySqlStyle
public static String formatSqlTimestampMySqlStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TIMESTAMP('2024-12-12 00:00:00')
-
formatSqlTimestampSqlServerStyle
public static String formatSqlTimestampSqlServerStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it either matches the formatyyyy-MM-ddoryyyy-MM-dd HH:mm:ssand represents a valid UTC-time.- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TO_TIMESTAMP('2024-12-12 00:00:00')
-
formatSqlDatePlain
public static String formatSqlDatePlain(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.This plain format is accepted by SQLite.
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
'yyyy-MM-dd'
-
formatSqlDateDefaultStyle
public static String formatSqlDateDefaultStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.This "standard" format works with H2 and PostreSql but for example not with SQLite.
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
DATE '2024-12-12'
-
formatSqlDateOracleStyle
public static String formatSqlDateOracleStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.Should also work for PostgreSQL
- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TO_DATE('2024-12-12', 'YYYY-MM-DD')
-
formatSqlDateSqlServerStyle
public static String formatSqlDateSqlServerStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
TO_DATE('2024-12-12')
-
formatSqlDateMySqlStyle
public static String formatSqlDateMySqlStyle(String argName, String argValue, de.calamanari.adl.irl.MatchOperator operator) Formats the given string if it matches the formatyyyy-MM-ddand represents a valid UTC-time.- Parameters:
argName-argValue-operator-- Returns:
- stamp of the form
DATE('2024-12-12')
-