home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / awt / pjads.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  5.8 KB  |  200 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.         Written by the Personal Journal developers of Dow Jones & Company, Inc.
  4.  
  5.     Dow Jones makes no representations or warranties about 
  6.     the suitability of this software, either express or 
  7.     implied, including but not limited to the implied warranties 
  8.     of merchantability, fitness for a particular purpose, 
  9.     or non-infringement.  Dow Jones will not be liable for 
  10.     any damages suffered by a user as a result of using, 
  11.     modifying or distributing this software or its derivatives.
  12.  
  13.  
  14.         @(#)PjAds.java
  15.  
  16.         A specification of advertisements in the Personal Journal notebook.
  17.  
  18.         Authors:
  19.  
  20.         rphall          Rick Hall
  21.  
  22.         Version Ident:
  23.  
  24.         $Header: /PjJavaClient/src/pj/awt/PjAds.java 4     1/24/96 1:32a Rphall $
  25.  
  26.         History:
  27.  
  28.         16-Jan-96 rphall     Initial Creation
  29.  
  30. ---------------------------------------------------------------------------*/
  31.  
  32. package pj.awt;
  33.  
  34. import pj.awt.PjAdSpec;
  35. import pj.net.RemoteImage;
  36. import pj.net.RemoteString;
  37. import pj.net.RemoteURL;
  38. import collections.Assertable;
  39. import collections.ImplementationCheckable;
  40. import collections.ImplementationError;
  41.  
  42. import java.net.MalformedURLException;
  43. import java.net.URL;
  44.  
  45. /**
  46.  * A specification of advertisements in the Personal Journal notebook.
  47.  *
  48.  * @version 0.00 16-Jan-96
  49.  * @author  rphall
  50. */
  51. public class PjAds implements Assertable, ImplementationCheckable
  52.     {
  53.  
  54.     // --- Class variables
  55.  
  56.     /** Index of the Portfolio Advertisement within adspecs() */
  57.     public static final int idxPortAd = 0;
  58.  
  59.     /** Index of the Sports Advertisement within adspecs() */
  60.     public static final int idxSpAd = 1;
  61.  
  62.     /** Index of the Weather Advertisement with adspecs() */
  63.     public static final int idxWthAd = 2;
  64.  
  65.  
  66.     
  67.  
  68.     private static PjAdSpec[] adspec;
  69.  
  70.     /**
  71.      * A relative URL to the Portfolio Advertisement image
  72.     */
  73.     private static final String strUrlPortAdImage = "PortfolioAdImage.gif";
  74.  
  75.     /**
  76.      * A relative URL to the Portfolio Advertisement copy
  77.     */
  78.     private static final String strUrlPortAdCopy  = "PortfolioAdCopy.txt";
  79.  
  80.     /**
  81.      * A relative URL to a file which contains the Portfolio Advertisement home page url
  82.     */
  83.     private static final String strUrlPortAdHome  = "PortfolioAdUrl.txt";
  84.  
  85.     /**
  86.      * A relative URL to the Sports Advertisement image
  87.     */
  88.     private static final String strUrlSpAdImage = "SportsAdImage.gif";
  89.  
  90.     /**
  91.      * A relative URL to the Sports Advertisement copy
  92.     */
  93.     private static final String strUrlSpAdCopy  = "SportsAdCopy.txt";
  94.  
  95.     /**
  96.      * A relative URL to a file which contains the Sports Advertisement home page url
  97.     */
  98.     private static final String strUrlSpAdHome  = "SportsAdUrl.txt";
  99.  
  100.     /**
  101.      * A relative URL to the Weather Advertisement image
  102.     */
  103.     private static final String strUrlWthAdImage = "WeatherAdImage.gif";
  104.  
  105.     /**
  106.      * A relative URL to the Weather Advertisement copy
  107.     */
  108.     private static final String strUrlWthAdCopy  = "WeatherAdCopy.txt";
  109.  
  110.     /**
  111.      * A relative URL to a file which contains the Weather Advertisement home page url
  112.     */
  113.     private static final String strUrlWthAdHome  = "WeatherAdUrl.txt";
  114.  
  115.  
  116.     // --- Public constructors
  117.  
  118.     /**
  119.      * Constructs an advertisement specification.
  120.      * @param base The base URL from which relative image, copy,
  121.      * and home page URL's are calculated.
  122.     */
  123.     public PjAds(URL base)
  124.         {
  125.         RemoteImage  ri;
  126.         RemoteString rs;
  127.         RemoteURL    ru;
  128.  
  129.         if (adspec == null)
  130.             {
  131.             adspec = new PjAdSpec[3];
  132.  
  133.             try {
  134.  
  135.                 // Portfolio Ad
  136.                 ri = new RemoteImage ( new URL(base,strUrlPortAdImage) );
  137.                 rs = new RemoteString( new URL(base,strUrlPortAdCopy ) );
  138.                 ru = new RemoteURL   ( new URL(base,strUrlPortAdHome ) );
  139.                 adspec[idxPortAd] = new PjAdSpec(ri,rs,ru);
  140.  
  141.                 // Sports Ad
  142.                 ri = new RemoteImage ( new URL(base,strUrlSpAdImage) );
  143.                 rs = new RemoteString( new URL(base,strUrlSpAdCopy ) );
  144.                 ru = new RemoteURL   ( new URL(base,strUrlSpAdHome ) );
  145.                 adspec[idxSpAd] = new PjAdSpec(ri,rs,ru);
  146.  
  147.                 // Weather Ad
  148.                 ri = new RemoteImage ( new URL(base,strUrlWthAdImage) );
  149.                 rs = new RemoteString( new URL(base,strUrlWthAdCopy ) );
  150.                 ru = new RemoteURL   ( new URL(base,strUrlWthAdHome ) );
  151.                 adspec[idxWthAd] = new PjAdSpec(ri,rs,ru);
  152.  
  153.                 } // try
  154.  
  155.             catch(MalformedURLException e)
  156.                 {   
  157.                 assert(false); 
  158.                 }
  159.  
  160.             } // if adspec null
  161.  
  162.         // Postconditions
  163.         checkImplementation();
  164.  
  165.         System.out.println("Debug-PjAds:constructed");
  166.         } // PjAds()
  167.  
  168.  
  169.     // --- Public operations
  170.  
  171.     /**
  172.      * Check the internal consistency of the a PjAds.
  173.      * Currently a NOP.
  174.      * @exception ImplementationError currently never thrown.
  175.     */
  176.     public void checkImplementation() throws ImplementationError
  177.         {
  178.         } // checkImplementation()
  179.  
  180.     /**
  181.      * Raise an exception if predicate is false.
  182.      * @see collections.Assertable
  183.      * @exception ImplementationError thrown if predicate is false.
  184.     */
  185.     public void assert(boolean predicate) throws ImplementationError
  186.         { 
  187.         ImplementationError.assert(this, predicate); 
  188.         }
  189.  
  190.     /**
  191.      * @return An array of ad specifications.
  192.     */
  193.     public PjAdSpec[] adspecs()
  194.         { 
  195.         return adspec; 
  196.         }
  197.  
  198.     
  199.     } // PjAds
  200.