public class jobject<T> extends BaseDataType
BaseDataType.Type, BaseDataType.WrapperHandler| Modifier and Type | Field and Description |
|---|---|
private T |
ref
The contained Java instance.
|
private java.lang.Class<T> |
type
The object's type.
|
| Constructor and Description |
|---|
jobject()
Default constructor.
|
jobject(BaseDataType value)
Create a new
jobject and assign it the given value. |
jobject(java.lang.Class<? extends java.lang.Object> type)
Initialize this object reference, allowing only assignment to objects compatible with the
specified type.
|
jobject(java.lang.Class<? extends java.lang.Object> type,
BaseDataType value)
Create a new
jobject with the specified type and assign it the given value. |
jobject(jobject<T> other)
Copy constructor.
|
jobject(T ref)
Initialize this object with the given reference.
|
| Modifier and Type | Method and Description |
|---|---|
void |
assign(BaseDataType value)
Sets the state (data and unknown value) of this instance based on the state of the passed
instance.
|
void |
assign(jobject<?> value)
Assign the current instance reference to the referenced wrapped by the specified value.
|
void |
assign(java.lang.Object ref)
Set this instance
ref to the specified value, directly. |
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 specified, 0 if the two instances
are equal and 1 if this instance is greater than the specified
instance.
|
java.lang.String |
defaultFormatString()
Return the default display format string for this type.
|
jobject<T> |
duplicate()
Does the same as standard
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException. |
static <T extends BaseDataType> |
fromJava(java.lang.Class<T> type,
jobject<?> value)
Convert the given Java-style value to a BDT instance.
|
(package private) static <T extends BaseDataType> |
fromJava(jobject<?> value)
Convert the given Java-style value to a BDT instance.
|
BaseDataType.Type |
getType()
Get the type
|
int |
hashCode()
A minimal implementation which satisfies the need for a concrete method.
|
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. |
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)
Replacement for the default object reading method.
|
T |
ref()
Return the wrapped reference if this instance is not set to unknown value.
|
(package private) void |
set(java.lang.Object 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. |
static <T> jobject<T> |
toJava(BaseDataType value)
Convert the given BDT value to a
jobject instance. |
static <T> jobject<T> |
toJava(java.lang.Class<T> type,
BaseDataType value)
Convert the given BDT value to a
jobject instance. |
private static java.lang.Object |
toJavaInstance(java.lang.Class<?> type,
BaseDataType value)
Convert the specified legacy BDT value to a Java-compatible instance.
|
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)
Replacement for the default object writing method.
|
calcFormatLength, createProxy, createProxy, deepCopy, elementsOfType, equals, fallback, formatLength, fromTypeName, generateDefault, generateUnknown, getAssigner, getSize, getTypeName, incompatibleTypesOnConversion, initialize, initializeDefaultExtent, instantiateDefaultExtent, invalidInitializer, isAllKnown, isAllKnown, isAssignDirect, isIncompatibleTypesOnConversion, isProxy, isUnknownValue, maximum, minimum, notUnknownValue, sameType, val, variablechanged, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobalprivate T ref
null is unknown value.private java.lang.Class<T> type
public jobject()
public jobject(java.lang.Class<? extends java.lang.Object> type,
BaseDataType value)
jobject with the specified type and assign it the given value.type - The expected type.value - The reference. If needed, convert from legacy 4GL type to Java.public jobject(BaseDataType value)
jobject and assign it the given value.value - The reference. If needed, convert from legacy 4GL type to Java.public jobject(java.lang.Class<? extends java.lang.Object> type)
type - The type of references this object can hold.public jobject(T ref)
ref - The reference.public static <T> jobject<T> toJava(BaseDataType value)
jobject instance.value - The BDT instance to be converted to Java.jobject instance wrapping the converted value. Note that if the
conversion is not possible, then an ERROR condition will be thrown.public static <T> jobject<T> toJava(java.lang.Class<T> type, BaseDataType value)
jobject instance.type - The expected type.value - The BDT instance to be converted to Java.jobject instance wrapping the converted value. Note that if the
conversion is not possible, then a ERROR condition will be thrown.public static <T extends BaseDataType> T fromJava(java.lang.Class<T> type, jobject<?> value)
type - The expected BDT instance for the value.value - The jobject wrapping a Java-style value.static <T extends BaseDataType> T fromJava(jobject<?> value)
value - The jobject wrapping a Java-style value.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(java.lang.Object 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.
assign in class BaseDataTyperef - The instance to assign.public void assign(jobject<?> value)
assign in class BaseDataTypevalue - The Java-style wrapped reference.public BaseDataType.Type getType()
getType in class BaseDataTypepublic 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(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 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 jobject<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 readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
in - The input source from which fields will be restored.java.io.NotSerializableException - Always, as legacy objects can't be serialized.java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
out - The output destination to which fields will be saved.java.io.NotSerializableException - Always, as legacy objects can't be serialized.java.io.IOExceptionvoid set(java.lang.Object ref)
ref - The object instance.public BaseDataType instantiateDefault()
instantiateDefault in class BaseDataTypeprivate static java.lang.Object toJavaInstance(java.lang.Class<?> type,
BaseDataType value)
type - The expected type of the Java instance.value - The legacy BDT value.