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 / swing / text / StyleContext$SmallAttributeSet.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.8 KB  |  166 lines

  1. package javax.swing.text;
  2.  
  3. import java.util.Enumeration;
  4.  
  5. public class StyleContext$SmallAttributeSet implements AttributeSet {
  6.    Object[] attributes;
  7.    int nrefs;
  8.    AttributeSet resolveParent;
  9.    // $FF: synthetic field
  10.    private final StyleContext this$0;
  11.  
  12.    public StyleContext$SmallAttributeSet(StyleContext var1, Object[] var2) {
  13.       this.this$0 = var1;
  14.       this.attributes = var2;
  15.       this.updateResolveParent();
  16.    }
  17.  
  18.    public StyleContext$SmallAttributeSet(StyleContext var1, AttributeSet var2) {
  19.       this.this$0 = var1;
  20.       int var3 = var2.getAttributeCount();
  21.       Object[] var4 = new Object[2 * var3];
  22.       Enumeration var5 = var2.getAttributeNames();
  23.  
  24.       for(int var6 = 0; var5.hasMoreElements(); var6 += 2) {
  25.          var4[var6] = var5.nextElement();
  26.          var4[var6 + 1] = var2.getAttribute(var4[var6]);
  27.       }
  28.  
  29.       this.attributes = var4;
  30.       this.updateResolveParent();
  31.    }
  32.  
  33.    private void updateResolveParent() {
  34.       this.resolveParent = null;
  35.       Object[] var1 = this.attributes;
  36.  
  37.       for(int var2 = 0; var2 < var1.length; var2 += 2) {
  38.          if (var1[var2] == StyleConstants.ResolveAttribute) {
  39.             this.resolveParent = (AttributeSet)var1[var2 + 1];
  40.             break;
  41.          }
  42.       }
  43.  
  44.    }
  45.  
  46.    Object getLocalAttribute(Object var1) {
  47.       if (var1 == StyleConstants.ResolveAttribute) {
  48.          return this.resolveParent;
  49.       } else {
  50.          Object[] var2 = this.attributes;
  51.  
  52.          for(int var3 = 0; var3 < var2.length; var3 += 2) {
  53.             if (var1.equals(var2[var3])) {
  54.                return var2[var3 + 1];
  55.             }
  56.          }
  57.  
  58.          return null;
  59.       }
  60.    }
  61.  
  62.    public String toString() {
  63.       String var1 = "{";
  64.       Object[] var2 = this.attributes;
  65.  
  66.       for(int var3 = 0; var3 < var2.length; var3 += 2) {
  67.          if (var2[var3 + 1] instanceof AttributeSet) {
  68.             var1 = var1 + var2[var3] + "=" + "AttributeSet" + ",";
  69.          } else {
  70.             var1 = var1 + var2[var3] + "=" + var2[var3 + 1] + ",";
  71.          }
  72.       }
  73.  
  74.       var1 = var1 + "nrefs=" + this.nrefs + "}";
  75.       return var1;
  76.    }
  77.  
  78.    public int hashCode() {
  79.       int var1 = 0;
  80.       Object[] var2 = this.attributes;
  81.  
  82.       for(int var3 = 1; var3 < var2.length; var3 += 2) {
  83.          var1 ^= var2[var3].hashCode();
  84.       }
  85.  
  86.       return var1;
  87.    }
  88.  
  89.    public boolean equals(Object var1) {
  90.       if (!(var1 instanceof AttributeSet)) {
  91.          return false;
  92.       } else {
  93.          AttributeSet var2 = (AttributeSet)var1;
  94.          return this.getAttributeCount() == var2.getAttributeCount() && this.containsAttributes(var2);
  95.       }
  96.    }
  97.  
  98.    public Object clone() {
  99.       return this;
  100.    }
  101.  
  102.    public int getAttributeCount() {
  103.       return this.attributes.length / 2;
  104.    }
  105.  
  106.    public boolean isDefined(Object var1) {
  107.       Object[] var2 = this.attributes;
  108.       int var3 = var2.length;
  109.  
  110.       for(int var4 = 0; var4 < var3; var4 += 2) {
  111.          if (var1.equals(var2[var4])) {
  112.             return true;
  113.          }
  114.       }
  115.  
  116.       return false;
  117.    }
  118.  
  119.    public boolean isEqual(AttributeSet var1) {
  120.       if (var1 instanceof StyleContext$SmallAttributeSet) {
  121.          return var1 == this;
  122.       } else {
  123.          return this.getAttributeCount() == var1.getAttributeCount() && this.containsAttributes(var1);
  124.       }
  125.    }
  126.  
  127.    public AttributeSet copyAttributes() {
  128.       return this;
  129.    }
  130.  
  131.    public Object getAttribute(Object var1) {
  132.       Object var2 = this.getLocalAttribute(var1);
  133.       if (var2 == null) {
  134.          AttributeSet var3 = this.getResolveParent();
  135.          if (var3 != null) {
  136.             var2 = var3.getAttribute(var1);
  137.          }
  138.       }
  139.  
  140.       return var2;
  141.    }
  142.  
  143.    public Enumeration getAttributeNames() {
  144.       return new StyleContext.KeyEnumeration(this.this$0, this.attributes);
  145.    }
  146.  
  147.    public boolean containsAttribute(Object var1, Object var2) {
  148.       return var2.equals(this.getAttribute(var1));
  149.    }
  150.  
  151.    public boolean containsAttributes(AttributeSet var1) {
  152.       boolean var2 = true;
  153.  
  154.       Object var4;
  155.       for(Enumeration var3 = var1.getAttributeNames(); var2 && var3.hasMoreElements(); var2 = var1.getAttribute(var4).equals(this.getAttribute(var4))) {
  156.          var4 = var3.nextElement();
  157.       }
  158.  
  159.       return var2;
  160.    }
  161.  
  162.    public AttributeSet getResolveParent() {
  163.       return this.resolveParent;
  164.    }
  165. }
  166.