public static final class DOFType.Typedef extends DOFType implements DOFType.Context.Resolver
DOFType.isDefined()
will return false
. At some point
the defineAs(org.opendof.core.oal.DOFType)
method must be called, and at that point the type becomes fully
defined. However, after the defineAs(org.opendof.core.oal.DOFType)
method call the type begins to appear
just like the referenced type.DOFType.Context, DOFType.Nullable, DOFType.Typedef
Constructor and Description |
---|
Typedef()
Construct a typedef that can be used for a forward reference.
|
Typedef(DOFType type)
Construct a typedef that is an alias for another existing type.
|
Modifier and Type | Method and Description |
---|---|
void |
defineAs(DOFType type)
Finalize a forward reference.
|
boolean |
equals(java.lang.Object obj)
Typedefs are equal only if their references are equal.
|
int |
getEncoding()
Get the string encoding for the type.
|
DOFValue |
getInstance(DOFPacket packet)
|
int |
getMaxLength()
Get the maximum length of the type.
|
int |
getMinLength()
Get the minimum length of the type.
|
java.util.List<DOFType> |
getSubtypes()
Return a list of subtypes associated with this type.
|
short |
getTypeID()
Get the type identifier of this type.
|
int |
hashCode()
Return a hash code for the type.
|
boolean |
isDefined()
Return whether of not the type is fully defined.
|
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, isCompatibleWith, marshal
public Typedef()
defineAs(org.opendof.core.oal.DOFType)
method
must be called.public Typedef(DOFType type)
type
- The type that the new type is equivalent to.public void defineAs(DOFType type)
defineAs
in interface DOFType.Context.Resolver
type
- The type of the forward reference. This must not be null or another forward reference. It
must also not be nullable.public java.util.List<DOFType> getSubtypes()
DOFType
getSubtypes
in class DOFType
public boolean isDefined()
DOFType
DOFType.Typedef
, for example).
In this case the constructed type must return false
until it is fully defined.
While in the partially defined state the results of other method calls on the type may return invalid
results or throw exceptions. Care must be taken whenever working with a type that may be partially defined.
Further, certain uses of types may be prohibited if the type is not yet defined. These cases are mentioned
in the documentation as requiring fully defined types.
Once a type is fully defined it becomes immutable, meaning that it can never become partially defined again.public int getMaxLength()
DOFType
getMaxLength
in class DOFType
public int getMinLength()
DOFType
getMinLength
in class DOFType
public short getTypeID()
DOFType
public int getEncoding()
DOFType
getEncoding
in class DOFType
DOFType.getCharSet(int)
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 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 java.lang.String toString()
DOFType
public boolean equals(java.lang.Object obj)
public int hashCode()
DOFType
DOFType.equals(java.lang.Object)
returns true
.