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.
-
contentType
- Mime type
-
isLocal
- Whether the contents are stored.
-
MAXSIZE
- If an image is larger than MAXSIZE, store only a reference.
-
URLPicture(String, String)
- Instantiates the picture.
-
display()
- displaying a picture consists of displaying it in a frame.
-
getContent()
- Returns the content.
-
getURLName()
- Returns the URL name.
-
setContent()
- Opens the URL and checks its size.
contentType
public String contentType
- Mime type
isLocal
public boolean isLocal
- Whether the contents are stored.
True if contents are locally stored
MAXSIZE
public static final int MAXSIZE
- If an image is larger than MAXSIZE, store only a reference.
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
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
getURLName
public String getURLName()
- Returns the URL name.
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
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