public final class FieldReference extends java.lang.Object implements Resolvable, Accessor
CompoundQuery, when
an inner loop where clause of a multi-table query refers to a field within
a buffer retrieved in an outer loop.
This class provides both read and write capability to the backing field, insofar as the DMO has both an accessor (getter) and a mutator (setter) method defined for the specified property. Both indexed and non-indexed versions of these methods are supported. It is assumed that the methods have bean-like signatures. Specifically, the following, public signature patterns are assumed:
<BaseDataType subclass> get<Property>()
<BaseDataType subclass> get<Property>(int)
void set<Property>(<BaseDataType subclass>)
void set<Property>(<BaseDataType subclass>, int)
| Modifier and Type | Field and Description |
|---|---|
private RecordBuffer |
buffer
The record buffer which contains the referent DMO.
|
private java.lang.Boolean |
bulk
When the reference is an EXTENT field and
index is null the bulk getter/setter
will be used. |
private Database |
database
The associated database
|
private java.lang.Object |
dmo
DMO or DMO proxy instance; the referent of the referencing method
|
private java.lang.Class<? extends DataModelObject> |
dmoIface
Interface of the target DMO.
|
private java.lang.Integer |
extent
This field's extent (if an array field), else
null |
private java.lang.reflect.Method |
getter
Method used to resolve this field reference at query execution time
|
private static java.lang.String |
ID
The special
id field. |
private java.lang.Integer |
index
Optional index, used with a DMO indexed getter method
|
private java.util.function.Supplier<NumberType> |
indexExpr
Optional index expression, used with a DMO indexed getter method
|
private boolean |
isBulkComputed
Flag that marks whether the bulk field has already been computed or not.
|
private boolean |
isExtentComputed
Flag that marks whether the extent field has already been computed or not.
|
private boolean |
isGetterComputed
Flag that marks whether the getter field has already been computed or not.
|
private boolean |
isIdAccessor
Marks this as a reference to
id special field. |
private boolean |
isSetterComputed
Flag that marks whether the setter field has already been computed or not.
|
private java.lang.String |
legacyName
Saved legacy field name.
|
private static CentralLogger |
LOG
Logger
|
private java.lang.String |
property
Property name
|
private DataModelObject |
proxy
DMO proxy, if available; may be
null |
private java.lang.reflect.Method |
setter
Method used to resolve this field reference at query execution time
|
private boolean |
uppercase
Flag to force resolved character result to uppercase/right-trim
|
| Constructor and Description |
|---|
FieldReference(Database database,
java.lang.Class<? extends DataModelObject> dmoIface,
java.lang.String property)
Create a new field reference given a DMO interface and property name.
|
FieldReference(DataModelObject dmo,
java.lang.String property)
Create a new field reference given a DMO proxy and property name.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase)
Create a new field reference given a DMO proxy and property name.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
int index)
Create a new field reference given a DMO proxy, a property name, and
an index for the property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
NumberType index)
Create a new field reference given a DMO proxy, a property name, and an index for the
property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
NumberType index,
boolean bulk)
Create a new field reference given a DMO proxy, a property name, an index for the
property, and a flag indicating whether or not to use bulk.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
NumberType index,
java.util.function.Supplier<NumberType> indexExpr,
boolean bulk)
Create a new field reference given a DMO proxy, a property name, and an index / index expression for the
property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
java.util.function.Supplier<NumberType> indexExpr)
Create a new field reference given a DMO proxy, a property name, and an index expression for the
property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
boolean uppercase,
java.util.function.Supplier<NumberType> indexExpr,
boolean bulk)
Create a new field reference given a DMO proxy, a property name, an index expression for the
property, and a flag indicating whether or not to use bulk.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
int index)
Create a new field reference given a DMO proxy, a property name, and
an index for the property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
int index,
boolean bulk)
Create a new field reference given a DMO proxy, a property name, an index for the
property, and a flag indicating whether or not to use bulk.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
NumberType index)
Create a new field reference given a DMO proxy, a property name, and
an index for the property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
java.util.function.Supplier<NumberType> indexExpr)
Create a new field reference given a DMO proxy, a property name, and
an index expression for the property.
|
FieldReference(DataModelObject dmo,
java.lang.String property,
java.util.function.Supplier<NumberType> indexExpr,
boolean bulk)
Create a new field reference given a DMO proxy, a property name, an index expression for the
property, and a flag indicating whether or not to use bulk.
|
FieldReference(FieldReference fieldRef,
java.lang.Integer index)
Specialized copy constructor which copies a non-indexed field reference and applies an
index to the copy.
|
FieldReference(FieldReference fieldRef,
java.lang.Integer index,
java.lang.Integer origExtent,
java.lang.String origPropName)
Specialized copy constructor which copies a non-indexed field reference and applies an
index to the copy.
|
FieldReference(RecordBuffer buffer,
java.lang.String property)
Create a new field reference given a property name and a DMO proxy.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Test the equality with another object.
|
BaseDataType |
get()
Resolve the current value of the referent field by invoking the getter
method for the target property.
|
(package private) java.lang.Object |
get(DataModelObject dmo)
Resolve the current value of the referent field by invoking the getter
method for the target property, using the given DMO as the target.
|
(package private) java.lang.Object |
get(Record dmo)
Resolve the current value of the referent field by invoking the getter
method for the target property, using the given DMO as the target.
|
java.lang.Object |
getDMO()
Get the DMO or proxy instance associated with this field reference.
|
java.lang.Class<? extends DataModelObject> |
getDMOInterface()
Get the interface of the DMO associated with this field reference.
|
java.lang.Integer |
getExtent()
Return field's extent, if field reference is to an extent field, else
null. |
private java.lang.Integer |
getExtent(java.lang.Class<? extends DataModelObject> dmoIface,
java.lang.String property)
Look up the extent for the specified property and interface.
|
BaseDataType[] |
getExtentValues()
Resolve the current value of the referent field by invoking the getter method for the
target property.
|
java.lang.String |
getFullFieldName()
Get full converted name of the associated field in the format
alias_name.field_name. |
private java.lang.reflect.Method |
getGetter()
Look up the getter method for the specified property and interface.
|
int |
getIndex()
Returns index used with the DMO indexed getter method.
|
java.lang.String |
getLegacyFieldName()
Get legacy field name as it is defined in 4GL.
|
private java.lang.Object |
getObject()
Resolve the current value of the referent field by invoking the getter method for the target property.
|
RecordBuffer |
getParentBuffer()
Returns the record buffer which contains the referent DMO.
|
java.lang.String |
getProperty()
Get property name (converted field name).
|
private java.lang.reflect.Method |
getSetter()
Look up the setter method for the specified property and interface.
|
(package private) java.lang.Object |
getTemp(DataModelObject dmo)
Resolve the current value of the referent field by invoking the getter
method for the target property, using the given DMO as the target.
|
(package private) java.lang.Object |
getTemp(Record dmo)
Resolve the current value of the referent field by invoking the getter
method for the target property, using the given DMO as the target.
|
java.lang.Class<?> |
getType()
Determine the data type that will be returned when this field reference
is resolved.
|
BaseDataType |
getValue()
Resolve the field reference's value, bracketed by calls to the error
manager to first enable, then disable, warning mode.
|
private void |
handleException(java.lang.Exception exc)
Handle a thread interruption or database connection error specially,
otherwise return normally.
|
int |
hashCode()
Compute the hash code for this object.
|
boolean |
hasIndex()
Returns
true if index is specified (either as a scalar or as an expression). |
boolean |
isUpperCase()
Indicate whether resolved character value will be uppercased/right-trimmed.
|
BaseDataType |
resolve()
Resolve the current value of the referent field by invoking the getter
method for the target property.
|
void |
set(BaseDataType value)
Set the current value of the referent field by invoking the setter
method for the target property.
|
void |
set(BaseDataType[] value)
Set the current value of the referent field by invoking the setter method for the target
property.
|
java.lang.String |
toString()
Return a string representation of this field reference, in the form:
|
(package private) BaseDataType |
unknownValue()
Create an instance of unknown value of the correct type for this field reference.
|
(package private) static BaseDataType |
unknownValue(java.lang.reflect.Method getter)
Convenience method to produce a
BaseDataType instance
initialized to the unknown value. |
private static final CentralLogger LOG
private static final java.lang.String ID
id field. It is used for rowid / recid of the record and
does not exist as real field in P4GL, only in converted SQL database. For this reason it is
handled a bit different. Its value is implemented as objects extending Record
and not the DMO as other fields.private final java.lang.String property
private java.lang.reflect.Method getter
private java.lang.reflect.Method setter
private java.lang.Integer extent
nullprivate final java.lang.Integer index
private final java.util.function.Supplier<NumberType> indexExpr
private java.lang.String legacyName
private Database database
private java.lang.Object dmo
private DataModelObject proxy
nullprivate boolean uppercase
private java.lang.Boolean bulk
index is null the bulk getter/setter
will be used.private RecordBuffer buffer
private final java.lang.Class<? extends DataModelObject> dmoIface
private final boolean isIdAccessor
id special field.IDprivate boolean isExtentComputed
private boolean isGetterComputed
private boolean isSetterComputed
private boolean isBulkComputed
public FieldReference(DataModelObject dmo, java.lang.String property)
dmo - DMO proxy.property - Target property name.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase)
dmo - DMO proxy.property - Target property name.uppercase - true to force a character value
returned by getObject() to be uppercased/right-trimmed;
false to leave the result unchanged.public FieldReference(DataModelObject dmo, java.lang.String property, int index)
dmo - DMO proxy.property - Target property name.index - Index to pass to property's getter method at resolve time.public FieldReference(DataModelObject dmo, java.lang.String property, java.util.function.Supplier<NumberType> indexExpr)
dmo - DMO proxy.property - Target property name.indexExpr - Index expression which is evaluated to pass to property's getter method at resolve time.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, int index)
dmo - DMO proxy.property - Target property name.uppercase - true to force a character value
returned by getObject() to be uppercased/right-trimmed;
false to leave the result unchanged.index - Index to pass to property's getter method at resolve time.public FieldReference(DataModelObject dmo, java.lang.String property, NumberType index)
dmo - DMO proxy.property - Target property name.index - Index to pass to property's getter method at resolve time.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, NumberType index)
dmo - DMO proxy.property - Target property name.uppercase - true to force a character value returned by getObject() to
be uppercased/right-trimmed; false to leave the result unchanged.index - Index to pass to property's getter method at resolve time.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, java.util.function.Supplier<NumberType> indexExpr)
dmo - DMO proxy.property - Target property name.uppercase - true to force a character value returned by getObject() to
be uppercased/right-trimmed; false to leave the result unchanged.indexExpr - Index expression which is evaluated to pass to property's getter method at resolve time.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, int index, boolean bulk)
bulk. This constructor does not support forcing a character value
returned by getObject() to be uppercased/right-trimmed;dmo - DMO proxy.property - Target property name.index - index which, when negative, will be passed as null to constructor.bulk - When true the bulk getter/setter will be used.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, java.util.function.Supplier<NumberType> indexExpr, boolean bulk)
bulk. This constructor does not support forcing a character value
returned by getObject() to be uppercased/right-trimmed;dmo - DMO proxy.property - Target property name.indexExpr - Index expression which is evaluated to pass to property's getter method at resolve time.bulk - When true the bulk getter/setter will be used.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, NumberType index, boolean bulk)
bulk.dmo - DMO proxy.property - Target property name.uppercase - true to force a character value returned by getObject() to
be uppercased/right-trimmed; false to leave the result unchanged.index - index which, when negative, will be passed as null to constructor.bulk - When true the bulk getter/setter will be used.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, java.util.function.Supplier<NumberType> indexExpr, boolean bulk)
bulk.dmo - DMO proxy.property - Target property name.uppercase - true to force a character value returned by getObject() to
be uppercased/right-trimmed; false to leave the result unchanged.indexExpr - Index expression which is evaluated to pass to property's getter method at resolve time.bulk - When true the bulk getter/setter will be used.java.lang.IllegalArgumentException - if field reference is not recognized.public FieldReference(DataModelObject dmo, java.lang.String property, boolean uppercase, NumberType index, java.util.function.Supplier<NumberType> indexExpr, boolean bulk)
bulk is true and index is null.dmo - DMO proxy.property - Target property name.uppercase - true to force a character value returned by getObject() to
be uppercased/right-trimmed; false to leave the result unchanged.index - Index to pass to property's getter method at resolve time. Can be null if there is
no index or indexExpr is specified.indexExpr - Index expression which is evaluated to pass to property's getter method at resolve time. Not
used is index is not null.bulk - When the reference is an EXTENT field and index is null the bulk
getter/setter will be used.java.lang.IllegalArgumentException - if field reference is not recognized.FieldReference(Database database, java.lang.Class<? extends DataModelObject> dmoIface, java.lang.String property)
get(Record) variant of the get method.
Note that the created instance can be used to read the related field only.
database - The associated database.dmoIface - Interface of the target DMO.property - Target property namepublic FieldReference(FieldReference fieldRef, java.lang.Integer index)
fieldRef - Original, non-indexed field reference. Although the field is non-indexed, this
should be a reference to an extent field.index - Zero-based index to be used as the subscript into the extent field represented by the copy.
Use null for bulk access.public FieldReference(FieldReference fieldRef, java.lang.Integer index, java.lang.Integer origExtent, java.lang.String origPropName)
fieldRef - Original, non-indexed field reference. Although the field is non-indexed, this
should be a reference to an extent field.index - Zero-based index to be used as the subscript into the extent field represented by the copy.
Use null for bulk access.origExtent - The original value of the extent. In case of denormalized fields the fieldRef might
lose this value.origPropName - The original property name. In case of denormalized fields the fieldRef might
lose this value.FieldReference(RecordBuffer buffer, java.lang.String property)
buffer - Record buffer which backs this field reference's DMO proxy.property - Target property name.static BaseDataType unknownValue(java.lang.reflect.Method getter)
BaseDataType instance
initialized to the unknown value. An attempt is made to return an
object of the correct type (i.e., the getter method's return type).
If this fails for some reason, a new instance of unknown
is returned.getter - Getter method whose return type is used to determine the type
of object to return.unknown.public java.lang.Class<?> getType()
getType in interface Resolvablepublic BaseDataType getValue()
public BaseDataType resolve()
resolve in interface Resolvablepublic BaseDataType get()
get in interface AccessorErrorConditionException - if any persistence level error occurs getting the value from
the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter
method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.public BaseDataType[] getExtentValues()
ErrorConditionException - if any persistence level error occurs getting the value from the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there is some other error at
the invocation target.public int getIndex()
-1 if the getter is
not indexed.public java.lang.Object getDMO()
public java.lang.String getProperty()
public java.lang.String getLegacyFieldName()
public void set(BaseDataType value)
set in interface Accessorvalue - New value to set into the field represented by this object.ErrorConditionException - if this field reference represents an element in an array, but
the index provided at construction is the unknown value;
if any persistence-level error occurs setting the value into
the DMO, including validation errors.java.lang.IllegalStateException - if the backing property is not write accessible (i.e., no
setter method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.public void set(BaseDataType[] value)
For non-extent fields, the value is placed on the first position in the array. For extent fields, the value is the actual value which needs to be set for the array.
value - New value to set into the field represented by this object.ErrorConditionException - if this field reference represents an element in an array, but the index provided
at construction is the unknown value; if any persistence-level error occurs setting
the value into the DMO, including validation errors.java.lang.IllegalStateException - if the backing property is not write accessible (i.e., no setter method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there is some other error at
the invocation target.public java.lang.String toString()
alias.propertyor, if indexed:
alias.property[index]If the field reference is to a case-insensitive character field, the result will be enclosed in the
upper() function.toString in class java.lang.Objectpublic java.lang.String getFullFieldName()
alias_name.field_name.
If this is a component of an extent field, the index is also added:
alias_name.field_name[index].public java.lang.Class<? extends DataModelObject> getDMOInterface()
public boolean isUpperCase()
public RecordBuffer getParentBuffer()
Note: this method only should be invoked on instances of this class which were constructed with a DMO proxy (as opposed to a DMO implementation class instance).
java.lang.NullPointerException - if this field reference was not constructed with a DMO proxy instance.public boolean hasIndex()
true if index is specified (either as a scalar or as an expression).true if index is specified (either as a scalar or as an expression).public java.lang.Integer getExtent()
null.null.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - The object to test against.true if both objects refer the same field.public int hashCode()
hashCode in class java.lang.Objectjava.lang.Object get(DataModelObject dmo)
null (or the unknown value for
BaseDataTypes return types).dmo - Target object which is used as the method's referent.null if no value exists.ErrorConditionException - if any persistence level error occurs getting the value from
the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter
method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.java.lang.Object get(Record dmo)
null (or the unknown value for
BaseDataTypes return types).dmo - Target object which is used as the method's referent.null if no value exists.ErrorConditionException - if any persistence level error occurs getting the value from
the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter
method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.java.lang.Object getTemp(Record dmo)
null (or the unknown value for
BaseDataTypes return types).
Unlike the get(com.goldencode.p2j.persist.Record) method, it
doesn't make this field reference use the passed DMO for future calls.
dmo - Target object which is used as the method's referent.null if no value exists.ErrorConditionException - if any persistence level error occurs getting the value from
the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter
method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.java.lang.Object getTemp(DataModelObject dmo)
null (or the unknown value for
BaseDataTypes return types).
Unlike the get(com.goldencode.p2j.persist.DataModelObject) method, it
doesn't make this field reference use the passed DMO for future calls.
dmo - Target object which is used as the method's referent.null if no value exists.ErrorConditionException - if any persistence level error occurs getting the value from
the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter
method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there
is some other error at the invocation target.BaseDataType unknownValue()
private java.lang.Integer getExtent(java.lang.Class<? extends DataModelObject> dmoIface, java.lang.String property)
dmoIface - Referent DMO interface.property - Name of target property (i.e., field).null if property does not match any
property name in the DMO API or is not an extent property.private java.lang.reflect.Method getGetter()
For the reserved id property, Record interface is substituted for
dmoIface.
For extent properties the method is capable to return the indexed or the non-indexed getter.
null if property does not match any property name
in the DMO API.private java.lang.reflect.Method getSetter()
For extent properties the method is capable to return the indexed or the non-indexed setter.
null if property does not match any property name
in the DMO API.private java.lang.Object getObject()
Note that this may return null (or the unknown value for BaseDataTypes return types).
null if no value exists.ErrorConditionException - if any persistence level error occurs getting the value from the DMO.java.lang.IllegalStateException - if the backing property is not read accessible (i.e., no getter method was found).java.lang.RuntimeException - if the backing, getter method cannot be accessed or if there is some other error at the
invocation target.private void handleException(java.lang.Exception exc)
exc - Exception to be inspected.DBUtils.handleException(Database, Exception)