public class DOFObjectID extends java.lang.Object implements DOFValue, java.lang.Comparable<DOFObjectID>, DOFImmutable, java.io.Serializable
create(byte[])
methods.Modifier and Type | Class and Description |
---|---|
static class |
DOFObjectID.Attribute
The Attribute class is used to add attributes to a DOFObjectID.
|
static class |
DOFObjectID.Authentication
The Authentication class is a subclass of DOFObjectID which is used to designate the DOFObjectID as an Authentication type.
|
static class |
DOFObjectID.Domain
The Domain class is a subclass of DOFObjectID which is used to designate the DOFObjectID as a Domain type.
|
static class |
DOFObjectID.Source
The Source class is a subclass of DOFObjectID which is used to designate the DOFObjectID as a Source type.
|
static class |
DOFObjectID.Type
|
Modifier and Type | Field and Description |
---|---|
static DOFObjectID |
ALL_OBJECTS
The broadcast (wildcard) object identifier.
|
static DOFObjectID |
BROADCAST
The broadcast (wildcard) object identifier.
|
static int |
CLASS_AS
The Authentication Server (AS) assigned object identifier class.
|
static int |
CLASS_AWS_RESOURCE_ID
The AWS Resource ID object identifier class.
|
static int |
CLASS_BROADCAST
The Broadcast object identifier class.
|
static int |
CLASS_DOMAIN
The Domain object identifier class.
|
static int |
CLASS_EMAIL
The Email object identifier class.
|
static int |
CLASS_EUI48
The EUI-48 object identifier class.
|
static int |
CLASS_EUI64
The EUI-64 object identifier class.
|
static int |
CLASS_GUID
The GUID object identifier class.
|
static int |
CLASS_HIDLC
The HiDLC object identifier class.
|
static int |
CLASS_IPV4
The IPv4 Address object identifier class.
|
static int |
CLASS_IPV6
The IPv6 Address object identifier class.
|
static int |
CLASS_LODLC
The LoDLC object identifier class.
|
static int |
CLASS_MAC
The Mac Address object identifier class.
|
static int |
CLASS_ODP
The OpenDOF Project assigned object identifier class.
|
static int |
CLASS_SMART_ENERGY_SYSTEM_SERIAL_NUMBER
The Smart Energy System Serial Number object identifier class.
|
static DOFObjectID.Domain |
DOMAIN_BROADCAST
The broadcast domain object identifier.
|
static DOFObjectID.Type |
TYPE
This is the default type for all object identifiers.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DOFObjectID objectID)
Compare against another DOFObjectID.
|
static DOFObjectID |
create(byte[] data)
Create an DOFObjectID from a byte[] of data.
|
static DOFObjectID |
create(byte[] data,
int offset)
Create an DOFObjectID from a byte[] of data at an offset.
|
static DOFObjectID |
create(DOFMarshalContext context,
java.lang.Object state,
DOFPacket packet)
Create a DOFObjectID from serial form.
|
static DOFObjectID |
create(DOFObjectID objectID,
DOFObjectID.Attribute... attributes)
Create a DOFObjectID, with a variable number of attributes, using an object identifier and zero or more attributes.
|
static DOFObjectID |
create(DOFObjectID objectID,
java.util.List<DOFObjectID.Attribute> attributes)
Create a DOFObjectID with a list of attributes, using an object identifier and attributes.
|
static DOFObjectID |
create(int idClass,
byte[] data,
DOFObjectID.Attribute... attributes)
Create a DOFObjectID given its class, byte data and optionally attributes.
|
static DOFObjectID |
create(int idClass,
byte[] data,
java.util.List<DOFObjectID.Attribute> attributes)
Create a DOFObjectID given its class, byte data and attributes.
|
static DOFObjectID |
create(java.lang.String format)
Constructs a DOFObjectID from a String in the standard string format defined by the OpenDOF Technical Committee.
|
boolean |
equals(java.lang.Object obj)
Return whether two values are equal.
|
boolean |
equalsIgnoreAttributes(DOFObjectID objectID)
Compare against another DOFObjectID.
|
DOFObjectID.Attribute |
getAttribute(byte type)
Get the specified attribute.
|
java.util.List<DOFObjectID.Attribute> |
getAttributes()
Get this identifier's list of attributes.
|
DOFObjectID |
getBase()
Get this object identifier without any attributes.
|
byte[] |
getBytes()
Get the binary form of this DOFObjectID.
|
byte[] |
getData()
Get the data associated with the base ID (the ID without attributes).
|
java.lang.String |
getDataString()
Return a string format of the base (the ID without attributes) data of the object identifier.
|
DOFType |
getDOFType()
Return the
DOFType of the value. |
int |
getIDClass()
Get the class of this DOFObjectID.
|
boolean |
hasAttribute(byte type)
Check if this DOFObjectID has a specific attribute type.
|
boolean |
hasAttributes()
Check if this DOFObjectID has any attributes.
|
int |
hashCode()
Return a hash code for the object.
|
boolean |
isBroadcast()
Determine if this DOFObjectID is the broadcast oid without attributes.
|
void |
isCompatibleWith(DOFType type)
Verify that a value is compatible with the specified
DOFType . |
boolean |
isMulticast()
Determine if this DOFObjectID is a multicast oid (broadcast with the Group attribute).
|
boolean |
isUnicast()
Determine if this DOFObjectID is unicast, meaning it doesn't use CLASS_BROADCAST.
|
void |
marshal(DOFType type,
DOFPacket packet)
Write a value to a
DOFPacket . |
boolean |
matchesAtLeast(DOFObjectID objectID)
Compare against another DOFObjectID.
|
java.lang.String |
toStandardString()
Get the identifier in a standardized string format.
|
java.lang.String |
toString()
Get the identifier in a standardized string format.
|
public static final DOFObjectID.Type TYPE
public static final DOFObjectID ALL_OBJECTS
DOFSystem.beginProvide(org.opendof.core.oal.DOFInterface, org.opendof.core.oal.DOFObject.Provider)
, then you
will see this object identifier in DOFObject.Provider
callbacks as the
DOFOperation.Provide
's object identifier.
However, do not create a DOFObject with this object identifier.public static final DOFObjectID BROADCAST
public static final DOFObjectID.Domain DOMAIN_BROADCAST
public static final int CLASS_BROADCAST
public static final int CLASS_MAC
public static final int CLASS_EMAIL
To use the same e-mail address to create multiple OIDs, a unique suffix can be added, but it must begin with an ASCII colon and contain only ASCII characters.
public static final int CLASS_IPV4
public static final int CLASS_IPV6
public static final int CLASS_DOMAIN
If necessary a unique suffix can be added, but it must begin with an ASCII colon and contain only ASCII characters.
public static final int CLASS_LODLC
public static final int CLASS_AS
public static final int CLASS_EUI48
public static final int CLASS_EUI64
public static final int CLASS_HIDLC
public static final int CLASS_SMART_ENERGY_SYSTEM_SERIAL_NUMBER
public static final int CLASS_AWS_RESOURCE_ID
public static final int CLASS_ODP
public static final int CLASS_GUID
public int getIDClass()
public byte[] getData()
public java.lang.String getDataString()
public DOFObjectID getBase()
public boolean hasAttributes()
public boolean hasAttribute(byte type)
type
- Attribute type.public DOFObjectID.Attribute getAttribute(byte type)
type
- Attribute type.public java.util.List<DOFObjectID.Attribute> getAttributes()
DOFObjectID.Attribute
public byte[] getBytes()
public boolean equalsIgnoreAttributes(DOFObjectID objectID)
objectID
- The object to compare against. This must not be null.public boolean matchesAtLeast(DOFObjectID objectID)
objectID
- The object to compare against. This must not be null.public boolean equals(java.lang.Object obj)
DOFValue
public int hashCode()
DOFValue
DOFValue.equals(java.lang.Object)
returns true
.public int compareTo(DOFObjectID objectID)
compareTo
in interface java.lang.Comparable<DOFObjectID>
objectID
- The object to compare against. If this is null, will return 1;public java.lang.String toString()
public java.lang.String toStandardString()
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 boolean isBroadcast()
public boolean isMulticast()
public boolean isUnicast()
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 static DOFObjectID create(byte[] data)
data
- The binary data to create the identifier. There may be additional data in the buffer after the object
identifier that is ignored. This must not be null.public static DOFObjectID create(byte[] data, int offset)
data
- The data to create the identifier from. There may be addition data in the array but after the
object identifier that will be ignored. This must not be null.offset
- The offset into the data where the identifier begins. This must not be negative.public static DOFObjectID create(int idClass, byte[] data, java.util.List<DOFObjectID.Attribute> attributes)
idClass
- The class of the identifier. This must be within the valid range.data
- The identifier. This will be stored in the object identifier without parsing. This must not
be null. The length must be valid (<= MAX_ID_LENGTH).attributes
- The attributes to be added to the DOFObjectID. List must only contain one attribute of each type.public static DOFObjectID create(int idClass, byte[] data, DOFObjectID.Attribute... attributes)
idClass
- The class of the identifier. This must be within the valid range.data
- The identifier. This will be stored in the object identifier without parsing. This must not
be null. The length must be valid (<= MAX_ID_LENGTH).attributes
- The attributes to be added to the DOFObjectID. List must only contain one attribute of each type.
May be omitted if no attributes are desired.public static DOFObjectID create(java.lang.String format)
DOFObjectID myOID = DOFObjectID.create("[128:{050234706bb1453289d9461055cef60c}]");The following is an example of how to create a domain class DOFObjectID:
DOFObjectID myOID = DOFObjectID.create("[6:provider.opendof.org]");The following is an example of how to create an email class DOFObjectID:
DOFObjectID myOID = DOFObjectID.create("[3:provider@opendof.org]");Attributes can be added to the standard string format to create an OID with attributes. To format an attribute in the standard string format, you must know its attribute identifier. Attribute identifiers, like OID classes, must be registered with the OpenDOF Project. The following rules apply to the standard string format for attributes:
DOFObjectID myOID = DOFObjectID.create("[3:provider@opendof.org(0:[3:service@opendof.org]|2:[3:group@opendof.org])]");An alternative to using this method to create the entire OID with its attributes is to use this method to create the base OID, use one of the
DOFObjectID.Attribute.create(byte, byte[])
methods to create the attributes, and then pass the base OID and attributes to the
create(DOFObjectID, Attribute...)
method.
format
- The standard format string for the object identifier.public static DOFObjectID create(DOFObjectID objectID, DOFObjectID.Attribute... attributes)
objectID
- The object identifier to add the attribute to. This must not be null.attributes
- The attributes for the identifier. List must only contain one attribute of each type.
Passing in no attributes results in an object identifier that is no different than the input. An object ID can have a maximum of 128 attributes.public static DOFObjectID create(DOFObjectID objectID, java.util.List<DOFObjectID.Attribute> attributes)
objectID
- The object identifier to add the attributes to. If the oid already has attributes the
attributes are added to the existing attributes. This must not be null.attributes
- The attributes for the identifier. List must only contain one attribute of each type.
An object ID can have a maximum of 128 attributes. Null may be passed, in which case the new object ID is the same as given objectID.public static DOFObjectID 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.Marshallable