home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 8.4 KB | 267 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.
-
-
-
- @(#)ViewFactory.java 0.00 07-Jan-96
-
- A class of objects that create PaperViews.
-
-
- Authors:
-
- rphall Rick Hall
-
-
- Version Ident:
-
- $Header$
-
-
- History:
-
- 0.00 07-Jan-96 rphall Initial Creation
-
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.Column;
- import pj.awt.DividerView;
- import pj.awt.HeadlineView;
- import pj.awt.MarketView;
- import pj.awt.PjStr;
- import pj.awt.PageView;
- import pj.awt.PaperView;
- import pj.io.Paper;
-
-
- import collections.Assertable;
- import collections.ImplementationCheckable;
- import collections.ImplementationError;
- import java.awt.Label; // FIXME: remove hack
-
- /**
- * A class of objects that create PaperViews.
- *
- * @see pj.awt.PaperView
- * @see pj.awt.PageView
- * @see pj.awt.DividerView
- * @version 0.00 07-Jan-96
- * @author rphall
- */
- public class ViewFactory implements Assertable, ImplementationCheckable
- {
-
-
- // --- Instance variables
-
- /** The paper upon which views gaze */
- protected Paper paper;
-
- /** Page indices */
-
- private final int idxFPHdlines = 100;
- private final int idxFPBusFin = 101;
- private final int idxFPWorld = 102;
- private final int idxFPNews = 103;
- private final int idxFPFlash = 104;
-
- private final int idxTJIHdlines = 200;
- private final int idxTJIBusFin = 201;
- private final int idxTJIWorld = 202;
- private final int idxTJINews = 203;
-
- private final int idxPort = 300;
-
- private final int idxMrk = 402401;
- private final int idxMrkExTrs = 403404;
- private final int idxMrkWrap = 405;
-
- private final int idxSpHilite = 501;
- private final int idxSpScoresAd = 502503;
-
- private final int idxWth = 600611;
- private final int idxWthUSNE = 601;
- private final int idxWthUSSE = 602;
- private final int idxWthUSMW = 603;
- private final int idxWthUSWest = 604;
- private final int idxWthCanada = 605;
- private final int idxWthSouthA = 606;
- private final int idxWthEurope = 607;
- private final int idxWthMidE = 608;
- private final int idxWthAfrica = 609;
- private final int idxWthAsia = 610;
-
- // --- Public constructors
-
- /**
- * Construct a factory.
- */
- public ViewFactory(Paper p)
- {
- assert(p != null);
- paper = p;
- checkImplementation();
- }
-
- // --- Public operations
-
- /**
- * Create a page view.
- * @param pagespec A specification for the page.
- * @return A PageView.
- * @exception ImplementationError thrown if the pagespec
- * is null or invalid.
- */
- public Page createPage(PjPageSpec spec)
- {
- Page pg = null;
- int idx = (new Integer(spec.strPageName)).intValue();
- switch ( idx )
- {
- case idxFPHdlines :
- pg = new HeadlineView(spec,paper);
- break;
-
- case idxFPBusFin :
- case idxFPWorld :
- case idxFPNews :
-
- case idxFPFlash :
- //pg = new Column(spec.strPageName,spec.strPageName,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- case idxTJIHdlines :
- pg = new HeadlineView(spec,paper);
- break;
-
- case idxTJIBusFin :
- case idxTJIWorld :
-
- case idxTJINews :
- //pg = new Column(spec.strPageName,spec.strPageName,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- case idxMrk :
- pg = new MarketView(spec,paper);
- break;
-
- case idxMrkExTrs :
- //pg = new ExTrsView(spec,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- case idxMrkWrap :
- //pg = new Column(spec.strPageName,spec.strPageName,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- case idxPort :
- pg = new PortView(spec,paper);
- break;
-
- case idxSpHilite :
- pg = new SpHiliteView(spec,paper);
- break;
-
- case idxSpScoresAd :
- //pg = new SpScoresAdView(spec,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- case idxWth :
- //pg = new WthView(spec,paper);
- pg = new DividerView(spec.tabspec);
- break;
-
- case idxWthUSNE :
- case idxWthUSSE :
-
- case idxWthUSMW :
- case idxWthUSWest :
-
- case idxWthCanada :
- case idxWthSouthA :
-
- case idxWthEurope :
- case idxWthMidE :
-
- case idxWthAfrica :
- case idxWthAsia :
- //pg = new Column(spec.strPageName,spec.strPageName,paper);
- pg = new PageView(spec.strPageName);
- break;
-
- default :
- assert(false);
-
- } // switch idx
-
- assert(pg != null);
-
- return pg;
- } // createPage
-
- /**
- * Raise an exception if predicate is false.
- * @see collections.Assertable
- */
- public void assert(boolean predicate) throws ImplementationError
- {
- ImplementationError.assert(this, predicate);
- }
-
- /**
- * Raise an exception if implementation is out of sync with PjStr.
- * @see PjNbSpec
- */
- public void checkImplementation() throws ImplementationError
- {
- assert( idxFPHdlines == (new Integer(PjStr.pageFPHdlines)).intValue() );
- assert( idxFPBusFin == (new Integer(PjStr.pageFPBusFin)).intValue() );
- assert( idxFPWorld == (new Integer(PjStr.pageFPWorld)).intValue() );
- assert( idxFPNews == (new Integer(PjStr.pageFPNews)).intValue() );
- assert( idxFPFlash == (new Integer(PjStr.pageFPFlash)).intValue() );
-
- assert( idxTJIHdlines == (new Integer(PjStr.pageTJIHdlines)).intValue() );
- assert( idxTJIBusFin == (new Integer(PjStr.pageTJIBusFin)).intValue() );
- assert( idxTJIWorld == (new Integer(PjStr.pageTJIWorld)).intValue() );
- assert( idxTJINews == (new Integer(PjStr.pageTJINews)).intValue() );
-
- assert( idxMrk == (new Integer(PjStr.pageMrk)).intValue() );
- assert( idxMrkExTrs == (new Integer(PjStr.pageMrkExTrs)).intValue() );
- assert( idxMrkWrap == (new Integer(PjStr.pageMrkWrap)).intValue() );
-
- assert( idxPort == (new Integer(PjStr.pagePort)).intValue() );
-
- assert( idxSpHilite == (new Integer(PjStr.pageSpHilite)).intValue() );
- assert( idxSpScoresAd == (new Integer(PjStr.pageSpScoresAd)).intValue() );
-
- assert( idxWth == (new Integer(PjStr.pageWth)).intValue() );
- assert( idxWthUSNE == (new Integer(PjStr.pageWthUSNE)).intValue() );
- assert( idxWthUSSE == (new Integer(PjStr.pageWthUSSE)).intValue() );
- ssert( idxWthUSMW == (new Integer(PjStr.pageWthUSMW)).intValue() );
- assert( idxWthUSWest == (new Integer(PjStr.pageWthUSWest)).intValue() );
- ssert( idxWthCanada == (new Integer(PjStr.pageWthCanada)).intValue() );
- assert( idxWthSouthA == (new Integer(PjStr.pageWthSouthA)).intValue() );
- assert( idxWthEurope == (new Integer(PjStr.pageWthEurope)).intValue() );
- assert( idxWthMidE == (new Integer(PjStr.pageWthMidE)).intValue() );
- assert( idxWthAfrica == (new Integer(PjStr.pageWthAfrica)).intValue() );
- assert( idxWthAsia == (new Integer(PjStr.pageWthAsia)).intValue() );
- }
-
-
- }; // ViewFactory
-