public class object<T extends _BaseObject_> extends BaseDataType
TODO: throwing errors from an appserver to the client will serialize the legacy instance.
BaseDataType.Type, BaseDataType.WrapperHandler| Modifier and Type | Field and Description |
|---|---|
protected ObjectOps.ObjectHelper |
helper
Helper to use the ObjectOps without any context local lookups.
|
protected T |
ref
The contained object instance.
|
private java.lang.Class<T> |
type
The object's type.
|
| Constructor and Description |
|---|
object()
Default constructor.
|
object(java.lang.Class<? extends _BaseObject_> type)
Initialize this object reference, allowing only assignment to objects compatible with the
specified type.
|
object(object<T> other)
Copy constructor.
|
object(ObjectResource res)
Initialize this object with the reference from the specified resource.
|
object(T ref)
Initialize this object with the given reference.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
_isValid()
Determines if this instance is valid (to be used).
|
void |
assign(_BaseObject_ ref)
Set this instance
ref to the specified value, directly. |
void |
assign(BaseDataType value)
Sets the state (data and unknown value) of this instance based on the state of the passed
instance.
|
void |
assign(object<?> value)
Copy the reference from another object instance to this one.
|
void |
assign(Undoable old)
Modify the contained data of the instance to copy the instance data
from the given instance.
|
int |
compareTo(java.lang.Object obj)
Compares this instance with the specified instance and returns -1 if this instance is less than the
instance specified, 0 if the two instances are equal and 1 if this instance is greater than the
specified instance.
|
protected void |
decrement()
Decrement the reference counter for this instance.
|
java.lang.String |
defaultFormatString()
Return the default display format string for this type.
|
object<T> |
duplicate()
Does the same as standard
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException. |
static object<? extends _BaseObject_> |
fromResourceId(long resId)
Resolve the legacy instance and build an object referencing it.
|
BaseDataType.Type |
getType()
Get the type.
|
int |
hashCode()
A minimal implementation which satisfies the need for a concrete method.
|
protected void |
increment()
Increment the reference counter for this instance.
|
private void |
initialize(java.lang.Class<? extends _BaseObject_> type,
T ref)
Initialize this object with the given reference.
|
BaseDataType |
instantiateDefault()
Creates a new instance of the same type that represents the
default initialized value.
|
BaseDataType |
instantiateUnknown()
Creates a new instance of the same type that represents the
unknown value. |
protected boolean |
isIncompatibleTypesOnConversion(BaseDataType value)
Returns true if dynamic data type conversion should not be attempted,
it can also throws in case of incompatible types for a POLY conversion.
|
boolean |
isTracked()
Reports if the given instance is managed as part of the legacy 4GL object life cycle.
|
boolean |
isUnknown()
Reports if this instance represents the
unknown value. |
logical |
isValid()
Determines if this instance is valid (to be used).
|
void |
readExternal(java.io.ObjectInput in)
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays.
|
T |
ref()
Return the wrapped reference if this instance is not set to unknown value.
|
static long |
resourceId(object<? extends _BaseObject_> obj)
Returns an ID for the resource-representation of this object's reference.
|
(package private) void |
set(_BaseObject_ ref)
Set this object's reference and type from the given instance.
|
void |
setUnknown()
Sets the state of this instance's
unknown value flag or state to
true. |
java.lang.String |
toString()
Obtain a short description of the current object/state to be used in debugging.
|
java.lang.String |
toString(java.lang.String fmt)
Creates a string representation of the instance data using the given
format string.
|
java.lang.String |
toStringExport()
Creates a string representation of the instance data using the 'export'
format.
|
java.lang.String |
toStringMessage()
Creates a string representation of the instance data in a form that is
compatible with the
MESSAGE language statement. |
(package private) java.lang.Class<T> |
type()
Get the object's declared class.
|
void |
writeExternal(java.io.ObjectOutput out)
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings,
and arrays.
|
assign, assign, calcFormatLength, createProxy, createProxy, deepCopy, elementsOfType, equals, fallback, formatLength, fromTypeName, generateDefault, generateUnknown, getAssigner, getSize, getTypeName, incompatibleTypesOnConversion, initialize, initializeDefaultExtent, instantiateDefaultExtent, invalidInitializer, isAllKnown, isAllKnown, isAssignDirect, isProxy, isUnknownValue, maximum, minimum, notUnknownValue, sameType, val, variablechanged, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobalprotected T extends _BaseObject_ ref
null is unknown value.private java.lang.Class<T extends _BaseObject_> type
protected ObjectOps.ObjectHelper helper
WARNING: this instance is used only in _isValid() and isUnknown(). These methods
are overridden in EnumObject. Any other usage must take care of this, as the enum must have no
context saved when is created.
public object()
public object(java.lang.Class<? extends _BaseObject_> type)
type - The type of references this object can hold.public object(T ref)
ref - The reference.public object(ObjectResource res)
res - The object resource.public static long resourceId(object<? extends _BaseObject_> obj)
obj - The object for which the resource ID is required.public BaseDataType.Type getType()
getType in class BaseDataTypepublic static object<? extends _BaseObject_> fromResourceId(long resId)
resId - The resource ID.public T ref()
public int compareTo(java.lang.Object obj)
Comparable interface.
The algorithm will fail to give meaningful results in the case where one tries to sort against other objects that do not represent compatible values.
obj - The instance to compare against.obj.public int hashCode()
hashCode in class BaseDataTypepublic void assign(_BaseObject_ ref)
ref to the specified value, directly.
If ref is null, it will be set to unknown.
If the type is not compatible with ref, an error condition is raised.
ref - The instance to assign.public void assign(BaseDataType value)
If the value is not of the same type, some form of automatic type conversion may occur, or an error will be raised.
This variant is meant to handle the cases of built-in functions and methods in the 4GL which have polymorphic return types (e.g. DYNAMIC-FUNCTION()). This should NOT be used for non-polymorphic assignments.
assign in class BaseDataTypevalue - The instance from which to copy state.public void assign(object<?> value)
value - The instance from which to copy state.public void assign(Undoable old)
assign method is
called, although this is not a strict requirement.old - The backup instance from which to copy data.public boolean isUnknown()
unknown value.isUnknown in class BaseDataTypetrue if this instance is set to the
unknown value.public logical isValid()
true if this instance can be used.public boolean _isValid()
true if this instance can be used.public boolean isTracked()
true if the instance is tracked and false if the instance exists
outside of the OO 4GL life cycle mechanisms.public void setUnknown()
unknown value flag or state to
true.
Warning: the data stored in this instance will be invalid after calling this method.
setUnknown in class BaseDataTypepublic object<T> duplicate()
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException.duplicate in class BaseDataTypepublic BaseDataType instantiateUnknown()
unknown value.instantiateUnknown in class BaseDataTypeunknown value.public java.lang.String toString(java.lang.String fmt)
unknown value, a '?' will be returned.toString in class BaseDataTypefmt - The format string to use.public java.lang.String toStringMessage()
MESSAGE language statement. If the
instance represents the unknown value, a '?' will be
returned.toStringMessage in class BaseDataTypepublic java.lang.String toStringExport()
unknown value, a
'?' will be returned.toStringExport in class BaseDataTypepublic java.lang.String defaultFormatString()
defaultFormatString in class BaseDataTypepublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
out - the stream to write the object tojava.io.IOException - Includes any I/O exceptions that may occurpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
in - the stream to read data from in order to restore the objectjava.io.IOException - if I/O errors occurjava.lang.ClassNotFoundException - If the class for an object being
restored cannot be found.void set(_BaseObject_ ref)
ref - The object instance.public BaseDataType instantiateDefault()
instantiateDefault in class BaseDataTypeprotected void decrement()
No-op for internal object instances.
protected void increment()
No-op for internal object instances.
private void initialize(java.lang.Class<? extends _BaseObject_> type, T ref)
type - The type of references this object can hold. It is safe to pass null.ref - The reference. It is safe to pass null.public java.lang.String toString()
toString in class java.lang.Objectprotected boolean isIncompatibleTypesOnConversion(BaseDataType value)
BaseDataTypeisIncompatibleTypesOnConversion in class BaseDataType