home *** CD-ROM | disk | FTP | other *** search
/ Internet News 1999 October / INEWS_10_CD.ISO / pc / jdk / jdk1.2.2 / docs / guide / serialization / examples / nonexternsuper / ReadingMaterial.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  2.0 KB  |  66 lines

  1. /*
  2.  * @(#)ReadingMaterial.java    1.1 98/10/03        
  3.  *
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  *
  19.  * 
  20.  */
  21.  
  22. import java.io.*;
  23.  
  24. /**
  25.  * The superclass DOES NOT implement externalizable
  26.  */
  27. class ReadingMaterial  {
  28.     
  29.     /*
  30.      * In order for us to be able to serialize this data, these must be
  31.      * either serializable/externalizable objects or primitive data types. 
  32.      *
  33.      *
  34.      * We do not make these private because we need the subclass Book to be
  35.      * able to save the state of this superclass.
  36.      * Alternatively, we could make these private and create set and get
  37.      * functions that would allow access to the Book subclass. 
  38.      * If we failed to do that with private fields, then fields would not
  39.      * be saveable!
  40.      */
  41.     String author;
  42.     String subject;
  43.     int yearwritten;
  44.     
  45.     // other relevant data and methods 
  46.     // .
  47.     // .
  48.     // .
  49.   
  50.     /* 
  51.      * A public no-arg constructor so that an externalizable sub-class can
  52.      * use it. If this did not exist, then the subclass would have to call
  53.      * the regular argument constructor with default arguments in its own
  54.      * public no-arg constructor
  55.      */
  56.     public ReadingMaterial() {}
  57.  
  58.     ReadingMaterial(String auth, String sub, int year) {
  59.     author = auth;
  60.     subject = sub;
  61.     yearwritten = year;
  62.     }
  63. }
  64.  
  65.  
  66.