home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / javax / naming / CompoundName.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  3.8 KB  |  144 lines

  1. package javax.naming;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.ObjectOutputStream;
  6. import java.io.StreamCorruptedException;
  7. import java.util.Enumeration;
  8. import java.util.Properties;
  9.  
  10. public class CompoundName implements Name {
  11.    protected transient NameImpl impl;
  12.    protected transient Properties mySyntax;
  13.  
  14.    protected CompoundName(Enumeration var1, Properties var2) {
  15.       this.mySyntax = var2;
  16.       this.impl = new NameImpl(var2, var1);
  17.    }
  18.  
  19.    public CompoundName(String var1, Properties var2) throws InvalidNameException {
  20.       this.mySyntax = var2;
  21.       this.impl = new NameImpl(var2, var1);
  22.    }
  23.  
  24.    public String toString() {
  25.       return this.impl.toString();
  26.    }
  27.  
  28.    public boolean equals(Object var1) {
  29.       return var1 != null && var1 instanceof CompoundName && this.impl.equals(((CompoundName)var1).impl);
  30.    }
  31.  
  32.    public int hashCode() {
  33.       return this.impl.hashCode();
  34.    }
  35.  
  36.    public Object clone() {
  37.       return new CompoundName(this.getAll(), this.mySyntax);
  38.    }
  39.  
  40.    public int compareTo(Object var1) {
  41.       if (!(var1 instanceof CompoundName)) {
  42.          throw new ClassCastException("Not a CompoundName");
  43.       } else {
  44.          return this.impl.compareTo(((CompoundName)var1).impl);
  45.       }
  46.    }
  47.  
  48.    public int size() {
  49.       return this.impl.size();
  50.    }
  51.  
  52.    public boolean isEmpty() {
  53.       return this.impl.isEmpty();
  54.    }
  55.  
  56.    public Enumeration getAll() {
  57.       return this.impl.getAll();
  58.    }
  59.  
  60.    public String get(int var1) {
  61.       return this.impl.get(var1);
  62.    }
  63.  
  64.    public Name getPrefix(int var1) {
  65.       Enumeration var2 = this.impl.getPrefix(var1);
  66.       return new CompoundName(var2, this.mySyntax);
  67.    }
  68.  
  69.    public Name getSuffix(int var1) {
  70.       Enumeration var2 = this.impl.getSuffix(var1);
  71.       return new CompoundName(var2, this.mySyntax);
  72.    }
  73.  
  74.    public boolean startsWith(Name var1) {
  75.       return var1 instanceof CompoundName ? this.impl.startsWith(var1.size(), var1.getAll()) : false;
  76.    }
  77.  
  78.    public boolean endsWith(Name var1) {
  79.       return var1 instanceof CompoundName ? this.impl.endsWith(var1.size(), var1.getAll()) : false;
  80.    }
  81.  
  82.    public Name addAll(Name var1) throws InvalidNameException {
  83.       if (var1 instanceof CompoundName) {
  84.          this.impl.addAll(var1.getAll());
  85.          return this;
  86.       } else {
  87.          throw new InvalidNameException("Not a compound name: " + var1.toString());
  88.       }
  89.    }
  90.  
  91.    public Name addAll(int var1, Name var2) throws InvalidNameException {
  92.       if (var2 instanceof CompoundName) {
  93.          this.impl.addAll(var1, var2.getAll());
  94.          return this;
  95.       } else {
  96.          throw new InvalidNameException("Not a compound name: " + var2.toString());
  97.       }
  98.    }
  99.  
  100.    public Name add(String var1) throws InvalidNameException {
  101.       this.impl.add(var1);
  102.       return this;
  103.    }
  104.  
  105.    public Name add(int var1, String var2) throws InvalidNameException {
  106.       this.impl.add(var1, var2);
  107.       return this;
  108.    }
  109.  
  110.    public Object remove(int var1) throws InvalidNameException {
  111.       return this.impl.remove(var1);
  112.    }
  113.  
  114.    private void writeObject(ObjectOutputStream var1) throws IOException {
  115.       var1.writeObject(this.mySyntax);
  116.       var1.writeInt(this.size());
  117.       Enumeration var2 = this.getAll();
  118.  
  119.       while(var2.hasMoreElements()) {
  120.          var1.writeObject(var2.nextElement());
  121.       }
  122.  
  123.    }
  124.  
  125.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  126.       this.mySyntax = (Properties)var1.readObject();
  127.       this.impl = new NameImpl(this.mySyntax);
  128.       int var2 = var1.readInt();
  129.  
  130.       try {
  131.          while(true) {
  132.             --var2;
  133.             if (var2 < 0) {
  134.                return;
  135.             }
  136.  
  137.             this.add((String)var1.readObject());
  138.          }
  139.       } catch (InvalidNameException var3) {
  140.          throw new StreamCorruptedException("Invalid name");
  141.       }
  142.    }
  143. }
  144.