public static final class DOFType.Nullable extends DOFType
null
.
This class is a wrapper around other types, giving them the ability to accept null
in addition to their normal values. The referenced type must may be partially defined, and in
fact the nullable type is required in cases of self-referential types in order to avoid infinite
values being required (there must be a nullable to break the cycle).DOFType.Context, DOFType.Nullable, DOFType.Typedef
Constructor and Description |
---|
Nullable(DOFType.Context context,
DOFPacket packet)
Construct a type from a packet.
|
Nullable(DOFType type)
Construct a nullable type from another (non-nullable) type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Return whether two types are equal.
|
DOFValue |
getInstance(DOFPacket packet)
|
java.util.List<DOFType> |
getSubtypes()
Return a list of subtypes associated with this type.
|
int |
hashCode()
Return a hash code for the type.
|
void |
marshal(DOFType.Context context,
DOFPacket buffer)
Marshal, or output a binary representation of this type, into the
specified packet.
|
java.lang.String |
toString()
Returns a description of the type.
|
asBoolean, asByte, asBytes, asDate, asDOFInterfaceID, asDOFObjectID, asDouble, asFloat, asInt, asLong, asShort, asString, asULong, getCharSet, getEncoding, getMaxLength, getMinLength, getTypeID, isCompatibleWith, isDefined, marshal
public Nullable(DOFType type)
type
- The type to make nullable. Must not be null or refer to a nullable type.public Nullable(DOFType.Context context, DOFPacket packet) throws DOFMarshalException
context
- The context used to resolve type references.packet
- The packet that contains the type.DOFMarshalException
- Thrown if the type cannot be created.public DOFValue getInstance(DOFPacket packet) throws DOFMarshalException
DOFType
DOFValue
instance from a DOFPacket
.
When called the current buffer location will point at the first byte of data associated with the
type. On completion, the buffer location must point at the first byte after the data, meaning the
first unread byte.getInstance
in class DOFType
packet
- The buffer which contains the serialized form of the object. Must not be null.null
if the type is nullable.DOFMarshalException
- If there are errors in the data or the buffer. This is an exception to the rule that
non-RuntimeExceptions not be thrown from a constructor.public void marshal(DOFType.Context context, DOFPacket buffer) throws DOFMarshalException
DOFType
context
- The context for this set of related types.buffer
- The packet to write the type to.DOFMarshalException
- If the type is not supported.public java.util.List<DOFType> getSubtypes()
DOFType
getSubtypes
in class DOFType
public java.lang.String toString()
DOFType
public int hashCode()
DOFType
DOFType.equals(java.lang.Object)
returns true
.public boolean equals(java.lang.Object obj)
DOFType