home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / rmi / server / RemoteObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.7 KB  |  88 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.NoSuchObjectException;
  9. import java.rmi.Remote;
  10. import java.rmi.UnmarshalException;
  11. import sun.rmi.transport.ObjectTable;
  12.  
  13. public abstract class RemoteObject implements Remote, Serializable {
  14.    protected transient RemoteRef ref;
  15.    private static final long serialVersionUID = -3215090123894869218L;
  16.  
  17.    protected RemoteObject() {
  18.       this.ref = null;
  19.    }
  20.  
  21.    protected RemoteObject(RemoteRef var1) {
  22.       this.ref = var1;
  23.    }
  24.  
  25.    public RemoteRef getRef() {
  26.       return this.ref;
  27.    }
  28.  
  29.    public static Remote toStub(Remote var0) throws NoSuchObjectException {
  30.       return var0 instanceof RemoteStub ? (RemoteStub)var0 : ObjectTable.getStub(var0);
  31.    }
  32.  
  33.    public int hashCode() {
  34.       return this.ref == null ? super.hashCode() : this.ref.remoteHashCode();
  35.    }
  36.  
  37.    public boolean equals(Object var1) {
  38.       if (var1 instanceof RemoteObject) {
  39.          if (this.ref == null) {
  40.             return var1 == this;
  41.          } else {
  42.             return this.ref.remoteEquals(((RemoteObject)var1).ref);
  43.          }
  44.       } else {
  45.          return var1 != null ? var1.equals(this) : false;
  46.       }
  47.    }
  48.  
  49.    public String toString() {
  50.       String var1 = this.getClass().getName();
  51.       return this.ref == null ? var1 : var1 + "[" + this.ref.remoteToString() + "]";
  52.    }
  53.  
  54.    private void writeObject(ObjectOutputStream var1) throws IOException, ClassNotFoundException {
  55.       if (this.ref == null) {
  56.          throw new MarshalException("Invalid remote object");
  57.       } else {
  58.          String var2 = this.ref.getRefClass(var1);
  59.          if (var2 != null && var2.length() != 0) {
  60.             var1.writeUTF(var2);
  61.             this.ref.writeExternal(var1);
  62.          } else {
  63.             var1.writeUTF("");
  64.             var1.writeObject(this.ref);
  65.          }
  66.  
  67.       }
  68.    }
  69.  
  70.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  71.       try {
  72.          String var2 = var1.readUTF();
  73.          if (var2 != null && var2.length() != 0) {
  74.             Class var3 = Class.forName("sun.rmi.server." + var2);
  75.             this.ref = (RemoteRef)var3.newInstance();
  76.             this.ref.readExternal(var1);
  77.          } else {
  78.             this.ref = (RemoteRef)var1.readObject();
  79.          }
  80.  
  81.       } catch (InstantiationException var4) {
  82.          throw new UnmarshalException("Unable to create remote reference", var4);
  83.       } catch (IllegalAccessException var5) {
  84.          throw new UnmarshalException("Illegal access creating remote reference");
  85.       }
  86.    }
  87. }
  88.