home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / io / paperstory.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  5.9 KB  |  239 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.  
  15.     @(#)PaperStory.java    0.00 20-Dec-95
  16.  
  17.  
  18.         Base class for stories in a Personal Journal paper.
  19.  
  20.  
  21.     Authors:
  22.  
  23.         rphall      Rick Hall
  24.  
  25.  
  26.     Version Ident:
  27.  
  28.         $Header$
  29.  
  30.  
  31.     History:
  32.  
  33.         12/20/95    rphall      Initial Creation
  34.  
  35.  
  36. ---------------------------------------------------------------------------*/
  37.  
  38. package pj.io;
  39.  
  40. import pj.io.MalformedPaperStoryException;
  41.  
  42. import collections.Assertable;
  43. import collections.ImplementationCheckable;
  44. import collections.ImplementationError;
  45.  
  46. import java.lang.IllegalArgumentException;
  47.  
  48. /**
  49.  * Base class for stories in a Personal Journal paper.
  50.  * @version 0.00, 20-Dec-95
  51.  * @author     Rick Hall
  52.  */
  53. public class PaperStory extends Object implements Assertable, ImplementationCheckable
  54.     {
  55.  
  56.     // --- Public constants
  57.  
  58.     static public final String markStartStory    = ".+FL" ;
  59.     static public final String markStartTitle    = ".+dt" ;
  60.     static public final String markStartBody     = ".+db" ;
  61.     static public final String markStopStory     = ".-FL" ;
  62.     static public final String markStopTitle     = ".-dt" ;
  63.     static public final String markStopBody      = ".-db" ;
  64.     static public final String markAttribSection = ".=SH ";
  65.     static public final String markAttribSubsect = ".=SS ";
  66.     static public final String markAttribType    = ".=TY ";
  67.     static public final String markAttribKeys    = ".=KY ";
  68.     static public final String markEOL           = "\r\n" ;
  69.  
  70.     
  71.  
  72.     // --- Package attributes
  73.     String strSection;
  74.     String strSubsect;
  75.     String strType;
  76.     String strTitle;
  77.     String strBody;
  78.     String strKeys;
  79.  
  80.  
  81.     // --- Private attributes
  82.     // PaperStoryParser psspParser;
  83.  
  84.  
  85.   
  86.  
  87.     // --- Public constructors
  88.  
  89.     public PaperStory (
  90.                 String section,    // Section
  91.                 String subsection, // Subsection
  92.                 String type,       // Type
  93.                 String keys,       // Keywords
  94.                 String title,      // Title
  95.                 String body)       // Body
  96.         throws MalformedPaperStoryException, IllegalArgumentException
  97.         {
  98.         //psspParser    = null;
  99.         strSection = section;
  100.         strSubsect = subsection;
  101.         strType    = type;
  102.         strTitle   = title;
  103.         strBody    = body;
  104.         strKeys    = keys;
  105.         
  106.         try { 
  107.             checkImplementation(); 
  108.             }
  109.         catch (ImplementationError e) 
  110.             throw new IllegalArgumentException();
  111.         }
  112.  
  113.     public PaperStory (
  114.                 String section,      // Section
  115.                 String subsection)   // Subsection
  116.         throws MalformedPaperStoryException, IllegalArgumentException
  117.         {
  118.         this( section, subsection,
  119.                 (String)null, (String)null, (String)null, (String)null);
  120.         }
  121.  
  122.     public PaperStory ()
  123.         throws MalformedPaperStoryException, IllegalArgumentException
  124.         {
  125.         strSection = null;
  126.         strSubsect = null;
  127.         strType    = null;
  128.         strTitle   = null;
  129.         strBody    = null;
  130.         strKeys    = null;
  131.         }
  132.  
  133.     public String toString()
  134.         {
  135.         String temp = markStartStory + markEOL
  136.                     + markAttribSection + strSection + markEOL
  137.                     + markAttribSubsect + strSubsect + markEOL;
  138.  
  139.         if (strType != null)
  140.             temp += markAttribType + strType + markEOL;
  141.  
  142.         if (strKeys != null)
  143.             temp += markAttribKeys + strKeys + markEOL;
  144.  
  145.         if (strTitle != null)
  146.             temp += markStartTitle + markEOL
  147.                     + strTitle + markEOL
  148.                     + markStopTitle + markEOL;
  149.  
  150.         if (strBody != null)
  151.             temp += markStartBody  + markEOL
  152.                     + strBody + markEOL
  153.                     + markStopBody + markEOL;
  154.  
  155.         temp += markStopStory + markEOL;
  156.  
  157.         return temp;
  158.         }
  159.  
  160.     // --- Public operations
  161.  
  162.     public String getSection() 
  163.         { 
  164.         return strSection; 
  165.         }
  166.  
  167.     public String getSubsect() 
  168.         { 
  169.         return strSubsect; 
  170.         }
  171.  
  172.     public String getType()    
  173.         { 
  174.         return strType; 
  175.         }
  176.  
  177.     public String getTitle()   
  178.         { 
  179.         return strTitle; 
  180.         }
  181.  
  182.     public String getBody()    
  183.         { 
  184.         return strBody; 
  185.         }
  186.  
  187.     public String getKeys()    
  188.         { 
  189.         return strKeys; 
  190.         }
  191.  
  192.     public void setSection(String s) 
  193.         { 
  194.         strSection = s; 
  195.         }
  196.  
  197.     public void setSubsect(String s) 
  198.         { 
  199.         strSubsect = s; 
  200.         }
  201.  
  202.     public void setType(String s)    
  203.         { 
  204.         strType    = s; 
  205.         }
  206.  
  207.     public void setTitle(String s)   
  208.         { 
  209.         strTitle   = s; 
  210.         }
  211.  
  212.     public void setBody(String s)    
  213.         { 
  214.         strBody    = s; 
  215.         }
  216.  
  217.     public void setKeys(String s)    
  218.         { 
  219.         strKeys    = s; 
  220.         }
  221.  
  222.       
  223.     public void assert(boolean predicate)
  224.         throws ImplementationError
  225.         {
  226.         ImplementationError.assert(this, predicate); 
  227.         }
  228.  
  229.     public void checkImplementation()
  230.         throws ImplementationError
  231.         {
  232.         assert (strSection != null);
  233.         assert (strSubsect != null);
  234.         }
  235.  
  236.  
  237.  
  238.     } // PaperStory
  239.