home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 5.8 KB | 200 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.
-
-
- @(#)PjAds.java
-
- A specification of advertisements in the Personal Journal notebook.
-
- Authors:
-
- rphall Rick Hall
-
- Version Ident:
-
- $Header: /PjJavaClient/src/pj/awt/PjAds.java 4 1/24/96 1:32a Rphall $
-
- History:
-
- 16-Jan-96 rphall Initial Creation
-
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.PjAdSpec;
- import pj.net.RemoteImage;
- import pj.net.RemoteString;
- import pj.net.RemoteURL;
- import collections.Assertable;
- import collections.ImplementationCheckable;
- import collections.ImplementationError;
-
- import java.net.MalformedURLException;
- import java.net.URL;
-
- /**
- * A specification of advertisements in the Personal Journal notebook.
- *
- * @version 0.00 16-Jan-96
- * @author rphall
- */
- public class PjAds implements Assertable, ImplementationCheckable
- {
-
- // --- Class variables
-
- /** Index of the Portfolio Advertisement within adspecs() */
- public static final int idxPortAd = 0;
-
- /** Index of the Sports Advertisement within adspecs() */
- public static final int idxSpAd = 1;
-
- /** Index of the Weather Advertisement with adspecs() */
- public static final int idxWthAd = 2;
-
-
-
-
- private static PjAdSpec[] adspec;
-
- /**
- * A relative URL to the Portfolio Advertisement image
- */
- private static final String strUrlPortAdImage = "PortfolioAdImage.gif";
-
- /**
- * A relative URL to the Portfolio Advertisement copy
- */
- private static final String strUrlPortAdCopy = "PortfolioAdCopy.txt";
-
- /**
- * A relative URL to a file which contains the Portfolio Advertisement home page url
- */
- private static final String strUrlPortAdHome = "PortfolioAdUrl.txt";
-
- /**
- * A relative URL to the Sports Advertisement image
- */
- private static final String strUrlSpAdImage = "SportsAdImage.gif";
-
- /**
- * A relative URL to the Sports Advertisement copy
- */
- private static final String strUrlSpAdCopy = "SportsAdCopy.txt";
-
- /**
- * A relative URL to a file which contains the Sports Advertisement home page url
- */
- private static final String strUrlSpAdHome = "SportsAdUrl.txt";
-
- /**
- * A relative URL to the Weather Advertisement image
- */
- private static final String strUrlWthAdImage = "WeatherAdImage.gif";
-
- /**
- * A relative URL to the Weather Advertisement copy
- */
- private static final String strUrlWthAdCopy = "WeatherAdCopy.txt";
-
- /**
- * A relative URL to a file which contains the Weather Advertisement home page url
- */
- private static final String strUrlWthAdHome = "WeatherAdUrl.txt";
-
-
- // --- Public constructors
-
- /**
- * Constructs an advertisement specification.
- * @param base The base URL from which relative image, copy,
- * and home page URL's are calculated.
- */
- public PjAds(URL base)
- {
- RemoteImage ri;
- RemoteString rs;
- RemoteURL ru;
-
- if (adspec == null)
- {
- adspec = new PjAdSpec[3];
-
- try {
-
- // Portfolio Ad
- ri = new RemoteImage ( new URL(base,strUrlPortAdImage) );
- rs = new RemoteString( new URL(base,strUrlPortAdCopy ) );
- ru = new RemoteURL ( new URL(base,strUrlPortAdHome ) );
- adspec[idxPortAd] = new PjAdSpec(ri,rs,ru);
-
- // Sports Ad
- ri = new RemoteImage ( new URL(base,strUrlSpAdImage) );
- rs = new RemoteString( new URL(base,strUrlSpAdCopy ) );
- ru = new RemoteURL ( new URL(base,strUrlSpAdHome ) );
- adspec[idxSpAd] = new PjAdSpec(ri,rs,ru);
-
- // Weather Ad
- ri = new RemoteImage ( new URL(base,strUrlWthAdImage) );
- rs = new RemoteString( new URL(base,strUrlWthAdCopy ) );
- ru = new RemoteURL ( new URL(base,strUrlWthAdHome ) );
- adspec[idxWthAd] = new PjAdSpec(ri,rs,ru);
-
- } // try
-
- catch(MalformedURLException e)
- {
- assert(false);
- }
-
- } // if adspec null
-
- // Postconditions
- checkImplementation();
-
- System.out.println("Debug-PjAds:constructed");
- } // PjAds()
-
-
- // --- Public operations
-
- /**
- * Check the internal consistency of the a PjAds.
- * Currently a NOP.
- * @exception ImplementationError currently never thrown.
- */
- public void checkImplementation() throws ImplementationError
- {
- } // checkImplementation()
-
- /**
- * Raise an exception if predicate is false.
- * @see collections.Assertable
- * @exception ImplementationError thrown if predicate is false.
- */
- public void assert(boolean predicate) throws ImplementationError
- {
- ImplementationError.assert(this, predicate);
- }
-
- /**
- * @return An array of ad specifications.
- */
- public PjAdSpec[] adspecs()
- {
- return adspec;
- }
-
-
- } // PjAds
-