X
- public class DurationFieldValue<X extends DataObject> extends java.lang.Object implements SQLAccessor<Duration,X>, FilterProvider<X,Duration>
NumberFieldExpression
into
an SQLAccessor
for a Duration
with a configurable resolution.
Note that NumberFieldExpression
can implement Duration
directly
(as a SQLExpression
if millisecond resolution is used as Duration
is a number.
This class is only a SQLValue
as the database resolution is different from the numerical
value of the Duration
.Modifier and Type | Field and Description |
---|---|
protected NumberFieldExpression<java.lang.Number,X> |
expression |
protected long |
resolution |
Constructor and Description |
---|
DurationFieldValue(NumberFieldExpression<java.lang.Number,X> expression,
long resolution)
convert a
NumberFieldExpression into a DurationFieldValue |
Modifier and Type | Method and Description |
---|---|
int |
add(java.lang.StringBuilder sb,
boolean qualify)
Add the expression to a StringBuilder
|
boolean |
canSet()
does this
Accessor support setting values. |
java.lang.String |
getFieldName() |
SQLFilter<X> |
getFilter(MatchCondition match,
Duration val)
Create a
SQLFilter comparing against the target value |
java.lang.Class<X> |
getFilterType()
get the type bounds on the produced
SQLFilter . |
SQLFilter<X> |
getNullFilter(boolean is_null)
create a
SQLFilter checking if the target value is or is not null. |
SQLFilter<X> |
getOrderFilter(boolean descending)
create a
SQLFilter that orders results by the target value. |
java.util.List<PatternArgument> |
getParameters(java.util.List<PatternArgument> list)
Add parameters for this value to a list.
|
SQLFilter |
getRequiredFilter()
Get an SQLFilter required to be added to the filter set.
|
java.lang.Class<Duration> |
getTarget()
Get the type of the returned object as far as it is known.
|
Duration |
getValue(X r)
get the value from the target object
|
Duration |
makeObject(java.sql.ResultSet rs,
int pos)
Extract a result of the expression from a ResultSet into an object of the specified type.
|
void |
setObject(java.sql.PreparedStatement stmt,
int pos,
Duration value) |
void |
setValue(X rec,
Duration duration)
Set value if supported otherwise throw a
UnsupportedOperationException . |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addGroup, checkContentsCanGroup, getGroupParameters, groupingIsomorphic
protected final NumberFieldExpression<java.lang.Number,X extends DataObject> expression
protected final long resolution
public DurationFieldValue(NumberFieldExpression<java.lang.Number,X> expression, long resolution)
NumberFieldExpression
into a DurationFieldValue
expression
- underlying expressionresolution
- resolution of stored value in milliseconds.public java.lang.Class<Duration> getTarget()
Targetted
public Duration getValue(X r)
Accessor
getValue
in interface Accessor<Duration,X extends DataObject>
r
- target objectpublic int add(java.lang.StringBuilder sb, boolean qualify)
SQLValue
public java.util.List<PatternArgument> getParameters(java.util.List<PatternArgument> list)
SQLValue
getParameters
in interface SQLValue<Duration>
list
- to modifypublic Duration makeObject(java.sql.ResultSet rs, int pos) throws DataException, java.sql.SQLException
SQLValue
makeObject
in interface SQLValue<Duration>
rs
- ResultSetDataException
java.sql.SQLException
public void setValue(X rec, Duration duration)
Accessor
UnsupportedOperationException
.setValue
in interface Accessor<Duration,X extends DataObject>
public void setObject(java.sql.PreparedStatement stmt, int pos, Duration value) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getFieldName()
public java.lang.String toString()
toString
in class java.lang.Object
public SQLFilter getRequiredFilter()
SQLValue
getRequiredFilter
in interface SQLValue<Duration>
public boolean canSet()
Accessor
Accessor
support setting values.canSet
in interface Accessor<Duration,X extends DataObject>
public SQLFilter<X> getFilter(MatchCondition match, Duration val) throws CannotFilterException
FilterProvider
SQLFilter
comparing against the target valuegetFilter
in interface FilterProvider<X extends DataObject,Duration>
SQLFilter
CannotFilterException
public SQLFilter<X> getNullFilter(boolean is_null) throws CannotFilterException
FilterProvider
SQLFilter
checking if the target value is or is not null.getNullFilter
in interface FilterProvider<X extends DataObject,Duration>
SQLFilter
CannotFilterException
public SQLFilter<X> getOrderFilter(boolean descending) throws CannotFilterException
FilterProvider
SQLFilter
that orders results by the target value. This may involve joins so
may not be just an OrderFilter
though it will contain one.getOrderFilter
in interface FilterProvider<X extends DataObject,Duration>
SQLFilter
CannotFilterException
public java.lang.Class<X> getFilterType()
FilterProvider
SQLFilter
.getFilterType
in interface FilterProvider<X extends DataObject,Duration>