1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-05-03 22:30:22 -04:00
parent f4b95f5ce6
commit 0b5aa9aefe
207 changed files with 2339 additions and 1460 deletions

View File

@@ -23,6 +23,7 @@ public class Xoa_url {
public byte[] Anchor_bry() {return anchor_bry;} public Xoa_url Anchor_bry_(byte[] v) {anchor_bry = v; return this;} private byte[] anchor_bry = null;
public String Anchor_str() {return anchor_bry == null ? null : String_.new_utf8_(anchor_bry);}
public Gfo_url_arg[] Args() {return args;} public Xoa_url Args_(Gfo_url_arg[] v) {args = v; return this;} private Gfo_url_arg[] args = Gfo_url_arg.Ary_empty;
public Xoa_url_arg_hash Args_hash() {if (args_hash == null) args_hash = new Xoa_url_arg_hash().Load(this); return args_hash;} private Xoa_url_arg_hash args_hash;
public byte Protocol_tid() {return protocol_tid;} public Xoa_url Protocol_tid_(byte v) {protocol_tid = v; return this;} private byte protocol_tid;
public byte[] Protocol_bry() {return protocol_bry;} public Xoa_url Protocol_bry_(byte[] v) {protocol_bry = v; return this;} private byte[] protocol_bry;
public boolean Protocol_is_relative() {return protocol_is_relative;} public Xoa_url Protocol_is_relative_(boolean v) {protocol_is_relative = v; return this;} private boolean protocol_is_relative;
@@ -82,6 +83,7 @@ public class Xoa_url {
public byte[] Xto_full_bry() {return wiki_bry == null ? page_bry : Bry_.Add(wiki_bry, Xoa_consts.Url_wiki_intermediary, page_bry);}
public String Xto_full_str() {return String_.new_utf8_(this.Xto_full_bry());}
public String Xto_full_str_safe() {try {return Xto_full_str();} catch (Exception e) {return gplx.Err_.Message_gplx_brief(e);}}
public static final Xoa_url Null = null;
public static Xoa_url blank_() {return new Xoa_url();}
public static Xoa_url new_(byte[] wiki, byte[] page) {
Xoa_url rv = new Xoa_url();

View File

@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
import gplx.core.primitives.*;
import gplx.xowa.langs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.net.*; import gplx.xowa.files.*;
public class Xoa_url_parser {
private Url_encoder encoder = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline); private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private final Url_encoder encoder = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
public Gfo_url_parser Url_parser() {return url_parser;} private Gfo_url_parser url_parser = new Gfo_url_parser(); private Gfo_url gfo_url = new Gfo_url();
public String Build_str(Xoa_url url) { // transform to "canonical" form that fits url box for both XOWA and Mozilla Firefox
tmp_bfr.Add(url.Wiki_bry()); // add wiki; EX: "en.wikipedia.org"
@@ -43,7 +43,7 @@ public class Xoa_url_parser {
Parse(rv, src);
return rv;
}
public boolean Parse(Xoa_url url, byte[] src, int bgn, int end) {return Parse(url, Bry_.Mid(src, bgn, end));}
private boolean Parse(Xoa_url url, byte[] src, int bgn, int end) {return Parse(url, Bry_.Mid(src, bgn, end));}
public boolean Parse(Xoa_url url, byte[] src) {
url.Init(src); // NOTE: need to call init to clear state; Xoa_url is often reused
src = encoder.Decode(src); // decode any url-encoded parameters