home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / netscape / constructor / TargetProxy.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  4.0 KB  |  133 lines

  1. package netscape.constructor;
  2.  
  3. import netscape.application.Target;
  4. import netscape.util.ClassInfo;
  5. import netscape.util.Codable;
  6. import netscape.util.CodingException;
  7. import netscape.util.Decoder;
  8. import netscape.util.Encoder;
  9. import netscape.util.Vector;
  10.  
  11. public class TargetProxy implements Target, Codable {
  12.    Vector commands;
  13.    TargetProxyManager manager;
  14.    String name;
  15.    int type;
  16.    Target _realTarget;
  17.    static final String COMMANDS_VECTOR_KEY = "commands";
  18.    static final String TP_MANAGER_KEY = "manager";
  19.    static final String NAME_KEY = "name";
  20.    static final String TYPE_KEY = "type";
  21.    public static final int APPLICATION_TYPE = 0;
  22.    public static final int TARGET_CHAIN_TYPE = 1;
  23.    public static final int CUSTOM_TYPE = 2;
  24.  
  25.    public TargetProxy() {
  26.       this.type = 2;
  27.    }
  28.  
  29.    public TargetProxy(TargetProxyManager var1) {
  30.       this.setTargetProxyManager(var1);
  31.       this.type = 2;
  32.    }
  33.  
  34.    public Vector commands() {
  35.       if (this.commands == null) {
  36.          this.commands = new Vector();
  37.       }
  38.  
  39.       return this.commands;
  40.    }
  41.  
  42.    public void setCommands(Vector var1) {
  43.       this.commands = var1;
  44.    }
  45.  
  46.    public TargetProxyManager targetProxyManager() {
  47.       return this.manager;
  48.    }
  49.  
  50.    public void setTargetProxyManager(TargetProxyManager var1) {
  51.       this.manager = var1;
  52.    }
  53.  
  54.    public String name() {
  55.       return this.name;
  56.    }
  57.  
  58.    public void setName(String var1) {
  59.       if (this.type == 0) {
  60.          this.name = "__APPLICATION__";
  61.       } else if (this.type == 1) {
  62.          this.name = "__TARGETCHAIN__";
  63.       } else {
  64.          this.name = var1;
  65.       }
  66.    }
  67.  
  68.    public int type() {
  69.       return this.type;
  70.    }
  71.  
  72.    public void setType(int var1) {
  73.       this.type = var1;
  74.       if (this.type == 0) {
  75.          this.setName("__APPLICATION__");
  76.       } else {
  77.          if (this.type == 1) {
  78.             this.setName("__TARGETCHAIN__");
  79.          }
  80.  
  81.       }
  82.    }
  83.  
  84.    public void performCommand(String var1, Object var2) {
  85.       System.err.println(this + " named: " + this.name + "\n  performCommand( " + var1 + " ,\n                  " + var2 + " )");
  86.    }
  87.  
  88.    public void describeClassInfo(ClassInfo var1) {
  89.       var1.addClass("netscape.constructor.TargetProxy", 2);
  90.       var1.addField("name", (byte)16);
  91.       var1.addField("manager", (byte)18);
  92.       var1.addField("commands", (byte)18);
  93.       var1.addField("type", (byte)8);
  94.    }
  95.  
  96.    public void encode(Encoder var1) throws CodingException {
  97.       var1.encodeString("name", this.name);
  98.       var1.encodeObject("manager", this.manager);
  99.       var1.encodeObject("commands", this.commands);
  100.       var1.encodeInt("type", this.type);
  101.    }
  102.  
  103.    public void decode(Decoder var1) throws CodingException {
  104.       this.setName(var1.decodeString("name"));
  105.       this.setTargetProxyManager((TargetProxyManager)var1.decodeObject("manager"));
  106.       if (this.targetProxyManager() != null) {
  107.          this._realTarget = this.manager.targetNamed(this.name);
  108.          if (this._realTarget != null) {
  109.             var1.replaceObject(this._realTarget);
  110.             return;
  111.          }
  112.       }
  113.  
  114.       this.setCommands((Vector)var1.decodeObject("commands"));
  115.       if (var1.versionForClassName("netscape.constructor.TargetProxy") > 1) {
  116.          this.setType(var1.decodeInt("type"));
  117.       } else {
  118.          this.setType(2);
  119.       }
  120.    }
  121.  
  122.    public void finishDecoding() throws CodingException {
  123.       if (this._realTarget != null) {
  124.          this.setAttributesToReplacingTarget(this._realTarget);
  125.       }
  126.  
  127.       this._realTarget = null;
  128.    }
  129.  
  130.    public void setAttributesToReplacingTarget(Target var1) {
  131.    }
  132. }
  133.