package run;
import java.util.Vector;

import jp.lang.RemoteObject;

import jp.lang.RMICompatibility;

import uka.karmi.rmi.RemoteException;

import uka.karmi.rmi.server.ReplicatedObject;

public class RplVector extends ReplicatedObject implements uka.patch.Patchable, uka.transport.Transportable {
   public void createPatch(Object _copy, uka.patch.PatchOutput po) throws java.io.IOException {
      RplVector copy = (RplVector)_copy;
      super.createPatch(copy, po);
      copy.v = this.v = (java.util.Vector)po.writeDiff(this.v, copy.v);
   }
   public void applyPatch(Object _copy, uka.patch.PatchInput pi) throws java.io.IOException, ClassNotFoundException {
      RplVector copy = (RplVector)_copy;
      super.applyPatch(copy, pi);
      if (pi.hasDiff()) copy.v = this.v = (java.util.Vector)pi.getDiffAsObject();
   }
   public void descendReferences(uka.patch.ReferenceConsumer c) throws java.io.IOException {
      super.descendReferences(c);
      c.descend(this.v);
   }
   public void filterReferences(uka.patch.ReferenceFilter f) {
      super.filterReferences(f);
      this.v = (java.util.Vector)f.filter(this.v);
   }
   public static final uka.transport.TransportDescriptor TRANSPORT_DESCRIPTOR = new uka.transport.TransportDescriptor(){
      public Object unmarshalReference(uka.transport.UnmarshalStream s, int id) throws java.io.IOException, ClassNotFoundException {
         return new RplVector(s, id);
      }
      public boolean unmarshal(Object obj, uka.transport.UnmarshalStream s) throws ClassNotFoundException, java.io.IOException {
         ((RplVector)obj).unmarshal(s);
         return false;
      }
      public void marshalReference(Object obj, uka.transport.MarshalStream s) throws java.io.IOException {
         ((RplVector)obj).marshalReference(s);
      }
      public void marshal(Object obj, uka.transport.MarshalStream s) throws java.io.IOException {
         ((RplVector)obj).marshal(s);
      }
      public Object deepClone(Object orig, int id, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
         try {
            return new RplVector((RplVector)orig, id, _helper);
         }  catch (java.io.IOException ex) {
            throw (CloneNotSupportedException)new CloneNotSupportedException().initCause(ex);
         }
      }
      public boolean deepCloneReferences(Object orig, Object copy, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
         ((RplVector)copy).deepCloneReferences((RplVector)orig, _helper);
         return false;
      }
      public Class getType() {
         return RplVector.class;
      }
   };
   public uka.transport.TransportDescriptor getTransportDescriptor() {
      return TRANSPORT_DESCRIPTOR;
   }
   public RplVector(uka.transport.UnmarshalStream _stream, int _id) throws java.io.IOException, ClassNotFoundException {
      super(_stream, _id);
   }
   public void unmarshal(uka.transport.UnmarshalStream _stream) throws java.io.IOException, ClassNotFoundException {
      super.unmarshal(_stream);
      this.v = (java.util.Vector)_stream.readReference();
   }
   public void marshal(uka.transport.MarshalStream _stream) throws java.io.IOException {
      super.marshal(_stream);
      _stream.writeReference(this.v);
   }
   public RplVector(RplVector _orig, int _id, uka.transport.DeepClone _helper) throws CloneNotSupportedException, java.io.IOException {
      super(_orig, _id, _helper);
   }
   public void deepCloneReferences(RplVector _orig, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
      super.deepCloneReferences(_orig, _helper);
      this.v = (java.util.Vector)_helper.internalDeepClone(_orig.v);
   }
   private Vector v;
   public RplVector(RemoteObject[] cluster_nodes) throws RemoteException {
      super(RMICompatibility.getStubs(cluster_nodes));
      run.RplVector.this.v = new Vector();
   }
   public RplVector(int number_of_elements) throws RemoteException {
      super(null);
      run.RplVector.this.v = new Vector(number_of_elements);
   }
   public boolean add(Object arg0) {
      return run.RplVector.this.v.add(arg0);
   }
   public Object elementAt(int arg0) {
      return run.RplVector.this.v.elementAt(arg0);
   }
   public Object firstElement() {
      return run.RplVector.this.v.firstElement();
   }
   public int indexOf(Object arg0) {
      return run.RplVector.this.v.indexOf(arg0);
   }
   public Object lastElement() {
      return run.RplVector.this.v.lastElement();
   }
   public boolean remove(Object arg0) {
      return run.RplVector.this.v.remove(arg0);
   }
   public void removeElementAt(int arg0) {
      run.RplVector.this.v.removeElementAt(arg0);
   }
   public int size() {
      return run.RplVector.this.v.size();
   }
   public void addElement(Object arg0) {
      run.RplVector.this.v.addElement(arg0);
   }
   public void insertElementAt(Object arg0, int arg1) {
      run.RplVector.this.v.insertElementAt(arg0, arg1);
   }
}
