Portlet API 2

org.apache.jetspeed.portlet
Interface DynamicData


public interface DynamicData

The DynamicData is a collection of attributes (name-value pairs) that the portlet can use to tempoarily or persistently store information. Dynamic data can be attached from a various objects: the request, the session, the configuration.

Actually, we want to put this up for discussion. Copying the Servlet API, the request and the session already have attribute manipulation. However, to introduce named section of attributes for configuration and personalized data, the dynamic data object was created which turned to be quite a good fit for request and session. It adds a uniform interface to attribute manipulation, plus it provides functionality for multi-value attributes an en-bloc copying.

The question is whether the similarity to the Servlet API or consistent APIs within the Portlet API has higher priority.


Method Summary
 void addAllFrom(DynamicData aData)
          Adds all attributes from the given data to this data.
 void addAttribute(String name, Object value)
          Adds the given attribute.
 Object getAttribute(String name)
          Returns the value of the attribute with the given name.
 Enumeration getAttributeNames()
          Returns an enumeration of all available attributes names.
 Vector getAttributes(String name)
          Returns a vector of attribute values for the given name.
 void removeAll()
          Removes all attributes.
 void removeAttribute(String name)
          Removes the attribute with the given name.
 void removeAttributes(String name)
          Removes all attributes with the given name.
 void setAttribute(String name, Object value)
          Sets the attribute with the given name and value.
 void setAttributes(String name, Vector values)
          Sets a vector of attributes with the given name and values.
 

Method Detail

setAttribute

public void setAttribute(String name,
                         Object value)
                  throws AccessDeniedException
Sets the attribute with the given name and value. If one or more attributes with the given name already exist, they will be replaced by the given attribute.
Parameters:
name - the attribute name
value - the attribute value
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

setAttributes

public void setAttributes(String name,
                          Vector values)
                   throws AccessDeniedException
Sets a vector of attributes with the given name and values. The order of attribute values within the identical attribute name space is preserved.

If one ore more attributes with the given name already exist, they will be replaced with the given vector of attributes.

Parameters:
aName - the attribute name
values - a vector of attribute values
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

addAttribute

public void addAttribute(String name,
                         Object value)
                  throws AccessDeniedException
Adds the given attribute. If one or more attributes with the given name already exist, this methods adds the given attribute rather than replacing existing attributes.
Parameters:
aName - the attribute name
values - a vector of attribute values
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

getAttribute

public Object getAttribute(String name)
                    throws AccessDeniedException
Returns the value of the attribute with the given name. If no such attribute exists, null is returned. If more than one attribute exists with the given name, this method returns the first attribute value in order.
Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

getAttributes

public Vector getAttributes(String name)
                     throws AccessDeniedException
Returns a vector of attribute values for the given name. If no such attributes exist, an empty vector is returned.
Parameters:
name - the attribute name
Returns:
a vector of attribute values.
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

getAttributeNames

public Enumeration getAttributeNames()
                              throws AccessDeniedException
Returns an enumeration of all available attributes names.
Returns:
an enumeration of attribute names
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object
See Also:
getAttribute(String)

removeAttribute

public void removeAttribute(String name)
                     throws AccessDeniedException
Removes the attribute with the given name. If no such attribute exists, this method does nothing. If more than attribute with the given name exists, this method removes the first attribute in order.
Parameters:
name - the attribute name
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object
See Also:
removeAttributes(String)

removeAttributes

public void removeAttributes(String name)
                      throws AccessDeniedException
Removes all attributes with the given name. If no such attributes exist, this method does nothing.
Parameters:
name - the attribute name
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

removeAll

public void removeAll()
               throws AccessDeniedException
Removes all attributes. If no attributes exist, this method does nothing.
Throws:
AccessDeniedException - if the caller isn't authorized to access this data object

addAllFrom

public void addAllFrom(DynamicData aData)
                throws AccessDeniedException
Adds all attributes from the given data to this data.
Parameters:
aData - the data which is to be copied into this data
Throws:
AccessDeniedException - if the caller isn't authorized to access either of the data objects

Portlet API 2