|
|
||||||||||||||||||||||||||||
Class ObjectBagpublic 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. ConstructorsObjectBagpublic ObjectBag(); ObjectBagpublic ObjectBag(MetaObject renderer); MethodsaddObjectpublic void addObject(Category category, Class cls, Object object); getObjectpublic Object getObject(Category category, Class cls); hasObjectpublic boolean hasObject(Category category, Class cls); objectCategoriespublic Enumeration objectCategories(); objectClassespublic Enumeration objectClasses(Category category);
|