public class DBNumber extends QueryableDatatype<Number> implements NumberResult
Use DBNumber when the column is a NUMBER or NUMBER(x,y), that
is any integer or real datatype..
Use DBInteger when the numbers do not have a decimal or fractional
part.
Generally DBNumber is declared inside your DBRow sub-class as:
@DBColumn public DBNumber myIntColumn = new DBNumber();
Support DBvolution at Patreon
SORT_ASCENDING, SORT_DESCENDING| Constructor and Description |
|---|
DBNumber()
The default constructor for DBNumber.
|
DBNumber(IntegerExpression integerExpression) |
DBNumber(Long aNumber) |
DBNumber(Number aNumber)
Creates a new DBNumber with the value set to the number provided.
|
DBNumber(NumberExpression... numberExpression)
Creates a column expression with a number result from the expression
provided.
|
| Modifier and Type | Method and Description |
|---|---|
DBNumber |
copy()
Copies a QueryableDatatype and returns the copy.
|
Double |
doubleValue()
The current
literal value of this DBNumber as a Double
Support DBvolution at Patreon |
void |
excludedRange(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
excludedRange(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
excludedRangeExclusive(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
excludedRangeInclusive(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
excludedValues(Collection<Number> excluded)
excludes the object, Set, List, Array, or vararg of objects
|
void |
excludedValues(Number... excluded)
excludes the object, Set, List, Array, or vararg of objects
|
void |
excludedValues(NumberResult... excluded)
excludes the object, Set, List, Array, or vararg of objects
|
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.
|
protected Number |
getFromResultSet(DBDefinition defn,
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.
|
static int |
getNumericPrecision() |
static int |
getNumericScale() |
DBNumber |
getQueryableDatatypeForExpressionValue()
Provides a blank instance of the
QueryableDatatype used by this
expression. |
String |
getSQLDatatype()
Support DBvolution at Patreon |
Set<DBRow> |
getTablesInvolved()
Returns a Set of the DBRow instances involved in this expression.
|
Number |
getValue()
Gets the current literal value of this DBNumber, without any formatting.
|
Integer |
intValue()
The current
literal value of this DBNumber as an
Integer
Support DBvolution at Patreon |
boolean |
isAggregator()
Returns TRUE if this expression is an Aggregator like SUM() or LEAST().
|
Long |
longValue()
The current
literal value of this DBNumber as a Long
Support DBvolution at Patreon |
Number |
numberValue()
The current
literal value of this DBNumber as a Number
Support DBvolution at Patreon |
void |
permittedRange(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
permittedRange(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
permittedRangeExclusive(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(Number lowerBound,
Number upperBound)
Performs searches based on a range.
|
void |
permittedRangeInclusive(NumberResult lowerBound,
NumberResult upperBound)
Performs searches based on a range.
|
void |
permittedValues(Collection<Number> permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValues(Number... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
permittedValues(NumberResult... permitted)
reduces the rows to only the object, Set, List, Array, or vararg of objects
|
void |
setValue(DBNumber newLiteralValue)
Sets the value of this DBNumber to the value of the DBNumber provided.
|
void |
setValue(Number newLiteralValue)
Set the value of this DBNumber to the Double, Long, Integer, or other
number 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.
|
clear, equals, formatColumnForSQLStatement, getColumnExpression, getLiteralValue, getOperator, getPreviousSQLValue, getPreviousValue, getPropertyWrapperDefinition, getQueryableDatatypeForObject, getQueryableDatatypeInstance, getSortOrder, hasBeenSet, hasChanged, hasColumnExpression, hashCode, includingNulls, isDefined, isNotNull, isNull, isPurelyFunctional, negateOperator, removeConstraints, setChanged, setColumnExpression, setDefined, setFromResultSet, setLiteralValue, setOperator, setPreviousValue, setSortOrderAscending, setSortOrderDescending, setToNull, setToNull, setUnchanged, setValueToNull, stringValue, toSQLString, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitisPurelyFunctional, toSQLStringpublic DBNumber()
Creates an unset undefined DBNumber object.
public DBNumber(NumberExpression... numberExpression)
Used in DBReport, and some DBRow, sub-classes to derive
data from the database prior to retrieval.
numberExpression - numberExpressionpublic DBNumber(Number aNumber)
aNumber - aNumberpublic DBNumber(Long aNumber)
aNumber - aNumberpublic DBNumber(IntegerExpression integerExpression)
public DBNumber copy()
QueryableDatatypeSupport DBvolution at Patreon
copy in interface DBExpressioncopy in interface NumberResultcopy in class QueryableDatatype<Number>public void setValue(DBNumber newLiteralValue)
This allows DBNumbers to be treated somewhat like normal numbers. However setValue(java.lang.Number) may be more useful in normal usage.
newLiteralValue - newLiteralValuepublic void setValue(Number newLiteralValue)
This is probably the method you want to use to set or change the value of
this DBNumber. When creating a new row or updating an existing row use this
method or setValue(nz.co.gregs.dbvolution.datatypes.DBNumber) to
correctly set the value.
Remember:
DBDatabase.insert(nz.co.gregs.dbvolution.DBRow...) or DBDatabase.update(nz.co.gregs.dbvolution.DBRow...) to make the changes permanent.newLiteralValue - newLiteralValuepublic String getSQLDatatype()
Support DBvolution at Patreon
getSQLDatatype in class QueryableDatatype<Number>public static int getNumericScale()
public static int getNumericPrecision()
public String formatValueForSQLStatement(DBDefinition defn)
QueryableDatatypeformatValueForSQLStatement in class QueryableDatatype<Number>db - db
Support DBvolution at Patreon
public Number getValue()
The literal value is undefined (and null) if using an operator
other than equals.
Support DBvolution at Patreon
getValue in class QueryableDatatype<Number>public Number numberValue()
literal value of this DBNumber as a Number
Support DBvolution at Patreon
public Double doubleValue()
literal value of this DBNumber as a Double
Support DBvolution at Patreon
public Long longValue()
literal value of this DBNumber as a Long
Support DBvolution at Patreon
public Integer intValue()
literal value of this DBNumber as an
Integer
Support DBvolution at Patreon
public DBNumber 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<Number>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<Number>public void permittedValues(Number... permitted)
permitted - permittedpublic void permittedValues(Collection<Number> permitted)
permitted - permittedpublic void permittedValues(NumberResult... permitted)
permitted - permittedpublic void excludedValues(Number... excluded)
excluded - excludedpublic void excludedValues(Collection<Number> excluded)
excluded - excludedpublic void excludedValues(NumberResult... excluded)
excluded - excludedpublic void permittedRange(Number lowerBound, Number 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 permittedRange(NumberResult lowerBound, NumberResult 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(Number lowerBound, Number 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 permittedRangeInclusive(NumberResult lowerBound, NumberResult 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(Number lowerBound, Number 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 permittedRangeExclusive(NumberResult lowerBound, NumberResult 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(Number lowerBound, Number 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 excludedRange(NumberResult lowerBound, NumberResult 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 return 4,3,2,1, etc.
lowerBound - lowerBoundupperBound - upperBoundpublic void excludedRangeInclusive(Number lowerBound, Number 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 excludedRangeInclusive(NumberResult lowerBound, NumberResult 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(Number lowerBound, Number 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 excludedRangeExclusive(NumberResult lowerBound, NumberResult 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 ExpressionCanHaveNullValuesprotected Number getFromResultSet(DBDefinition defn, ResultSet resultSet, String fullColumnName) throws SQLException
QueryableDatatypegetFromResultSet in class QueryableDatatype<Number>defn - databaseresultSet - resultSetfullColumnName - fullColumnName
Support DBvolution at Patreon
SQLException - java.sql.SQLExceptionpublic 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 ExpressionHasStandardStringResultprotected 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<Number>encodedValue - the value of the QDT in the appropriate encodingCopyright © 2017. All Rights Reserved.