home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / rmi / server / RemoteObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.5 KB  |  64 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 (var1 instanceof RemoteObject) {
  28.          if (this.ref == null) {
  29.             return var1 == this;
  30.          } else {
  31.             return this.ref.remoteEquals(((RemoteObject)var1).ref);
  32.          }
  33.       } else {
  34.          return var1 != null ? var1.equals(this) : false;
  35.       }
  36.    }
  37.  
  38.    public String toString() {
  39.       String var1 = this.getClass().getName();
  40.       return this.ref == null ? var1 : var1 + "[" + this.ref.remoteToString() + "]";
  41.    }
  42.  
  43.    private void writeObject(ObjectOutputStream var1) throws IOException, ClassNotFoundException {
  44.       if (this.ref == null) {
  45.          throw new MarshalException("Invalid remote object");
  46.       } else {
  47.          var1.writeUTF(this.ref.getRefClass(var1));
  48.          this.ref.writeExternal(var1);
  49.       }
  50.    }
  51.  
  52.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  53.       try {
  54.          Class var2 = Class.forName(RemoteRef.packagePrefix + "." + var1.readUTF());
  55.          this.ref = (RemoteRef)var2.newInstance();
  56.          this.ref.readExternal(var1);
  57.       } catch (InstantiationException var3) {
  58.          throw new UnmarshalException("Unable to create remote reference", var3);
  59.       } catch (IllegalAccessException var4) {
  60.          throw new UnmarshalException("Illegal access creating remote reference");
  61.       }
  62.    }
  63. }
  64.