home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 November / PCO1197.ISO / FilesBBS / WIN95 / NET_COM / N32E403.EXE / nav40l.z / java40.jar / netscape / security / PrivilegeTable.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-09-04  |  3.0 KB  |  128 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.  
  16.    public int size() {
  17.       return this.itsTable != null ? this.itsTable.size() : 0;
  18.    }
  19.  
  20.    public boolean isEmpty() {
  21.       return this.itsTable == null ? true : this.itsTable.isEmpty();
  22.    }
  23.  
  24.    public Enumeration keys() {
  25.       return this.itsTable == null ? theEmptyTable.keys() : this.itsTable.keys();
  26.    }
  27.  
  28.    public Enumeration elements() {
  29.       return this.itsTable == null ? theEmptyTable.elements() : this.itsTable.elements();
  30.    }
  31.  
  32.    public String toString() {
  33.       StringBuffer var1 = new StringBuffer();
  34.       if (this.itsTable == null) {
  35.          return "Empty Table";
  36.       } else {
  37.          Hashtable var2 = this.itsTable;
  38.          synchronized(var2){}
  39.  
  40.          try {
  41.             Enumeration var4 = this.keys();
  42.  
  43.             while(var4.hasMoreElements()) {
  44.                Object var5 = var4.nextElement();
  45.                var1.append(var5.toString());
  46.                var1.append(" ");
  47.                var1.append(this.get(var5).toString());
  48.                var1.append("\n");
  49.             }
  50.          } catch (Throwable var7) {
  51.             throw var7;
  52.          }
  53.  
  54.          return var1.toString();
  55.       }
  56.    }
  57.  
  58.    public Privilege get(Object var1) {
  59.       if (this.itsTable == null) {
  60.          return Privilege.findPrivilege(2, 1);
  61.       } else {
  62.          Privilege var2 = (Privilege)this.itsTable.get(var1);
  63.          return var2 == null ? Privilege.findPrivilege(2, 1) : var2;
  64.       }
  65.    }
  66.  
  67.    public Privilege get(Target var1) {
  68.       return this.get((Object)var1);
  69.    }
  70.  
  71.    public synchronized Privilege put(Object var1, Privilege var2) {
  72.       if (this.itsTable == null) {
  73.          this.itsTable = new Hashtable();
  74.       }
  75.  
  76.       return (Privilege)this.itsTable.put(var1, var2);
  77.    }
  78.  
  79.    public synchronized Privilege put(Target var1, Privilege var2) {
  80.       return this.put((Object)var1, var2);
  81.    }
  82.  
  83.    public synchronized Privilege remove(Object var1) {
  84.       return this.itsTable == null ? (Privilege)theEmptyTable.remove(var1) : (Privilege)this.itsTable.remove(var1);
  85.    }
  86.  
  87.    public synchronized Privilege remove(Target var1) {
  88.       return this.itsTable == null ? (Privilege)theEmptyTable.remove(var1) : (Privilege)this.itsTable.remove(var1);
  89.    }
  90.  
  91.    public synchronized void clear() {
  92.       if (this.itsTable != null) {
  93.          this.itsTable.clear();
  94.       }
  95.  
  96.    }
  97.  
  98.    public Object clone() {
  99.       PrivilegeTable var1 = new PrivilegeTable();
  100.       if (this.itsTable == null) {
  101.          var1.itsTable = null;
  102.       } else {
  103.          var1.itsTable = (Hashtable)this.itsTable.clone();
  104.       }
  105.  
  106.       return var1;
  107.    }
  108.  
  109.    public void describeClassInfo(ClassInfo var1) {
  110.       var1.addClass("PrivilegeTable", 1);
  111.       var1.addField("Table", (byte)18);
  112.    }
  113.  
  114.    public void encode(Encoder var1) throws CodingException {
  115.       var1.encodeObject("Table", this.itsTable);
  116.    }
  117.  
  118.    public void decode(Decoder var1) throws CodingException {
  119.       PrivilegeManager var2 = PrivilegeManager.getPrivilegeManager();
  120.       if (var2 == null || !var2.isSecurityInited()) {
  121.          this.itsTable = (Hashtable)var1.decodeObject("Table");
  122.       }
  123.    }
  124.  
  125.    public void finishDecoding() throws CodingException {
  126.    }
  127. }
  128.