DOFValue InterfaceOpenDOF Object Access Library
This interface defines common functionality for all values that can be used by the OAL.

Namespace: org.opendof.core.oal
Assembly: dof-oal (in dof-oal.dll) Version: 7.0.1.2
Syntax

C#
public interface DOFValue : DOFImmutable

The DOFValue type exposes the following members.

Methods

  NameDescription
Public methodEquals
Return whether two values are equal.
Public methodgetDOFType
Return the 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(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.

Public methodGetHashCode
Return a hash code for the object.
Public methodisCompatibleWith
Verify that a value is compatible with the specified 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 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.
Public methodmarshal
Write a value to a 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 .

Public methodToString
Returns a representation of the value.
Top
Remarks

This interface defines common functionality for all values that can be used by the OAL. Values are used in a variety of different calls, for example DOFObject.set(Property, DOFValue, int) , DOFObject.invoke(Method, System.Collections.Generic.IList<E>, int) , Provider.set(Provide, Set, Property, DOFValue) , and Provider.invoke(Provide, Invoke, Method, System.Collections.Generic.IList<E>) .

DOFValue provides a common representation for all values, but itself is not very useful. In order to create or use a value the implementor must know the specific class being used, and must create that class or cast a given value to that class.

Each implementation of DOFValue provides a corresponding implementation of DOFType . The two implementations are related to one other directly through the getDOFType() and DOFType.getInstance(DOFPacket) calls.

See Also

Reference

DOFValue