public class DBString extends QueryableDatatype<String> implements StringResult
Use DBString when the column is a char, varchar, or
nvarchar datatype.
Generally DBString is declared inside your DBRow sub-class as:
@DBColumn public DBString myCharColumn = new DBString();
If the string column encodes repeating information like a status code, use
DBStringEnum to encapsulate the values.
Support DBvolution at Patreon
SORT_ASCENDING, SORT_DESCENDING| Constructor and Description |
|---|
DBString()
The default constructor for DBString.
|
DBString(String string)
Creates a DBString with the value provided.
|
DBString(StringExpression stringExpression)
Creates a column expression with a string result from the expression
provided.
|
| Modifier and Type | Method and Description |
|---|---|
DBString |
copy()
Copies a QueryableDatatype and returns the copy.
|
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(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
excludedRange(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
excludedValues(Collection<String> excluded)
excludes the object, Set, List, Array, or vararg of objects
|
void |
excludedValues(String... excluded)
excludes the object, Set, List, Array, or vararg of objects
|
void |
excludedValues(StringExpression... excluded)
excludes the object, Set, List, Array, or vararg of objects
|
void |
excludedValuesIgnoreCase(Collection<String> excluded)
Reduces the rows to excluding the object, Set, List, Array, or vararg of
Strings ignoring letter case.
|
void |
excludedValuesIgnoreCase(String... excluded)
Reduces the rows to excluding the object, Set, List, Array, or vararg of
Strings ignoring letter case.
|
void |
excludedValuesIgnoreCase(StringExpression... excluded)
Reduces the rows to excluding the object, Set, List, Array, or vararg of
Strings ignoring letter case.
|
String |
formatValueForSQLStatement(DBDefinition defn)
Returns the value of the object formatted for the database
This should be overridden in each subclass
This method is called by toSQLString after checking for NULLs and should
return a string representation of the object formatted for use within a SQL
select, insert, update, or delete statement.
|
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.
|
boolean |
getIncludesNull()
Returns TRUE if this expression requires support for possible NULL database
values.
|
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().
|
boolean |
isEmptyOrNullString()
Returns TRUE if the database value is the empty string or NULL
Support DBvolution at Patreon |
boolean |
isEmptyString()
Indicates whether this DBString value is the SQL equivalent of a java empty
String.
|
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 |
permittedPatternIgnoreCase(String pattern)
Perform case-insensitive searches based on using database compatible
pattern matching.
|
void |
permittedRange(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
permittedRange(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(StringExpression lowerBound,
StringExpression upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(String lowerBound,
String upperBound)
Performs searches based on a range.
|
void |
permittedValues(Collection<String> permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValues(Object... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValues(String... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValues(StringExpression... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValuesIgnoreCase(List<String> permitted)
reduces the rows to only the object, Set, List, Array, or vararg of Strings
ignoring letter case.
|
void |
permittedValuesIgnoreCase(Set<String> 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 to only the object, Set, List, Array, or vararg of Strings
ignoring letter case.
|
void |
permittedValuesIgnoreCase(StringExpression... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of Strings
ignoring letter case.
|
protected DBOperator |
setToNull(DBDefinition database)
Used during setFromResultSet to set the QDT to a database NULL value.
|
void |
setValue(String str)
Sets the value of this DBString to the value provided.
|
protected void |
setValueFromStandardStringEncoding(String encodedValue)
Set the value of this QDT to the value provided from the standard string
encoding of this datatype
|
StringExpression |
stringResult()
Converts the expression into the standard string/character expression
representing the value.
|
static List<String> |
toStringList(List<DBString> dbStrings)
Utility function to return the values of a list of DBStrings in a list of
Strings.
|
clear, 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, setUnchanged, setValueToNull, stringValue, toSQLString, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcreateSQLForFromClause, isComplexExpression, isPurelyFunctional, toSQLStringpublic DBString()
Creates an unset undefined DBString object.
public DBString(String string)
The resulting DBString will be set as having the value provided but will not be defined in the database.
string - stringpublic DBString(StringExpression stringExpression)
Used in DBReport, and some DBRow, sub-classes to derive
data from the database prior to retrieval.
stringExpression - stringExpressionpublic static List<String> toStringList(List<DBString> dbStrings)
dbStrings - dbStrings
Support DBvolution at Patreon
public void setValue(String str)
str - strpublic 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>public 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 String formatValueForSQLStatement(DBDefinition defn)
QueryableDatatypeformatValueForSQLStatement in class QueryableDatatype<String>defn - db
Support DBvolution at Patreon
public DBString copy()
QueryableDatatypeSupport DBvolution at Patreon
copy in interface DBExpressioncopy in interface StringResultcopy 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 DBExpressionpublic 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 permittedValues(String... permitted)
permitted - permittedpublic void permittedValues(Object... permitted)
permitted - permittedpublic void permittedValues(Collection<String> permitted)
permitted - permittedpublic void permittedValuesIgnoreCase(String... permitted)
permitted - permittedpublic void permittedValuesIgnoreCase(StringExpression... permitted)
permitted - permittedpublic void permittedValuesIgnoreCase(List<String> permitted)
permitted - permittedpublic void permittedValuesIgnoreCase(Set<String> permitted)
permitted - permittedpublic void excludedValuesIgnoreCase(String... excluded)
excluded - excludedpublic void excludedValuesIgnoreCase(StringExpression... excluded)
excluded - excludedpublic void excludedValuesIgnoreCase(Collection<String> excluded)
excluded - excludedpublic void excludedValues(String... excluded)
excluded - excludedpublic void excludedValues(Collection<String> excluded)
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 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(String lowerBound, String upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e excludedRange(1,null) will exclude 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e excludedRange(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeInclusive(String lowerBound, String upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e excludedRangeInclusive(1,null) will exclude 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended 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 the upper-bound is null the range will be open ended and exclusive.
I.e excludedRangeExclusive(1,null) will exclude 2,3,4,5, etc.
if the upper-bound is null the range will be open ended 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 - patternpublic void permittedValues(StringExpression... permitted)
permitted - permittedpublic void excludedValues(StringExpression... excluded)
excluded - excludedpublic void permittedRange(StringExpression lowerBound, StringExpression 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(StringExpression lowerBound, StringExpression 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(StringExpression lowerBound, StringExpression 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(StringExpression lowerBound, StringExpression upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e excludedRange(1,null) will exclude 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e excludedRange(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeInclusive(StringExpression lowerBound, StringExpression upperBound)
if the upper-bound is null the range will be open ended and inclusive.
I.e excludedRangeInclusive(1,null) will exclude 1,2,3,4,5, etc.
if the upper-bound is null the range will be open ended and inclusive.
I.e excludedRangeInclusive(null, 5) will exclude 5,4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeExclusive(StringExpression lowerBound, StringExpression upperBound)
if the upper-bound is null the range will be open ended and exclusive.
I.e excludedRangeExclusive(1,null) will exclude 2,3,4,5, etc.
if the upper-bound is null the range will be open ended and exclusive.
I.e excludedRangeExclusive(null, 5) will exclude 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic boolean getIncludesNull()
ExpressionCanHaveNullValuesSupport DBvolution at Patreon
getIncludesNull in interface ExpressionCanHaveNullValuespublic boolean isEmptyString()
Some databases, notably Oracle, cannot differentiate between empty strings and NULL strings. This method helps programmers access the empty or NULL states will allowing DBV to provide a consistent interface.
In Oracle and similar databases isDBNull and isEmptyString will both be TRUE when the value is NULL. However most databases will have isEmptyString false when the string is null, and isDBNull false when the string is empty.
Support DBvolution at Patreon
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.SQLExceptionpublic void permittedPatternIgnoreCase(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 - patternprotected DBOperator setToNull(DBDefinition database)
QueryableDatatypeDBDatabase is supplied so that database-specific processing, such as Oracle empty strings, can be performed.
Sets the value of this column to DBNull Also changes the operator to DBIsNullOperator for comparisons.
The default implementation just calls QueryableDatatype.setToNull()
setToNull in class QueryableDatatype<String>database - database
Support DBvolution at Patreon
public boolean isEmptyOrNullString()
Support DBvolution at Patreon
protected 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.public StringExpression stringResult()
ExpressionHasStandardStringResultNot all types have a standard string/character representation, notably dates.
Please note that this is not the SQL version of the expression
(toSQLString() will provide that),
nor does this provide a String of the value.
To get the string value use the
stringValue method of the
appropriate QDT.
Support DBvolution at Patreon
stringResult in interface ExpressionHasStandardStringResultCopyright © 2018. All Rights Reserved.