Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

54
LINES

< > BotCompany Repo | #1016488 // URL Checker [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14736L/101K).

!7

//set flag InputChooser_verbose.

sclass URLChecker extends DynTextArea {
  InputChooser inputChooser = new(this);
  S url;
  bool mayQuery;
  Map<S, L<S>> headers;
  long size;
  PersistableThrowable loadError;
  
  JComponent visualize() {
    ret northAndCenter(wrap(inputChooser), super.visualize());
  }
  
  void update {
    temp enter();
    if (!inputChooser.update()) ret;
    
    fS input = inputChooser.input();
    if (!isURL(input)) ret;
    if (!setField(url := input)) ret;
    actualUpdate();
  }
  
  void actualUpdate {
    temp enter();
    setFields(mayQuery := false, headers := null, loadError := null);
    clearText();
    printToText("URL found: " + url);
    setField(mayQuery := mayQueryURLByHead(url));
    printToText("May query: " + yn(mayQuery));
    if (!mayQuery) ret;
    // TODO: also get content type
    try {
      setField(headers := getURLHeadersByHEAD(url));
    } catch e {
      printShortException(e);
      setField(loadError := persistableThrowable(e));
    }
    if (headers != null) {
      printToText("Headers:");
      for (S key, L<S> values : headers) {
        for (S value : values)
          printToText(key + " = " + value);
      }
    }
  }
  
  bool mayQueryURLByHead(S url) {
    true;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016488
Snippet name: URL Checker [Dyn Module]
Eternal ID of this version: #1016488/9
Text MD5: 5bea58adecdc9ffe6db4f2a23c1c1028
Transpilation MD5: 2dc63cfdc13963b43794599984448121
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-21 23:33:53
Source code size: 1311 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 391 / 1971
Version history: 8 change(s)
Referenced in: [show references]