home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-02-11 | 3.5 KB | 130 lines |
- /* ****************************************************************
- ** @(#)RoloEntry.java 1.2 0
- **
- ** Copyright 1997 Sun Microsystems, Inc. All Rights Reserved
- **
- ** ****************************************************************
- */
-
- import java.util.*;
- import java.io.*;
-
- /* RoloEntry contains data structure for NameDB application
- ** stores name,address1,address2,phone,email,other
- */
-
- public class RoloEntry implements Listable {
- public String name;
- public String address1;
- public String address2;
- public String phone;
- public String email;
- public String other;
-
- public static RoloEntry roloobj = new RoloEntry();
-
- public RoloEntry(String name,String address1,String address2,String phone,
- String email,String other) {
- this.name=name;
- this.address1=address1;
- this.address2=address2;
- this.phone=phone;
- this.email=email;
- this.other=other;
- }
- public RoloEntry() {
- this("","","","","","");
- }
-
- public Listable read_from_file(DataInputStream din) {
-
- // Read one rolo entry from file passed in.
- // We assume file pointer is at beginning of record in file.
- // Populate object member vars with values read in.
- // Assume one line per field.
- RoloEntry re = new RoloEntry();
- String s = new String("");
-
- try {
- s = din.readLine();
- if (s!=null)
- re.name = new String(s);
-
- s = din.readLine();
- if (s!=null) re.address1 = new String(s);
-
- s = din.readLine();
- if (s!=null) re.address2 = new String(s);
-
- s = din.readLine();
- if (s!=null) re.phone = new String(s);
-
- s = din.readLine();
- if (s!=null) re.email = new String(s);
-
- s = din.readLine();
- if (s!=null) re.other = new String(s);
- if (s==null) return null;
- }
-
- catch (IOException e) {
- System.out.println("msg" + e.getMessage());
- }
-
- return re;
- }
-
- public void write_to_file(PrintStream pout){
- // Write one rolo entry to file passed in.
- // We assume file pointer is correctly positioned
- // Write out one object member var per line
- pout.println(name);
- pout.println(address1);
- pout.println(address2);
- pout.println(phone);
- pout.println(email);
- pout.println(other);
- }
-
- public String getKey() {
- return name;
- }
-
- public boolean equals(RoloEntry other_rolo) {
- // Returns true if key values match, false otherwise.
-
- return name.equals(other_rolo.getKey());
- }
-
- public void print() {
- System.out.println(name);
- System.out.println(address1);
- System.out.println(address2);
- System.out.println(phone);
- System.out.println(email);
- System.out.println(other);
- }
-
- public Object clone() {
- // Return a clone of the current object
-
- RoloEntry theClone = new RoloEntry();
- theClone.name = new String(name);
- theClone.address1 = new String(address1);
- theClone.address2 = new String(address2);
- theClone.phone = new String(phone);
- theClone.email = new String(email);
- theClone.other = new String(other);
- return (Object)theClone;
- }
-
- public void clear() {
- name = new String("");
- address1 = new String("");
- address2 = new String("");
- phone = new String("");
- email = new String("");
- other = new String("");
- }
- }
-