Package com.ms.object
 In this topic

*Constructors

*Methods

 

Packages
  PreviousThis PackageNext
Package com.ms.object   Previous This
Package
Next

 


Class ObjectBag

public class ObjectBag implements MetaObject
{
  // Constructors
  public ObjectBag();
  public ObjectBag(MetaObject renderer);

  // Methods
  public void addObject(Category category, Class cls, Object object);
  public Object getObject(Category category, Class cls);
  public boolean hasObject(Category category, Class cls);
  public Enumeration objectCategories();
  public Enumeration objectClasses(Category category);
}

This class is a default implementation of the MetaObject interface that can be used to implement delayed rendering. Delayed rendering allows a data source to support several different data formats and convert these formats as necessary, based on the requirements of the recipient.

For instance, a word processor might have an internal text representation, but it might also know how to convert its text representation to plain text, rich text, or other formats. Instead of providing all possible conversions when it constructs the MetaObject for a data transfer, the word processor could run the conversion on demand, depending on the format required by the recipient.

To implement delayed rendering, a data source might implement a MetaObject that always does format conversions and then wrap an ObjectBag around it. When the ObjectBag is asked for a data format it does not support, it asks the source MetaObject to obtain the data, thereby running the conversion. The converted data is then stored in the ObjectBag for future use.

Constructors

ObjectBag

public ObjectBag();

Creates an assignable ObjectBag object with no delayed renderer.

ObjectBag

public ObjectBag(MetaObject renderer);

Creates an ObjectBag object with a delayed renderer.

ParameterDescription
renderer The MetaObject that the ObjectBag should use for delayed rendering

Methods

addObject

public void addObject(Category category, Class cls, Object object);

Adds an object to the ObjectBag.

Return Value:

No return value.

ParameterDescription
category The Category of the object being added.
cls The Class of the object being added. If cls is null, the class is inferred from the specified Object.
object The object to add to the object bag.

getObject

public Object getObject(Category category, Class cls);

Requests an object with the specified category and class from the ObjectBag.

Return Value:

Returns an object with the specified category and class.

ParameterDescription
category The Category object that represents the category that is requested.
cls The Class object that represents the class that is requested.

hasObject

public boolean hasObject(Category category, Class cls);

Determines whether the specified category and class are supported by the ObjectBag.

Return Value:

Returns true if the ObjectBag supports the specified category and class; otherwise, returns false.

ParameterDescription
category The Category object that represents the category being queried for.
cls The Class object that represents the class being queried for.

objectCategories

public Enumeration objectCategories();

Enumerates the categories in the ObjectBag.

Return Value:

Returns an Enumeration of the categories in the ObjectBag.

objectClasses

public Enumeration objectClasses(Category category);

Enumerates the classes in the ObjectBag that are in the specified category.

Return Value:

Returns an Enumeration of the classes in the ObjectBag that are in the specified category.

ParameterDescription
category The category that identifies which classes to enumerate.

upnrm.gif