E - an enumeration class that implements the DBEnumValue
interface for String values.public class DBStringEnum<E extends Enum<E> & DBEnumValue<String>> extends DBEnum<E,String>
DBString except that the database value can be easily
interpreted as an enumeration with integer codes.
DBStringEnum maps string values automatically from the database value to the
enumeration value via the DBEnumValue interface.
Internally stores only the database-centric literal value in its type. Conversion to the enumeration type is done lazily so that it's possible to handle the case where a database has an invalid value or a new value that isn't in the enumeration.
SORT_ASCENDING, SORT_DESCENDING| Constructor and Description |
|---|
DBStringEnum()
The default constructor for DBStringEnum.
|
DBStringEnum(E value)
Creates a DBStringEnum with the value set to the value of the supplied Enum
object..
|
DBStringEnum(String value)
Creates a DBStringEnum with the value provided.
|
DBStringEnum(StringExpression stringExpression)
Creates a DBStringEnum column expression based on the
StringExpression provided. |
| Modifier and Type | Method and Description |
|---|---|
protected String[] |
convertToLiteral(E... enumValues)
Provides the literal values for all the enumeration values provided.
|
void |
excludedPattern(String pattern)
Perform searches based on using database compatible pattern matching
|
void |
excludedPattern(StringExpression pattern)
Perform searches based on using database compatible pattern matching
|
void |
excludedRange(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
excludedRange(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedValuesIgnoreCase(Collection<E> excluded)
Reduces the rows to excluding the object, Set, List, Array, or vararg of
Strings ignoring letter case.
|
void |
excludedValuesIgnoreCase(E... excluded)
Reduces the rows to excluding the object, Set, List, Array, or vararg of
Strings ignoring letter case.
|
void |
excludedValuesIgnoreCase(List<String> excluded)
Reduces the rows returned from a query by excluding those matching the
provided objects.
|
void |
excludedValuesIgnoreCase(Set<String> excluded)
Reduces the rows returned from a query by excluding those matching the
provided objects.
|
void |
excludedValuesIgnoreCase(String... excluded)
Reduces the rows returned from a query by excluding those matching the
provided objects.
|
void |
excludedValuesIgnoreCase(StringExpression... excluded)
Reduces the rows returned from a query by excluding those matching the
provided objects.
|
StringColumn |
getColumn(RowDefinition row)
Creates a Column Provider suitable to this QDT.
|
protected String |
getFromResultSet(DBDefinition database,
ResultSet resultSet,
String fullColumnName)
Returns the correct object from the ResultSet for the QueryableDatatype to
handle.
|
DBString |
getQueryableDatatypeForExpressionValue()
Provides a blank instance of the
QueryableDatatype used by this
expression. |
String |
getSQLDatatype()
Provides the SQL datatype used by default for this type of object.
|
Set<DBRow> |
getTablesInvolved()
Returns a Set of the DBRow instances involved in this expression.
|
String |
getValue()
Gets the current literal value of this queryable data type.
|
boolean |
isAggregator()
Returns TRUE if this expression is an Aggregator like SUM() or LEAST().
|
void |
permittedPattern(String pattern)
Perform searches based on using database compatible pattern matching
|
void |
permittedPattern(StringExpression pattern)
Perform searches based on using database compatible pattern matching
|
void |
permittedRange(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
permittedRange(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(E lowerBound,
E upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedValuesIgnoreCase(Collection<E> permitted)
Reduces the rows returned from a query to only those matching the provided
objects.
|
void |
permittedValuesIgnoreCase(E... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of Strings
ignoring letter case.
|
void |
permittedValuesIgnoreCase(String... permitted)
Reduces the rows returned from a query to only those matching the provided
objects.
|
void |
permittedValuesIgnoreCase(StringExpression... permitted)
Reduces the rows returned from a query to only those matching the provided
expression.
|
protected void |
setValueFromStandardStringEncoding(String encodedValue)
Set the value of this QDT to the value provided from the standard string
encoding of this datatype
|
protected void |
validateLiteralValue(E enumValue)
Validates whether the given type is acceptable as a literal value.
|
convertToLiteral, enumValue, excludedValues, excludedValues, formatValueForSQLStatement, permittedValues, permittedValues, setValueclear, copy, createSQLForFromClause, equals, formatColumnForSQLStatement, getColumnExpression, getLiteralValue, getOperator, getPreviousSQLValue, getPreviousValue, getPropertyWrapperDefinition, getQueryableDatatypeForObject, getQueryableDatatypeInstance, getSortOrder, hasBeenSet, hasChanged, hasColumnExpression, hashCode, includingNulls, isComplexExpression, isDefined, isNotNull, isNull, isPurelyFunctional, negateOperator, removeConstraints, setChanged, setColumnExpression, setDefined, setFromResultSet, setLiteralValue, setOperator, setPreviousValue, setSortOrderAscending, setSortOrderDescending, setToNull, setToNull, setUnchanged, setValueToNull, stringValue, toSQLString, toStringpublic DBStringEnum()
Creates an unset undefined DBStringEnum object.
public DBStringEnum(String value)
value - valuepublic DBStringEnum(StringExpression stringExpression)
StringExpression provided.
This is used to generate a DBStringEnum result from data in the database.at runtime. Use a StringExpression to create the data.
DBvolution can not ensure that the results of your expression will conform to the particular DBStringEnum values, so construct your expression carefully.
This can also be used to transform an existing column into a DBStringEnum, the above warning still applies.
stringExpression - stringExpressionpublic DBStringEnum(E value)
value - valueprotected void validateLiteralValue(E enumValue)
DBEnumDBEnumValue.getCode().
Throw an IncompatibleClassChangeError to indicate that the literal value failed validation
validateLiteralValue in class DBEnum<E extends Enum<E> & DBEnumValue<String>,String>enumValue - non-null enum value, for which the literal value may be
nullpublic String getSQLDatatype()
QueryableDatatypeThis should be overridden in each subclass
Example return value: "VARCHAR(1000)"
Database specific datatypes are provided by the DBDefinition in the method
DBDefinition.getDatabaseDataTypeOfQueryableDatatype(nz.co.gregs.dbvolution.datatypes.QueryableDatatype<?>)
Support DBvolution at Patreon
getSQLDatatype in class QueryableDatatype<String>public DBString getQueryableDatatypeForExpressionValue()
DBExpressionQueryableDatatype used by this
expression.
You are probably looking for ExpressionColumn.asExpressionColumn().
Note that this method is not good for use in everyday DBvolution code and should probably be reserved for meta-programming.
Support DBvolution at Patreon
getQueryableDatatypeForExpressionValue in interface DBExpressiongetQueryableDatatypeForExpressionValue in class QueryableDatatype<String>public boolean isAggregator()
DBExpressionSubclasses must implement this method returning TRUE if the expression will combine the results of several rows to produce a result. If the expression relies on subexpressions, then the isAggregator method must return TRUE if the subexpressions include an aggregator.
Aggregators collect several rows together to produce a single result. Examples are MAX, MIN, and AVERAGE.
They are only appropriate in the SELECT clause and generally require the GROUP BY clause to be useful.
Aggregators are used with DBReport. Aggregator expressions are
included in the SELECT clause but excluded from the GROUP BY clause.
Support DBvolution at Patreon
isAggregator in interface DBExpressionisAggregator in class DBEnum<E extends Enum<E> & DBEnumValue<String>,String>public Set<DBRow> getTablesInvolved()
DBExpressionUsed by QueryGraph to plot the connections between tables and avoid cartesian joins.
Support DBvolution at Patreon
getTablesInvolved in interface DBExpressiongetTablesInvolved in class QueryableDatatype<String>public void permittedValuesIgnoreCase(String... permitted)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
permitted - permittedpublic void permittedValuesIgnoreCase(StringExpression... permitted)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
permitted - permittedpublic void permittedValuesIgnoreCase(Collection<E> permitted)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
permitted - permittedpublic void excludedValuesIgnoreCase(String... excluded)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
excluded - excludedpublic void excludedValuesIgnoreCase(StringExpression... excluded)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
excluded - excludedpublic void excludedValuesIgnoreCase(List<String> excluded)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
excluded - excludedpublic void excludedValuesIgnoreCase(Set<String> excluded)
The case, upper or lower, will be ignored.
Defining case for Unicode characters is complicated and may not work as expected.
excluded - excludedpublic void permittedRange(String lowerBound, String upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRange(1,null) will return 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e permittedRange(null, 5) will return 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void permittedRangeInclusive(String lowerBound, String upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRangeInclusive(1,null) will return 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRangeInclusive(null, 5) will return 5,4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void permittedRangeExclusive(String lowerBound, String upperBound)
if both ends of the range are specified both the lower- and upper-bound will be excluded in the search. I.e permittedRangeExclusive(1,3) will return 2.
if the upper-bound is null the range will be open ended up and exclusive.
I.e permittedRangeExclusive(1,null) will return 2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e permittedRangeExclusive(null, 5) will return 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRange(String lowerBound, String upperBound)
if both ends of the range are specified the lower-bound will included and the upper-bound will be excluded in the range. I.e excludedRange(1,3) will exclude 1,2.
if the upper-bound is null the range will be open ended up and inclusive.
I.e excludedRange(1,null) will exclude 1,2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e excludedRange(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeInclusive(String lowerBound, String upperBound)
if both ends of the range are specified both the lower-bound and the upper-bound will be included in the range. I.e excludedRangeInclusive(1,3) will exclude 1,2,3.
if the upper-bound is null the range will be open ended up and inclusive.
I.e excludedRangeInclusive(1,null) will exclude 1,2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and inclusive.
I.e excludedRangeInclusive(null, 5) will exclude 5,4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeExclusive(String lowerBound, String upperBound)
if both ends of the range are specified both the lower-bound and the upper-bound will be excluded in the range. I.e excludedRangeExclusive(1,3) will exclude 2.
if the upper-bound is null the range will be open ended up and exclusive.
I.e excludedRangeExclusive(1,null) will exclude 2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e excludedRangeExclusive(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void permittedPattern(String pattern)
This facilitates the LIKE operator.
Please use the pattern system appropriate to your database.
Java-style regular expressions are not yet supported.
pattern - patternpublic void excludedPattern(String pattern)
This facilitates the LIKE operator.
Please use the pattern system appropriate to your database.
Java-style regular expressions are not yet supported.
pattern - patternpublic void permittedPattern(StringExpression pattern)
This facilitates the LIKE operator.
Please use the pattern system appropriate to your database.
Java-style regular expressions are not yet supported.
pattern - patternpublic void excludedPattern(StringExpression pattern)
This facilitates the LIKE operator.
Please use the pattern system appropriate to your database.
Java-style regular expressions are not yet supported.
pattern - pattern@SafeVarargs protected final String[] convertToLiteral(E... enumValues)
DBEnumconvertToLiteral in class DBEnum<E extends Enum<E> & DBEnumValue<String>,String>enumValues - enumValues
Support DBvolution at Patreon
@SafeVarargs public final void permittedValuesIgnoreCase(E... permitted)
permitted - permitted@SafeVarargs public final void excludedValuesIgnoreCase(E... excluded)
excluded - excludedpublic void excludedValuesIgnoreCase(Collection<E> excluded)
excluded - excludedpublic void permittedRange(E lowerBound, E upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRange(1,null) will return 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e permittedRange(null, 5) will return 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void permittedRangeInclusive(E lowerBound, E upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRangeInclusive(1,null) will return 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and inclusive.
I.e permittedRangeInclusive(null, 5) will return 5,4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void permittedRangeExclusive(E lowerBound, E upperBound)
if the upper-bound is null the range will be open ended and exclusive.
I.e permittedRangeExclusive(1,null) will return 2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e permittedRangeExclusive(null, 5) will return 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRange(E lowerBound, E upperBound)
if both ends of the range are specified the lower-bound will included and the upper-bound will be excluded in the range. I.e excludedRange(1,3) will exclude 1,2.
if the upper-bound is null the range will be open ended up and inclusive.
I.e excludedRange(1,null) will exclude 1,2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e excludedRange(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeInclusive(E lowerBound, E upperBound)
if both ends of the range are specified both the lower-bound and the upper-bound will be excluded in the range. I.e excludedRangeExclusive(1,3) will exclude 2.
if the upper-bound is null the range will be open ended up and exclusive.
I.e excludedRangeExclusive(1,null) will exclude 2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e excludedRangeExclusive(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeExclusive(E lowerBound, E upperBound)
if both ends of the range are specified both the lower-bound and the upper-bound will be excluded in the range. I.e excludedRangeExclusive(1,3) will exclude 2.
if the upper-bound is null the range will be open ended up and exclusive.
I.e excludedRangeExclusive(1,null) will exclude 2,3,4,5, etc.
if the lower-bound is null the range will be open ended down and exclusive.
I.e excludedRangeExclusive(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic String getValue()
QueryableDatatype
This method will return NULL if the QDT represents a database NULL OR the
field is undefined. Use QueryableDatatype.isNull() and QueryableDatatype.isDefined() to
differentiate the 2 states.
Undefined QDTs represents a QDT that is not a field from the database.
Undefined QDTs are similar to undefined DBRows
Support DBvolution at Patreon
getValue in class QueryableDatatype<String>protected String getFromResultSet(DBDefinition database, ResultSet resultSet, String fullColumnName) throws SQLException
QueryableDatatypegetFromResultSet in class QueryableDatatype<String>database - databaseresultSet - resultSetfullColumnName - fullColumnName
Support DBvolution at Patreon
SQLException - java.sql.SQLExceptionprotected void setValueFromStandardStringEncoding(String encodedValue)
QueryableDatatypeSubclass writers should ensure that the method handles nulls correctly and throws an exception if an inappropriate value is supplied.
setValueFromStandardStringEncoding in class QueryableDatatype<String>encodedValue - the value of the QDT in the appropriate encodingpublic StringColumn getColumn(RowDefinition row) throws IncorrectRowProviderInstanceSuppliedException
QueryableDatatypeCreates a ColumnProvider object of the correct type for this QueryableDatatype, using this object and the provided row.
Used internally to maintain the relationship between QDTs and their ColumnProvider equivalents.
getColumn in class QueryableDatatype<String>IncorrectRowProviderInstanceSuppliedException - if this object is not
a field in the row.Copyright © 2018. All Rights Reserved.