public class DOFUInt32 extends java.lang.Object implements DOFValue
DOFValue
that supports 32-bit unsigned integers.DOFUInt32.Type
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
DOFUInt32.Type
|
Modifier and Type | Field and Description |
---|---|
static DOFUInt32.Type |
TYPE
This is the default type for all 32-bit unsigned integer values.
|
Constructor and Description |
---|
DOFUInt32(DOFUInt32.Type pattern,
DOFPacket packet)
Create a DOFUInt32 instance from serial form.
|
DOFUInt32(long data)
Create a new 32-bit unsigned integer given data.
|
Modifier and Type | Method and Description |
---|---|
static DOFUInt32[] |
array(java.util.List<java.lang.Long> data)
Convert a list of language types into an array of OAL values.
|
static DOFUInt32[] |
array(long[] data)
Convert an array of language types into an array of OAL values.
|
boolean |
equals(java.lang.Object object)
Return whether two values are equal.
|
long |
get()
Return the data associated with a 32-bit unsigned integer.
|
DOFType |
getDOFType()
Return the
DOFType of the value. |
int |
hashCode()
Return a hash code for the object.
|
void |
isCompatibleWith(DOFType type)
Verify that a value is compatible with the specified
DOFType . |
void |
marshal(DOFType type,
DOFPacket packet)
Write a value to a
DOFPacket . |
java.lang.String |
toString()
Returns a representation of the value.
|
public static final DOFUInt32.Type TYPE
public DOFUInt32(long data)
data
- The data to encapsulate.public DOFUInt32(DOFUInt32.Type pattern, DOFPacket packet) throws DOFMarshalException
pattern
- The type of the variable. Must not be null.packet
- The buffer which contains the serialized form of the object. Must not be null.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.Marshallable
public static DOFUInt32[] array(long[] data)
data
- The data to encapsulate. Must not be null.getDOFType()
public static DOFUInt32[] array(java.util.List<java.lang.Long> data)
data
- The data to encapsulate. Must not be null.public long get()
public java.lang.String toString()
DOFValue
public DOFType getDOFType()
DOFValue
DOFType
of the value.
The type returned must be the one that is related directly
to this value implementation. In other words, calling DOFType.getInstance(org.opendof.core.oal.DOFPacket)
on that type
must return the same class as this value.
Note that queries made against the type of the value do not represent the specific details
of the value itself, rather they represent the capabilities of the value. For example, asking
the type what a type's maximum length is by using DOFType.getMaxLength()
does not indicate
anything about the actual length of a given value - even if that value returned the type using this call.
This allows a common DOFType
implementation to be associated with many different values.getDOFType
in interface DOFValue
public void isCompatibleWith(DOFType type) throws DOFErrorException
DOFValue
DOFType
.
Compatibility is less strict of a requirement that saying that the type of the value is
equal to the given type. Instead, compatibility is verified by introspecting the value
and the type, and checking whether or not they are compatible.
A simple example of this is a string value that has a length of 25 characters. The type
associated with the value (as returned by DOFValue.getDOFType()
) may have a maximum length of
50 characters. The type passed to this routine may have a maximum length of 30 characters
as indicated by DOFType.getMaxLength()
. In this case the value would be compatible,
even though the value's type is not compatible with the passed type as the maximum lengths
are not compatible. It is the actual data length (25 characters) that matters for this
routine.
The following must always succeed without an exception:
value.CompatibleWith( value.getDOFType() )
In other words, a value must always be compatible with its own type.isCompatibleWith
in interface DOFValue
type
- The type to compare against. The type must be reflected in order
to determine equivalence, although equality of the argument with the type of the value
ensures compatibility.DOFErrorException
- The value is not compatible.public void marshal(DOFType type, DOFPacket packet) throws DOFMarshalException, DOFErrorException
DOFValue
DOFPacket
.
This is an advanced routine and requires knowledge of the DOF Protocol Specification
in order to ensure that the value written to the buffer follows the specification requirements for
the value's type. Note that even "custom" types are built using DOF core types, and so the
buffered format for all values is determined by the specification.
NOTE: Values are written from back to front. In other words, the first item written to the packet
will be the last item in the packet.
Finally, implements must ensure that the value (data) cannot change during this call.
This means that unless the implementation
is immutable it should lock itself for the duration of this call. Once this call is
complete then the value may be changed without affecting the value written to the packet.
Note that the library has likely already done a compatibility check between the value and the
type, and so the check should not be made again (for performance reasons). However, in the case
that the check has not been done, it is possible that this method will encounter various
failures due to type casting. These should be caught and returned as a DOFErrorException
.marshal
in interface DOFValue
type
- The type that must be written. This type determines the wire formatting of the value.packet
- The destination packet.DOFMarshalException
- The value cannot be written.DOFErrorException
- There were problems between the type and the value.public boolean equals(java.lang.Object object)
DOFValue
public int hashCode()
DOFValue
DOFValue.equals(java.lang.Object)
returns true
.