home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 5.9 KB | 239 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.
-
-
-
- @(#)PaperStory.java 0.00 20-Dec-95
-
-
- Base class for stories in a Personal Journal paper.
-
-
- Authors:
-
- rphall Rick Hall
-
-
- Version Ident:
-
- $Header$
-
-
- History:
-
- 12/20/95 rphall Initial Creation
-
-
- ---------------------------------------------------------------------------*/
-
- package pj.io;
-
- import pj.io.MalformedPaperStoryException;
-
- import collections.Assertable;
- import collections.ImplementationCheckable;
- import collections.ImplementationError;
-
- import java.lang.IllegalArgumentException;
-
- /**
- * Base class for stories in a Personal Journal paper.
- * @version 0.00, 20-Dec-95
- * @author Rick Hall
- */
- public class PaperStory extends Object implements Assertable, ImplementationCheckable
- {
-
- // --- Public constants
-
- static public final String markStartStory = ".+FL" ;
- static public final String markStartTitle = ".+dt" ;
- static public final String markStartBody = ".+db" ;
- static public final String markStopStory = ".-FL" ;
- static public final String markStopTitle = ".-dt" ;
- static public final String markStopBody = ".-db" ;
- static public final String markAttribSection = ".=SH ";
- static public final String markAttribSubsect = ".=SS ";
- static public final String markAttribType = ".=TY ";
- static public final String markAttribKeys = ".=KY ";
- static public final String markEOL = "\r\n" ;
-
-
-
- // --- Package attributes
- String strSection;
- String strSubsect;
- String strType;
- String strTitle;
- String strBody;
- String strKeys;
-
-
- // --- Private attributes
- // PaperStoryParser psspParser;
-
-
-
-
- // --- Public constructors
-
- public PaperStory (
- String section, // Section
- String subsection, // Subsection
- String type, // Type
- String keys, // Keywords
- String title, // Title
- String body) // Body
- throws MalformedPaperStoryException, IllegalArgumentException
- {
- //psspParser = null;
- strSection = section;
- strSubsect = subsection;
- strType = type;
- strTitle = title;
- strBody = body;
- strKeys = keys;
-
- try {
- checkImplementation();
- }
- catch (ImplementationError e)
- throw new IllegalArgumentException();
- }
-
- public PaperStory (
- String section, // Section
- String subsection) // Subsection
- throws MalformedPaperStoryException, IllegalArgumentException
- {
- this( section, subsection,
- (String)null, (String)null, (String)null, (String)null);
- }
-
- public PaperStory ()
- throws MalformedPaperStoryException, IllegalArgumentException
- {
- strSection = null;
- strSubsect = null;
- strType = null;
- strTitle = null;
- strBody = null;
- strKeys = null;
- }
-
- public String toString()
- {
- String temp = markStartStory + markEOL
- + markAttribSection + strSection + markEOL
- + markAttribSubsect + strSubsect + markEOL;
-
- if (strType != null)
- temp += markAttribType + strType + markEOL;
-
- if (strKeys != null)
- temp += markAttribKeys + strKeys + markEOL;
-
- if (strTitle != null)
- temp += markStartTitle + markEOL
- + strTitle + markEOL
- + markStopTitle + markEOL;
-
- if (strBody != null)
- temp += markStartBody + markEOL
- + strBody + markEOL
- + markStopBody + markEOL;
-
- temp += markStopStory + markEOL;
-
- return temp;
- }
-
- // --- Public operations
-
- public String getSection()
- {
- return strSection;
- }
-
- public String getSubsect()
- {
- return strSubsect;
- }
-
- public String getType()
- {
- return strType;
- }
-
- public String getTitle()
- {
- return strTitle;
- }
-
- public String getBody()
- {
- return strBody;
- }
-
- public String getKeys()
- {
- return strKeys;
- }
-
- public void setSection(String s)
- {
- strSection = s;
- }
-
- public void setSubsect(String s)
- {
- strSubsect = s;
- }
-
- public void setType(String s)
- {
- strType = s;
- }
-
- public void setTitle(String s)
- {
- strTitle = s;
- }
-
- public void setBody(String s)
- {
- strBody = s;
- }
-
- public void setKeys(String s)
- {
- strKeys = s;
- }
-
-
- public void assert(boolean predicate)
- throws ImplementationError
- {
- ImplementationError.assert(this, predicate);
- }
-
- public void checkImplementation()
- throws ImplementationError
- {
- assert (strSection != null);
- assert (strSubsect != null);
- }
-
-
-
- } // PaperStory
-