home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / text / html / HTMLDocument$HTMLReader.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  19.7 KB  |  1,049 lines

  1. package com.sun.java.swing.text.html;
  2.  
  3. import com.sun.java.swing.JButton;
  4. import com.sun.java.swing.JCheckBox;
  5. import com.sun.java.swing.JComboBox;
  6. import com.sun.java.swing.JRadioButton;
  7. import com.sun.java.swing.JScrollPane;
  8. import com.sun.java.swing.JTextArea;
  9. import com.sun.java.swing.JTextField;
  10. import com.sun.java.swing.text.AttributeSet;
  11. import com.sun.java.swing.text.BadLocationException;
  12. import com.sun.java.swing.text.DefaultStyledDocument;
  13. import com.sun.java.swing.text.JTextComponent;
  14. import com.sun.java.swing.text.MutableAttributeSet;
  15. import com.sun.java.swing.text.SimpleAttributeSet;
  16. import com.sun.java.swing.text.Style;
  17. import com.sun.java.swing.text.StyleConstants;
  18. import com.sun.java.swing.text.StyleContext;
  19. import java.awt.Color;
  20. import java.awt.Component;
  21. import java.io.IOException;
  22. import java.io.Reader;
  23. import java.net.MalformedURLException;
  24. import java.net.URL;
  25. import java.util.Stack;
  26. import java.util.Vector;
  27.  
  28. class HTMLDocument$HTMLReader extends HTMLParserCallbackDefault {
  29.    // $FF: synthetic field
  30.    private final HTMLDocument this$0;
  31.    boolean openTagSeen;
  32.    boolean inPre;
  33.    boolean inTitle;
  34.    boolean inOption;
  35.    Stack dataCountStack;
  36.    JComboBox combobox;
  37.    Vector parseBuffer;
  38.    MutableAttributeSet charAttr;
  39.    Stack charAttrStack;
  40.    Style resolver;
  41.    Stack styleStack;
  42.    MutableAttributeSet attr;
  43.    int inBlock;
  44.    html32 parser;
  45.    SpecialCharTable specTable;
  46.  
  47.    public void read(int var1, Reader var2) throws IOException {
  48.       this.parser = new html32(var2);
  49.       StyleContext var3 = this.this$0.getStyleContext();
  50.       this.charAttr = var3.addStyle((String)null, (Style)null);
  51.       this.attr = var3.addStyle((String)null, (Style)null);
  52.       this.resolver = this.this$0.getStyle("default-hierarchy");
  53.       String var4 = " ";
  54.       DefaultStyledDocument.ElementSpec var5 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)3, var4.toCharArray(), 0, 1);
  55.       this.parseBuffer.addElement(var5);
  56.       var5 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)2);
  57.       this.parseBuffer.addElement(var5);
  58.       this.parser.setCallback(this);
  59.  
  60.       try {
  61.          this.parser.html();
  62.       } catch (Exception var9) {
  63.          ((Throwable)var9).printStackTrace();
  64.          throw new IOException(((Throwable)var9).toString());
  65.       }
  66.  
  67.       DefaultStyledDocument.ElementSpec[] var6 = new DefaultStyledDocument.ElementSpec[this.parseBuffer.size()];
  68.       this.parseBuffer.copyInto(var6);
  69.  
  70.       try {
  71.          this.this$0.insert(var1, var6);
  72.       } catch (BadLocationException var8) {
  73.          throw new IOException("BadLocationException: " + ((Throwable)var8).getMessage());
  74.       }
  75.    }
  76.  
  77.    public Style getChildStyle(String var1) {
  78.       Style var2 = this.this$0.getStyle("SH" + var1);
  79.       return (Style)var2.getAttribute("child-style");
  80.    }
  81.  
  82.    public void attributeAction(String var1, String var2) {
  83.       if (var2 == null) {
  84.          var2 = "#DEFAULT";
  85.       }
  86.  
  87.       this.attr.addAttribute(var1.toLowerCase(), var2);
  88.    }
  89.  
  90.    private void setAlignment(MutableAttributeSet var1) {
  91.       String var2 = (String)var1.getAttribute("align");
  92.       if (var2 != null) {
  93.          var2 = var2.toLowerCase();
  94.          if (var2.equals("left")) {
  95.             StyleConstants.setAlignment(var1, 0);
  96.             return;
  97.          }
  98.  
  99.          if (var2.equals("center")) {
  100.             StyleConstants.setAlignment(var1, 1);
  101.             return;
  102.          }
  103.  
  104.          if (var2.equals("right")) {
  105.             StyleConstants.setAlignment(var1, 2);
  106.          }
  107.       }
  108.  
  109.    }
  110.  
  111.    public void blockOpenAction(String var1) {
  112.       this.setAlignment(this.attr);
  113.       this.blockOpen(var1, false);
  114.    }
  115.  
  116.    public void blockCloseAction(String var1) {
  117.       this.blockClose();
  118.    }
  119.  
  120.    public void incrementPCData() {
  121.       if (!this.dataCountStack.empty()) {
  122.          HTMLDocument.HTMLReader.DataCounter var1 = (HTMLDocument.HTMLReader.DataCounter)this.dataCountStack.pop();
  123.          var1.incCounter();
  124.          this.dataCountStack.push(var1);
  125.       }
  126.  
  127.    }
  128.  
  129.    public void pcdataAction(String var1) {
  130.       this.incrementPCData();
  131.       String var2 = this.xlateSpecialChars(var1);
  132.       if (var2 != null) {
  133.          var1 = var2;
  134.       }
  135.  
  136.       if (this.inPre) {
  137.          this.preContent(var1);
  138.       } else if (this.inTitle) {
  139.          this.titleContent(var1);
  140.       } else if (this.inOption) {
  141.          var1 = this.cleanString(var1);
  142.          this.combobox.addItem(var1);
  143.       } else if (this.inBlock > 0) {
  144.          var1 = this.cleanString(var1);
  145.          if (var1.length() >= 1) {
  146.             AttributeSet var3 = this.charAttr.copyAttributes();
  147.             DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec(var3, (short)3, var1.toCharArray(), 0, var1.length());
  148.             this.parseBuffer.addElement(var4);
  149.          }
  150.       }
  151.  
  152.       this.attr.removeAttributes(this.attr);
  153.    }
  154.  
  155.    protected void cleanEndTag(boolean var1) {
  156.       DefaultStyledDocument.ElementSpec var2 = (DefaultStyledDocument.ElementSpec)this.parseBuffer.lastElement();
  157.       if (var2 != null) {
  158.          char[] var3 = var2.getArray();
  159.          if (var3 != null) {
  160.             String var4 = new String(var3);
  161.             if (var4.length() != 0) {
  162.                if (this.isWhiteSpace(var4.charAt(var4.length() - 1))) {
  163.                   var4 = var4.substring(0, var4.length() - 1);
  164.                }
  165.  
  166.                if (var1) {
  167.                   var4 = var4 + "\n";
  168.                }
  169.  
  170.                DefaultStyledDocument.ElementSpec var5 = new DefaultStyledDocument.ElementSpec(var2.getAttributes(), (short)3, var4.toCharArray(), 0, var4.length());
  171.                this.parseBuffer.removeElementAt(this.parseBuffer.size() - 1);
  172.                this.parseBuffer.addElement(var5);
  173.             }
  174.          }
  175.       }
  176.    }
  177.  
  178.    protected boolean isWhiteSpace(char var1) {
  179.       return var1 == ' ' || var1 == '\n' || var1 == '\r' || var1 == '\t';
  180.    }
  181.  
  182.    protected String cleanString(String var1) {
  183.       if (var1.length() < 1) {
  184.          return var1;
  185.       } else {
  186.          String var2 = "";
  187.          String var3 = "";
  188.          if (var1.length() > 1 && this.isWhiteSpace(var1.charAt(var1.length() - 1))) {
  189.             var2 = new String(" ");
  190.          }
  191.  
  192.          if (this.isWhiteSpace(var1.charAt(0))) {
  193.             var3 = new String(" ");
  194.          }
  195.  
  196.          String var4 = var3 + var1.trim() + var2;
  197.          if (this.openTagSeen && var3.equals(" ")) {
  198.             var4 = var4.substring(1, var4.length());
  199.          }
  200.  
  201.          this.openTagSeen = false;
  202.          int var5 = 0;
  203.  
  204.          while(var5 < var4.length()) {
  205.             int var6 = var5;
  206.             if (this.isWhiteSpace(var4.charAt(var5))) {
  207.                while(var6 < var4.length() && this.isWhiteSpace(var4.charAt(var6))) {
  208.                   ++var6;
  209.                }
  210.  
  211.                var4 = var4.substring(0, var5) + " " + var4.substring(var6, var4.length());
  212.                var5 = var6;
  213.             } else {
  214.                ++var5;
  215.             }
  216.          }
  217.  
  218.          return var4;
  219.       }
  220.    }
  221.  
  222.    public void fontOpenAction() {
  223.       this.openTagSeen = true;
  224.       this.pushCharacterStyle();
  225.       Color var1 = this.getColor(this.attr);
  226.       if (var1 != null) {
  227.          StyleConstants.setForeground(this.charAttr, var1);
  228.       }
  229.  
  230.       String var2 = (String)this.attr.getAttribute("face");
  231.       if (var2 != null) {
  232.          StyleConstants.setFontFamily(this.charAttr, var2);
  233.       }
  234.  
  235.       String var3 = (String)this.attr.getAttribute("size");
  236.       StyleSheet var4 = StyleReader.getStyleSheet();
  237.       if (var3 != null) {
  238.          StyleConstants.setFontSize(this.charAttr, var4.getPtSize(var3));
  239.       }
  240.  
  241.    }
  242.  
  243.    public void fontCloseAction() {
  244.       this.popCharacterStyle();
  245.    }
  246.  
  247.    public void htmlOpenAction() {
  248.    }
  249.  
  250.    public void htmlCloseAction() {
  251.    }
  252.  
  253.    public void headOpenAction() {
  254.    }
  255.  
  256.    public void headCloseAction() {
  257.    }
  258.  
  259.    public void bodyOpenAction() {
  260.       this.this$0.setRootElementAttributes(this.attr);
  261.    }
  262.  
  263.    public void bodyCloseAction() {
  264.    }
  265.  
  266.    public void whitespaceAction(String var1) {
  267.       this.addContent(var1);
  268.    }
  269.  
  270.    public void titleOpenAction() {
  271.       this.inTitle = true;
  272.    }
  273.  
  274.    public void titleCloseAction() {
  275.       this.inTitle = false;
  276.    }
  277.  
  278.    public void preOpenAction() {
  279.       this.inPre = true;
  280.       this.blockOpen("pre", true);
  281.       this.blockOpen("pre-line", true);
  282.    }
  283.  
  284.    public void preCloseAction() {
  285.       this.inPre = false;
  286.       this.blockClose();
  287.       this.blockClose();
  288.    }
  289.  
  290.    void titleContent(String var1) {
  291.       this.this$0.putProperty("title", var1);
  292.    }
  293.  
  294.    void preContent(String var1) {
  295.       int var2 = 0;
  296.  
  297.       for(int var3 = var1.indexOf(10); var3 >= 0; var3 = var1.indexOf(10, var2)) {
  298.          String var4 = var1.substring(var2, var3);
  299.          this.addContent(var4);
  300.          this.blockClose();
  301.          this.blockOpen("pre-line", true);
  302.          var2 = var3 + 1;
  303.       }
  304.  
  305.       if (var2 < var1.length()) {
  306.          this.addContent(var1.substring(var2, var1.length()));
  307.       }
  308.  
  309.    }
  310.  
  311.    public void ttOpenAction() {
  312.       this.pushCharacterStyle();
  313.       this.attr.addAttribute("tt", "true");
  314.       Style var1 = this.getChildStyle("tt");
  315.       if (var1 != null) {
  316.          this.charAttr.addAttributes(var1);
  317.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  318.       } else {
  319.          StyleConstants.setFontFamily(this.charAttr, "Monospaced");
  320.       }
  321.  
  322.       this.charAttr.addAttributes(this.attr);
  323.    }
  324.  
  325.    public void ttCloseAction() {
  326.       this.popCharacterStyle();
  327.    }
  328.  
  329.    public void dfnOpenAction() {
  330.       this.pushCharacterStyle();
  331.       Style var1 = this.getChildStyle("dfn");
  332.       if (var1 != null) {
  333.          this.charAttr.addAttributes(var1);
  334.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  335.       } else {
  336.          StyleConstants.setItalic(this.charAttr, true);
  337.       }
  338.  
  339.       this.charAttr.addAttributes(this.attr);
  340.    }
  341.  
  342.    public void dfnCloseAction() {
  343.       this.popCharacterStyle();
  344.    }
  345.  
  346.    public void citeOpenAction() {
  347.       this.pushCharacterStyle();
  348.       Style var1 = this.getChildStyle("cite");
  349.       if (var1 != null) {
  350.          this.charAttr.addAttributes(var1);
  351.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  352.       } else {
  353.          StyleConstants.setItalic(this.charAttr, true);
  354.       }
  355.  
  356.       this.charAttr.addAttributes(this.attr);
  357.    }
  358.  
  359.    public void citeCloseAction() {
  360.       this.popCharacterStyle();
  361.    }
  362.  
  363.    public void bigOpenAction() {
  364.       this.pushCharacterStyle();
  365.       Style var1 = this.getChildStyle("big");
  366.       if (var1 != null) {
  367.          this.charAttr.addAttributes(var1);
  368.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  369.       } else {
  370.          String var2 = StyleXlater.convertFontSizeString("x-large");
  371.          StyleSheet var3 = StyleReader.getStyleSheet();
  372.          int var4 = var3.getPtSize(var2);
  373.          StyleConstants.setFontSize(this.charAttr, var4);
  374.       }
  375.    }
  376.  
  377.    public void bigCloseAction() {
  378.       this.popCharacterStyle();
  379.    }
  380.  
  381.    public void smallOpenAction() {
  382.       this.pushCharacterStyle();
  383.       Style var1 = this.getChildStyle("small");
  384.       if (var1 != null) {
  385.          this.charAttr.addAttributes(var1);
  386.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  387.       } else {
  388.          String var2 = StyleXlater.convertFontSizeString("x-small");
  389.          StyleSheet var3 = StyleReader.getStyleSheet();
  390.          int var4 = var3.getPtSize(var2);
  391.          StyleConstants.setFontSize(this.charAttr, var4);
  392.       }
  393.    }
  394.  
  395.    public void smallCloseAction() {
  396.       this.popCharacterStyle();
  397.    }
  398.  
  399.    public void sampOpenAction() {
  400.       this.pushCharacterStyle();
  401.       Style var1 = this.getChildStyle("samp");
  402.       if (var1 != null) {
  403.          this.charAttr.addAttributes(var1);
  404.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  405.       } else {
  406.          String var2 = StyleXlater.convertFontSizeString("small");
  407.          StyleSheet var3 = StyleReader.getStyleSheet();
  408.          int var4 = var3.getPtSize(var2);
  409.          StyleConstants.setFontSize(this.charAttr, var4);
  410.          StyleConstants.setFontFamily(this.charAttr, "Monospaced");
  411.       }
  412.    }
  413.  
  414.    public void sampCloseAction() {
  415.       this.popCharacterStyle();
  416.    }
  417.  
  418.    public void codeOpenAction() {
  419.       this.pushCharacterStyle();
  420.       Style var1 = this.getChildStyle("code");
  421.       if (var1 != null) {
  422.          this.charAttr.addAttributes(var1);
  423.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  424.       } else {
  425.          String var2 = StyleXlater.convertFontSizeString("small");
  426.          StyleSheet var3 = StyleReader.getStyleSheet();
  427.          int var4 = var3.getPtSize(var2);
  428.          StyleConstants.setFontSize(this.charAttr, var4);
  429.          StyleConstants.setFontFamily(this.charAttr, "Monospaced");
  430.       }
  431.    }
  432.  
  433.    public void codeCloseAction() {
  434.       this.popCharacterStyle();
  435.    }
  436.  
  437.    public void strikeOpenAction() {
  438.       this.pushCharacterStyle();
  439.       Style var1 = this.getChildStyle("strike");
  440.       if (var1 != null) {
  441.          this.charAttr.addAttributes(var1);
  442.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  443.       }
  444.  
  445.    }
  446.  
  447.    public void strikeCloseAction() {
  448.       this.popCharacterStyle();
  449.    }
  450.  
  451.    public void blockquoteOpenAction() {
  452.       this.blockOpen("blockquote", false);
  453.    }
  454.  
  455.    public void blockquoteCloseAction() {
  456.       this.blockClose();
  457.    }
  458.  
  459.    public void emOpenAction() {
  460.       this.pushCharacterStyle();
  461.       Style var1 = this.getChildStyle("em");
  462.       if (var1 != null) {
  463.          this.charAttr.addAttributes(var1);
  464.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  465.       } else {
  466.          StyleConstants.setItalic(this.charAttr, true);
  467.       }
  468.  
  469.       this.charAttr.addAttributes(this.attr);
  470.    }
  471.  
  472.    public void emCloseAction() {
  473.       this.popCharacterStyle();
  474.    }
  475.  
  476.    public void addressOpenAction() {
  477.       this.pushCharacterStyle();
  478.       Style var1 = this.getChildStyle("address");
  479.       if (var1 != null) {
  480.          this.charAttr.addAttributes(var1);
  481.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  482.       } else {
  483.          StyleConstants.setItalic(this.charAttr, true);
  484.       }
  485.  
  486.       this.charAttr.addAttributes(this.attr);
  487.    }
  488.  
  489.    public void addressCloseAction() {
  490.       this.popCharacterStyle();
  491.    }
  492.  
  493.    public void strongOpenAction() {
  494.       this.pushCharacterStyle();
  495.       Style var1 = this.getChildStyle("strong");
  496.       if (var1 != null) {
  497.          this.charAttr.addAttributes(var1);
  498.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  499.       } else {
  500.          StyleConstants.setBold(this.charAttr, true);
  501.       }
  502.  
  503.       this.charAttr.addAttributes(this.attr);
  504.    }
  505.  
  506.    public void strongCloseAction() {
  507.       this.popCharacterStyle();
  508.    }
  509.  
  510.    public void varOpenAction() {
  511.       this.pushCharacterStyle();
  512.       Style var1 = this.getChildStyle("_var");
  513.       if (var1 != null) {
  514.          this.charAttr.addAttributes(var1);
  515.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  516.       } else {
  517.          StyleConstants.setBold(this.charAttr, true);
  518.          StyleConstants.setItalic(this.charAttr, true);
  519.       }
  520.  
  521.       this.charAttr.addAttributes(this.attr);
  522.    }
  523.  
  524.    public void varCloseAction() {
  525.       this.popCharacterStyle();
  526.    }
  527.  
  528.    public void basefontAction() {
  529.       this.attr.addAttribute("htmltag", "basefont");
  530.       this.addSpecialElement(this.attr);
  531.    }
  532.  
  533.    public void brAction() {
  534.    }
  535.  
  536.    public void aOpenAction() {
  537.       this.pushCharacterStyle();
  538.       Style var1 = this.getChildStyle("a");
  539.       if (var1 != null) {
  540.          this.charAttr.addAttributes(var1);
  541.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  542.       }
  543.  
  544.       this.charAttr.addAttributes(this.attr);
  545.    }
  546.  
  547.    private void checkPCData() {
  548.       if (!this.dataCountStack.empty()) {
  549.          HTMLDocument.HTMLReader.DataCounter var1 = (HTMLDocument.HTMLReader.DataCounter)this.dataCountStack.peek();
  550.          if (var1.noPCData()) {
  551.             AttributeSet var2 = this.charAttr.copyAttributes();
  552.             String var3 = new String("");
  553.             DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec(var2, (short)3, var3.toCharArray(), 0, var3.length());
  554.             this.parseBuffer.addElement(var4);
  555.          }
  556.       }
  557.  
  558.    }
  559.  
  560.    public void aCloseAction() {
  561.       this.checkPCData();
  562.       this.popCharacterStyle();
  563.    }
  564.  
  565.    public void hrAction() {
  566.       this.setAlignment(this.attr);
  567.       this.attr.addAttribute("$ename", "hr");
  568.       this.addSpecialElement(this.attr);
  569.    }
  570.  
  571.    public void imgAction() {
  572.       this.attr.addAttribute("$ename", "img");
  573.       this.attr.addAttributes(this.charAttr);
  574.       ImageView.addImageDataAttribute(this.attr);
  575.       this.addSpecialElement(this.attr);
  576.    }
  577.  
  578.    public void iOpenAction() {
  579.       this.pushCharacterStyle();
  580.       Style var1 = this.getChildStyle("i");
  581.       if (var1 != null) {
  582.          this.charAttr.addAttributes(var1);
  583.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  584.       } else {
  585.          StyleConstants.setItalic(this.charAttr, true);
  586.       }
  587.  
  588.       this.charAttr.addAttributes(this.attr);
  589.    }
  590.  
  591.    public void iCloseAction() {
  592.       this.popCharacterStyle();
  593.    }
  594.  
  595.    public void bOpenAction() {
  596.       this.pushCharacterStyle();
  597.       Style var1 = this.getChildStyle("b");
  598.       if (var1 != null) {
  599.          this.charAttr.addAttributes(var1);
  600.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  601.       } else {
  602.          StyleConstants.setBold(this.charAttr, true);
  603.       }
  604.  
  605.       this.charAttr.addAttributes(this.attr);
  606.    }
  607.  
  608.    public void bCloseAction() {
  609.       this.popCharacterStyle();
  610.    }
  611.  
  612.    public void uOpenAction() {
  613.       this.pushCharacterStyle();
  614.       Style var1 = this.getChildStyle("u");
  615.       if (var1 != null) {
  616.          this.charAttr.addAttributes(var1);
  617.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  618.       } else {
  619.          StyleConstants.setUnderline(this.charAttr, true);
  620.       }
  621.    }
  622.  
  623.    public void uCloseAction() {
  624.       this.popCharacterStyle();
  625.    }
  626.  
  627.    public void kbdOpenAction() {
  628.       this.pushCharacterStyle();
  629.       Style var1 = this.getChildStyle("kbd");
  630.       if (var1 != null) {
  631.          this.charAttr.addAttributes(var1);
  632.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  633.       } else {
  634.          StyleConstants.setFontFamily(this.charAttr, "Monospaced");
  635.          String var2 = StyleXlater.convertFontSizeString("small");
  636.          StyleSheet var3 = StyleReader.getStyleSheet();
  637.          int var4 = var3.getPtSize(var2);
  638.          StyleConstants.setFontSize(this.charAttr, var4);
  639.       }
  640.  
  641.       this.charAttr.addAttributes(this.attr);
  642.    }
  643.  
  644.    public void kbdCloseAction() {
  645.       this.popCharacterStyle();
  646.    }
  647.  
  648.    public void baseAction() {
  649.       String var1 = (String)this.attr.getAttribute("href");
  650.       if (var1 != null) {
  651.          this.this$0.putProperty("basehref", var1);
  652.  
  653.          try {
  654.             this.this$0.reference = new URL(var1);
  655.          } catch (MalformedURLException var2) {
  656.          }
  657.       }
  658.    }
  659.  
  660.    public void subOpenAction() {
  661.       this.openTagSeen = true;
  662.       this.pushCharacterStyle();
  663.       Style var1 = this.getChildStyle("sub");
  664.       if (var1 != null) {
  665.          this.charAttr.addAttributes(var1);
  666.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  667.       }
  668.  
  669.       this.charAttr.addAttributes(this.attr);
  670.    }
  671.  
  672.    public void subCloseAction() {
  673.       this.cleanEndTag(false);
  674.       this.popCharacterStyle();
  675.    }
  676.  
  677.    public void supOpenAction() {
  678.       this.openTagSeen = true;
  679.       this.attr.addAttribute("sup", "true");
  680.       this.pushCharacterStyle();
  681.       Style var1 = this.getChildStyle("sup");
  682.       if (var1 != null) {
  683.          this.charAttr.addAttributes(var1);
  684.          this.charAttr.removeAttribute(StyleConstants.ResolveAttribute);
  685.       }
  686.  
  687.       this.charAttr.addAttributes(this.attr);
  688.    }
  689.  
  690.    public void supCloseAction() {
  691.       this.cleanEndTag(false);
  692.       this.popCharacterStyle();
  693.    }
  694.  
  695.    public void liOpenAction() {
  696.       this.blockOpen("li", true);
  697.    }
  698.  
  699.    public void liCloseAction() {
  700.       this.blockClose();
  701.    }
  702.  
  703.    public void ulOpenAction() {
  704.       this.blockOpen("ul", true);
  705.    }
  706.  
  707.    public void ulCloseAction() {
  708.       this.blockClose();
  709.    }
  710.  
  711.    public void olOpenAction() {
  712.       this.blockOpen("ol", true);
  713.    }
  714.  
  715.    public void olCloseAction() {
  716.       this.blockClose();
  717.    }
  718.  
  719.    public void dlOpenAction() {
  720.       this.blockOpen("dl", true);
  721.    }
  722.  
  723.    public void dlCloseAction() {
  724.       this.blockClose();
  725.    }
  726.  
  727.    public void ddOpenAction() {
  728.       this.blockOpen("dd", true);
  729.    }
  730.  
  731.    public void ddCloseAction() {
  732.       this.blockClose();
  733.    }
  734.  
  735.    public void dtOpenAction() {
  736.       this.blockOpen("dt", true);
  737.    }
  738.  
  739.    public void dtCloseAction() {
  740.       this.blockClose();
  741.    }
  742.  
  743.    public void dirOpenAction() {
  744.       this.blockOpen("dir", true);
  745.    }
  746.  
  747.    public void dirCloseAction() {
  748.       this.blockClose();
  749.    }
  750.  
  751.    public void menuOpenAction() {
  752.       this.blockOpen("menu", true);
  753.    }
  754.  
  755.    public void menuCloseAction() {
  756.       this.blockClose();
  757.    }
  758.  
  759.    public void formOpenAction() {
  760.    }
  761.  
  762.    public void formCloseAction() {
  763.    }
  764.  
  765.    public void inputAction() {
  766.       String var1 = (String)this.attr.getAttribute("type");
  767.       if (var1 == null) {
  768.          var1 = new String("text");
  769.       }
  770.  
  771.       if (var1.equalsIgnoreCase("hidden")) {
  772.          this.addSpecialElement(this.attr);
  773.       } else {
  774.          Object var2;
  775.          if (!var1.equalsIgnoreCase("submit") && !var1.equalsIgnoreCase("reset")) {
  776.             if (var1.equalsIgnoreCase("image")) {
  777.                String var7 = (String)this.attr.getAttribute("src");
  778.                var2 = new JButton(var7);
  779.             } else if (var1.equalsIgnoreCase("checkbox")) {
  780.                var2 = new JCheckBox();
  781.             } else if (var1.equalsIgnoreCase("radio")) {
  782.                String var8 = (String)this.attr.getAttribute("value");
  783.                var2 = new JRadioButton(var8);
  784.             } else if (!var1.equalsIgnoreCase("text") && !var1.equalsIgnoreCase("password")) {
  785.                var2 = new JButton();
  786.             } else {
  787.                String var4 = (String)this.attr.getAttribute("size");
  788.                int var9;
  789.                if (var4 != null) {
  790.                   try {
  791.                      var9 = Integer.valueOf(var4);
  792.                   } catch (NumberFormatException var6) {
  793.                      var9 = 40;
  794.                   }
  795.                } else {
  796.                   var9 = 40;
  797.                }
  798.  
  799.                String var5 = (String)this.attr.getAttribute("value");
  800.                var2 = new JTextField(var5, var9);
  801.             }
  802.          } else {
  803.             String var3 = (String)this.attr.getAttribute("value");
  804.             var2 = new JButton(var3);
  805.          }
  806.  
  807.          this.attr.addAttribute("input-component", "input-component");
  808.          StyleConstants.setComponent(this.attr, (Component)var2);
  809.          this.addSpecialElement(this.attr);
  810.       }
  811.    }
  812.  
  813.    public void selectOpenAction() {
  814.       String var3 = (String)this.attr.getAttribute("rows");
  815.       if (var3 != null) {
  816.          try {
  817.             int var8 = Integer.valueOf(var3);
  818.          } catch (NumberFormatException var7) {
  819.             boolean var2 = true;
  820.          }
  821.       } else {
  822.          boolean var9 = true;
  823.       }
  824.  
  825.       String var5 = (String)this.attr.getAttribute("cols");
  826.       if (var5 != null) {
  827.          try {
  828.             int var10 = Integer.valueOf(var5);
  829.          } catch (NumberFormatException var6) {
  830.             boolean var4 = true;
  831.          }
  832.       } else {
  833.          boolean var11 = true;
  834.       }
  835.  
  836.       String var10000 = (String)this.attr.getAttribute("value");
  837.       this.combobox = new JComboBox();
  838.       this.combobox.setEditable(false);
  839.       JComboBox var1 = this.combobox;
  840.       this.attr.addAttribute("input-component", "input-component");
  841.       StyleConstants.setComponent(this.attr, var1);
  842.       this.addSpecialElement(this.attr);
  843.    }
  844.  
  845.    public void selectCloseAction() {
  846.    }
  847.  
  848.    public void optionOpenAction() {
  849.       this.inOption = true;
  850.    }
  851.  
  852.    public void optionCloseAction() {
  853.       this.inOption = false;
  854.    }
  855.  
  856.    public void textareaOpenAction() {
  857.       String var3 = (String)this.attr.getAttribute("rows");
  858.       int var2;
  859.       if (var3 != null) {
  860.          try {
  861.             var2 = Integer.valueOf(var3);
  862.          } catch (NumberFormatException var10) {
  863.             var2 = 10;
  864.          }
  865.       } else {
  866.          var2 = 10;
  867.       }
  868.  
  869.       String var5 = (String)this.attr.getAttribute("cols");
  870.       int var4;
  871.       if (var5 != null) {
  872.          try {
  873.             var4 = Integer.valueOf(var5);
  874.          } catch (NumberFormatException var9) {
  875.             var4 = 40;
  876.          }
  877.       } else {
  878.          var4 = 40;
  879.       }
  880.  
  881.       String var6 = (String)this.attr.getAttribute("value");
  882.       JTextArea var7 = new JTextArea(var6, var2, var4);
  883.       ((JTextComponent)var7).setEditable(true);
  884.       JScrollPane var8 = new JScrollPane(22, 32);
  885.       var8.getViewport().add(var7);
  886.       this.attr.addAttribute("input-component", "input-component");
  887.       StyleConstants.setComponent(this.attr, var8);
  888.       this.addSpecialElement(this.attr);
  889.    }
  890.  
  891.    public void textareaCloseAction() {
  892.    }
  893.  
  894.    Color getColor(AttributeSet var1) {
  895.       String var2 = (String)this.attr.getAttribute("color");
  896.       if (var2 != null) {
  897.          try {
  898.             Color var3 = HTMLUtils.stringToColor(var2);
  899.             return var3;
  900.          } catch (HTMLException var4) {
  901.             return null;
  902.          }
  903.       } else {
  904.          return null;
  905.       }
  906.    }
  907.  
  908.    void pushCharacterStyle() {
  909.       this.charAttrStack.push(this.charAttr.copyAttributes());
  910.    }
  911.  
  912.    void popCharacterStyle() {
  913.       this.charAttr = (MutableAttributeSet)this.charAttrStack.peek();
  914.       this.charAttrStack.pop();
  915.    }
  916.  
  917.    void pushStyle(String var1) {
  918.       this.styleStack.push(this.resolver);
  919.       String var2 = "SH" + var1;
  920.       Style var3 = (Style)this.resolver.getAttribute(var2);
  921.       if (var3 == null && var1.equalsIgnoreCase("impliedp")) {
  922.          var2 = new String("SHp");
  923.          var3 = (Style)this.resolver.getAttribute(var2);
  924.       }
  925.  
  926.       if (var3 != null) {
  927.          this.resolver = var3;
  928.       }
  929.  
  930.    }
  931.  
  932.    void popStyle() {
  933.       this.resolver = (Style)this.styleStack.peek();
  934.       this.styleStack.pop();
  935.    }
  936.  
  937.    void blockOpen(String var1, boolean var2) {
  938.       this.incrementPCData();
  939.       this.dataCountStack.push(new HTMLDocument.HTMLReader.DataCounter(this));
  940.       this.openTagSeen = true;
  941.       ++this.inBlock;
  942.       this.pushStyle(var1);
  943.       if (this.resolver != null) {
  944.          Style var3 = (Style)this.resolver.getAttribute("child-style");
  945.          if (var3 != null) {
  946.             this.attr.addAttribute(StyleConstants.ResolveAttribute, var3);
  947.          }
  948.       }
  949.  
  950.       if (var2) {
  951.          this.attr.addAttribute("$ename", var1);
  952.       }
  953.  
  954.       if (var1.equalsIgnoreCase("impliedp")) {
  955.          this.attr.addAttribute("impliedp", "impliedp");
  956.       }
  957.  
  958.       DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec(this.attr.copyAttributes(), (short)1);
  959.       this.parseBuffer.addElement(var4);
  960.       this.attr.removeAttributes(this.attr);
  961.    }
  962.  
  963.    void blockClose() {
  964.       this.checkPCData();
  965.       this.dataCountStack.pop();
  966.       this.cleanEndTag(true);
  967.       --this.inBlock;
  968.       this.popStyle();
  969.       DefaultStyledDocument.ElementSpec var1 = (DefaultStyledDocument.ElementSpec)this.parseBuffer.lastElement();
  970.       if (var1 != null && var1.getType() == 1) {
  971.          this.addContent(" ");
  972.       }
  973.  
  974.       DefaultStyledDocument.ElementSpec var2 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)2);
  975.       this.parseBuffer.addElement(var2);
  976.    }
  977.  
  978.    void addContent(String var1) {
  979.       AttributeSet var2 = this.charAttr.copyAttributes();
  980.       DefaultStyledDocument.ElementSpec var3 = new DefaultStyledDocument.ElementSpec(var2, (short)3, var1.toCharArray(), 0, var1.length());
  981.       this.parseBuffer.addElement(var3);
  982.    }
  983.  
  984.    void addSpecialElement(AttributeSet var1) {
  985.       char[] var2 = new char[]{' '};
  986.       var1 = var1.copyAttributes();
  987.       DefaultStyledDocument.ElementSpec var3 = new DefaultStyledDocument.ElementSpec(var1.copyAttributes(), (short)3, var2, 0, 1);
  988.       this.parseBuffer.addElement(var3);
  989.       this.attr.removeAttributes(this.attr);
  990.    }
  991.  
  992.    private String replaceSpecialChar(String var1, int var2, int var3, char var4) {
  993.       Object var5 = null;
  994.       String var6 = var1.substring(0, var2) + var4 + var1.substring(var3 + 1, var1.length());
  995.       return var6;
  996.    }
  997.  
  998.    private String xlateSpecialChars(String var1) {
  999.       String var2 = null;
  1000.       boolean var3 = false;
  1001.  
  1002.       for(int var9 = var1.indexOf(38); var9 < var1.length() && var9 > 0; var9 = var1.indexOf(38, var9 + 1)) {
  1003.          int var4 = 0;
  1004.          var4 = var1.indexOf(59, var9);
  1005.          if (var4 < 0) {
  1006.             return null;
  1007.          }
  1008.  
  1009.          if (var1.charAt(var9 + 1) == '#') {
  1010.             String var5 = var1.substring(var9 + 2, var4);
  1011.             int var6 = Integer.valueOf(var5);
  1012.             var2 = this.replaceSpecialChar(var1, var9, var4, (char)var6);
  1013.          } else {
  1014.             String var11 = var1.substring(var9 + 1, var4);
  1015.             char var12 = ' ';
  1016.             boolean var7 = false;
  1017.  
  1018.             try {
  1019.                var12 = this.specTable.getSymbol(var11);
  1020.                var7 = true;
  1021.             } catch (HTMLException var8) {
  1022.             }
  1023.  
  1024.             if (var7) {
  1025.                var2 = this.replaceSpecialChar(var1, var9, var4, var12);
  1026.             }
  1027.          }
  1028.       }
  1029.  
  1030.       return var2;
  1031.    }
  1032.  
  1033.    HTMLDocument$HTMLReader(HTMLDocument var1) {
  1034.       this.this$0 = var1;
  1035.       this.this$0 = var1;
  1036.       this.openTagSeen = false;
  1037.       this.inPre = false;
  1038.       this.inTitle = false;
  1039.       this.inOption = false;
  1040.       this.dataCountStack = new Stack();
  1041.       this.parseBuffer = new Vector();
  1042.       this.charAttr = new SimpleAttributeSet();
  1043.       this.charAttrStack = new Stack();
  1044.       this.styleStack = new Stack();
  1045.       this.attr = new SimpleAttributeSet();
  1046.       this.specTable = new SpecialCharTable();
  1047.    }
  1048. }
  1049.