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 / CompositeName.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  4.3 KB  |  153 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 CompositeName implements Name {
  11.    private transient NameImpl impl;
  12.    private static Properties compositeSyntax = new Properties();
  13.  
  14.    protected CompositeName(Enumeration var1) {
  15.       this.impl = new NameImpl(compositeSyntax, var1);
  16.    }
  17.  
  18.    public CompositeName(String var1) throws InvalidNameException {
  19.       this.impl = new NameImpl(compositeSyntax, var1);
  20.    }
  21.  
  22.    public CompositeName() {
  23.       this.impl = new NameImpl(compositeSyntax);
  24.    }
  25.  
  26.    public String toString() {
  27.       return this.impl.toString();
  28.    }
  29.  
  30.    public boolean equals(Object var1) {
  31.       return var1 != null && var1 instanceof CompositeName && this.impl.equals(((CompositeName)var1).impl);
  32.    }
  33.  
  34.    public int hashCode() {
  35.       return this.impl.hashCode();
  36.    }
  37.  
  38.    public int compareTo(Object var1) {
  39.       if (!(var1 instanceof CompositeName)) {
  40.          throw new ClassCastException("Not a CompositeName");
  41.       } else {
  42.          return this.impl.compareTo(((CompositeName)var1).impl);
  43.       }
  44.    }
  45.  
  46.    public Object clone() {
  47.       return new CompositeName(this.getAll());
  48.    }
  49.  
  50.    public int size() {
  51.       return this.impl.size();
  52.    }
  53.  
  54.    public boolean isEmpty() {
  55.       return this.impl.isEmpty();
  56.    }
  57.  
  58.    public Enumeration getAll() {
  59.       return this.impl.getAll();
  60.    }
  61.  
  62.    public String get(int var1) {
  63.       return this.impl.get(var1);
  64.    }
  65.  
  66.    public Name getPrefix(int var1) {
  67.       Enumeration var2 = this.impl.getPrefix(var1);
  68.       return new CompositeName(var2);
  69.    }
  70.  
  71.    public Name getSuffix(int var1) {
  72.       Enumeration var2 = this.impl.getSuffix(var1);
  73.       return new CompositeName(var2);
  74.    }
  75.  
  76.    public boolean startsWith(Name var1) {
  77.       return var1 instanceof CompositeName ? this.impl.startsWith(var1.size(), var1.getAll()) : false;
  78.    }
  79.  
  80.    public boolean endsWith(Name var1) {
  81.       return var1 instanceof CompositeName ? this.impl.endsWith(var1.size(), var1.getAll()) : false;
  82.    }
  83.  
  84.    public Name addAll(Name var1) throws InvalidNameException {
  85.       if (var1 instanceof CompositeName) {
  86.          this.impl.addAll(var1.getAll());
  87.          return this;
  88.       } else {
  89.          throw new InvalidNameException("Not a composite name: " + var1.toString());
  90.       }
  91.    }
  92.  
  93.    public Name addAll(int var1, Name var2) throws InvalidNameException {
  94.       if (var2 instanceof CompositeName) {
  95.          this.impl.addAll(var1, var2.getAll());
  96.          return this;
  97.       } else {
  98.          throw new InvalidNameException("Not a composite name: " + var2.toString());
  99.       }
  100.    }
  101.  
  102.    public Name add(String var1) throws InvalidNameException {
  103.       this.impl.add(var1);
  104.       return this;
  105.    }
  106.  
  107.    public Name add(int var1, String var2) throws InvalidNameException {
  108.       this.impl.add(var1, var2);
  109.       return this;
  110.    }
  111.  
  112.    public Object remove(int var1) throws InvalidNameException {
  113.       return this.impl.remove(var1);
  114.    }
  115.  
  116.    private void writeObject(ObjectOutputStream var1) throws IOException {
  117.       var1.writeInt(this.size());
  118.       Enumeration var2 = this.getAll();
  119.  
  120.       while(var2.hasMoreElements()) {
  121.          var1.writeObject(var2.nextElement());
  122.       }
  123.  
  124.    }
  125.  
  126.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  127.       this.impl = new NameImpl(compositeSyntax);
  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.    static {
  145.       compositeSyntax.put("jndi.syntax.direction", "left_to_right");
  146.       compositeSyntax.put("jndi.syntax.separator", "/");
  147.       compositeSyntax.put("jndi.syntax.ignorecase", "false");
  148.       compositeSyntax.put("jndi.syntax.escape", "\\");
  149.       compositeSyntax.put("jndi.syntax.beginquote", "\"");
  150.       compositeSyntax.put("jndi.syntax.beginquote2", "'");
  151.    }
  152. }
  153.