home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Premium Edition) / mycd.iso / INTERNET / NETSCAP4.06 / CP32E406.EXE / nav40.z / java40.jar / netscape / security / PrivilegeTable.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-08-13  |  3.3 KB  |  129 lines

  1. package netscape.security;
  2.  
  3. import netscape.util.ClassInfo;
  4. import netscape.util.Codable;
  5. import netscape.util.CodingException;
  6. import netscape.util.Decoder;
  7. import netscape.util.Encoder;
  8. import netscape.util.Enumeration;
  9. import netscape.util.Hashtable;
  10.  
  11. public class PrivilegeTable implements Cloneable, Codable {
  12.    static final int VERSION = 1;
  13.    private Hashtable itsTable = null;
  14.    private static Hashtable theEmptyTable = new Hashtable();
  15.    private boolean itsInited = false;
  16.  
  17.    public int size() {
  18.       return this.itsTable != null ? this.itsTable.size() : 0;
  19.    }
  20.  
  21.    public boolean isEmpty() {
  22.       return this.itsTable == null ? true : this.itsTable.isEmpty();
  23.    }
  24.  
  25.    public Enumeration keys() {
  26.       return this.itsTable == null ? theEmptyTable.keys() : this.itsTable.keys();
  27.    }
  28.  
  29.    public Enumeration elements() {
  30.       return this.itsTable == null ? theEmptyTable.elements() : this.itsTable.elements();
  31.    }
  32.  
  33.    public String toString() {
  34.       StringBuffer var1 = new StringBuffer();
  35.       if (this.itsTable == null) {
  36.          return "Empty Table";
  37.       } else {
  38.          Hashtable var2 = this.itsTable;
  39.          synchronized(var2){}
  40.  
  41.          try {
  42.             Enumeration var4 = this.keys();
  43.  
  44.             while(var4.hasMoreElements()) {
  45.                Object var5 = var4.nextElement();
  46.                var1.append(var5.toString());
  47.                var1.append(" ");
  48.                var1.append(this.get(var5).toString());
  49.                var1.append("\n");
  50.             }
  51.          } catch (Throwable var7) {
  52.             throw var7;
  53.          }
  54.  
  55.          return var1.toString();
  56.       }
  57.    }
  58.  
  59.    public Privilege get(Object var1) {
  60.       if (this.itsTable == null) {
  61.          return Privilege.findPrivilege(2, 1);
  62.       } else {
  63.          Privilege var2 = (Privilege)this.itsTable.get(var1);
  64.          return var2 == null ? Privilege.findPrivilege(2, 1) : var2;
  65.       }
  66.    }
  67.  
  68.    public Privilege get(Target var1) {
  69.       return this.get((Object)var1);
  70.    }
  71.  
  72.    public synchronized Privilege put(Object var1, Privilege var2) {
  73.       if (this.itsTable == null) {
  74.          this.itsTable = new Hashtable();
  75.       }
  76.  
  77.       return (Privilege)this.itsTable.put(var1, var2);
  78.    }
  79.  
  80.    public synchronized Privilege put(Target var1, Privilege var2) {
  81.       return this.put((Object)var1, var2);
  82.    }
  83.  
  84.    public synchronized Privilege remove(Object var1) {
  85.       return this.itsTable == null ? (Privilege)theEmptyTable.remove(var1) : (Privilege)this.itsTable.remove(var1);
  86.    }
  87.  
  88.    public synchronized Privilege remove(Target var1) {
  89.       return this.itsTable == null ? (Privilege)theEmptyTable.remove(var1) : (Privilege)this.itsTable.remove(var1);
  90.    }
  91.  
  92.    public synchronized void clear() {
  93.       if (this.itsTable != null) {
  94.          this.itsTable.clear();
  95.       }
  96.  
  97.    }
  98.  
  99.    public Object clone() {
  100.       PrivilegeTable var1 = new PrivilegeTable();
  101.       if (this.itsTable == null) {
  102.          var1.itsTable = null;
  103.       } else {
  104.          var1.itsTable = (Hashtable)this.itsTable.clone();
  105.       }
  106.  
  107.       return var1;
  108.    }
  109.  
  110.    public void describeClassInfo(ClassInfo var1) {
  111.       var1.addClass("PrivilegeTable", 1);
  112.       var1.addField("Table", (byte)18);
  113.    }
  114.  
  115.    public void encode(Encoder var1) throws CodingException {
  116.       var1.encodeObject("Table", this.itsTable);
  117.    }
  118.  
  119.    public void decode(Decoder var1) throws CodingException {
  120.       if (!this.itsInited) {
  121.          this.itsInited = true;
  122.          this.itsTable = (Hashtable)var1.decodeObject("Table");
  123.       }
  124.    }
  125.  
  126.    public void finishDecoding() throws CodingException {
  127.    }
  128. }
  129.