home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 4.4 KB | 159 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)PjLauncher.java 0.00 15-Jan-96
-
- A Java applet that launches PjJava.
-
- Authors:
-
- rphall Rick Hall
-
- Version Ident:
-
- $Header: /PjJavaClient/src/pj/applet/PjLauncher.java 5 2/07/96 11:25a Rphall $
-
- History:
-
- 0.00 15-Jan-96 rphall Initial Creation
- 20-Mar-96 jlee Added static applet variable and getPjApplet()
-
- ---------------------------------------------------------------------------*/
-
- package pj.applet;
-
- import pj.applet.PjJava;
-
- import java.applet.Applet;
- import java.applet.AppletContext;
- import java.net.URL;
-
- /**
- * An applet that launches PjJava. PjJava is launched by
- * by invoking its "main" routine. PjLauncher can optionally
- * pass arguments to PjJava; see
- * <a href="pj.applet.PjJava.html#main">PjJava.main</a> for
- * a list of valid arguments.
- * <P>
- * Arguments intended for PjJava can be passed as applet
- * parameters to PjLauncher. The valid parameter names
- * and values are:
- * <pre>
- * name=PjJavaContentUrl value=<a url for content>
- * name=PjJavaAdsUrl value=<a base url for advertisements>
- * name=PjJavaImagesUrl value=<a base url for images>
- * </pre>
- *
- * @version 0.00, 15-Jan-96
- * @author Rick Hall
- */
- public class PjLauncher extends Applet
- {
-
- // --- Class variables
- private static Applet pjApplet;
-
- // --- Instance variables
- private final String nameContentUrl = "PjJavaContentUrl";
- private final String nameAdsUrl = "PjJavaAdsUrl";
- private final String nameImagesUrl = "PjJavaImagesUrl";
-
-
- // --- Public operations
- public static void main(String[] args)
- {
- (new PjLauncher()).init();
- }
-
- public void init()
- {
- pjApplet = this;
-
- // Initialize PjJava arguments to empty strings
- String[] args =
- {
- /*--content*/ "", /*ContentUrl*/ "",
- /*--ads */ "", /*AdsUrl */ "",
- /*--images */ "", /*ImagesUrl */ ""
- };
-
- // Try to get content parameter
- try {
- URL content = getUrlFromParameter((URL)null,nameContentUrl);
- if (content != null)
- {
- args[0] = PjJava.flagContentUrl;
- args[1] = content.toExternalForm();
- }
- } // try
- catch(Exception e) {}
-
- // Try to get ads parameter
- try {
- URL ads = getUrlFromParameter((URL)null,nameAdsUrl);
- if (ads != null)
- {
- args[2] = PjJava.flagAdsUrl;
- args[3] = ads.toExternalForm();
- }
- } // try
- catch(Exception e) {}
-
- // Try to get images parameter
- try {
- URL images = getUrlFromParameter((URL)null,nameImagesUrl);
- if (images != null)
- {
- args[4] = PjJava.flagImagesUrl;
- args[5] = images.toExternalForm();
- }
- } // try
- catch(Exception e) {}
-
- PjJava.main(args);
- }
-
- public static Applet getPjApplet()
- {
- return pjApplet;
- }
-
- // --- Private operations
-
- /**
- * Get a url from an applet tag parameter
- */
- private URL getUrlFromParameter(URL urlDefault, String param)
- {
- URL url;
- String str = getParameter(param);
-
- // Try interpretting str as absolute URL
- url = PjJava.getURL(str);
- if (url != null)
- return url;
-
- // Try interpretting as relative
- url = PjJava.getURL(getDocumentBase(), str);
- if (url != null)
- return url;
-
- // If neither absolute and nor relative, ignore it
- return urlDefault;
-
- } // getUrlFromParameter
-
-
-
- } // PjLauncher
-