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 / html / FormView$SubmitThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.6 KB  |  116 lines

  1. package javax.swing.text.html;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.OutputStreamWriter;
  6. import java.io.PrintWriter;
  7. import java.net.MalformedURLException;
  8. import java.net.URL;
  9. import java.net.URLConnection;
  10. import javax.swing.JEditorPane;
  11. import javax.swing.SwingUtilities;
  12. import javax.swing.text.AttributeSet;
  13. import javax.swing.text.Element;
  14. import javax.swing.text.html.HTML.Attribute;
  15.  
  16. class FormView$SubmitThread extends Thread {
  17.    String data;
  18.    HTMLDocument hdoc;
  19.    HTMLDocument newDoc;
  20.    AttributeSet formAttr;
  21.    // $FF: renamed from: in java.io.InputStream
  22.    InputStream field_0;
  23.    // $FF: synthetic field
  24.    private final FormView this$0;
  25.  
  26.    public FormView$SubmitThread(FormView var1, Element var2, String var3) {
  27.       this.this$0 = var1;
  28.       this.data = var3;
  29.       this.hdoc = (HTMLDocument)var2.getDocument();
  30.       this.formAttr = this.hdoc.getFormAttributes(var2.getAttributes());
  31.    }
  32.  
  33.    public void run() {
  34.       if (this.data.length() > 0) {
  35.          String var1 = this.getMethod();
  36.          String var2 = this.getAction();
  37.  
  38.          try {
  39.             URL var5 = this.hdoc.getBase();
  40.             URL var4;
  41.             if (var2 == null) {
  42.                String var6 = var5.getFile();
  43.                var4 = new URL(var5.getProtocol(), var5.getHost(), var5.getPort(), var6);
  44.             } else {
  45.                var4 = new URL(var5, var2);
  46.             }
  47.  
  48.             URL var3;
  49.             URLConnection var12;
  50.             if ("post".equals(var1)) {
  51.                var3 = var4;
  52.                var12 = var4.openConnection();
  53.                this.postData(var12, this.data);
  54.             } else {
  55.                var3 = new URL(var4 + "?" + this.data);
  56.                var12 = var3.openConnection();
  57.             }
  58.  
  59.             this.field_0 = var12.getInputStream();
  60.             JEditorPane var7 = (JEditorPane)this.this$0.getContainer();
  61.             HTMLEditorKit var8 = (HTMLEditorKit)var7.getEditorKit();
  62.             this.newDoc = (HTMLDocument)var8.createDefaultDocument();
  63.             this.newDoc.putProperty("stream", var3);
  64.             FormView.2 var9 = new FormView.2(this);
  65.             SwingUtilities.invokeLater(var9);
  66.          } catch (MalformedURLException var10) {
  67.          } catch (IOException var11) {
  68.          }
  69.       }
  70.  
  71.    }
  72.  
  73.    public void loadDocument() {
  74.       JEditorPane var1 = (JEditorPane)this.this$0.getContainer();
  75.  
  76.       try {
  77.          var1.read(this.field_0, this.newDoc);
  78.       } catch (IOException var3) {
  79.       }
  80.  
  81.    }
  82.  
  83.    public String getAction() {
  84.       return this.formAttr == null ? null : (String)this.formAttr.getAttribute(Attribute.ACTION);
  85.    }
  86.  
  87.    String getMethod() {
  88.       if (this.formAttr != null) {
  89.          String var1 = (String)this.formAttr.getAttribute(Attribute.METHOD);
  90.          if (var1 != null) {
  91.             return var1.toLowerCase();
  92.          }
  93.       }
  94.  
  95.       return null;
  96.    }
  97.  
  98.    public void postData(URLConnection var1, String var2) {
  99.       var1.setDoOutput(true);
  100.       PrintWriter var3 = null;
  101.  
  102.       try {
  103.          var3 = new PrintWriter(new OutputStreamWriter(var1.getOutputStream()));
  104.          var3.print(var2);
  105.          var3.flush();
  106.       } catch (IOException var9) {
  107.       } finally {
  108.          if (var3 != null) {
  109.             var3.close();
  110.          }
  111.  
  112.       }
  113.  
  114.    }
  115. }
  116.