com.sas.entities
Class BaseEntity

com.sas.entities.BaseEntity
All Implemented Interfaces:
BaseEntityInterface, BaseEntityValueInterface, EntityKeyInterface, java.lang.Cloneable, java.rmi.Remote
Direct Known Subclasses:
ActionList, ActionSupportFilter, BaseAction, BaseCommand, CompositeDynamicAttributeCommand, Entity

public class BaseEntity
implements BaseEntityInterface, EntityKeyInterface, java.lang.Cloneable

BaseEntity is an entity object that is not a remote object. It is a simple entity object that contains methods for setting and getting attribute values. Unlike Entity, it does not create an AttributeGroup or AttributeDescriptors for its attributes.

See Also:
Entity

Constructor Summary
BaseEntity()
          Create a default entity.
 
Method Summary
 java.lang.Object clone()
          Create a new BaseEntity object using the BaseEntity's attributes.
 boolean containsAttributeNamed(java.lang.String attributeName)
          Test if the Entity contains an attribute of a specified name.
 boolean equals(BaseEntity p)
          Returns a boolean indicating whether the entities are "equal".
 boolean equals(java.lang.Object o)
          Returns a boolean indicating whether the entities are "equal".
 java.lang.Object getAttribute(java.lang.String attributeName)
          Get an attribute value from the Entity.
 java.lang.Object getAttribute(java.lang.String attributeName, java.lang.Object defaultValue)
          Get a value of an attribute from the Entity or return a default value if it does not exist.
 int getAttributeCount()
          Returns the number of attributes defined.
 java.util.Map getAttributes(java.util.Map query)
          Perform a bulk value get on the Entity.
 java.lang.String getEntityKey()
          Return this entity's key or GUID (Globally Unique Identifier).
 java.util.Map getPropertyDescriptors()
          Returns a map of PropertyDescriptors.
 java.lang.String getStringAttribute(java.lang.String attributeName, java.lang.String defaultValue)
          Get a string value of an attribute from the Entity.
 java.lang.String[] listAttributeNames()
          Return an array of the attribute names on the Entity.
 void removeAllAttributes()
          Remove all attributes from the Entity.
 void removeAttribute(java.lang.String attributeName)
          Remove an attribute from the Entity if the attribute is an instance-based attribute.
 void reset()
          Clear the underlying list, reset fields to default values and release references to other non-default objects held by this instance.
 boolean sameEntity(EntityKeyInterface entity)
          Test if this Entity's key equals the key of another Entity.
 void setAttribute(java.lang.String attributeName, java.lang.Object value)
          Set an attribute and its value in the Entity.
 void setAttributes(java.util.Map update)
          Perform a bulk attribute set on the Entity.
 void setEntityKey(java.lang.String guid)
          Assign this entity's key or GUID (Globally Unique Identifier).
 java.lang.String toString()
          Returns the string representation of the Entity.
 

Constructor Detail

BaseEntity

public BaseEntity()
Create a default entity. It has no attributes. The Entity is created with a unique GUID (Globally Unique Identifier) or entity key.

Method Detail

getEntityKey

public java.lang.String getEntityKey()
Return this entity's key or GUID (Globally Unique Identifier).

Specified by:
getEntityKey in interface EntityKeyInterface
Returns:
entity key
See Also:
setEntityKey(String guid)

setEntityKey

public void setEntityKey(java.lang.String guid)
Assign this entity's key or GUID (Globally Unique Identifier).

Specified by:
setEntityKey in interface EntityKeyInterface
Parameters:
guid - a unique entity key, also known as a Globally Unique Identifer (GUID)
Throws:
java.lang.IllegalStateException - Subclasses may throw an IllegalStateException if this entity already has a GUID, although this base class method does not.
See Also:
getEntityKey()

sameEntity

public boolean sameEntity(EntityKeyInterface entity)
Description copied from interface: EntityKeyInterface
Test if this Entity's key equals the key of another Entity.

Specified by:
sameEntity in interface EntityKeyInterface
Returns:
true if the other entity's key is the same as EntityKeyInterface.getEntityKey(). Return false if entity is null

removeAttribute

public void removeAttribute(java.lang.String attributeName)
Description copied from interface: BaseEntityInterface
Remove an attribute from the Entity if the attribute is an instance-based attribute. You cannot remove type-based attributes from entities. After removing an instance-based attribute, BaseEntityInterface.containsAttributeNamed(String) will return false and BaseEntityValueInterface.getAttribute(String) will throw a NoSuchElementException

Specified by:
removeAttribute in interface BaseEntityInterface
Parameters:
attributeName - the name of the attribute

removeAllAttributes

public void removeAllAttributes()
Description copied from interface: BaseEntityInterface
Remove all attributes from the Entity.

Specified by:
removeAllAttributes in interface BaseEntityInterface

reset

public void reset()
Clear the underlying list, reset fields to default values and release references to other non-default objects held by this instance.


getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName)
                              throws java.util.NoSuchElementException
Description copied from interface: BaseEntityValueInterface
Get an attribute value from the Entity.

Specified by:
getAttribute in interface BaseEntityValueInterface
Parameters:
attributeName - the name of the value
Returns:
the object associated with the attributeName
Throws:
java.util.NoSuchElementException - if there is no such value in the Entity (this is necessary to distinguish between no such attributeName and a value of null)

getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName,
                                     java.lang.Object defaultValue)
Description copied from interface: BaseEntityInterface
Get a value of an attribute from the Entity or return a default value if it does not exist.

Specified by:
getAttribute in interface BaseEntityInterface
Parameters:
attributeName - the name of the value
defaultValue - a default value to return if the named attribute, attributeName does not exist in the Entity
Returns:
the object associated with the attributeName, or the defaultValue if the Entity does not contain an element for the specified attributeName

getAttributes

public java.util.Map getAttributes(java.util.Map query)
Description copied from interface: BaseEntityInterface
Perform a bulk value get on the Entity. This gets each attribute named in the query map.

Specified by:
getAttributes in interface BaseEntityInterface
Parameters:
query - a set of name/value pairs. This object is updated if the operation is performed locally.
Returns:
a map with names from the query and the values taken from the Entity
See Also:
BaseEntityInterface.setAttributes(Map update)

getStringAttribute

public java.lang.String getStringAttribute(java.lang.String attributeName,
                                           java.lang.String defaultValue)
Description copied from interface: BaseEntityInterface
Get a string value of an attribute from the Entity. This method is an alias for BaseEntityValueInterface.getAttribute(String).

Specified by:
getStringAttribute in interface BaseEntityInterface
Parameters:
attributeName - the name of the value
defaultValue - a default value to return if the named attribute, attributeName does not exist in the Entity
Returns:
the object associated with the attributeName, or the defaultValue if the Entity does not contain an element for the specified attributeName.

setAttribute

public void setAttribute(java.lang.String attributeName,
                         java.lang.Object value)
                  throws AttributeSetException
Description copied from interface: BaseEntityValueInterface
Set an attribute and its value in the Entity.

Specified by:
setAttribute in interface BaseEntityValueInterface
Parameters:
attributeName - the name of the attribute
value - the value to associate with the attribute. Attribute values may be null if permitted by the AttributeType associated with the AttributeDescriptor
Throws:
AttributeSetException - if the AttributeType of the parameter, value, is not compatible with a previous setting of the attribute OR the attribute corresponding to the parameter, attributeName, has been designated as non-modifiable
See Also:
AttributeTypeInterface

setAttributes

public void setAttributes(java.util.Map update)
                   throws AttributeSetException
Description copied from interface: BaseEntityInterface
Perform a bulk attribute set on the Entity. This sets each attribute named in the update map.

Specified by:
setAttributes in interface BaseEntityInterface
Parameters:
update - a set of name/value pairs to assign to the attributes of the Entity
Throws:
AttributeSetException - if the AttributeType of a parameter is not compatible with a previous setting of the attribute OR an attribute has been designated as non-modifiable
See Also:
BaseEntityInterface.getAttributes(Map query)

getPropertyDescriptors

public java.util.Map getPropertyDescriptors()
Returns a map of PropertyDescriptors.

Returns:
map of PropertyDescriptors

containsAttributeNamed

public boolean containsAttributeNamed(java.lang.String attributeName)
Description copied from interface: BaseEntityInterface
Test if the Entity contains an attribute of a specified name.

Specified by:
containsAttributeNamed in interface BaseEntityInterface
Parameters:
attributeName - the attribute name to test
Returns:
true if this entity contains an attribute named name

getAttributeCount

public int getAttributeCount()
Returns the number of attributes defined.

Returns:
number of attributes

listAttributeNames

public java.lang.String[] listAttributeNames()
Description copied from interface: BaseEntityInterface
Return an array of the attribute names on the Entity.

Specified by:
listAttributeNames in interface BaseEntityInterface

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a new BaseEntity object using the BaseEntity's attributes.

Overrides:
clone in class java.lang.Object
Returns:
new BaseEntity that will have the same attributes as the BaseEntity
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(BaseEntity p)
Returns a boolean indicating whether the entities are "equal". The entities are considered equal if they have the same number of attributes and all of the attribute values are the same.

Parameters:
p - instance of BaseEntity to compare
Returns:
true if the entities have the same attributes, false otherwise

equals

public boolean equals(java.lang.Object o)
Returns a boolean indicating whether the entities are "equal". The entities are considered equal if the input parameter is an instance of BaseEntity, they have the same number of attributes, and all of the attribute values are the same.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare
Returns:
true if the entities have the same attributes, false otherwise

toString

public java.lang.String toString()
Returns the string representation of the Entity. The string representation is a concatentation of the class name, identityHashCode, and the string representation of the map that holds the values of the instance-based attributes.

Overrides:
toString in class java.lang.Object
Returns:
string representation of the Entity



Copyright © 2009 SAS Institute Inc. All Rights Reserved.