public final class DOFInterfaceID extends java.lang.Object implements DOFValue, DOFImmutable, java.lang.Comparable<DOFInterfaceID>, java.io.Serializable
create(byte[])
methods.DOFInterface
,
DOFObject
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
DOFInterfaceID.Type
Implementation of
DOFType that matches DOFInterfaceID . |
Modifier and Type | Field and Description |
---|---|
static long |
MAX_IDENTIFIER
The max registry identifier.
|
static byte |
MAX_REGISTRY
The max registry value.
|
static byte |
TEST_REGISTRY
The "test" or "development" registry.
|
static DOFInterfaceID.Type |
TYPE
This is the default type for all interface identifiers.
|
static DOFInterfaceID |
WILDCARD
The wildcard DOFInterfaceID.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DOFInterfaceID other)
Compares two DOFInterfaceIDs byte-by-byte until the shortest length.
|
static DOFInterfaceID |
create(byte[] data)
Construct an interface identifier using a byte array.
|
static DOFInterfaceID |
create(byte[] data,
int offset)
Construct an interface identifier using a byte array, starting at an
offset into the array.
|
static DOFInterfaceID |
create(byte registry,
long identifier)
Construct an interface identifier by specifying a registry and an identifier.
|
static DOFInterfaceID |
create(DOFMarshalContext context,
java.lang.Object state,
DOFPacket packet)
Construct an interface identifier from serial form.
|
static DOFInterfaceID |
create(java.lang.String formatIID)
Construct an interface identifier using the standard format.
|
boolean |
equals(java.lang.Object obj)
Return whether two values are equal.
|
int |
getByteLength()
Get the length of the identifier, including the registry and length byte.
|
byte[] |
getBytes()
Get the interface identifier as a byte array.
|
DOFType |
getDOFType()
Gets the DOFType of an interface (the same as DOFType.IID).
|
long |
getIdentifier()
Get the InterfaceID identifier, which is unique to a registry.
|
byte |
getRegistry()
Get the identifier's registry number.
|
int |
hashCode()
Compute hash code.
|
void |
isCompatibleWith(DOFType type)
Verify that a value is compatible with the specified
DOFType . |
boolean |
isWildcard()
Return true if the interface identifier represents a wildcard.
|
void |
marshal(DOFType type,
DOFPacket packet)
Write the value of the IID as a DOFValue.
|
java.lang.String |
toStandardString()
Get a standard string representation of this DOFInterfaceID.
|
java.lang.String |
toString()
Get a string representation of this object.
|
public static final DOFInterfaceID.Type TYPE
public static final DOFInterfaceID WILDCARD
public static final byte TEST_REGISTRY
public static final byte MAX_REGISTRY
public static final long MAX_IDENTIFIER
public static DOFInterfaceID create(byte[] data)
data
- The byte array.public static DOFInterfaceID create(byte[] data, int offset)
data
- The byte array containing a marshaled interface id.offset
- Offset index into the array at which the interface identifier
data begins.public static DOFInterfaceID create(DOFMarshalContext context, java.lang.Object state, DOFPacket packet) throws DOFMarshalException
context
- The context of the unmarshalling to be performed.state
- The state in which the unmarshalling is done. This may affect the result.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 DOFInterfaceID create(byte registry, long identifier)
registry
- The registry number.identifier
- The identifier. On the wire, identifier's from 0-255 have a 1
byte length, 65535 have a a 2 byte length, 65536 and greater have a 4 byte length.public static DOFInterfaceID create(java.lang.String formatIID)
formatIID
- The interface identifier in standard format form.toStandardString()
public boolean isWildcard()
public long getIdentifier()
public byte getRegistry()
public byte[] getBytes()
public DOFType getDOFType()
getDOFType
in interface DOFValue
public int getByteLength()
public java.lang.String toStandardString()
create(String)
public void marshal(DOFType type, DOFPacket packet) throws DOFMarshalException, DOFErrorException
marshal
in interface DOFValue
type
- The type for compatibility checking.packet
- The packet to write the value to.DOFMarshalException
- Thrown if the value cannot be marshalled.DOFErrorException
- Thrown if there were type compatibility problems.public int hashCode()
public boolean equals(java.lang.Object obj)
DOFValue
public java.lang.String toString()
public int compareTo(DOFInterfaceID other)
compareTo
in interface java.lang.Comparable<DOFInterfaceID>
other
- The other DOFInterfaceID to compare against.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.