home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / browser / net_linx / jae40.jar / java / rmi / server / RemoteObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  2.3 KB  |  60 lines

  1. package java.rmi.server;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.ObjectOutputStream;
  6. import java.io.Serializable;
  7. import java.rmi.MarshalException;
  8. import java.rmi.Remote;
  9. import java.rmi.UnmarshalException;
  10.  
  11. public abstract class RemoteObject implements Remote, Serializable {
  12.    protected transient RemoteRef ref;
  13.  
  14.    protected RemoteObject() {
  15.       this.ref = null;
  16.    }
  17.  
  18.    protected RemoteObject(RemoteRef var1) {
  19.       this.ref = var1;
  20.    }
  21.  
  22.    public int hashCode() {
  23.       return this.ref == null ? super.hashCode() : this.ref.remoteHashCode();
  24.    }
  25.  
  26.    public boolean equals(Object var1) {
  27.       if (this.ref == null) {
  28.          return var1 == this;
  29.       } else {
  30.          return var1 instanceof RemoteObject ? this.ref.remoteEquals(((RemoteObject)var1).ref) : false;
  31.       }
  32.    }
  33.  
  34.    public String toString() {
  35.       String var1 = this.getClass().getName();
  36.       return this.ref == null ? var1 : var1 + "[" + this.ref.remoteToString() + "]";
  37.    }
  38.  
  39.    private void writeObject(ObjectOutputStream var1) throws IOException, ClassNotFoundException {
  40.       if (this.ref == null) {
  41.          throw new MarshalException("Invalid remote object");
  42.       } else {
  43.          var1.writeUTF(this.ref.getRefClass(var1));
  44.          this.ref.writeExternal(var1);
  45.       }
  46.    }
  47.  
  48.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  49.       try {
  50.          Class var2 = Class.forName(RemoteRef.packagePrefix + "." + var1.readUTF());
  51.          this.ref = (RemoteRef)var2.newInstance();
  52.          this.ref.readExternal(var1);
  53.       } catch (InstantiationException var3) {
  54.          throw new UnmarshalException("Unable to create remote reference", var3);
  55.       } catch (IllegalAccessException var4) {
  56.          throw new UnmarshalException("Illegal access creating remote reference");
  57.       }
  58.    }
  59. }
  60.