org.openadaptor.dataobjects
Interface DOType

All Known Subinterfaces:
DOCollection, DOEnumeration
All Known Implementing Classes:
DDOType, DOBuilder.DDOType, FixedDOType, MOAlias, MOAtomic, MOClass, MOCollection, MOEnumeration, MOStructure, MOType, SDOType

public interface DOType

The DOType interface defines methods for describing the type of a DataObject. A DOType instance contains a name (String) and collection of attributes (DOAttribute). A DOType can inherit from a parent DOType instance, in which case it contains all the attributes of its parent DOType. Duplicate attribute names are not permitted. Note that when the type of an attribute is another DataObject (a "nested" DataObject) then the attribute is implicitly an Array of those DataObjects, even if only one will be used.
A DOType instance can also represent a "primitive" data type. The supported primitive types are: String, 32 bit and 64 bit Integer, Float, Double and "Opaque" (bytestream). Future types will include Date, Time, DateTime and "Infinite" precision integers and floating point numbers. Primitive types can have no attributes.

Version:
1.0
Author:
Tim Bissell

Method Summary
 boolean equals(DOType other)
          Returns true if other and the receiver are structurally equal.
 boolean equals(DOType other, java.util.Hashtable checkedTypes)
          Returns true if other and the receiver are structurally equal.
 DOAttribute getAttribute(java.lang.String name)
          Returns the attribute named name, or null if it is not defined.
 int getAttributeCount()
          Returns the number of attributes defined in the receiver.
 java.lang.String[] getAttributeNames()
          Returns array of names of all the attributes defined in this type.
 DOAttribute[] getAttributes()
          Returns all the attributes defined in the receiver.
 java.lang.String getName()
          Returns the type name.
 long getVersion()
          Returns the version of the type.
 boolean isCollection()
          Returns true if this DOType acts as a collection
 boolean isEnumeration()
          Returns true if this DOType acts as an enumeration
 boolean isPrimitive()
          Returns true if the receiver is a primitive type.
 

Method Detail

getName

java.lang.String getName()
Returns the type name.

Returns:
String containing type name.

isPrimitive

boolean isPrimitive()
Returns true if the receiver is a primitive type. Primitive types are: Int32 etc.


isCollection

boolean isCollection()
Returns true if this DOType acts as a collection


isEnumeration

boolean isEnumeration()
Returns true if this DOType acts as an enumeration


getVersion

long getVersion()
Returns the version of the type.


equals

boolean equals(DOType other)
Returns true if other and the receiver are structurally equal. This will usually call equals(other, new Hashtable())<> to implement a full recursive comparison.

Parameters:
other - the DOType to be compared
Returns:
true if other and receiver are Structurally equal.

equals

boolean equals(DOType other,
               java.util.Hashtable checkedTypes)
Returns true if other and the receiver are structurally equal. This method should does a recursive comparison of this and other. It should not compare the types of attributes whose type names match one of the keys in checkedTypes. In addition, it should add its own type name as a key to checkedTypes - before it checks any attributes - to signify that it does not need to be checked again. This is because we allow recursive nested types; e.g. type X containing an attribute of type X, or X containing Y containing X, and we need to avoid endless loops in type comparison operations. Note this method is protected so it cannot be misused outside the dataobjects package.

Parameters:
other - the DOType to be compared
checkedTypes - a table of names of types that have already been checked.
Returns:
true if other and receiver are Structurally equal.

getAttributeCount

int getAttributeCount()
Returns the number of attributes defined in the receiver.


getAttributes

DOAttribute[] getAttributes()
Returns all the attributes defined in the receiver. Note that this a copy of the array of attributes; you cannot replace an attribute in the DOType by replacing a DOAttribute in the array that was returned.

Returns:
An array of DOAttributes.
See Also:
DOAttribute

getAttributeNames

java.lang.String[] getAttributeNames()
Returns array of names of all the attributes defined in this type. The ordering of the names is not significant.

Returns:
Array of String containing attribute names.

getAttribute

DOAttribute getAttribute(java.lang.String name)
                         throws InvalidParameterException
Returns the attribute named name, or null if it is not defined.

Parameters:
name - attribute name.
Returns:
a DOAttribute.
Throws:
InvalidParameterException - If name is not an attribute name in the type.
See Also:
DOAttribute