![]() |
Storing Objects and Classes
|
|
Storing Media Objects and Playing Them within CloudviewPart of the reason for the popularity of the Java programming language is how easy it makes it to integrate media objects like pictures, video, and sound into your applications. You can use Cloudscape to help organize your application's media in a number of different ways. If a class is serializable, you can store it directly in the database. If it is not, you can store the object as a binary (LONG VARBINARY or VARBINARY) data type. However, you cannot execute any database-side methods on objects stored as non-object binaries. (To execute application-side methods on objects stored in that way, reserialize the object after retrieval.) If you want to execute database-side methods on objects stored in the database, one solution is to make a serializable thin wrapper class around a byte array field. The examples in this section use that solution. Media objects such as these aren't much use unless you have a way to play them. Application developers provide such a way in end-user applications. However, you may want to "play" such objects stored in the database while still in the development phase. If your class has a method that creates a window or dialog box and then displays the object in the window or dialog box, Cloudview lets you "play" these objects. For example, toursDB has a table called Maps. This table stores objects of type JBMSTours.serializabletypes.Picture. The Picture class has a field called content which stores an image as a byte array. Its display() method creates a new Image from that byte array and displays it in a window, so it can be displayed by Cloudview. Play the Maps in toursDB
Examine Picture.java to See How the Image Is Stored
Insert Some URLPicturesJBMSTours.serializabletypes.Picture loads a picture available to the JVM on the class path. Sometimes you want to work with media in various places, such as on the Internet. You may want to store the actual media, or you may want to store only references to the media. JBMSTours.serializabletypes.URLPicture is a subclass of Picture that gets its content from a URL. It contains a static field called MAXSIZE. If the content is larger than that field, the class stores only the URL as a reference. If the content is smaller than that field, the class gets the entire content from the URL and stores that. The display() method is implemented to allow Cloudview to display the picture in either case.
|
||
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |