All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.serializabletypes.URLPicture

java.lang.Object
   |
   +----JBMSTours.serializabletypes.Picture
           |
           +----JBMSTours.serializabletypes.URLPicture

public class URLPicture
extends Picture
Look at the Source.

Defines a Picture that is obtained from a URL. If the picture is larger than a certain size, store only the URL. If smaller, store the entire content. Can display picture regardless of whether content was stored. Demonstrates some optional way to store media such as pictures, sounds, movies, etc., from the internet--in the database, or as references only.


Variable Index

 o contentType
Mime type
 o isLocal
Whether the contents are stored.
 o MAXSIZE
If an image is larger than MAXSIZE, store only a reference.

Constructor Index

 o URLPicture(String, String)
Instantiates the picture.

Method Index

 o display()
displaying a picture consists of displaying it in a frame.
 o getContent()
Returns the content.
 o getURLName()
Returns the URL name.
 o setContent()
Opens the URL and checks its size.

Variables

 o contentType
 public String contentType
Mime type

 o isLocal
 public boolean isLocal
Whether the contents are stored. True if contents are locally stored

 o MAXSIZE
 public static final int MAXSIZE
If an image is larger than MAXSIZE, store only a reference.

Constructors

 o URLPicture
 public URLPicture(String URLName,
                   String name) throws Exception
Instantiates the picture. Most of the work is cone in setContent.

Parameters:
URLName - URL for the source picture
name - your name for the picture
Throws: Exception
if there is a problem reading the source

Methods

 o setContent
 protected void setContent() throws Exception
Opens the URL and checks its size. If the URL is below MAXSIZE, it reads the contents directly into the class. If the object is being instantiated within Cloudscape, this has the effect of storing the URL content along with the rest of the object in the database.

Throws: Exception
if there is a problem reading the source
Overrides:
setContent in class Picture
 o getURLName
 public String getURLName()
Returns the URL name.

 o getContent
 public byte[] getContent()
Returns the content. If the content is local, this method simply returns the array reference. If not, we open the URL and read from it. Notice that this stores the content in memory, so that if someone asks for it again we already have it.

Overrides:
getContent in class Picture
 o display
 public void display() throws Exception
displaying a picture consists of displaying it in a frame.

Throws: Exception
If there is an error.
Overrides:
display in class Picture

All Packages  Class Hierarchy  This Package  Previous  Next  Index