FileDocCategorySizeDatePackage
ReadingMaterial.javaAPI DocExample3461Wed Apr 19 11:21:16 BST 2000None

ReadingMaterial

public class ReadingMaterial extends Object implements Externalizable
The Externalizable Superclass: When the Externalizable Subclass Book implements its writeExternal and readExternal Methods, it needs to save the state of its superclass using the superclass's writeExternal and readExternal Methods

Fields Summary
private String
author
private String
subject
private int
yearwritten
Constructors Summary
public ReadingMaterial()

public ReadingMaterial(String auth, String sub, int year)
Initialize the fields

	author = auth;
	subject = sub;
	yearwritten = year;
    
Methods Summary
public java.lang.StringgetAuthor()
A public field access method, since the data fields are private and will need to be accessed by the subclass to print them or use them otherwise.

 
	return author; 
public java.lang.StringgetSubject()
A field access method, since the data fields are private and will need to be accessed by the subclass to print them or use them otherwise.

 
	return subject; 
public intgetYearwritten()
A field access method, since the data fields are private and will need to be accessed by the subclass to print them or use them otherwise.

 
	return yearwritten; 
public voidreadExternal(java.io.ObjectInput in)
Mandatory readExternal method. Will read in the data that we wrote out in the writeExternal method. MUST BE IN THE SAME ORDER and type as we wrote it out. By the time, readExternal is called, an object of this class has already been created using the public no-arg constructor, so this method is used to restore the data to all of the fields of the newly created object.

   
    author = (String)in.readObject();
    subject = (String)in.readObject();
    yearwritten = in.readInt();
  
public voidwriteExternal(java.io.ObjectOutput out)
Mandatory writeExternal method.

serialData
Write author and subject field as objects and then write yearwritten field as an integer.

    
	out.writeObject(author);
	out.writeObject(subject);
	out.writeInt(yearwritten);