org.eclipse.higgins.idas.api
Interface IAttribute

All Superinterfaces:
IHasAttributes
All Known Subinterfaces:
ISingleValuedAttribute

public interface IAttribute
extends IHasAttributes

As defined at (TODO (Doc): add reference), This interface represents an attribute of an Entity.

An attribute is a typed set of values. When the attribute's model dictates that it is single-valued isSingleValued() then this object may be cast to an ISingleValuedAttribute

This extends IHasAttributes so that metadata about the attribute may be presented as attributes on this attribute.


Method Summary
 IComplexAttrValue addComplexValue(URI dataType)
          Creates a new complex value for this attribute.
 ISimpleAttrValue addSimpleValue(URI dataType, Object data)
          Creates a new simple value for this attribute.
 IAttributeValue addValue(IAttributeValue copyFrom)
          Creates a new value for this attribute by copying the passed IAttributeValue Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.
 IAttributeValue addValue(URI dataType)
          Creates a new value for this attribute.
 boolean equals(IAttribute attr)
          Returns true if the passed attribute is equal to this one.
 URI getAttrID()
          Returns the attribute ID of this attribute as a URI.
 IAttributeModel getModel()
          Returns a model of this type of attribute as it defined in the context's schema.
 Iterator getValues()
          Returns all values for this attribute.
 Iterator getValues(IExtension[] extensions)
          Returns all values for this attribute.
 boolean isSingleValued()
          Convenience method which returns true when the model for this attribute dictates that only a single value may exist.
 void remove()
          Removes this attribute from its container Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.
 
Methods inherited from interface org.eclipse.higgins.idas.api.IHasAttributes
addAttribute, addAttribute, equals, getAttribute, getAttributes, getSingleValuedAttribute, removeAttribute, removeAttributeValue, removeAttributeValue
 

Method Detail

getAttrID

public URI getAttrID()
              throws IdASException
Returns the attribute ID of this attribute as a URI.

From this URI, a consumer should be able to derive some kind of human-readable identifier (such as "age", "title", "employeeNumber", etc.).

This attribute ID is used to distinguish this attribute from other attributes within a collection of attributes. Note that IModel.getType() will return the same URI that this method returns. The reason we use the term "AttrID" here is because from an attribute instance point of view, this is the identifier which distinguishes this attribute from others. The reason it is referred to as a type from the attribute's model point of view is because it's tied to the capabilities of the attribute.

Throws:
IdASException

getValues

public Iterator getValues()
                   throws IdASException
Returns all values for this attribute.

Returns:
an Iterator of IAttributeValues
Throws:
IdASException

getValues

public Iterator getValues(IExtension[] extensions)
                   throws IdASException
Returns all values for this attribute.

Parameters:
extensions - may be null. One or more extensions valid for this operation.
Returns:
an Iterator of IAttributeValues
Throws:
IdASException

addValue

public IAttributeValue addValue(URI dataType)
                         throws IdASException,
                                InvalidTypeException
Creates a new value for this attribute. This method is useful when the caller doesn't know whether the URI specified in the dataType param will build an ITypedValue or IComplexAttrValue. Otherwise callers will typically call addSimpleValue(URI, Object) or addComplexValue(URI) This call is typically followed by a call to IAttributeValue.isSimple() on the returned IAttributeValue. When found to be an ISimpleAttrValue, ITypedValue.setData(Object) is typically called on the returned IAttributeValue (cast as an ISimpleAttrValue). When found to be an IComplexAttrValue, one typically calls IHasAttributes.addAttribute(URI) on the returned IAttributeValue (cast as an IComplexAttrValue or IHasAttributes). Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.

Parameters:
dataType - The URI specifying the data type of Value being created
Throws:
{@link - IdASException}
{@link - InvalidTypeException} when the type is invalid
IdASException
InvalidTypeException

addValue

public IAttributeValue addValue(IAttributeValue copyFrom)
                         throws IdASException
Creates a new value for this attribute by copying the passed IAttributeValue Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.

Parameters:
copyFrom - The IAttributeValue from which data is copied to create the returned IAttributeValue
Throws:
{@link - IdASException}
IdASException

addSimpleValue

public ISimpleAttrValue addSimpleValue(URI dataType,
                                       Object data)
                                throws IdASException,
                                       InvalidTypeException
Creates a new simple value for this attribute. Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.

Parameters:
dataType - The URI specifying the type of Value being created
data - The data of the attribute value
Throws:
{@link - IdASException}
{@link - InvalidTypeException} when the type is invalid
IdASException
InvalidTypeException

addComplexValue

public IComplexAttrValue addComplexValue(URI dataType)
                                  throws IdASException,
                                         InvalidTypeException
Creates a new complex value for this attribute. This call is typically followed by one or more calls to IHasAttributes.addAttribute(java.net.URI) on the returned IComplexAttrValue. Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.

Parameters:
dataType - The URI specifying the type of complex value being created
Throws:
{@link - IdASException}
{@link - InvalidTypeException} when the type is invalid
IdASException
InvalidTypeException

remove

public void remove()
            throws IdASException
Removes this attribute from its container Note: This operation is only applied to any backing data store after IContext.applyUpdates() is called.

Throws:
{@link - IdASException}
IdASException

getModel

public IAttributeModel getModel()
                         throws IdASException
Returns a model of this type of attribute as it defined in the context's schema. The returned model could be used to analyze the attribute's type and discover what its value model is.

Returns:
a model of this type of attribute
Throws:
IdASException

isSingleValued

public boolean isSingleValued()
                       throws IdASException
Convenience method which returns true when the model for this attribute dictates that only a single value may exist. This is analogous to calling
 (myAttribute.getModel().getMaxCardinality() == 1) 
 

Returns:
boolean. When true, this object may be cast to an ISingleValuedAttribute
Throws:
IdASException

equals

public boolean equals(IAttribute attr)
               throws IdASException
Returns true if the passed attribute is equal to this one. The Attribute id's are compared, the metadata sets are compared, and all values are compared for equality

Parameters:
attr - the attribute to be compared to this one
Returns:
true if the passed attrribute is equal to this attribute.
Throws:
IdASException