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