home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / netscape / application / TextViewHTMLContainer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  4.0 KB  |  199 lines

  1. package netscape.application;
  2.  
  3. import netscape.util.Hashtable;
  4. import netscape.util.Vector;
  5.  
  6. public abstract class TextViewHTMLContainer extends TextViewHTMLElement {
  7.    String marker;
  8.    String attributes;
  9.    Object[] children = new Object[0];
  10.    String prefix;
  11.    String suffix;
  12.    int[] lengths;
  13.  
  14.    public String prefix(Hashtable var1, char var2) {
  15.       return "";
  16.    }
  17.  
  18.    public String suffix(Hashtable var1, char var2) {
  19.       return "";
  20.    }
  21.  
  22.    public void setupContext(Hashtable var1) {
  23.    }
  24.  
  25.    public void cleanupContext(Hashtable var1) {
  26.    }
  27.  
  28.    public Hashtable attributesForPrefix(Hashtable var1, Hashtable var2, TextView var3) {
  29.       return var2;
  30.    }
  31.  
  32.    public Hashtable attributesForContents(Hashtable var1, Hashtable var2, TextView var3) {
  33.       return var2;
  34.    }
  35.  
  36.    public Hashtable attributesForSuffix(Hashtable var1, Hashtable var2, TextView var3) {
  37.       return var2;
  38.    }
  39.  
  40.    public String string(Hashtable var1) {
  41.       FastStringBuffer var2 = new FastStringBuffer();
  42.       int var5 = 0;
  43.       if (this.children.length > 0) {
  44.          this.lengths = new int[this.children.length];
  45.       }
  46.  
  47.       int var3 = 0;
  48.  
  49.       for(int var4 = this.children.length; var3 < var4; ++var3) {
  50.          ((TextViewHTMLElement)this.children[var3]).appendString(var1, var2);
  51.          if (var3 == 0) {
  52.             this.lengths[var3] = var2.length();
  53.             var5 = this.lengths[var3];
  54.          } else {
  55.             this.lengths[var3] = var2.length() - var5;
  56.             var5 += this.lengths[var3];
  57.          }
  58.       }
  59.  
  60.       return var2.toString();
  61.    }
  62.  
  63.    public Object[] children() {
  64.       return this.children;
  65.    }
  66.  
  67.    public Vector childrenVector() {
  68.       Vector var1 = new Vector();
  69.  
  70.       for(int var2 = 0; var2 < this.children.length; ++var2) {
  71.          var1.addElement(this.children[var2]);
  72.       }
  73.  
  74.       return var1;
  75.    }
  76.  
  77.    public String marker() {
  78.       return this.marker;
  79.    }
  80.  
  81.    public Hashtable attributes() {
  82.       return ((TextViewHTMLElement)this).hashtableForHTMLAttributes(this.attributes);
  83.    }
  84.  
  85.    public void setMarker(String var1) {
  86.       this.marker = var1;
  87.    }
  88.  
  89.    public void setAttributes(String var1) {
  90.       this.attributes = var1;
  91.    }
  92.  
  93.    public void setChildren(Object[] var1) {
  94.       if (var1 == null) {
  95.          this.children = new Object[0];
  96.       } else {
  97.          this.children = var1;
  98.       }
  99.    }
  100.  
  101.    void appendString(Hashtable var1, FastStringBuffer var2) {
  102.       char var3 = 0;
  103.       if (var2.length() > 0) {
  104.          var3 = var2.charAt(var2.length() - 1);
  105.       }
  106.  
  107.       this.prefix = this.prefix(var1, var3);
  108.       if (this.prefix != null && this.prefix.length() > 0) {
  109.          var2.append(this.prefix);
  110.       }
  111.  
  112.       if (this.children != null) {
  113.          this.setupContext(var1);
  114.          var2.append(this.string(var1));
  115.          this.cleanupContext(var1);
  116.       }
  117.  
  118.       if (var2.length() > 0) {
  119.          var3 = var2.charAt(var2.length() - 1);
  120.       }
  121.  
  122.       this.suffix = this.suffix(var1, var3);
  123.       if (this.suffix != null && this.suffix.length() > 0) {
  124.          var2.append(this.suffix);
  125.       }
  126.  
  127.    }
  128.  
  129.    void setAttributesStartingAt(int var1, Hashtable var2, TextView var3, Hashtable var4) {
  130.       int var7 = 0;
  131.       Object var8 = null;
  132.       if (this.prefix != null && this.prefix.length() > 0) {
  133.          Hashtable var10 = this.attributesForPrefix(var4, var2, var3);
  134.          if (var10 != var2) {
  135.             var3.addAttributesForRange(var10, new Range(var1, this.prefix.length()));
  136.          }
  137.  
  138.          var7 += this.prefix.length();
  139.       }
  140.  
  141.       if (this.appliesAttributesToChildren()) {
  142.          if (this.children != null && this.children.length > 0 && this.lengths != null) {
  143.             Hashtable var12 = this.attributesForContents(var4, var2, var3);
  144.             this.setupContext(var4);
  145.             int var5 = 0;
  146.  
  147.             for(int var6 = this.children.length; var5 < var6; ++var5) {
  148.                ((TextViewHTMLElement)this.children[var5]).setAttributesStartingAt(var1 + var7, var12, var3, var4);
  149.                if (this.lengths != null) {
  150.                   var7 += this.lengths[var5];
  151.                } else {
  152.                   var7 += ((TextViewHTMLElement)this.children[var5]).string(var4).length();
  153.                }
  154.             }
  155.  
  156.             this.cleanupContext(var4);
  157.          } else {
  158.             Range var9 = TextView.allocateRange(var1 + var7, 0);
  159.             Hashtable var11 = this.attributesForContents(var4, var2, var3);
  160.             var3.addAttributesForRange(var11, var9);
  161.             TextView.recycleRange(var9);
  162.          }
  163.       } else {
  164.          Hashtable var13 = this.attributesForContents(var4, var2, var3);
  165.          if (var13 != var2) {
  166.             var3.addAttributesForRange(var13, new Range(var1 + var7, this.string(var4).length()));
  167.          }
  168.       }
  169.  
  170.       if (this.suffix != null && this.suffix.length() > 0) {
  171.          Hashtable var14 = this.attributesForPrefix(var4, var2, var3);
  172.          if (var14 != var2) {
  173.             var3.addAttributesForRange(var14, new Range(var1 + var7, this.suffix.length()));
  174.          }
  175.  
  176.          int var10000 = var7 + this.suffix.length();
  177.       }
  178.  
  179.    }
  180.  
  181.    public boolean appliesAttributesToChildren() {
  182.       return true;
  183.    }
  184.  
  185.    public void setString(String var1) {
  186.    }
  187.  
  188.    public String toString() {
  189.       StringBuffer var1 = new StringBuffer();
  190.       var1.append(this.marker + this.attributes);
  191.  
  192.       for(int var2 = 0; var2 < this.children.length; ++var2) {
  193.          var1.append(this.children[var2].toString());
  194.       }
  195.  
  196.       return var1.toString();
  197.    }
  198. }
  199.