src/share/classes/sun/applet/AppletViewerPanel.java

Print this page
rev 10175 : 8042872: Fix raw and unchecked warnings in sun.applet
Reviewed-by:


  42  * @author      Arthur van Hoff
  43  */
  44 class AppletViewerPanel extends AppletPanel {
  45 
  46     /* Are we debugging? */
  47     static boolean debug = false;
  48 
  49     /**
  50      * The document url.
  51      */
  52     URL documentURL;
  53 
  54     /**
  55      * The base url.
  56      */
  57     URL baseURL;
  58 
  59     /**
  60      * The attributes of the applet.
  61      */
  62     Hashtable atts;
  63 
  64     /*
  65      * JDK 1.1 serialVersionUID
  66      */
  67     private static final long serialVersionUID = 8890989370785545619L;
  68 
  69     /**
  70      * Construct an applet viewer and start the applet.
  71      */
  72     AppletViewerPanel(URL documentURL, Hashtable atts) {
  73         this.documentURL = documentURL;
  74         this.atts = atts;
  75 
  76         String att = getParameter("codebase");
  77         if (att != null) {
  78             if (!att.endsWith("/")) {
  79                 att += "/";
  80             }
  81             try {
  82                 baseURL = new URL(documentURL, att);
  83             } catch (MalformedURLException e) {
  84             }
  85         }
  86         if (baseURL == null) {
  87             String file = documentURL.getFile();
  88             int i = file.lastIndexOf('/');
  89             if (i >= 0 && i < file.length() - 1) {
  90                 try {
  91                     baseURL = new URL(documentURL, file.substring(0, i + 1));
  92                 } catch (MalformedURLException e) {
  93                 }
  94             }
  95         }
  96 
  97         // when all is said & done, baseURL shouldn't be null
  98         if (baseURL == null)
  99                 baseURL = documentURL;
 100 
 101 
 102     }
 103 
 104     /**
 105      * Get an applet parameter.
 106      */
 107     public String getParameter(String name) {
 108         return (String)atts.get(name.toLowerCase());
 109     }
 110 
 111     /**
 112      * Get the document url.
 113      */
 114     public URL getDocumentBase() {
 115         return documentURL;
 116 
 117     }
 118 
 119     /**
 120      * Get the base url.
 121      */
 122     public URL getCodeBase() {
 123         return baseURL;
 124     }
 125 
 126     /**
 127      * Get the width.
 128      */




  42  * @author      Arthur van Hoff
  43  */
  44 class AppletViewerPanel extends AppletPanel {
  45 
  46     /* Are we debugging? */
  47     static boolean debug = false;
  48 
  49     /**
  50      * The document url.
  51      */
  52     URL documentURL;
  53 
  54     /**
  55      * The base url.
  56      */
  57     URL baseURL;
  58 
  59     /**
  60      * The attributes of the applet.
  61      */
  62     Hashtable<String, String> atts;
  63 
  64     /*
  65      * JDK 1.1 serialVersionUID
  66      */
  67     private static final long serialVersionUID = 8890989370785545619L;
  68 
  69     /**
  70      * Construct an applet viewer and start the applet.
  71      */
  72     AppletViewerPanel(URL documentURL, Hashtable<String, String> atts) {
  73         this.documentURL = documentURL;
  74         this.atts = atts;
  75 
  76         String att = getParameter("codebase");
  77         if (att != null) {
  78             if (!att.endsWith("/")) {
  79                 att += "/";
  80             }
  81             try {
  82                 baseURL = new URL(documentURL, att);
  83             } catch (MalformedURLException e) {
  84             }
  85         }
  86         if (baseURL == null) {
  87             String file = documentURL.getFile();
  88             int i = file.lastIndexOf('/');
  89             if (i >= 0 && i < file.length() - 1) {
  90                 try {
  91                     baseURL = new URL(documentURL, file.substring(0, i + 1));
  92                 } catch (MalformedURLException e) {
  93                 }
  94             }
  95         }
  96 
  97         // when all is said & done, baseURL shouldn't be null
  98         if (baseURL == null)
  99                 baseURL = documentURL;
 100 
 101 
 102     }
 103 
 104     /**
 105      * Get an applet parameter.
 106      */
 107     public String getParameter(String name) {
 108         return atts.get(name.toLowerCase());
 109     }
 110 
 111     /**
 112      * Get the document url.
 113      */
 114     public URL getDocumentBase() {
 115         return documentURL;
 116 
 117     }
 118 
 119     /**
 120      * Get the base url.
 121      */
 122     public URL getCodeBase() {
 123         return baseURL;
 124     }
 125 
 126     /**
 127      * Get the width.
 128      */