1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2025-06-13 12:54:14 +00:00

Compare commits

...

1096 Commits

Author SHA1 Message Date
gnosygnu
2a4abd8f75 Gui: Fix NullPointerException when pressing backspace on empty search box [#841] 2021-03-03 03:37:22 -05:00
gnosygnu
17a3b4e7b3 Parser: Only print value without ± if lo and hi are null [#839] 2021-02-14 08:13:31 -05:00
gnosygnu
659bca3660 Parser: Prepend 0 to all strings starting with ., even just . [#838] 2021-02-13 20:19:16 -05:00
gnosygnu
8684783139 Lang: Rename Pft_fmt_itm_hijri [#837] 2021-02-08 08:03:06 -05:00
gnosygnu
7e53c8462d Lang: Fix misspelling of hijri [#837] 2021-02-07 10:41:56 -05:00
gnosygnu
559503786b Release: Update app version [#833] 2021-01-26 08:03:13 -05:00
gnosygnu
e117823e60 Gui: Manually fire javascript event and exit [#836] 2021-01-25 08:07:23 -05:00
gnosygnu
ff0f92b950 Gui: Encode and decode image sources [#829] 2021-01-11 08:03:10 -05:00
gnosygnu
4187dc4a76 Gui: Strip about: from links during Copy [#823] 2021-01-05 02:06:20 -05:00
gnosygnu
1a6a203cfd Parser: Match for < + onlyinclude to fix false match [#825] 2020-12-17 07:48:28 -05:00
gnosygnu
814e85ea70 Release: Release v4.6.14.2012 to fix about:/wiki/ when doing "Open in new tab" [#823] 2020-12-16 09:02:02 -05:00
gnosygnu
0ef5058cfd Gui: Strip about:/wiki/ from links [#823] 2020-12-16 09:00:45 -05:00
gnosygnu
aeef520228 Dev: Fix failing tests after project rebuild [#826] 2020-12-14 08:53:28 -05:00
gnosygnu
4a7bd19056 Wikibase: Fix failing tests [#792] 2020-12-14 08:50:31 -05:00
gnosygnu
7d357540c7 ParserFunctions: Fail if e0 or pi0 [#819] 2020-11-25 06:34:13 -05:00
gnosygnu
b1c52aa2b2 ParserFunctions: Handle spaces in {{int}} keys [#817] 2020-11-03 07:59:21 -05:00
gnosygnu
845253af79 Mass_parse: Do not reuse json_parser else threading issues with itwiki [#818] 2020-11-03 06:51:31 -05:00
gnosygnu
541f5f6524 Css: Do not preprend selector for body [#815] 2020-11-01 10:45:38 -05:00
gnosygnu
067e62dd03 Release: Release v4.6.13.2010 [#797] 2020-10-19 09:42:18 -04:00
gnosygnu
19a315b8cd Skin: Change to mustache-backed Skin.Vector [#797] 2020-10-18 10:53:38 -04:00
gnosygnu
5c3d6a173b Wikibase: Calc precision by using longitude when precision is null [#792] 2020-09-25 08:42:52 -04:00
gnosygnu
c801e3a20b Scribunto: Allow int for find parameter [#802] 2020-09-23 08:44:58 -04:00
gnosygnu
59d8a42b22 Release: Update to 4.6.12.2009 [#801] 2020-09-23 08:44:14 -04:00
desb42
567e03dc1d Gui: Strip blank: from links [#799] 2020-09-21 19:29:29 -04:00
gnosygnu
7550894dda Release: Update for 4.6.11.2009 [#801] 2020-09-19 12:49:47 -04:00
gnosygnu
caad4145d5 Gui: Strip about: from links [#799] 2020-09-19 12:47:56 -04:00
gnosygnu
de841f8ff2 Wikibase: Reproduce geocoordinate logic of en.w:Module:Wd [#792] 2020-09-07 17:28:20 -04:00
gnosygnu
5f2e9c7514 Parser: Require coefficient for scientific notation [#795] 2020-09-07 08:32:47 -04:00
gnosygnu
d3896bf547 Parser: Remove Tmpl_result_cache, Bld_key, and corresponding code in Xot_invk_tkn [#793] 2020-09-04 08:20:18 -04:00
gnosygnu
316c6c6a58 Map: Compare precision against 4 not 0 [#792] 2020-09-03 08:32:16 -04:00
gnosygnu
72051f4ce9 Wikibase: Default 'null' to 0, not 1 [#792] 2020-09-03 08:23:57 -04:00
gnosygnu
f19228c886 Mass_parse: Add error_filter to ignore logging certain errors [#793] 2020-09-01 09:02:47 -04:00
gnosygnu
1b6324938c Release: Upgrade version to 4.6.10.2008 for Mac OS X fix [#687] 2020-09-01 08:45:14 -04:00
gnosygnu
9b4ea48753 Install: Upgrade to SWT 4.16 [#687] 2020-08-31 09:06:19 -04:00
gnosygnu
6ed7659b4d Core: Parse decimal 'e' as 'E' [#565] 2020-08-27 06:04:17 -04:00
gnosygnu
1eea3682ca SyntaxHighlight: Treat syntaxHighlight inline as enclose=none [#794] 2020-08-27 05:25:59 -04:00
gnosygnu
4f87d1a195 Image: Mark tif orig files as not images [#788] 2020-08-26 09:01:43 -04:00
gnosygnu
ea9b592cfd Html: Do not remove role= attributes from html tags [#785] 2020-08-18 06:14:25 -04:00
gnosygnu
3c9fd50ddc Pagebanner: Show pageBanner for Wikivoyage namespace [#748] 2020-08-17 07:46:44 -04:00
gnosygnu
619d2f9844 Dev: Include baselib in core classpath [#697] 2020-08-14 09:09:17 -04:00
gnosygnu
bdae819908 Scribunto: Trim zeroes when stringifying Doubles [#697] 2020-08-12 08:48:30 -04:00
gnosygnu
f122a8d8a3 Wikibase: Prepend claim_type with "wikibase-" for lexeme, form, sense [#771] 2020-08-09 13:18:19 -04:00
gnosygnu
174e93cbfa Parser: Add namespace to Template title [#784] 2020-08-09 13:03:41 -04:00
gnosygnu
0aced904a5 Edit: Save compiled HTML when editing pages [#699] 2020-08-06 07:09:34 -04:00
gnosygnu
dc374fa7fc Html: Add 'contentSub2' to xowa.gfs [#783] 2020-08-04 08:28:02 -04:00
gnosygnu
95e833d70c Wikibase: Fix NullPointerException on a few fr.w pages [#773] 2020-08-04 07:24:52 -04:00
gnosygnu
afed865c84 Scribunto: Implement'lang argument for mw.ext.data.get [#779] 2020-08-03 08:37:51 -04:00
gnosygnu
7b6b3ed09a Wikibase: Implement lexeme, form, and sense [#771] 2020-07-31 07:44:00 -04:00
gnosygnu
a0c0b5b2fd HTTP Server: Fix broken links in left nav [#768] 2020-07-23 08:19:24 -04:00
gnosygnu
062d308128 Scribunto: Do not return early in Gsub if source is String.empty [#731] 2020-07-20 08:28:08 -04:00
gnosygnu
ad607d952c Release: Bump version to 4.6.9.2007 [#761] 2020-07-17 09:08:55 -04:00
gnosygnu
6592eaf8de Gui: Fix page loading in wrong wiki after switching tab positions [#761] 2020-07-17 09:07:18 -04:00
gnosygnu
45adc036a2 Luaj: Check for error in LoadString [#759] 2020-07-15 08:06:21 -04:00
gnosygnu
6b2e120fc1 Css: Fix top tabs showing vertically instead of horizontally [#754] 2020-07-02 09:08:26 -04:00
gnosygnu
7c0a8c5064 Luaj: Sync LuaString with latest Luaj source [#735] 2020-07-02 08:00:10 -04:00
gnosygnu
35475d631c Http_server: Fix images not downloading on some Portal pages [#686] 2020-06-27 19:28:42 -04:00
gnosygnu
efe415d3a3 Scribunto: Add help text for xowa.app.settings.publish [#737] 2020-06-20 17:55:01 -04:00
gnosygnu
97b1055b4e Scribunto: Add configurable timeout for en.wikipedia.org and 'Authority_control' [#737] 2020-06-20 17:47:42 -04:00
gnosygnu
b51d224f09 Html: Add 'mw-footer' class to 'footer' div [#745] 2020-06-16 09:05:16 -04:00
gnosygnu
b87e4d07cb Scribunto: Hack fix for stopping long-running threads [#737] 2020-06-15 10:18:34 -04:00
gnosygnu
b4516f5060 Luaj: Change table.sort from MergeSort to QuickSort variant with stable sorting [#743] 2020-06-13 09:37:43 -04:00
gnosygnu
49e18a2255 Css: Prepend '.mw-parser-output' to all nested classes [#741] 2020-06-09 08:38:26 -04:00
gnosygnu
026288f809 Css: Change java.lang.String.charAt to JsString_.charAt (with JsString_.charAt) [#741] 2020-06-08 09:00:39 -04:00
gnosygnu
1103674d88 Css: Change java.lang.String.charAt to JsString_.charAt [#741] 2020-06-08 08:58:32 -04:00
gnosygnu
27756f8056 Scribunto: Hack timeout to limit Scribunto execution to 5 seconds [#737] 2020-06-07 21:41:46 -04:00
gnosygnu
398a1c854a Luaj: Use substring.m_bytes, not substring.getBytes() [#735] 2020-06-03 09:21:25 -04:00
gnosygnu
35f2027b20 Scribunto: Create match string using char-indexes, not codepointIndexes (to handle UTF-8 strings) [#726] 2020-05-31 01:19:24 -04:00
gnosygnu
be072de8d9 Luaj: Reinstate next variable for frontier matches [#732] 2020-05-29 09:15:00 -04:00
gnosygnu
f760fd9cd0 Luaj: Do not match end-of-string for frontier patterns [#732] 2020-05-29 07:23:38 -04:00
gnosygnu
3d5ec47aa8 Html: Do not call Xtn property for non-Xtn XML nodes [#730] 2020-05-27 09:18:53 -04:00
gnosygnu
53762288d7 Release: Release embeddable app version (v4.6.7) [#733] 2020-05-27 08:19:26 -04:00
gnosygnu
7a0247417d Embeddable: Do not call hxtn code during embeddable [#733] 2020-05-27 07:29:39 -04:00
gnosygnu
0cdfa0992c Hdump: Serialize / deserialize top-icon [#721] 2020-05-26 08:38:50 -04:00
gnosygnu
dc66b926d3 Release: Change default download server from dumps.wikimedia.your.org to dumps.wikimedia.org [#727] 2020-05-20 20:16:00 -04:00
gnosygnu
8c7c9f88ff Hdump: Show category at bottom of Category pages [#722] 2020-05-17 17:04:25 -04:00
gnosygnu
94b757682a Luaj: Make anypos captures base-1, not base-0 (with fixed test) [#724] 2020-05-17 11:38:06 -04:00
gnosygnu
1ebc9d3488 Luaj: Make anypos captures base-1, not base-0 [#726] 2020-05-17 11:27:38 -04:00
gnosygnu
654810d56c Html: Add 'lang' to <h1> [#724] 2020-05-15 09:34:09 -04:00
gnosygnu
b551c1875b Html: Show Read, Edit, ViewHtml in correct right-to-left order for RTL languages [#723] 2020-05-15 09:02:45 -04:00
gnosygnu
ba1d4e0b7c XOMW: Add Globals and refine XomwMediaWikiServices [#632] 2020-05-14 08:58:45 -04:00
gnosygnu
a2fe75f402 RandomRootPage: Do not fail to find page for some random selections; also, do not show 'Redirected from redirected_title' [#719] 2020-05-13 09:20:46 -04:00
gnosygnu
a6331f5c89 XOMW: Finish XomwServiceContainer [#632] 2020-05-12 08:13:31 -04:00
gnosygnu
43866163b9 XOMW: Add Assert [#632] 2020-05-11 08:38:35 -04:00
gnosygnu
49f8d4b000 Lst: Handle keys with whitespace [#720] 2020-05-10 09:37:04 -04:00
gnosygnu
994d405a26 Release: Increase version number [#694] 2020-05-10 08:33:43 -04:00
gnosygnu
04c499ce3e XOMW: Add PHP array-diff and array-diff-key [#632] 2020-05-10 07:43:30 -04:00
gnosygnu
ebe82bea6a LuaJ: Always format in Locale.US, not current locale [#694] 2020-05-09 16:24:59 -04:00
gnosygnu
a9367eaca8 XOMW: Consolidate XophpArray_ into XophpArray [#632] 2020-05-09 07:21:14 -04:00
gnosygnu
ee68162a4a XOMW: Add more implementation for XomwServiceContainer [#632] 2020-05-08 09:18:46 -04:00
gnosygnu
6663b769d5 Dev: Fix broken 'xowa_get_and_make.sh' due to JDK 8 and new *Test files [#718] 2020-05-07 09:30:48 -04:00
gnosygnu
2dab6a90be XOMW: Start XomwServiceContainer [#632] 2020-05-07 08:58:15 -04:00
gnosygnu
b0e02979ac XOMW: Start XomwRequestContext [#632] 2020-05-05 08:14:21 -04:00
gnosygnu
f9cf49c160 XOMW: Start XomwMessage [#632] 2020-05-04 08:29:37 -04:00
gnosygnu
0d917bccc7 XOMW: Finish XomwHooks - part 2 [#632] 2020-05-03 09:19:47 -04:00
gnosygnu
d1345bf724 XOMW: Finish XomwHooks [#632] 2020-05-03 09:19:19 -04:00
gnosygnu
3d74406a3e XOMW: Add array_filter [#632] 2020-05-02 08:30:47 -04:00
gnosygnu
a6b128422e XOMW: More XomwHooks implementation [#632] 2020-05-01 09:01:40 -04:00
gnosygnu
0c3cb1ba3d HTTP Server: Do not show new logic for SWT/GUI tabs ('wikiName - message' if mainPage, else 'pageName - wikiName') [#715] 2020-05-01 08:55:03 -04:00
gnosygnu
105446f5ca HTTP Server: Show correct tab / html.head name for pages ('wikiName - message' if mainPage, else 'pageName - wikiName') [#715] 2020-05-01 08:45:01 -04:00
gnosygnu
db73b4302d Xomw: Add some implementation for XomwHooks [#632] 2020-04-29 07:32:10 -04:00
gnosygnu
bd71db3ed6 Xomw: Add more implementation near statelessFetchTemplate [#632] 2020-04-27 08:39:30 -04:00
gnosygnu
a4b5f5de5d TemplateStyles: Apply wrapper to each class, not to top only [#712] 2020-04-26 15:51:56 -04:00
gnosygnu
ecbcf1e707 GFLucene: Add lucene binaries [#707] 2020-04-26 08:09:27 -04:00
gnosygnu
7b00918941 XOMW: Rename XomwTitle to XomwTitleOld [#632] 2020-04-26 08:08:39 -04:00
gnosygnu
8807dcfbeb TemplateStyles: Support wrapper argument [#712] 2020-04-23 08:18:03 -04:00
gnosygnu
a6ac592212 TemplateStyles: Add mw-parser-output in XoCssMin, not in TemplateStyles [#704] 2020-04-22 08:17:54 -04:00
gnosygnu
b05e3cd188 File: Add '.stl' and '.webp' as image extensions [#710] 2020-04-21 08:31:40 -04:00
gnosygnu
9c8650a4d9 Dev: Modify .gitignore files for IntelliJ .iml files [#709] 2020-04-20 07:31:23 -04:00
gnosygnu
73a56ffab3 TemplateStyles: Add XoCssMin from @desb42 [#704] 2020-04-19 08:54:54 -04:00
gnosygnu
e9e5724a2a Make: Add baselib to xowa classpath [#706] 2020-04-13 07:23:39 -04:00
gnosygnu
c3c9d4ad1e Html: Do not add '\n' to media anchor links [#703] 2020-04-10 07:53:45 -04:00
gnosygnu
5a35f3b05b TemplateStyles: Scope TemplateStyles css to main content div by adding 'mw-parser-output' [#426] 2020-04-10 07:07:28 -04:00
gnosygnu
7ad1291768 XomwTemplateParser: Port XomwPreprocessor classes as direct translation of MW code [#632] 2020-04-09 08:10:22 -04:00
gnosygnu
17d7a7ebed XomwTemplateParser: Port other XomwPPTemplateFrame classes [#632] 2020-04-03 06:39:35 -04:00
gnosygnu
9809dfd6c7 XomwTemplateParser: Port XomwPPTemplateFrame_Hash [#632] 2020-03-31 07:46:17 -04:00
gnosygnu
b56673c56e HTTP Server: Url-encode urls in portal div [#572] 2020-03-28 10:33:04 -04:00
gnosygnu
8629292960 Wikibase: Parse e as exponent in wikidata json [#565] 2020-03-25 06:09:57 -04:00
gnosygnu
bc30fd8526 ParserFunctions: Round numbers to default precision of 14 [#683] 2020-03-24 06:46:24 -04:00
gnosygnu
c47820b1a9 Category: (partial) Deactivate mw-category logic [#677] 2020-03-16 07:32:06 -04:00
gnosygnu
292726bd13 Category: (partial) Update messages for category [#677] 2020-03-16 07:29:05 -04:00
gnosygnu
23eefef91a Log: Fix garbled messages still during HTML build [#646] 2020-03-16 06:31:31 -04:00
gnosygnu
89d0ba1271 Dev: Refactor Xoa_ttl to use one url_encoder [#627] 2020-03-10 08:18:04 -04:00
gnosygnu
b2a6f7bbf1 Xtn.Is_in: Escape double-quotes as &quot; [#627] 2020-03-10 07:49:38 -04:00
gnosygnu
ed010f76a8 Table_of_contents: Skip whitespace after slash; Add <mark> as valid HTML tag [#542] 2020-03-09 07:56:21 -04:00
gnosygnu
bc65e9fa61 Hxtn: Edit comment message [#634] 2020-03-08 16:36:42 -04:00
gnosygnu
db01707032 Hxtn: Ignore unknown wkr_ids to allow hxtns developed by others [#634] 2020-03-08 16:32:00 -04:00
gnosygnu
7b3d6e5271 Html: Update HTML Santizer whitelist [#636] 2020-03-08 12:04:46 -04:00
gnosygnu
c3d524c493 Wikibase: Reset pageEntityId on each new page [#638] 2020-03-07 23:46:21 -05:00
gnosygnu
f33f9c4ae9 References: Do not make linkLabelMgr a global reference [#495] 2020-03-07 08:49:09 -05:00
gnosygnu
02f9b9dae3 Category: Show either Category or Categories depending on number of categories [#674] 2020-03-04 08:24:14 -05:00
gnosygnu
891cf53228 Dev: Rename 'Pxd_itm_tz_abbr .java' to 'Pxd_itm_tz_abbr.java' (remove trailing space) [#676] 2020-03-04 08:00:51 -05:00
gnosygnu
f73164d55e Wikibase: Add extra-case to RenderSnaks for key=pid,val=snaks [#666] 2020-03-01 18:48:08 -05:00
gnosygnu
3355d03c44 Wikibase: Use 2nd argument to GetSiteLinkPageName for wiki name [#665] 2020-02-19 08:39:43 -05:00
gnosygnu
bae9ba9e7a Parser: Return length of 0 for empty arrays [#668] 2020-02-17 08:47:34 -05:00
gnosygnu
a5cbc4ede9 ParserFunctions: Add constructor for future use [#661] 2020-02-17 08:42:25 -05:00
gnosygnu
da87b17902 ParserFunctions: Comment out unused variables [#661] 2020-02-17 08:34:29 -05:00
gnosygnu
bfce37f0ba ParserFunctions: Add PHP implementation of strtotime [#661] 2020-02-08 21:58:12 -05:00
gnosygnu
3e9bc6d93a Category: Parse year as yyyy not YYYY [#664] 2020-02-05 08:15:19 -05:00
gnosygnu
775bff3bac Wikibase: Do not fail for FormatStatements and getPropertyOrder [#658] 2020-02-02 21:02:11 -05:00
gnosygnu
bc2beba148 Pages: Do not escape <pages> if invalid attributes [#656] 2020-01-19 14:28:22 -05:00
gnosygnu
af337493af Pages: Forward unknown args to header template [#635] 2020-01-19 13:49:24 -05:00
gnosygnu
ca8afe657e Pages: Treat empty-string as non-null for from / to [#657] 2020-01-19 10:44:38 -05:00
gnosygnu
57ad8e459a ParserFunctions: Fix some comments for meridian [#648] 2020-01-18 16:47:13 -05:00
gnosygnu
763c7b52b7 ParserFunctions: Support timezone / meridian formats [#648] 2020-01-18 16:39:16 -05:00
gnosygnu
9cb60f2540 Redirect: Add span for 'mw-redirected' [#642] 2020-01-14 06:31:23 -05:00
gnosygnu
c6bca54d90 Hdump: Try to eliminate dupes by updating Html_uid for lnki [#643] 2020-01-12 11:00:11 -05:00
gnosygnu
374de22699 ParserFunctions: Set day to last day of month if only Year-Feb passed [#644] 2020-01-12 09:50:01 -05:00
gnosygnu
2dee585fc1 Pages: Treat empty-string as null for fromsection and tosection [#650] 2020-01-11 21:41:37 -05:00
gnosygnu
898701131d Css: Skip comments when importing CSS [#652] 2020-01-11 09:40:34 -05:00
gnosygnu
c1b8911a7d Log: Fix out-of-order log messages during HTML build [#646] 2020-01-09 07:09:47 -05:00
gnosygnu
f384d40e56 Doc: Add HTTP_Server Advanced doc [#621] 2020-01-08 22:56:16 -05:00
gnosygnu
278d55cd62 Gallery: Apply Math.Ceil to packed gallery [#640] 2020-01-08 22:53:37 -05:00
gnosygnu
11447820f2 Doc: Add instructions for disabling Special pages and edit mode [#621] 2020-01-05 12:36:46 -05:00
gnosygnu
5e2ce08abb Xomw: Standardize static classes [#633] 2020-01-05 08:52:37 -05:00
gnosygnu
5aec368f8d Lang: Support explicit plural indexes and rules in other languages [#633] 2020-01-04 04:14:36 -05:00
gnosygnu
5f1d9c6f15 Category: Group category members under same upper-cased letter [#637] 2019-12-14 19:35:13 -05:00
gnosygnu
e0de779e1d Gallery: Enable packed-hover for galleries [#631] 2019-12-08 08:50:07 -05:00
gnosygnu
bc5947507f XomwTemplateParser: Start porting over newChild [#632] 2019-12-08 08:30:28 -05:00
gnosygnu
7e2f832c33 Refactor: Rename Xoa_ttl.Full_txt_w_ttl_case to Full_txt [#626] 2019-12-08 08:24:47 -05:00
gnosygnu
357c725798 Add missing segments to subtitle_caption; also, do not url-encode caption [#626] 2019-12-07 17:18:48 -05:00
gnosygnu
694c3bb133 XomwTemplateParser: Initial port of PPFrame_Hash [#632] 2019-12-07 08:13:52 -05:00
gnosygnu
3285a3c87d Xtn.Pages: Do not show missing pages in subpages bread-crumb trail (also, proper-case titles) [#626] 2019-12-01 11:43:33 -05:00
gnosygnu
520a73537f Xtn.Pages: Do not escape XML in header previous / current / next links [#624] 2019-11-30 17:15:23 -05:00
gnosygnu
9d8ab5d206 Xtn.Pages: Treat header=0 as false [#622] 2019-11-28 09:16:16 -05:00
gnosygnu
d49eda32a8 DB: Add misc commit for fieldList [#619] 2019-11-28 09:15:54 -05:00
gnosygnu
eca943d7a6
Merge pull request #620 from gnosygnu/dependabot/maven/res/dev/make/maven/org.apache.commons-commons-compress-1.19
Bump commons-compress from 1.18 to 1.19 in /res/dev/make/maven
2019-11-26 07:05:40 -05:00
gnosygnu
a7114ecb5a Dev: Update Apache Compress to 1.19 in pom.xml [#619] 2019-11-25 20:58:02 -05:00
dependabot[bot]
ad5613265d
Bump commons-compress from 1.18 to 1.19 in /res/dev/make/maven
Bumps commons-compress from 1.18 to 1.19.

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-26 01:35:44 +00:00
gnosygnu
734206fbd6 Dev: Update Apache Compress to 1.18 in pom.xml [#619] 2019-11-25 20:35:21 -05:00
gnosygnu
605038d8c6 Release: v4.6.5.1911 [#619] 2019-11-25 20:24:12 -05:00
gnosygnu
ae484a8234 Pagebanner: Add extra space after hasPosition or some pageBanners will omit wpb-banner-image [#618] 2019-11-25 16:43:11 -05:00
gnosygnu
cb3b78895c Html_dump: Add no-op related commits [#547] 2019-11-25 16:31:45 -05:00
gnosygnu
38f670649b Html_dump: Show images with plus symbol [#547] 2019-11-25 16:31:02 -05:00
gnosygnu
9e97a7ea9f Html_dump: Show images for files with url-encoded characters (space, symbols, non-ascii) [#547] 2019-11-25 05:26:39 -05:00
gnosygnu
966b0eed59 Luaj: Do not treat superscript 1 as a DIGIT character [#617] 2019-11-24 16:20:58 -05:00
gnosygnu
59985227fb Wikibase: Change siteGlobalID to wiki-specific abbreviation, not wikidatawiki [#614] 2019-11-23 17:32:18 -05:00
gnosygnu
c307946bd2 Scribunto: Synchronize latest of mw.wikibase.entity.lua [#614] 2019-11-23 05:30:44 -05:00
gnosygnu
b2864f8c6a Scribunto: Cache results of title.exists [#597] 2019-11-18 06:25:57 -05:00
gnosygnu
41a521850b TemplateStyles: Add unit test for single-word paragraph bug [#616] 2019-11-18 05:25:22 -05:00
gnosygnu
20c1e32ff2 PageBanner: Fix NullPointer Exception [#610] 2019-11-17 21:02:41 -05:00
gnosygnu
90363fb9fa Template_styles: Close block opened by template-styles [#616] 2019-11-17 20:59:18 -05:00
gnosygnu
46aab7944d Pagebanner: Fix TOC not working from header; also, hide TOC always, not just on 2nd+ load [#610] 2019-11-17 20:14:44 -05:00
gnosygnu
5ddf50d5b5 Search: Wait for page to load before displaying search results [#606] 2019-11-17 15:57:35 -05:00
gnosygnu
e2aa551feb Search: Fix no search results for en.d [#606] 2019-11-17 14:30:49 -05:00
gnosygnu
11810c4fff HTTP_Server: Fix broken test by adding manual override for wiki.Installed [#613] 2019-11-17 14:28:37 -05:00
gnosygnu
e9024e057f HTTP Server: Show error page when navigating to wikis which are not installed [#613] 2019-11-13 08:43:34 -05:00
gnosygnu
9483b56121 Pagebanner: Disable toc if pagebanner html exists; also, sync PageBanner css [#610] 2019-11-11 06:27:49 -05:00
gnosygnu
8653e665cc HTTP_Server: Add 2 line breaks to redirect response for proxy servers [#600] 2019-11-05 06:04:19 -05:00
gnosygnu
dbdc558ed5 Gui: Remove unused serialization code for history items [#608] 2019-11-03 19:49:54 -05:00
gnosygnu
bdb1945d4f Scribunto: Synchronize latest of ustring.lua [#609] 2019-11-03 19:34:59 -05:00
gnosygnu
af9d6c3a92 Gui: Fix NPE when reloading a MISSING_PAGE at start-up [#608] 2019-11-03 17:45:30 -05:00
gnosygnu
de1b9a3991 Pagebanner: Update css classes for 'wpb-banner-image-panorama' [#610] 2019-11-03 17:40:50 -05:00
gnosygnu
d908d4f8b5 HTTP Server: Redirect xwiki urls to different wikis [#600] 2019-11-03 11:43:09 -05:00
gnosygnu
79bdab7946 HTTP Server: Redirect xwiki urls to different wikis [#600] 2019-11-03 11:42:28 -05:00
gnosygnu
0f8dd4a1f8 Luaj: Return NIL not NONE for table.remove and empty table [#604] 2019-10-30 09:40:08 -04:00
gnosygnu
cb3f915cb2 Wikibase: Redirect formatValue and formatValues to renderSnak and renderSnakValues [#593] 2019-10-20 13:25:19 -04:00
gnosygnu
a453ebd4cb Wikibase: Reorganize Wikibase classes; add some basic support for formatters [#593] 2019-10-20 09:28:28 -04:00
gnosygnu
7971f71dc3 Category: Add basic enums for 'numeric' and 'identity' [#601] 2019-10-15 05:15:50 -04:00
gnosygnu
f8bbdb1727 Wikibase: Combine same references from Wikidata [#596] 2019-10-15 04:30:14 -04:00
gnosygnu
bc976ac300 ParserFunctions: Add ParserFunction for PageLanguage [#595] 2019-10-13 16:52:32 -04:00
gnosygnu
c67970b5b9 Parser: Do not assume that Name_ui_w_colon matches Name [#594] 2019-10-13 11:30:40 -04:00
gnosygnu
eac055214c Scribunto: Update Diagnostics for Scribunto Hash:Diagnostics/Scribunto/HashLibrary [#589] 2019-10-12 15:19:45 -04:00
gnosygnu
866debd51d Scribunto: Add HashLibrary [#589] 2019-10-12 15:07:21 -04:00
gnosygnu
9f0cfc27bb Parser: Auto-inline dangling references tag [#583] 2019-10-06 08:40:26 -04:00
gnosygnu
a10c2cd1dc Parser: Auto-close dangling references tag [#583] 2019-10-05 12:41:48 -04:00
gnosygnu
4955748f6d Wikibase: Serialize 'references' [#587] 2019-10-03 06:34:11 -04:00
gnosygnu
73eb42c0ba Score: Clean-up test [#577] 2019-10-03 06:30:22 -04:00
gnosygnu
fca507568f Score: Check for missing src for score generated images [#577] 2019-10-02 05:51:21 -04:00
gnosygnu
1bffdadbaf Scribunto: Make table accessible from datawrapper in mw.lua [#586] 2019-09-29 23:21:08 -04:00
gnosygnu
bb86b026fe Html_dump: Include namespace+title in redlink ttl, not just title [#568] 2019-09-29 08:35:50 -04:00
gnosygnu
88e0398696 Html: Add 'lang=page_lang' to html and div tag [#576] 2019-09-28 16:39:59 -04:00
gnosygnu
e82641f341 Luaj: Do not treat '_' as a SPACE character [#582] 2019-09-28 08:37:00 -04:00
gnosygnu
597c138b56 Parser: Do not reset attributes when tag has more than 16 attributes (comment) [#579] 2019-09-27 21:09:55 -04:00
gnosygnu
fdd05c99a9 Parser: Do not reset attributes when tag has more than 16 attributes [#579] 2019-09-27 20:39:09 -04:00
gnosygnu
742e61b718 Hdump: Add missing Xoh_hdump_wkr [#584] 2019-09-27 20:24:32 -04:00
gnosygnu
1caeea5705 Xtn.Graph: Do not dump build-path for graph [#553] 2019-09-25 23:38:02 -04:00
gnosygnu
24ea3793a2 Xtn.Imap: Do not dump build-path for imap [#553] 2019-09-25 23:37:59 -04:00
gnosygnu
ec9b3ee442 Xtn.Hiero: Do not dump build-path for hiero [#553] 2019-09-25 23:37:55 -04:00
gnosygnu
ea28172885 Parser: Add hdump wkrs [#553] 2019-09-25 23:37:52 -04:00
gnosygnu
d362597d8f Parser: Do not dump build-path for imgs [#553] 2019-09-25 23:37:49 -04:00
gnosygnu
924b5fd17b Parser: Add parser-related test methods [#553] 2019-09-25 23:37:45 -04:00
gnosygnu
b980351989 Parser: Add Bfr to hdoc_wkr [#553] 2019-09-25 23:37:42 -04:00
gnosygnu
518605ece1 Parser: Rename Hzip types to Hdb_htxt and Hdb_hzip [#553] 2019-09-25 23:37:39 -04:00
gnosygnu
115ae8139e Parser:Add extra method overload to Log_file [#553] 2019-09-25 23:37:35 -04:00
gnosygnu
b17cb05edf Parser: Move alt attribute earlier in tag [#553] 2019-09-25 23:37:32 -04:00
gnosygnu
a082e3cf5d Parser: Add Init_once for wiki [#553] 2019-09-25 23:37:29 -04:00
gnosygnu
5b2db5badf Parser: Add To_str for Html_init [#553] 2019-09-25 23:37:24 -04:00
gnosygnu
32cb332b18 Wikidata: Remove unnecessary novalue / somevalue [#553] 2019-09-25 23:37:21 -04:00
gnosygnu
23cbefdeb8 Xtn.Dpl: Move Dpl_page_sorter to separate file [#553] 2019-09-25 23:37:18 -04:00
gnosygnu
620f196d4e Core: Add additional test classes [#553] 2019-09-25 23:37:04 -04:00
gnosygnu
75105c8397 Performance: Disable dirty flag after formatter is compiled [#575] 2019-09-16 22:15:47 -04:00
gnosygnu
b67e528088 Luaj: Handle % at end of replacement string [#571] 2019-09-08 23:05:25 -04:00
gnosygnu
9e302b19b5 Parser: Trim url-encoded space from the end of a title [#567] 2019-09-07 08:23:46 -04:00
gnosygnu
ce5fd232d8 Html_dump: Count 0 byte entries as 1 byte [#561] 2019-09-04 20:33:27 -04:00
gnosygnu
cda21d987f Parser: Do not reuse byte array when trimming bfr [#562] 2019-09-02 22:30:08 -04:00
gnosygnu
8f029f479b Wikibase: Show 'unknown value' / 'no value' instead of 'somevalue' / 'no value' [#529] 2019-09-02 15:33:48 -04:00
gnosygnu
d61fd33a87 References: Ignore follow items when writing primary reference [#555] 2019-09-01 10:29:55 -04:00
gnosygnu
1873c7c5f8 Wikibase: Fix typo on 'addSiteLinksUsage' and disable fineGrainedLuaTracking [#551] 2019-08-31 15:57:40 -04:00
gnosygnu
88dfc857bd Wikibase: Return label and language, not just label [#407] 2019-08-31 08:57:25 -04:00
gnosygnu
9bc0c2c75d Wikibase: Add namespacing to Scribunto libraries [#551] 2019-08-28 22:56:11 -04:00
gnosygnu
2598dee844 Xtn.Dpl: Change dynamicPageList to always get categories from cache [#556] 2019-08-25 21:39:21 -04:00
gnosygnu
42842f0bcc Category: Replace spaces with underscores in category name [#557] 2019-08-22 07:07:15 -04:00
gnosygnu
a7029f8cf1 Search: Do not fail with error when searching in wikidata / commons [#539] 2019-08-21 21:43:44 -04:00
gnosygnu
8c55d2406a Wikibase: Fix 'Module:Infobox/Cycliste:218 attempt to call nil' on many fr.w pages [#551] 2019-08-19 22:21:22 -04:00
gnosygnu
0295d816fd HTTP Server: Handle both 'file:///cur_root' and 'file:///bad_root/' [#524] 2019-08-16 02:30:10 -04:00
gnosygnu
80f4a0fbf5 Category: Fix 'A table in the database is locked' when importing en.d [#543] 2019-08-14 22:58:46 -04:00
gnosygnu
227f7943ff Html_dump: Add missing file for showing configuration to show WIKITEXT / HTML indicators in top-right [#525] 2019-08-14 22:14:00 -04:00
gnosygnu
7f3ab5f381 HTTP_Server: Ignore other request headers (Chrome incognito related) [#524] 2019-08-14 21:52:25 -04:00
gnosygnu
5ac949e8c0 HTTP Server: Generalize file:///root logic even more [#524] 2019-08-14 21:51:50 -04:00
gnosygnu
1e254caa79 Html_dump: Synchronize Xol_name_mgr [#549] 2019-08-14 08:03:20 -04:00
gnosygnu
41e9fc1287 Release: v4.6.4.1908 2019-08-14 08:01:00 -04:00
gnosygnu
be5c65c24c User.Cfg: Ignore duplicate keys in user cache [#534] 2019-08-11 14:28:51 -04:00
gnosygnu
87163c5104 Luaj: Add deprecated foreach / foreachi [#531] 2019-08-11 11:53:14 -04:00
gnosygnu
e213d123f8 Search.Suggest: Move highlighting code out of cache pathway to js_wtr [#538] 2019-08-11 08:33:17 -04:00
gnosygnu
dee491a684 HTTP Server: Remove trailing new line else POST log messages will show up with extra blank line [#537] 2019-08-11 08:02:10 -04:00
gnosygnu
2ef6211e87 HTTP Server: Fix NullPointerException when restarting HTTP_Server and going directly to search suggest [#537] 2019-08-11 08:00:49 -04:00
gnosygnu
6449368800 HTTP_Server: Move call to fsys_hack for mild performance improvement [#524] 2019-08-10 17:35:45 -04:00
gnosygnu
06afe7a7b1 Html_dump: Add configuration to show WIKITEXT / HTML indicators in top-right [#525] 2019-08-10 17:17:50 -04:00
gnosygnu
6559a2b858 Cfg: Fix 'Show search' and 'Show toolbar' not working [#532] 2019-08-10 08:39:53 -04:00
gnosygnu
a421703fb1 HTTP_Server: Generalize file:///.*/file/.* logic [#524] 2019-08-10 08:17:39 -04:00
gnosygnu
a94279c922 Sqlite: Fix faster wiki loading for read-only devices not working for Read-only files [#534] 2019-08-08 20:36:36 -04:00
gnosygnu
19c50b94be Release: v4.6.3.1908 2019-08-04 23:35:48 -04:00
gnosygnu
55a4891064 HTTP Server: Fix search-suggest not working for vector ul [#489] 2019-08-04 23:18:24 -04:00
gnosygnu
b350d95206 HTTP Server: Add search-suggest [#489] 2019-08-04 21:25:04 -04:00
gnosygnu
f5abfa11da HTTP Server: Append url_args to page [#489] 2019-08-03 17:33:04 -04:00
gnosygnu
66039fc9b3 HTTP_Server: Temporary fix to handle broken links and images in 2019-05 enwiki [#524] 2019-08-03 10:04:11 -04:00
gnosygnu
a1da02a99f HTTP_Server: Add initial implementation for post-processing HTML to change to /fsys/ etc [#524] 2019-08-03 10:00:40 -04:00
gnosygnu
a51906bf4b Make: Update wiki domains for 2019-06 Wikidata [#528] 2019-07-31 23:31:20 -04:00
gnosygnu
f38930b63a Xomw.Preprocessor: Remove deleted classes [#508] 2019-07-29 21:41:58 -04:00
gnosygnu
0854cf9ba1 Xomw.Preprocessor: Integrate rest of Preprocessor_Hash tests [#508] 2019-07-28 10:42:02 -04:00
gnosygnu
0280254e8a Scribunto: Use m_offset when doing string.substring [#520] 2019-07-25 23:34:34 -04:00
gnosygnu
9dcc571fc5 Release: 4.6.2.1907 2019-07-25 21:51:41 -04:00
gnosygnu
dea0556df5 Xomw.Preprocessor: Add XomwPPDStackElement [#508] 2019-07-24 22:17:21 -04:00
gnosygnu
436f219477 Mass_parse: Add thread-locking to LRU cache [#518] 2019-07-23 22:47:22 -04:00
gnosygnu
5c8b70fd76 Mass_parse: Use page_cache hashCode, not wiki hashCode [#514] 2019-07-22 22:38:17 -04:00
gnosygnu
4547fa541f Dev: Move XomwEnv.NewTest to XomwEnv_fxt.NewTest [#512] 2019-07-22 21:57:47 -04:00
gnosygnu
9bc2bd400c Dev: Rename test files to use '_tst' and '_fxt' convention [#512] 2019-07-22 21:51:24 -04:00
gnosygnu
877b305136 Luaj: Fix invalid url-encoding for non-ASCII characters like 'æ' [#504] 2019-07-22 21:01:30 -04:00
gnosygnu
0181a42d3d Xomw.Preprocessor: Add initial unit tests for DOM [#508] 2019-07-21 22:09:21 -04:00
gnosygnu
3b5a1f8ffc Xtn.Popups: Disable popups by default for en.wiktionary.org [#511] 2019-07-20 15:43:17 -04:00
gnosygnu
34dcfdde7d User.Logs: Delete log folders if logs are disabled [#510] 2019-07-20 09:40:26 -04:00
gnosygnu
989ccde83a Sqlite: Add option for read-only detection [#509] 2019-07-19 07:14:24 -04:00
gnosygnu
7f76d8128d Xomw.Preprocessor: Start integrating Preprocessor_Hash [#508] 2019-07-11 23:17:06 -04:00
gnosygnu
b65fda764f Luaj: Support PCRE character definitions for Luaj Regex [#502] 2019-07-01 14:09:31 -04:00
gnosygnu
5055f82d21 Scribunto: Print dbg arguments to console [#506] 2019-06-30 14:36:40 -04:00
gnosygnu
e3dce04680 Scribunto: Adjust index position correctly for ucs-2 strings [#506] 2019-06-30 14:28:46 -04:00
gnosygnu
0bfacb2ea5 Scribunto: Add frame_ttl to all Xot_invk_tkn [#503] 2019-06-29 22:29:15 -04:00
gnosygnu
9b51a7c660 Scribunto: Synchronize mw.uri.lua file with changes for uri.encode(s, 'WIKI') [#504] 2019-06-29 17:55:32 -04:00
gnosygnu
9da8b4dde8 Add gplx.xowa.mediawiki source to gplx.xowa [#508] 2019-06-29 10:18:43 -04:00
gnosygnu
5d886501e8 Language: Escape left-to-right / right-to-left marks in names.json ('\xE2\x80\x8E' to '\u200E') [#501] 2019-06-23 21:35:21 -04:00
gnosygnu
d4a28d3ffe Wikibase: Add qualifiers-order to GetEntityStatements [#374] 2019-06-22 21:53:07 -04:00
gnosygnu
2526b677fa Scribunto: Format date correctly for years with less than 4 digits (EX: +0065 -> 65 x> 2065) [#500] 2019-06-22 17:19:58 -04:00
gnosygnu
334bb0a6d0 Xtn.SyntaxHighlight: Add 'class=pretty-print lang-{lang_name}' if 'lang' is passed [#498] 2019-06-22 08:43:13 -04:00
gnosygnu
cbae5d55bb Xtn.SyntaxHighlight: Highlight lines if 'highlight' is passed but 'line' is not [#498] 2019-06-22 08:17:11 -04:00
gnosygnu
a01e7409eb Mass_parse: Change page_cache to LRU cache [#483] 2019-06-21 23:02:49 -04:00
gnosygnu
0cfb0b19ad Parser: Do not parse '&amp;#x;' as byte 0 [#494] 2019-06-16 15:38:56 -04:00
gnosygnu
d812b21dec Add comment for /LocalNames/ support [#388] 2019-06-11 07:10:29 -04:00
gnosygnu
70d845f438 Xtn.Cldr: Check CldrNames for IsKnownLanguageTag [#388] 2019-06-11 06:49:06 -04:00
gnosygnu
8ab9bc5444 Category: Replace UNION with sequential loading from each catlink db [#268] 2019-06-09 06:58:16 -04:00
gnosygnu
c459454da3 Allow hxtn command to be run multiple times during xomp_resume [#482] 2019-06-07 21:50:18 -04:00
gnosygnu
3b6efe4274 Scribunto: Fix 'Module:Exception:2 attempt to index ? (a nil value)' on some en.u pages [#475] 2019-06-02 21:44:47 -04:00
gnosygnu
c7f54287af Html: Change self-link pages from <b> to <a class='mw-selflink selflink'> [#478] 2019-06-02 21:11:51 -04:00
gnosygnu
3852d4762b HttpServer: Navigate to an error page for invalid titles like Earth] [#480] 2019-06-02 18:10:48 -04:00
gnosygnu
43cc4b15e8 Json: Parse surrogate-pairs correctly in unicode-escaped strings [#487] 2019-06-02 16:43:39 -04:00
gnosygnu
641a17621f Json: Skip forward by 5 characters, not 4 for unicode sequences [#486] 2019-06-02 14:31:04 -04:00
gnosygnu
a6ce48fffa Remove trailing whitespace [#482] 2019-06-02 13:05:13 -04:00
gnosygnu
491d1905c9 Scribunto: Ignore snak if novalue [#481] 2019-06-02 13:04:49 -04:00
gnosygnu
3d9491e2de Xtns.TemplateStyles: Cache TemplateStyles for HTML databases [#482] 2019-06-02 12:50:56 -04:00
gnosygnu
fbe158537e Fix build failing due to mis-named _fxt class [#476] 2019-06-02 11:32:57 -04:00
gnosygnu
17da6dc17f Fix build failing due to mis-named _fxt class [#476] 2019-06-02 10:07:40 -04:00
gnosygnu
b48b6def4e Xtn.Translate: Add #translation function with no implementation [#445] 2019-05-26 09:18:11 -04:00
gnosygnu
ee03d79536 Scribunto: Set frame title for pages when invoking Scribunto code [#476] 2019-05-25 17:19:47 -04:00
gnosygnu
cca043dff6 Do not wipe table upon initialization, else will lose data after xomp_resume [#456] 2019-05-24 19:31:11 -04:00
gnosygnu
05e8c11338 Scribunto: Apply namespace argument only if in main namespace [#473] 2019-05-22 22:36:15 -04:00
gnosygnu
b74ca77786 ParserFunctions: Increase precedence of E over ln and other operations [#397] 2019-05-19 11:08:08 -04:00
gnosygnu
42dbaff1d2 Scribunto: Encode key / val in GetUrl [#465] 2019-05-18 17:22:42 -04:00
gnosygnu
648cd4944a Remove unused invk branch; Update tests [#460] 2019-05-12 23:42:42 -04:00
gnosygnu
c07e6e25b5 Parser: Change encoding of html id to encode fewer characters [#462] 2019-05-12 23:31:48 -04:00
gnosygnu
ba35901865 Parser: Parse html in internal link captions [#460] 2019-05-12 20:09:51 -04:00
gnosygnu
4d9072830c HTTP Server: Parse links with trailing slash [#459] 2019-05-11 23:45:51 -04:00
gnosygnu
c94090cd09 Parser: Add test for djvu [#440] 2019-05-11 11:00:08 -04:00
gnosygnu
31c6576b50 Parser: Handle UTF-8 characters in attribute keys / values [#457] 2019-05-11 10:55:37 -04:00
gnosygnu
3a748eea32 Add comment to clarify that NULL content should return NULL [#450] 2019-05-08 06:40:52 -04:00
gnosygnu
cf94f252e9 Make: Add xomp_stats to track time per page (and other attributes) [#456] 2019-05-08 06:35:10 -04:00
gnosygnu
5db81504fb Upgrade Apache Commons Compress from 1.5 to 1.18 2019-04-28 18:36:24 -04:00
gnosygnu
4e920af183 Fix broken gmatch test; Fix broken maven build 2019-04-28 18:29:57 -04:00
gnosygnu
0f75a625db Update build files for new baselib [#413] 2019-04-28 18:06:57 -04:00
gnosygnu
f860edf064 Scribunto: Use Luaj for pattern-matching (instead of Java Regex) [#413] 2019-04-28 17:31:33 -04:00
gnosygnu
4a1b2e25c0 Parser: Comment|Terminate comment if new-line found [#437] 2019-04-27 09:00:30 -04:00
gnosygnu
f895259be6 Wikibase: Add entity-type for lexeme so that 2019-04 wikidata jsons don't fail 2019-04-26 22:27:36 -04:00
gnosygnu
42953aaa0f MassParse: Fix multi-threaded issues b/c wbase caches aren't locked 2019-04-26 22:26:54 -04:00
gnosygnu
74b63d5f08 Test: Add utility core.Page_url for easier logging; also do not run cfg during tests 2019-04-26 22:26:00 -04:00
gnosygnu
1cde843264 Project: Rename test classes for xowa_maven script 2019-04-26 22:24:44 -04:00
gnosygnu
5204d33af7 Dev: Fix more echo mistakes; rename boot.sh [#427] 2019-04-07 23:08:03 -04:00
gnosygnu
bc9e017906 Dev: Fix bootstrapping issues and bad echoes [#427] 2019-04-07 22:57:36 -04:00
gnosygnu
a5644dea07 Dev: Add Maven build files [#427] 2019-04-07 22:35:38 -04:00
gnosygnu
bbbc14eb34 Refactor: Move database-server tests into tst folder [#427] 2019-04-07 22:12:07 -04:00
gnosygnu
022d551760 Refactor: Add _tst suffix to test classes.gfs [#427] 2019-04-07 21:35:27 -04:00
gnosygnu
73cb63c493 Refactor: Remove stray f from beginning of xowa.gfs [#427] 2019-04-07 21:27:42 -04:00
gnosygnu
4909799a67 Refactor: Rename *_test.java files to *_mock.java files [#427] 2019-04-07 21:26:54 -04:00
gnosygnu
367a3a94b9 Refactor: Remove unused experimental files [#427] 2019-04-07 21:15:11 -04:00
gnosygnu
f22a0cca43 Refactor: Remove unnecessary junit import [#427] 2019-04-07 21:14:13 -04:00
gnosygnu
42b158c165 Css: Add 'mw-parser-output' to main div [#274] 2019-04-07 14:22:53 -04:00
gnosygnu
09d9f93d20 Parser.Wikibase: Retrieve by label if pid is not present; also, return pid, not label [#354] 2019-04-07 12:27:50 -04:00
gnosygnu
623c7a129e Fix broken Luaj jar [#419] 2019-04-03 00:19:01 -04:00
gnosygnu
cc8b9810a7 Parser.Tidy: Add vnu as additional tidy engine [#417] 2019-04-01 23:50:26 -04:00
gnosygnu
31c7604f03 Scribunto: Add initial support for LuaJ StringLib as replacement for Regex [#413] 2019-04-01 22:34:45 -04:00
gnosygnu
2fc03f6211 Parser.TemplateStyles: Check if title is null [#416] 2019-04-01 00:13:30 -04:00
gnosygnu
581aa5123c Parser.Wikibase: Return null instead of empty string if invalid title passed to getEntityId [#415] 2019-04-01 00:00:05 -04:00
gnosygnu
8c1f30039b Css: Change css jump-to class from 'mw-navigation' to 'mw-head' [#394] 2019-03-30 10:08:20 -04:00
gnosygnu
61cc5e89a7 Release: v4.6.1.1903 [#404] 2019-03-26 22:52:55 -04:00
gnosygnu
7bcbdabbfc Htxt: Extract img.src data [#404] 2019-03-26 22:26:26 -04:00
gnosygnu
04c7326b1d Release: v4.6.0.1903 [#403] 2019-03-24 18:13:15 -04:00
gnosygnu
2dfa751958 Parser.Lnki: Treat keywords as caption if not File namespace or if keyless [#303] 2019-03-24 10:26:58 -04:00
gnosygnu
ef0300dfeb Make: Rewrite pagelink builder [#396] 2019-03-24 07:54:33 -04:00
gnosygnu
14d978e2af Html: Reformat HTML for jump-to div [#394] 2019-03-20 22:46:14 -04:00
gnosygnu
9b5d585750 Scribunto: Pull 0th argument if %1 is specified and 0 groups [#393] 2019-03-20 21:41:54 -04:00
gnosygnu
71232e4402 Gui: Fix Read / Edit / HTML not working by keyboard shortcuts / in personal wikis [#392] 2019-03-20 08:33:30 -04:00
gnosygnu
ab4cbbd3c1 Htxt: Do not redlink interwiki links [#391] 2019-03-20 02:58:37 -04:00
gnosygnu
ca8c4ce5a4 Htxt: Show Table of Contents [#390] 2019-03-20 02:42:45 -04:00
gnosygnu
82bee2e877 Html: Write full page url to log file, not just page title [#387] 2019-03-20 01:44:22 -04:00
gnosygnu
4f22548121 Transpiler: Misc whitespace changes 2019-03-20 01:15:42 -04:00
gnosygnu
ad317bd90e Html_dump: Lock calls to cat_core Select [#389] 2019-03-20 01:12:47 -04:00
gnosygnu
a94a9f0c7f Cite: Change Cite to follow MediaWiki behavior for super-scripting [#382] 2019-03-18 23:11:26 -04:00
gnosygnu
41deb3c0c1 Language: Update language list [#384] 2019-03-17 19:02:12 -04:00
gnosygnu
8ef5854eb7 Scribunto: Iterate regx by codepoint not by bytes [#383] 2019-03-16 23:50:26 -04:00
gnosygnu
4cd23b9827 Update ant files for new icu4j-57_1.jar [#237] 2019-03-10 21:31:42 -04:00
gnosygnu
92927687a5 Doc: Add FAQ for why date-related pages are empty [#367] 2019-03-10 20:41:47 -04:00
gnosygnu
7d747b6d28 Htxt: Register gallery images [#370] 2019-03-10 20:30:23 -04:00
gnosygnu
bafa4e31dd Setup: Update css and images for home wiki [#380] 2019-03-10 14:30:32 -04:00
gnosygnu
91a100f154 Parser: Fix anchorencode for trailing lnki [#373] 2019-03-10 10:09:08 -04:00
gnosygnu
dd750c6c4e Add classpath for upgraded icu47 [#237] 2019-03-10 10:00:01 -04:00
gnosygnu
0eabd9efc2 Category: Upgrade toicu4j-57_1.jar [#237] 2019-03-09 23:25:19 -05:00
gnosygnu
992cde7e71 Update comments [#377] 2019-03-09 23:25:01 -05:00
gnosygnu
f40f227454 Htxt: Set src_bgn at start of block, not after video element [#369] 2019-03-07 07:14:26 -05:00
gnosygnu
790e82ac9e Scribunto: Classify 3 byte UTF-8 sequences as 1 Java char, not 2 Java chars [#377] 2019-03-04 23:16:43 -05:00
gnosygnu
beab14117e Parser.Lnke: Escape ampersand in external links [#371] 2019-03-03 21:20:34 -05:00
gnosygnu
a70131254f Math: Increment math uid [#375] 2019-03-03 16:39:47 -05:00
gnosygnu
5c724dc93d Timeline: Fix many minor timeline bugs [#368] 2019-03-03 15:33:04 -05:00
gnosygnu
3488084eca Scribunto: Use PHP.empty for noCommafy [#372] 2019-03-02 09:00:02 -05:00
gnosygnu
3fd759b020 Scribunto: Do not fail in ustring.find if negative bgn is large [#366] 2019-02-24 16:14:34 -05:00
gnosygnu
91cbb34fa5 Lang: Update comments for fallbacks [#330] 2019-02-17 20:14:16 -05:00
gnosygnu
c383f2a231 Language: Check if lang exists in fallback hash before adding it [#330] 2019-02-17 19:22:26 -05:00
gnosygnu
e744c5123a Luaj: Do not auto-case strings to ints in LuaTable.set [#360] 2019-02-17 08:26:39 -05:00
gnosygnu
81ea765714 Dev: Downgrade 'no cldrName file exists for lang' to session.txt [#351] 2019-02-12 23:04:58 -05:00
gnosygnu
b822997638 Dev: Downgrade 'lang does not have a cldrName file' to session.txt [#351] 2019-02-12 22:52:02 -05:00
gnosygnu
be4d2fdfb4 Lang: Add more error message detail to track 'counts do not match' [#330] 2019-02-12 22:46:15 -05:00
gnosygnu
a5f8b6e482 Wikidata: Trim whitespace from start and end of qid in GetEntity [#363] 2019-02-12 22:19:52 -05:00
gnosygnu
21309d66be Wikidata: Trim whitespace from start and end of property keys [#361] 2019-02-11 22:36:28 -05:00
gnosygnu
298c83a806 Dev: Log page for messages of form 'wbase:could not find datatype for pid' [#351] 2019-02-10 14:13:17 -05:00
gnosygnu
2fa5d9bc03 Dev: Downgrade missing-cldrName-file message to session.txt [#351] 2019-02-10 09:10:55 -05:00
gnosygnu
78e8db95b9 Dev: Log page url not page ttl when missing wikidata doc [#351] 2019-02-10 09:05:31 -05:00
gnosygnu
e80dfc6adc Dev: Add synchronized block when loading lang [#330] 2019-02-10 08:33:58 -05:00
gnosygnu
571f0a2388 Dev: Release bry_bfr in Tag_html_wkr_basic [#351] 2019-02-05 22:37:45 -05:00
gnosygnu
ba40cf6c69 Htxt: Add comments for htxt [#320] 2019-02-04 23:32:12 -05:00
gnosygnu
cde0163ae7 Xtn.Cldr: Fix missing lang returning Cldr_name_file.Empty instead of null [#349] 2019-02-04 23:25:38 -05:00
gnosygnu
ebfd7a8352 Scribunto: Add 'dotted' form of file path [#353] 2019-02-04 22:11:45 -05:00
gnosygnu
cd56234e28 HTML Databases: Show redlinks for htxt [#320] 2019-02-03 23:48:23 -05:00
gnosygnu
4c47bb8793 HTML Databases: Allow Hzip_none for saving / loading images [#320] 2019-02-02 09:35:12 -05:00
gnosygnu
739d302850 Scribunto: Return ['en'] not [] if unknown language [#340] 2019-02-01 23:12:24 -05:00
gnosygnu
5daf74516a Dev: Convert file-names with underscores to keys; EX: En_gb -> en-gb [#349] 2019-02-01 22:51:04 -05:00
gnosygnu
6b5c014e75 Xtn.Popups: Do not show category pages from popup [#339] 2019-02-01 22:14:36 -05:00
gnosygnu
c32a4ae253 Xtn.Popups: Update page title on Scrib_core when generating popup [#338] 2019-02-01 22:05:42 -05:00
gnosygnu
8b13930d30 Dev: Add comment to explain Id_xowa_wikidata [#348] 2019-01-31 23:46:14 -05:00
gnosygnu
46ec06986e Dev: Remove previous items with 'rm -rf' [#345] 2019-01-31 23:18:36 -05:00
gnosygnu
29d82a5b88 Dev: Remove previous items with 'rm -rf' [#345] 2019-01-30 00:28:47 -05:00
gnosygnu
560e3c9685 Dev: Extend lock scope over Get_by_exact_id_or_null [#347] 2019-01-29 23:58:30 -05:00
gnosygnu
5fa8c20561 Scribunto: Change fetchForLanguages to return a key of languageCode, not integer-id [#331] 2019-01-27 21:25:30 -05:00
gnosygnu
4626203f16 Scribunto: Handle anypos flag [#337] 2019-01-27 21:18:20 -05:00
gnosygnu
f44a1874a8 Dev: Replace wget with curl; fix JAVA_HOME [#335] 2019-01-22 03:32:09 -05:00
gnosygnu
0ecb31575f Wikidata: Exit early if invalid title [#333] 2019-01-21 00:38:16 -05:00
gnosygnu
aaa402119b Wikidata: Add 'P' to property link [#332] 2019-01-21 00:27:52 -05:00
gnosygnu
5d8a139903 Scribunto: Change default for fetchLanguageName from 'mw' to null [#331] 2019-01-21 00:16:23 -05:00
gnosygnu
b3120bab39 Dev: Update README.md for command-line 2019-01-20 21:38:46 -05:00
gnosygnu
a08f7f362d Dev: Add example make script 2019-01-20 21:30:59 -05:00
gnosygnu
1517fcd585 Dev: Fix missing junit import 2019-01-20 19:45:56 -05:00
gnosygnu
bc60e09823 Dev: Add xul_runner and update ant xml files 2019-01-20 17:32:07 -05:00
gnosygnu
c4682aad9c Dev: Initial commit of artifacts for build script 2019-01-19 21:16:59 -05:00
gnosygnu
f1c8fb3404 Scribunto: Allow strings and other primitive values for jsonEncode / jsonDecode [#329] 2019-01-13 17:33:35 -05:00
gnosygnu
8412119902 File: Suppress mismatch_exts for opus file_type [#295] 2019-01-10 23:26:37 -05:00
gnosygnu
2f3f84fba3 Html: Change message from 'was last modified' to 'was last edited' (en.gfs) [#321] 2019-01-10 23:13:45 -05:00
gnosygnu
8cd39534a6 Html: Change message from 'was last modified' to 'was last edited' [#321] 2019-01-10 23:12:09 -05:00
gnosygnu
85478ad7e7 Dev: Do not log 'inserting cat_link row' [#322] 2019-01-10 21:53:41 -05:00
gnosygnu
42d15b726c HTML Databases: Make plain-text parser thread-safe; Simplify code; Fix gallery not working [#320] 2019-01-06 21:27:33 -05:00
gnosygnu
2b4320b302 HTML Databases: Fix loading of plain-text pages; Normalize some behavior in page-sync code [#320] 2019-01-05 11:50:11 -05:00
gnosygnu
9e5a13f54f Category: Pass count into category msg [#316] 2019-01-01 18:18:07 -05:00
gnosygnu
e250331e97 HTTP Server: Retain new-line when processing form-data [#315] 2018-12-31 07:09:36 -05:00
gnosygnu
cc502c872f TemplateStyles: Add templatestyles to html.head [#314] 2018-12-30 23:25:29 -05:00
gnosygnu
e65d9268d6 Html: Change div_view_fmtr to be sitename aware [#313] 2018-12-29 10:12:28 -05:00
gnosygnu
b86228d6f2 Minor refactorings 2018-12-29 09:36:32 -05:00
gnosygnu
87cb6b5a01 Html: Do not hzip anchors with invalid href [#311] 2018-12-27 09:41:00 -05:00
gnosygnu
1f2b73699b Html: Standardize spacing between subpage entries [#308] 2018-12-27 08:46:53 -05:00
gnosygnu
1d54b8a756 Parser: Fix inconsistent html-encoding of {{#tag}} calls [#312] 2018-12-25 12:30:21 -05:00
gnosygnu
54ad1d697d Html: Replace underscores with spaces in subpages [#308] 2018-12-23 21:49:57 -05:00
gnosygnu
43ec6a8163 Css: Trim whitespace from start and end of css-related urls [#307] 2018-12-23 21:24:36 -05:00
gnosygnu
64cd27e9fe Search: Remove duplicate line in link_score builder [#305] 2018-12-20 23:40:40 -05:00
gnosygnu
166963d767 Parser: Treat empty class / alt keys as caption [#303] 2018-12-16 22:13:08 -05:00
gnosygnu
089661a0bc HTTP Server: Change url parsing logic to support slashes [#301] 2018-12-16 21:39:48 -05:00
gnosygnu
af19381e3c Scribunto: Fix broken test for fetchLanguageNames 2018-12-09 22:00:07 -05:00
gnosygnu
3935d10b45 Gui: Fix Ctrl+E | Ctrl+E not activating debug expansion 2018-12-09 17:09:43 -05:00
gnosygnu
f151d7babf ParserFunctions: Do not add '/wiki/' for non-WMF wikis [#298] 2018-12-09 09:35:03 -05:00
gnosygnu
225959160c Wikibase: Fix getBestStatements to return normal if no preferred [#297] 2018-12-09 03:42:26 -05:00
gnosygnu
51e42d65ad File: Add opus file type [#295] 2018-12-05 23:31:00 -05:00
gnosygnu
333c507720 HTTP Server: Preliminary push of Search code to fix compile error [#289] 2018-11-27 07:07:35 -05:00
gnosygnu
68fe39f5e1 HTTP Server: Update href for 'shortcut icon' [#285] 2018-11-26 06:58:50 -05:00
gnosygnu
8abb2cd0ee HTTP Server: Fix broken read tab; fix preview not working [#264] 2018-11-25 22:05:05 -05:00
gnosygnu
38bdc95acf HTTP Server: Support popups [#264] 2018-11-25 10:17:03 -05:00
gnosygnu
2e5994788f ParserFunctions: Support next / previous for day of week [#262] 2018-11-18 23:04:59 -05:00
gnosygnu
50d1fbfed1 Category: Add comment and change casting order [#269] 2018-11-14 23:28:26 -05:00
gnosygnu
41773e586b Parser: Change ttl.Page_db() to ttl.Full_db() [#277] 2018-11-14 22:57:34 -05:00
gnosygnu
dca2357067 HTTP Server: Support 'action=edit' / 'action=html' [#264]
Also:
* Change XOWA GUI to use 'action' query args, instead of xowa-cmd
* Remove nginx http_variables due to compiler warnings
2018-11-03 11:04:03 -04:00
gnosygnu
6e361414f5 HTTP Server: Use url-encoded article link [#254] 2018-11-03 01:19:33 -04:00
gnosygnu
5137eda4fb HTTP Server: Ignore nginx http headers [#255] 2018-11-02 20:58:51 -04:00
gnosygnu
9a81e1b593 HTTP Server: Reorder href attribute so that it follows a tag [#252] 2018-11-02 20:37:37 -04:00
gnosygnu
5721913241 Res: Add resources from xowa_app_windows_64_v4.5.26.1810 2018-11-02 09:58:55 -04:00
gnosygnu
a672fd8340 Cfg: Escape textarea content [#250] 2018-11-01 23:27:19 -04:00
gnosygnu
0f89d3aa3a TemplateStyles: Handle empty files 2018-10-21 22:25:11 -04:00
gnosygnu
4cadd6b89b Wikibase: Support bcp in language node 2018-10-21 21:50:17 -04:00
gnosygnu
62f41ebbd3 CldrNames: Handle case-sensitive file systems 2018-10-14 11:13:37 -04:00
gnosygnu
a8f6fd0fb0 Template_styles: Add support for template styles 2018-10-12 23:16:31 -04:00
gnosygnu
e78382a8ac Cldr: Add initial support for cldr 2018-08-05 21:21:40 -04:00
gnosygnu
be3979c5af General: Remove text database support 2018-07-11 07:53:27 -04:00
gnosygnu
fe0d1abde5 Wikibase: Add datatype for lexeme 2018-07-08 09:27:29 -04:00
gnosygnu
d35adffa31 Wikibase: Fix import failing due to NPE on wbase_db 2018-07-08 09:26:23 -04:00
gnosygnu
d98639c18a Scribunto: Handle fake capturing groups from balanced regex 2018-07-08 07:51:43 -04:00
gnosygnu
f85cf8ad77 ParserFunctions: Cache ifexist result of common wiki in current wiki 2018-07-03 08:42:02 -04:00
gnosygnu
eb9cca66ed Wikibase: Fix regex for balanced pairs 2018-07-02 22:56:26 -04:00
gnosygnu
070eb3c53a Wikibase: Check for null in getEntityId when title is invalid 2018-07-01 08:45:49 -04:00
gnosygnu
372cd3958d Wikibase: Fix script error 'libraryUtil.lua:13 bad argument #1 to message.newRawMessage' on sever dozen military pages 2018-07-01 07:55:55 -04:00
gnosygnu
10c39e4c76 Wikibase: Add basic support for getSetting 2018-07-01 07:15:13 -04:00
gnosygnu
341d2e13a4 Wikibase: Add getReferencedEntityId; refactor some wikibase code 2018-06-24 08:36:34 -04:00
gnosygnu
6348aa6177 Wikibase: Add entityExists 2018-06-23 11:07:35 -04:00
gnosygnu
29a8fb7824 Wikibase: Add isValidEntityId 2018-06-23 10:52:47 -04:00
gnosygnu
fbe19f4614 Wikibase: Do not fail to run util.site_meta if wikimedia api returns nothing 2018-04-17 17:27:28 -04:00
gnosygnu
24aefd43e4 Html_dump: Fix repeating links on many de.w pages 2018-04-17 07:19:37 -04:00
gnosygnu
3923df5e19 HTTP Server: Fix random deadlocks when serving multiple concurrent requests (writing json) 2018-03-13 22:10:39 -04:00
gnosygnu
5e668b96c7 HTTP Server: Fix random deadlocks when serving multiple concurrent requests 2018-03-11 21:28:29 -04:00
gnosygnu
93bac15244 Graph: Support version 2 graphs 2018-03-03 08:52:14 -05:00
gnosygnu
54d74b0acd JsonConfig: Add Localize function for tabular data 2018-02-18 08:16:43 -05:00
gnosygnu
8967ca810a Wikibase: Revert script error '=Module:Cycling race:3070 attempt to index ? (a nil value)' on 1 de.w page (test) 2017-12-31 07:49:07 -05:00
gnosygnu
af3e8aef00 Wikibase: Fix script error '=Module:Cycling race:3070 attempt to index ? (a nil value)' on 1 de.w page 2017-12-30 09:50:18 -05:00
gnosygnu
2550a87a60 JsonConfig: Fix script error '=Module:Data:8 attempt to index ? (a nil value)' on a dozen de.w pages 2017-12-28 08:22:53 -05:00
gnosygnu
f999febe6d Parser: Fix doubling up of images 2017-12-20 06:31:31 -05:00
gnosygnu
8332509b60 Wikibase: Add preliminary classes for getLabelByLanguage 2017-12-05 05:12:51 -05:00
gnosygnu
4182c18b1d Parser: Parse image.link args with with xwiki, namespace, but no title 2017-12-02 10:19:02 -05:00
gnosygnu
e30828a270 Scribunto: Fix script error 'NullPointerException' on a few en.w pages 2017-11-29 23:10:44 -05:00
gnosygnu
539a6fad6a Wikibase: Support hiwikivoyage 2017-11-29 06:17:58 -05:00
gnosygnu
698ee7451d Wikibase: Support tabular-data 2017-11-29 06:12:30 -05:00
gnosygnu
3126b46faf Wikibase: Add getBestStatements / getEntityUrl; ParserFunctions: Improve support for relative month 2017-11-29 06:04:23 -05:00
gnosygnu
66877212bf Embeddable: Create core dbs in proper subdirectory 2017-10-23 20:50:50 -04:00
gnosygnu
1336d44f34 Embeddable: Create core dbs in proper subdirectory 2017-10-23 20:50:22 -04:00
gnosygnu
dc22c15895 Embeddable: Download interwiki map 2017-10-23 17:44:33 -04:00
gnosygnu
ecc27daec8 Scribunto: Trim whitespace for keys 2017-10-23 08:18:23 -04:00
gnosygnu
3157551d1d Refactor: Clean up Int_ classes 2017-10-22 08:07:00 -04:00
gnosygnu
d270cce881 Refactor: Clean up Type_ classes 2017-10-08 18:24:59 -04:00
gnosygnu
209601744e Graph: Add stripComments and removeTrailingCommas 2017-09-24 17:02:32 -04:00
gnosygnu
e9381c9b38 Embeddable: Append categories to HTML 2017-09-18 21:43:02 -04:00
gnosygnu
ea3f0ffbcc App: Release v4.5.15.1709 2017-09-17 22:39:30 -04:00
gnosygnu
4ca98f7333 App: Release v4.5.15.1709 2017-09-17 22:38:44 -04:00
gnosygnu
131c2f696c Scribunto: Return null if integer key is not found 2017-09-16 21:36:50 -04:00
gnosygnu
5e7263ec5c Wikibase: Add dinwiki and hiwikiversity 2017-09-10 08:22:00 -04:00
gnosygnu
a50031b261 Wikibase: Add id to wikibase data table 2017-09-04 11:38:10 -04:00
gnosygnu
4705592259 Hzip: Compress and decompress recent xowa_alt_text 2017-09-04 10:05:54 -04:00
gnosygnu
b101b356ad Scribunto: Evaluate template-args when expanding template, not separately afterwards 2017-09-04 08:30:33 -04:00
gnosygnu
9f6ef68bfa Http_server: Ignore all special pages if empty-string is passed to --http_server.special_pages_safelist 2017-08-04 22:02:21 -04:00
gnosygnu
7c2e3f7295 Http_server: Do not fail if Search has invalid title characters 2017-07-24 21:03:07 -04:00
gnosygnu
1db737405f Html: Add option to hide xowa-alt in html db 2017-07-23 10:23:46 -04:00
gnosygnu
1dbe526051 Http_server: Add special_pages_safelist 2017-07-22 08:25:08 -04:00
gnosygnu
c1e66a7e7d Html: Fix last_modified_msg not updating 2017-07-11 21:11:34 -04:00
gnosygnu
df63a6ff6b Html: Add customizable footer 2017-07-08 17:02:17 -04:00
gnosygnu
807c911cdf Http_server: Do not override command-line port with config port 2017-07-07 20:17:49 -04:00
gnosygnu
0eabb64abc Http_server: Fix full-text search not working 2017-07-05 06:55:36 -04:00
gnosygnu
f1da174c5c Night-mode: Allow global user-overrides for night-mode css / logo 2017-06-25 15:47:30 -04:00
gnosygnu
67fc90d43f Night-mode: Allow custom night-mode logos per wiki 2017-06-25 09:19:29 -04:00
gnosygnu
31bc573a29 Table_of_contents: Deprecate id='toctitle' in favor of class='toctitle' 2017-06-17 19:18:39 -04:00
gnosygnu
abe79be6cb Categories: Add colon to Categories if page_grouping is disabled 2017-06-17 11:02:22 -04:00
gnosygnu
0765beb04a Table_of_contents: Ignore NOTOC commands at template level 2017-06-17 10:44:08 -04:00
gnosygnu
e2e68342e0 Table_of_contents: Ignore NOTOC commands at template level 2017-06-17 10:34:29 -04:00
gnosygnu
a439f53c1a ParserFunctions: Fix broken test for {#tag} and apos 2017-06-07 22:05:48 -04:00
gnosygnu
c2dca930f3 Embeddable: Handler null pointer exceptions for <gallery> when no de.wikipedia.org-file-core.xowa file is available 2017-06-06 22:05:28 -04:00
gnosygnu
e687f23586 ParserFunctions: Fix broken navboxes on many fr.v pages 2017-06-01 23:15:35 -04:00
gnosygnu
d521299987 Embeddable: Handle redirects 2017-05-29 14:43:13 -04:00
gnosygnu
f129344506 Scribunto: Fix 'gplx.Err: bad argument: nil: idx=0 len=0' on a few dozen fr.u pages 2017-05-28 09:28:30 -04:00
gnosygnu
c4a2bbcd95 Parser.Xml: Do not print <meta> and <link> tags 2017-05-28 09:13:49 -04:00
gnosygnu
633fb2979f Threading: Add 'redirectTarget' to Scrib_lib_title 2017-05-27 21:53:21 -04:00
gnosygnu
2776790369 Threading: Fix rare multi-thread error for Hiero parser 2017-05-26 06:09:10 -04:00
gnosygnu
3b4a3a5af5 Parser: Show page name for [[Media:]] links without caption (XOWA-122) 2017-05-20 09:11:41 -04:00
gnosygnu
ffe4c0d094 Scribunto: Fix script error 'NullPointerException' on 1 en.w page 2017-05-11 22:08:42 -04:00
gnosygnu
bee71c22fe Page_sync: Sync recently-created pages 2017-05-07 11:47:53 -04:00
gnosygnu
417fd8b990 Xomw: Add more implementation for extractParam 2017-04-30 08:47:54 -04:00
gnosygnu
af2d0c51db Release: Release v4.5.2.1704 2017-04-27 19:25:04 -04:00
gnosygnu
b43ec6d2e2 Parser.Date: Parse times with format of 'm/d/yyyy' where d == 13 2017-04-25 07:29:38 -04:00
gnosygnu
efae8aff51 Search: Include pages with scores of 10,000 or less 2017-04-24 21:23:00 -04:00
gnosygnu
ea3cb238fd Scribunto.Regex: Reinstate codepoint calculations for ustring.find 2017-04-24 21:16:20 -04:00
gnosygnu
0e3af23c87 Scribunto.Regex: Do not exit early if regx_proc fails match 2017-04-24 07:08:08 -04:00
gnosygnu
4a1546b9a2 Scribunto.Regex: Add only first match for mw.ustring.match, not all of them 2017-04-23 17:31:20 -04:00
gnosygnu
1d6b3779a0 Scribunto: Fix script error '=Module:zh-glyph:120 attempt to concatenate nil and string' on a few hundred en.d pages for Chinese chars 2017-04-23 09:47:58 -04:00
gnosygnu
eaa83db644 Mass_parse: Embed score in full-text search index 2017-04-22 09:40:15 -04:00
gnosygnu
53c3400366 Scribunto.Regex: If gsub_replace lua proc returns nothing, do not replace with empty string 2017-04-22 08:35:53 -04:00
gnosygnu
fb934457f9 Xomw: Add commafy 2017-04-18 21:38:55 -04:00
gnosygnu
80f572a06c Parser.Xml: Fix script error 'Unable to convert section' on 1 en.w page 2017-04-10 21:32:56 -04:00
gnosygnu
d9377b5162 Parser.Xnde: Add better warning message for dangling extensions ('<ref>a</ref') 2017-04-10 21:20:40 -04:00
gnosygnu
60d752723b Download_central: Comment support for wikitext downloads 2017-04-09 22:13:57 -04:00
gnosygnu
aaa8ebadd7 Download_central: Add support for wikitext downloads 2017-04-09 22:08:54 -04:00
gnosygnu
00318ce8cf Scribunto.Common: Fix script error 'Country data' on many en.w game pages 2017-04-09 09:42:51 -04:00
gnosygnu
be0d09aaff Xomw: Add minor changes to XomwMessage / XomwLanguage 2017-04-09 08:43:51 -04:00
gnosygnu
ea46354cf8 Parser.Table: Close previous paragraph when starting table 2017-04-08 20:56:12 -04:00
gnosygnu
680e6b88d6 Mass_parse: Do not fail when generating full-text search indexes 2017-04-08 08:14:21 -04:00
gnosygnu
5fef0af3a5 Personal_wikis: Create personal wikis with latest search database schema 2017-04-06 22:37:30 -04:00
gnosygnu
0d1b478aa2 Xomw: Add paramVal methods to XomwMessage 2017-04-05 07:07:27 -04:00
gnosygnu
1ba6f094e3 Wikibase.Scribunto: Support #statements keyword 2017-04-04 06:02:51 -04:00
gnosygnu
26a56950cd Wikibase.Coordinate: Reverse NS / EW direction for geocoordinates; also, standardize spacing / symbols for wikibase 2017-04-02 08:46:12 -04:00
gnosygnu
8501ec6fd8 Parser.Time: Ignore multiple years / multiple days when parsing date for #time function 2017-04-01 17:06:41 -04:00
gnosygnu
3674dcf8de Scribunto.Site: Use fully-qualified url for url property, not domain 2017-04-01 09:38:20 -04:00
gnosygnu
8cda46bef9 Scribunto.Lang: Return 1st three letters of unknown language codes, not blank 2017-04-01 08:13:49 -04:00
gnosygnu
83c40c8771 Parser: Add more support for UNIQ substitutions with extension tags 2017-03-31 19:17:47 -04:00
gnosygnu
145635b6c7 Xomw: Add message param utility classes 2017-03-31 09:36:47 -04:00
gnosygnu
f57fd74e13 Parser.Ref: Change UNIQ prefix / suffix 2017-03-31 08:04:08 -04:00
gnosygnu
3441135fad Parser.Ref: Add commented fix for ref tag in template 2017-03-30 22:11:00 -04:00
gnosygnu
3023353154 Xomw: Add more implementation for XomwMessage 2017-03-30 08:38:23 -04:00
gnosygnu
67787c720a Gui: Change back-color of Options.Shortcut.Bindings window from gray to white 2017-03-29 18:31:19 -04:00
gnosygnu
ff3b65c438 Personal_wikis: Fix perpetual 'Do you want to upgrade your search databases' when using Search field for personal wikis 2017-03-29 18:22:00 -04:00
gnosygnu
e5beacf7c4 Full-text search: Remove logic to reset portal due to regression error with Wikivoyage diagnostic 2017-03-29 18:02:35 -04:00
gnosygnu
541b6e461d Full-text search: Add fallback behavior to Special:Search if index is not available 2017-03-29 15:10:57 -04:00
gnosygnu
62d7e6adfe Full-text search: Add option to switch between Special:Search and Special:XowaSearch 2017-03-29 14:51:36 -04:00
gnosygnu
04b798483e Gui: Add url_box format for displaying custom urls like 'English Wikipedia/Earth' 2017-03-29 08:52:38 -04:00
gnosygnu
b01b85fcc1 Full-text search: Upgrade oojs-ui and other minor changes 2017-03-28 22:25:25 -04:00
gnosygnu
27e582441a Full-text search: Tweak searcher and cfg for Android 2017-03-28 15:00:27 -04:00
gnosygnu
9e53bfdb05 Gui: Change SWT layout call due to incompatibility with Android library 2017-03-28 09:17:01 -04:00
gnosygnu
dfde355703 Full-text search: Show warning message if indexes are not available 2017-03-28 09:05:20 -04:00
gnosygnu
909a715332 Gui: Use constants for showing / hiding search / allpages 2017-03-28 07:57:28 -04:00
gnosygnu
13002e5efb Full-text search: Support paging for XOWA Wikitext search 2017-03-28 07:47:32 -04:00
gnosygnu
36cb2c22f6 Gui: Add allpages and search buttons 2017-03-27 21:49:50 -04:00
gnosygnu
c964eedd58 Full-text search: Add expand_pages 2017-03-27 16:58:57 -04:00
gnosygnu
968e8917c2 Full-text search: Allow multiple-wiki specificity for expand_snips 2017-03-27 12:42:30 -04:00
gnosygnu
f8f8fa3c3b Wikibase: Add 'datatype' property to 'Property:' pages 2017-03-27 10:04:10 -04:00
gnosygnu
7e476fde06 Xomw: Add XomwMessageContent and related classes 2017-03-27 08:53:30 -04:00
gnosygnu
39830cfa4f Full-text search: Add menu entry for title search 2017-03-26 21:26:03 -04:00
gnosygnu
e6ae41d9fd Full-text search: Add unpack lucene 2017-03-26 21:06:42 -04:00
gnosygnu
a43c0d17ba Full-text search: Add pack_lucene 2017-03-26 20:14:18 -04:00
gnosygnu
f2520ef81f Full-text search: Rename directory to java7-v1 2017-03-26 11:02:29 -04:00
gnosygnu
176ac30b0e Full-text search: Add menu options for XowaSearch and AllPages 2017-03-26 11:00:03 -04:00
gnosygnu
25945ed072 Xomw: Add fragment implementation; Stub out classes for XomwMessageContent 2017-03-26 10:22:37 -04:00
gnosygnu
022cb2684e Full-text search: Tweak minor UI settings 2017-03-26 02:08:19 -04:00
gnosygnu
dcdc69e374 Xomw: Implement Interwiki part of GetTitleCodec 2017-03-25 08:54:59 -04:00
gnosygnu
0b762933b2 Full-text search: Add expand_options; clean up other options 2017-03-24 21:54:02 -04:00
gnosygnu
688f276552 Full-text search: Rename mustache arg to qarg_search 2017-03-24 09:59:54 -04:00
gnosygnu
66f744b11d Db: Add exec reader by prepared statement 2017-03-24 09:02:22 -04:00
gnosygnu
7269befb14 Full-text search: Change xo.page_guid to xo_page_guid (actual commit) 2017-03-24 08:17:56 -04:00
gnosygnu
477929e559 Full-text search: Add ooui-js call 2017-03-24 07:09:44 -04:00
gnosygnu
879ef3a7d0 Full-text search: Clear cache if more than 8 entries 2017-03-23 08:18:31 -04:00
gnosygnu
c3eca52574 Full-text search: Fix caching; also, continue searching until finding desired number of results 2017-03-22 21:10:20 -04:00
gnosygnu
ab1b9f7509 Full-text search: Add searcher_type 2017-03-22 19:00:44 -04:00
gnosygnu
4360e42e95 Gui: Add option to display actual HTML in SWT browser 2017-03-22 15:53:43 -04:00
gnosygnu
a9afa7a827 Full-text search: Add IndexOptions to Indexer 2017-03-22 09:30:45 -04:00
gnosygnu
49924110f4 Full-text search: Implement basic paging 2017-03-21 10:42:47 -04:00
gnosygnu
7924e26522 Full-text search: Automatically execute search if search_text is available; also, add limited caching 2017-03-20 19:26:12 -04:00
gnosygnu
e486d139e0 Full-text search: Use mustache templates for html updates 2017-03-19 14:31:37 -04:00
gnosygnu
c84cdf13b3 Xomw: Add XomwXowaSiteLookup 2017-03-19 10:03:00 -04:00
gnosygnu
96d1299273 Full-text search: Print links to non main-namespace pages 2017-03-19 03:34:42 -04:00
gnosygnu
cc8c120982 Special: Broadcast events to one specific tab, not all tabs with same name 2017-03-19 03:08:57 -04:00
gnosygnu
67548465fc Full-text search: Change popups to pub-sub system 2017-03-18 13:22:46 -04:00
gnosygnu
a1d2e69211 Xomw: Add XomwSiteList and XomwGenericArrayObject 2017-03-18 09:49:11 -04:00
gnosygnu
5967c75433 Js: Update references to mobile lib; change Add_core to Add_baselib 2017-03-18 08:06:13 -04:00
gnosygnu
a4380b6d48 Full-text search: Specify namespaces for indexing 2017-03-17 09:59:58 -04:00
gnosygnu
10d13a3cd9 Wikibase: Fix 'mw.wikibase.entity.lua:56 attempt to call nil' on several dozen ru.w pages 2017-03-16 20:12:43 -04:00
gnosygnu
6ccee10526 Full-text search: Adjust indexing weights and scores 2017-03-16 17:02:19 -04:00
gnosygnu
8524120a14 Mass_parse: Fix critical import failure when importing ru.wikinews.org 2017-03-16 13:31:59 -04:00
gnosygnu
66eeef6ab1 Full-text search: Limit index size to default of 1 GB 2017-03-16 11:27:12 -04:00
gnosygnu
a214575391 Full-text search: Ignore HTML tags 2017-03-16 10:32:51 -04:00
gnosygnu
2270a35c83 File: Handle long directories on Windows systems 2017-03-15 23:28:45 -04:00
gnosygnu
19b2d6226c Category: Fix fatal page load error when page_cat_db_id is invalid 2017-03-15 19:58:11 -04:00
gnosygnu
8c31c8fd62 Full-text search: Change to lucene 6.4.2 2017-03-15 19:51:58 -04:00
gnosygnu
8f8e414c80 Full-text search: Add highlighter 2017-03-15 13:11:09 -04:00
gnosygnu
d53fe9628f Xomw: Add XomwSite 2017-03-14 21:26:29 -04:00
gnosygnu
c08ea3bb03 Full-text search: Use Lucene 5.x instead of 6.x to stay on Java 1.7 2017-03-13 15:48:54 -04:00
gnosygnu
af6f7cf657 Page_sync: Show synced page immediately, not after another refresh 2017-03-13 12:53:45 -04:00
gnosygnu
5fca68f9f0 Full-text search: Add analyzer jar 2017-03-13 10:31:21 -04:00
gnosygnu
3b6cc45084 Full-text search: Add analyzers for non-English languages 2017-03-13 10:05:21 -04:00
gnosygnu
77de7215ce Full-text search: Add lucene indexer 2017-03-12 22:57:42 -04:00
gnosygnu
ae9d0fccd3 Full-text search: Add lucene searcher 2017-03-12 14:45:54 -04:00
gnosygnu
c91416801b Full-text search: Add lucene index generation 2017-03-10 13:24:41 -05:00
gnosygnu
062d958ead Full-text search: Add autosave options; read query from url args 2017-03-10 06:33:21 -05:00
gnosygnu
37b78543af Import: Fix file selector not working on Import offline 2017-03-09 23:58:27 -05:00
gnosygnu
d0399d6b04 Full-text search: Save and load options 2017-03-09 23:54:15 -05:00
gnosygnu
06acdd7335 Full-text search: Add 'expand matches' and 'show more' 2017-03-09 19:02:21 -05:00
gnosygnu
d5d3c68350 Bldr: Call recentchanges api 2017-03-07 16:47:52 -05:00
gnosygnu
e5baaaabc6 Bldr: Call remote then local repos 2017-03-07 09:15:57 -05:00
gnosygnu
848496c51b Bldr: Add omitted tests for normalizing title, timestamp 2017-03-06 20:42:56 -05:00
gnosygnu
5b2f3136a2 Log: Delete old Download Central logs 2017-03-06 15:45:25 -05:00
gnosygnu
3ebc338797 Personal_wikis: Update page_modified on page save 2017-03-06 09:28:48 -05:00
gnosygnu
7a8228c709 Bldr: Update orig_regy with api results from missing origs 2017-03-06 09:01:15 -05:00
gnosygnu
e92710483f Gui: Add nightmode css for popups and search suggest 2017-03-05 16:37:32 -05:00
gnosygnu
2d415cb1d2 Gui: Toggle nightmode for dropdown list 2017-03-05 13:10:22 -05:00
gnosygnu
ae9a00fade Gui: Update colors dynamically when changed from options screen 2017-03-05 11:41:18 -05:00
gnosygnu
e77916a02e Bldr: Add more implementation for missing origs 2017-03-05 08:40:52 -05:00
gnosygnu
98fb49687b Gui: Add options for nightmode; switch window icons; switch wiki css 2017-03-05 07:16:35 -05:00
gnosygnu
3e39b2fe77 Bldr: Add more implementation for missing origs 2017-03-04 09:44:22 -05:00
gnosygnu
ef11577d08 Edit: Add try catch for page backups 2017-03-03 17:42:50 -05:00
gnosygnu
a28ba26ca6 Gui: Add initial support for night-mode 2017-03-03 16:20:00 -05:00
gnosygnu
3e69a06434 Personal_wikis: Show wiki in left sidebar 2017-03-03 10:12:18 -05:00
gnosygnu
96b3b0afb8 Edit: Add page backup feature 2017-03-03 08:39:19 -05:00
gnosygnu
45d355454e Dansguardian: Skip specified namespaces 2017-03-02 21:07:15 -05:00
gnosygnu
7dd01b6e23 Full-text search: Do not fail rest of search if one result has invalid json 2017-03-02 16:34:18 -05:00
gnosygnu
269a3c3f65 Full-text search: Escape angle bracket in results 2017-03-02 16:16:59 -05:00
gnosygnu
0e3ebac674 Full-text search: Notify pages searched 2017-03-02 13:27:27 -05:00
gnosygnu
389726f219 Full-text search: Escape tab and carriage return in json callbacks 2017-03-02 11:06:15 -05:00
gnosygnu
1d509aa232 Full-text search: Send page_id and encode page_titles 2017-03-02 10:12:40 -05:00
gnosygnu
d672b829b9 Search: Convert to async search 2017-03-02 09:52:58 -05:00
gnosygnu
fa9d2d4040 Xomw: Add initial Interwiki classes 2017-03-02 08:41:02 -05:00
gnosygnu
c60936f165 Search: Add more punctuation symbols 2017-03-02 07:43:54 -05:00
gnosygnu
ca88091d90 Search: Add some search options 2017-03-01 22:08:06 -05:00
gnosygnu
8de3cf0cc6 Search: Add more punctuation support 2017-03-01 16:37:47 -05:00
gnosygnu
9301973825 Log: Fix broken test 2017-03-01 11:32:24 -05:00
gnosygnu
c702745bc0 Search: Add NOT logic 2017-03-01 11:29:43 -05:00
gnosygnu
8be6311cd6 Log: Remove current directory; always use timestamp directory 2017-03-01 10:35:37 -05:00
gnosygnu
c10cf2ca15 Search: Refactor search to handle multiple boolean searches 2017-03-01 08:52:21 -05:00
gnosygnu
7f04fc5f74 Search: Add more implementation for full-text search 2017-02-28 08:42:17 -05:00
gnosygnu
1feb2b9877 Search: Add special page for full-text search 2017-02-27 17:26:49 -05:00
gnosygnu
27951c428d Personal_wikis: Add timestamp to quick save status message 2017-02-27 11:08:38 -05:00
gnosygnu
ece9e59145 Personal_wikis: If personal_wiki, call personal_wiki init when loading wiki from wiki_mgr 2017-02-27 10:55:26 -05:00
gnosygnu
1f10e61371 Xomw: Add XomwMessage class and related 2017-02-27 08:36:18 -05:00
gnosygnu
2416ccb7e9 Xomw: Add basic namespace parsing to title 2017-02-27 07:54:10 -05:00
gnosygnu
ba4634919c Wikibase: Use scribunto key name for datatypes 2017-02-26 21:56:07 -05:00
gnosygnu
1cab009d3c Xomw: Add getNamespaceIds, getNamespaceAliases 2017-02-26 17:05:08 -05:00
gnosygnu
5a6ac3a335 Xomw: Add XomwMediaWikiServices to XomwEnv; Add XomwNamespaceHash 2017-02-26 09:55:57 -05:00
gnosygnu
a661f90ede Xomw: Do not load every personal wiki on startup 2017-02-25 21:05:36 -05:00
gnosygnu
26f786d4b9 Personal_wikis: Do not try to download css when creating wikis 2017-02-25 20:01:01 -05:00
gnosygnu
e48a70860b App: Fix null reference when starting app 2017-02-25 18:13:13 -05:00
gnosygnu
2b2f93b766 Xomw: Add wfUrlencode 2017-02-25 18:06:47 -05:00
gnosygnu
4781529d12 Xomw: Convert XomwBlockLevelPass 2017-02-25 09:31:07 -05:00
gnosygnu
0f92bb55db Xomw: Convert XomwHtml 2017-02-25 08:37:34 -05:00
gnosygnu
1328288cd2 App_update: Add more logging for app boot process 2017-02-24 17:37:33 -05:00
gnosygnu
e389bcbee9 App_update: Redownload update_db if download fails 2017-02-24 14:08:35 -05:00
gnosygnu
a114880f2b Core: Call toString on Error, not getMessage 2017-02-24 12:12:52 -05:00
gnosygnu
af4e7ab6c4 Xomw: Add TitlePrefix regex 2017-02-24 09:38:15 -05:00
gnosygnu
35bbd888ae Xomw: Complete conversion of XomwParser 2017-02-24 09:04:27 -05:00
gnosygnu
dc87cdcb5e Xomw: Convert XomwLinkRenderer 2017-02-24 08:38:12 -05:00
gnosygnu
d8c2eaba1d Xomw: Change Php classes to Xophp; move to root namespace 2017-02-24 07:56:49 -05:00
gnosygnu
a8c7f27ff5 Xomw: Add XomwStringUtils.delimiterReplace 2017-02-23 12:01:49 -05:00
gnosygnu
31fcfaf1bd Xomw: Convert Sanitizer, StringUtils; also, support stripAllTags 2017-02-23 09:08:03 -05:00
gnosygnu
09dbfc894e Xomw: Convert Parser; also support caption 2017-02-22 22:46:56 -05:00
gnosygnu
b6abbf2ffe Search: Clear cache after reindex 2017-02-22 16:45:50 -05:00
gnosygnu
12848b7cf5 Html: Move get_elem_val to xo.elem 2017-02-22 09:41:37 -05:00
gnosygnu
5bd3371802 Command-line: Fix curid argument not working 2 2017-02-22 08:44:14 -05:00
gnosygnu
0e85cc90ff Command-line: Fix curid argument not working 2017-02-22 07:54:00 -05:00
gnosygnu
4a07fdf291 Dev: Change command-line license to GPLv3 / Apache2 2017-02-21 21:28:48 -05:00
gnosygnu
1d58dca0f4 Dev: Change command-line license to GPLv3 / Apache2 2017-02-21 19:06:51 -05:00
gnosygnu
319120364c Gui: Fix null ref if 0 tabs and exiting app 2017-02-21 18:54:26 -05:00
gnosygnu
8b6bda0b6d Wiki.Dom: Ignore null siteinfo_misc else personal_wikis will fail 2017-02-21 18:51:27 -05:00
gnosygnu
344e709552 Wiki.Dom: Load site_name from xowa_cfg 2017-02-21 18:34:51 -05:00
gnosygnu
ece168e960 Personal_wikis: Update page_id from -1 to 1, not 0 for old v4.2 wikis with only 1 page 2017-02-21 17:24:24 -05:00
gnosygnu
7e6f26f740 Personal_wikis: Update mainpage in user_wiki.json 2017-02-21 17:04:15 -05:00
gnosygnu
fa056807d5 Personal_wikis: Change json name from 'main_page' to 'mainpage' 2017-02-21 16:59:59 -05:00
gnosygnu
edb23bb47e Category: Fix Category updates not working in layout.few databases 2017-02-21 16:24:33 -05:00
gnosygnu
1179e2848f Developer: Change license to GPLv3 / Apache2 in source code headers 2017-02-21 15:45:17 -05:00
gnosygnu
1ba13dd5f7 Sql_exec: Change page alias 2017-02-21 15:21:28 -05:00
gnosygnu
1609fe6c8e Sql_exec: Add Special:XowaSqlExec 2017-02-21 11:16:59 -05:00
gnosygnu
17f3de3124 Import: Fix wrong main_page for non-English wikis 2017-02-20 22:11:02 -05:00
gnosygnu
94a755124e Import: Fix page_redirects to English namespaces in non-English wikis 2017-02-20 20:18:39 -05:00
gnosygnu
b171592d77 Personal_wikis: Change mainpage to main_page 2017-02-20 13:40:54 -05:00
gnosygnu
c1559077cf Xomw: Start converting XomwParser 2017-02-20 12:05:39 -05:00
gnosygnu
dec8dbc713 Xomw: Convert XomwLinkHolderArray 2017-02-20 08:48:31 -05:00
gnosygnu
7fe4ed59ac Xomw: Start converting XomwLinkHolderArray 2017-02-20 05:16:43 -05:00
gnosygnu
428f2837c9 Category: Support addition / deletion in existing WMF wikis 2017-02-19 16:25:16 -05:00
gnosygnu
b028228d3d Personal_wikis: Fix Category page deletion failing 2017-02-19 11:55:32 -05:00
gnosygnu
7924a85b33 Xomw: Add title=enlarge 2017-02-19 11:37:54 -05:00
gnosygnu
7894c6d6f4 Xomw: Change href to use proper File: namespace 2017-02-19 11:11:26 -05:00
gnosygnu
704809e5b9 Xomw: Convert many class names to camelCase 2017-02-19 09:21:04 -05:00
gnosygnu
92c9fbddcc Personal_wikis: Change new wikis to automatically have upgraded cat_link / page table 2017-02-19 00:35:40 -05:00
gnosygnu
42c54e2029 Developer: Change license to GPLv3 / Apache2 2017-02-18 23:04:57 -05:00
gnosygnu
665137d453 Personal_wikis: Add upgrade version 2017-02-18 18:28:27 -05:00
gnosygnu
caa1eb2237 Personal_wikis: Update invalid page_ids to valid page_ids 2017-02-18 11:09:32 -05:00
gnosygnu
95632e0e98 Wiki.Dom: Remove wiki dependency from search db_mgr 2017-02-18 10:45:42 -05:00
gnosygnu
1188122823 Wiki.Dom: Remove wiki dependency from db_mgr 2017-02-18 10:37:40 -05:00
gnosygnu
4ec913b807 Personal_wikis: Add update page_id function 2017-02-18 09:58:11 -05:00
gnosygnu
04a58326e2 Personal_wikis: Assert name prop is in wiki.core 2017-02-18 08:16:45 -05:00
gnosygnu
083ab133f7 Personal_wikis: Add Main_Page back to json 2017-02-17 23:28:40 -05:00
gnosygnu
c9e22b69f7 Wiki.Dom: Refactor Wiki.Props 2017-02-17 17:57:17 -05:00
gnosygnu
22b6d4dbde Gui: Use GridLayout for progress messages window 2017-02-17 11:34:22 -05:00
gnosygnu
4593483522 Personal_wikis: Simplify wiki_import verification code 2017-02-17 09:39:51 -05:00
gnosygnu
a0dacdcf38 Personal_wikis: Refactor wiki_json update 2017-02-16 18:22:56 -05:00
gnosygnu
632fad62ae Personal_wikis: Add working implementation of wiki import 2017-02-16 13:14:18 -05:00
gnosygnu
00ab87b1b5 Gui: Tweak positioning of gui elements / font sizes 2017-02-15 19:18:41 -05:00
gnosygnu
451962a97f Wiki: Add more comments / exception handling for curid query argument 2017-02-15 17:52:04 -05:00
gnosygnu
a8fa783c32 Wiki: Support curid query argument 2017-02-15 15:50:39 -05:00
gnosygnu
aee0d2a9e0 Options: Remove Javascript enabled option else user can inadvertently cause many Special screens to stop working 2017-02-15 12:59:31 -05:00
gnosygnu
12c78cf89f Personal_wikis: Add page delete; refactor category updates 2017-02-15 11:44:30 -05:00
gnosygnu
b37b5ceddd Gui: Force escape in url bar to restore url 2017-02-15 05:02:08 -05:00
gnosygnu
faebc72c4f Gui: Fix Keyboard binding screen 2017-02-15 04:55:45 -05:00
gnosygnu
140351c2ed Gui: Standardize SWT api calls 2017-02-14 20:49:25 -05:00
gnosygnu
70cfdf0c44 Gui: Change UI to use SWT Grid Layout instead of manual XOWA layout 2017-02-14 18:34:46 -05:00
gnosygnu
dd6b3cabed Personal_wikis: Support creation / editing of categories 2017-02-13 15:23:05 -05:00
gnosygnu
935dda389a Personal_wikis: Add hack to handle rarely-reproducible problem of editing-after-renaming 2017-02-12 11:36:08 -05:00
gnosygnu
f7a7ba00f3 Personal_wikis: Add mock-up for editing categories 2017-02-12 11:00:37 -05:00
gnosygnu
01fbd21c6e Personal_wikis: Add search-indexing and auto-page rescan 2017-02-11 20:32:22 -05:00
gnosygnu
451c504166 Xomw: Convert Xoa_ttl to Xomw_Title 2017-02-11 09:55:27 -05:00
gnosygnu
8bc1a37531 Personal_wiki: Make domain and mainpage readonly when editing existing entries 2017-02-10 18:39:13 -05:00
gnosygnu
b2781ffc9d Personal_wiki: Refactor special pages 2017-02-10 15:19:12 -05:00
gnosygnu
0eee0f0207 Xomw: Add title parsing 2017-02-09 08:45:15 -05:00
gnosygnu
0cdd3d437f Wikis: Support renamed folders and different langs 2017-02-08 22:22:32 -05:00
gnosygnu
4dba081399 DownloadCentral: Add initial implementation for skipping categories 2017-02-08 22:06:36 -05:00
gnosygnu
9a19be675e Xomw: Move Mw_parse classes into separate project 2017-02-08 17:38:39 -05:00
gnosygnu
fdf6c49a05 Mw_parse: Start porting Title 2017-02-08 13:45:23 -05:00
gnosygnu
85f05bfd02 Mw_parse: Refactor Linker class 2017-02-08 11:37:14 -05:00
gnosygnu
26527a8800 Mw_parse: Add fixBoxWidth, scaleByHeight, etc. 2017-02-08 09:44:08 -05:00
gnosygnu
ff7952447d Mw_parse: Refactor Xomw_ThumbnailImage 2017-02-07 23:30:45 -05:00
gnosygnu
906bcdc6fe Wiki: Support renamed folders for non-commons images 2017-02-07 21:06:35 -05:00
gnosygnu
ffc112a085 Mw_parse: Add more support for original files 2017-02-07 20:57:57 -05:00
gnosygnu
e4e899f72a DownloadCentral: When moving items between tables, add item to correct spot in table, not at bottom 2017-02-07 13:49:12 -05:00
gnosygnu
3b59ea50b0 DownloadCentral: Add button to remove items from 'Available' list 2017-02-07 10:56:15 -05:00
gnosygnu
c98344b5b3 Mw_parse: Add more support for thumbs 2017-02-07 09:15:32 -05:00
gnosygnu
3bfeb94b43 Source: Restore broken commit 2017-02-06 22:14:55 -05:00
gnosygnu
938beac9f9 Wiki: Support renamed folders (fix) 2017-02-06 22:12:56 -05:00
gnosygnu
6f9e92afff Mw_parse: Add more implementation for thumbnails 2017-02-06 16:52:40 -05:00
gnosygnu
b30f10b647 Mw_parse: Add initial implementation for thumbnails 2017-02-05 19:46:25 -05:00
gnosygnu
8011f9e979 Mw_parse: Add magicWord classes 2017-02-05 13:59:30 -05:00
gnosygnu
352238a9c5 Mw_parse: Add code for imageParams 2017-02-04 19:28:08 -05:00
gnosygnu
909c96a1ff Mw_parse: Add code for getUrl 2017-02-04 12:30:10 -05:00
gnosygnu
55f148480c Updater: Show error message after failing to download 2017-02-03 17:50:16 -05:00
gnosygnu
c9d1193e7f Updater: Initial commit of standalone update app 2017-02-03 16:57:50 -05:00
gnosygnu
42c7bc61fb Mw_parse: Implement plain image link 2017-02-03 14:20:50 -05:00
gnosygnu
911be09aef Mw_parse: Port over more code for thumb links (part 2) 2017-02-03 12:13:33 -05:00
gnosygnu
472f12e60d Mw_parse: Port over more code for thumb links 2017-02-02 14:20:19 -05:00
gnosygnu
e7ae5d0435 Custom_wiki: Do not delete xml file after import 2017-02-02 11:16:43 -05:00
gnosygnu
9916c3efaf Custom_wiki: Do not limit file search to subdirectories in /orig/file/ 2017-02-02 11:04:46 -05:00
gnosygnu
f60b94760d Mw_parse: Add initial conversion for image thumbs 2017-02-02 10:50:20 -05:00
gnosygnu
4ade9c71b1 Mw_parse: Implement most of external_links 2017-02-02 04:12:33 -05:00
gnosygnu
bcd4bd46ef Cfg: Change operating-system specific config file from os.gfs to os.os_name.gfs 2017-02-01 19:44:53 -05:00
gnosygnu
cf30fd140e Wiki: Support renamed folders 2017-02-01 19:23:40 -05:00
gnosygnu
9c700e4b34 Custom_wiki: Open up file in image viewer when clicking on pages in File namespace 2017-02-01 13:52:29 -05:00
gnosygnu
ac13d00ef8 Custom_wiki: Integrate fs_root files into app image_cache 2017-02-01 12:25:44 -05:00
gnosygnu
3581371d29 Custom_wiki: Rename file if title has spaces to use underscore 2017-02-01 07:42:32 -05:00
gnosygnu
32b4fafe10 Mw_parse: Add merge_attributes 2017-02-01 05:16:43 -05:00
gnosygnu
78526c00c6 Custom_wiki: Refactor code; also show images on file namespace page 2017-02-01 04:08:34 -05:00
gnosygnu
ca8017a876 Mw_parse: Add more implementation to link_renderer 2017-01-31 08:20:12 -05:00
gnosygnu
7bb09a8320 Mw_parse: Add Get_external_link_attribs 2017-01-31 04:01:47 -05:00
gnosygnu
df45f141ca Fsdb.check: Add new command to check for missing images 2017-01-31 03:26:23 -05:00
gnosygnu
9a5c70b506 Mw_parse: Add clean_url and associated functions to sanitizer 2017-01-30 09:51:17 -05:00
gnosygnu
c77e8a4374 Mw_parse: Support num_post_proto rule; clarify variable names 2017-01-28 07:15:35 -05:00
gnosygnu
7e27b5415d Mw_parse: Handle interrupt and separator logic for magiclinks 2017-01-28 02:47:22 -05:00
gnosygnu
e231df0ce1 Mw_parse: Add case-match logic and more keywords for double_underscore 2017-01-27 12:30:01 -05:00
gnosygnu
31ade6aa5f Mw_parse: Add basic implementation for double_underscore 2017-01-27 11:10:15 -05:00
gnosygnu
aa1f1ec801 Mw_parse: Add basic implementation for magiclinks 2017-01-27 07:18:34 -05:00
gnosygnu
7bd176f51f Parser: Fix broken tables on a few dozen en.w pages 2017-01-26 19:14:27 -05:00
gnosygnu
ccd8b204c5 Embeddable: Fix video files using old v1 meta system 2017-01-26 09:45:01 -05:00
gnosygnu
6b0dcffbca Mass_parse: Fix lnki_temp merger ending prematurely 2017-01-26 08:21:36 -05:00
gnosygnu
9ea81f3b26 Embeddable: Add method to selectively clear pages from cache (additional code) 2017-01-26 04:02:20 -05:00
gnosygnu
27f6811e1f Embeddable: Add method to selectively clear pages from cache 2017-01-26 03:58:06 -05:00
gnosygnu
f683e272ee Embeddable: Fix multi-threaded diffs due to non thread-safe parser function {{urldecode}} 2017-01-26 02:44:26 -05:00
gnosygnu
fddc6e2737 Embeddable: Fix multi-threaded error due to null ref error when generating file urls 2017-01-26 01:48:50 -05:00
gnosygnu
af5b7569ee Embeddable: Fix multi-threaded error due to incorrect locking when lowercasing template names 2017-01-26 01:42:25 -05:00
gnosygnu
6867cc23b4 Embeddable: Fix default ns_mgr being used for wikis 2017-01-26 01:14:21 -05:00
gnosygnu
99c968e1e2 Mass_parse: Update wkr_id in resume cmd 2017-01-26 01:00:21 -05:00
gnosygnu
3a3bc01e82 Parser.Uniq: Fix possible bug with readding entire page instead of only sections 2017-01-25 10:00:04 -05:00
gnosygnu
f138db17ca Mass_parse: Add resume command 2017-01-25 09:20:45 -05:00
gnosygnu
cef2d7e2f6 Mw_parse: Mass checkin of various mediawiki parse files 2017-01-25 01:27:18 -05:00
gnosygnu
6a5c114998 Mw_parse.Apos: Add more tests 2017-01-13 16:50:43 -05:00
gnosygnu
32a857f062 Mw_parse.Apos: Add initial implementation 2017-01-13 13:57:25 -05:00
gnosygnu
f8fcb553d5 Mw_parse.Table: Support attributes 2017-01-12 23:15:04 -05:00
gnosygnu
5f1609a869 Mw_parse.Table: Add tests for basic functionality 2017-01-12 15:17:14 -05:00
gnosygnu
d22c5e5f3d Mass_parse: Add perf logger 2017-01-12 13:26:35 -05:00
gnosygnu
305c2f9762 Mw_parse.Table: Add more implementation 2017-01-12 10:20:17 -05:00
gnosygnu
b35a45657c Mw_parse.Block: Add initial implementation 2017-01-11 23:45:11 -05:00
gnosygnu
086cdea9fb Mw_parse.Prepro: Add more support for templates 2017-01-11 22:18:08 -05:00
gnosygnu
1c0f9f4555 Mw_parse.Prepro: Convert some calls to Strspan 2017-01-11 21:33:39 -05:00
gnosygnu
40b520ecc6 Mw_parse.Prepro: Support more heading edge cases 2017-01-11 18:18:46 -05:00
gnosygnu
46274e9b6a Mw_parse.Prepro: Support template pipe; Cover more tests 2017-01-11 16:48:21 -05:00
gnosygnu
7fae7b832b Mw_parse.Prepro: Optimize elements_trie 2017-01-11 15:04:32 -05:00
gnosygnu
2ad1be255c Mw_parse.Prepro: Support heading and onlyinclude 2017-01-11 13:52:41 -05:00
gnosygnu
683481abbd Mw_parse.Tblw: Add more implementation of tblw 2017-01-11 09:31:15 -05:00
gnosygnu
3af333e563 Mw_parse: Add more comment support 2017-01-11 08:48:57 -05:00
gnosygnu
75972fcff0 Mw_parse: Add support for gobbling single-line comments 2017-01-11 08:35:16 -05:00
gnosygnu
25f74d7d80 Mw_parse: Add equivalent of htmlspecialchar 2017-01-11 06:42:52 -05:00
gnosygnu
6ee274efd6 Mass_parse: Clear all mem when ns changes else outofmemory error 2017-01-11 05:48:08 -05:00
gnosygnu
bac00076b5 Mw_parse: Support ext xml nodes 2017-01-10 21:16:30 -05:00
gnosygnu
7813e41e34 Mw_parse: Support comment 2017-01-10 19:24:57 -05:00
gnosygnu
b989ff63df Mw_parse: Support bracket, template, and tplarg 2017-01-10 17:36:24 -05:00
gnosygnu
08eb098422 Parser: Escape dangling tags; do not let them gobble up rest of page 2017-01-10 14:01:04 -05:00
gnosygnu
f7b088e7a8 Mw_parse: Add test for basic text 2017-01-10 12:16:00 -05:00
gnosygnu
9610db0cab Mw_parse: Add more implementation of Mw_preprocessor 2017-01-10 12:01:03 -05:00
gnosygnu
d15630c433 Mw_parse: Add basic implementation of Mw_preprocessor 2017-01-09 21:33:45 -05:00
gnosygnu
006c14db4e Bldr: Add basic implementation of orig_regy.find_missing 2017-01-08 11:29:03 -05:00
gnosygnu
4bcefa2621 App_update: Add menu link to new Special page 2017-01-07 23:10:15 -05:00
gnosygnu
ad646efb5c Mass_parse: Clear ns_loaded cache; Add different cache clearing methods 2017-01-07 10:57:41 -05:00
gnosygnu
5840ebe592 App_update: Use version_id as cutoff, not version_date 2017-01-06 22:45:43 -05:00
gnosygnu
19571facdd App_update: Standardize date format 2017-01-06 20:21:07 -05:00
gnosygnu
0cc664121a App_update: Do not show Special:XowaAppUpdate if brand-new install 2017-01-06 20:13:25 -05:00
gnosygnu
200356d8ff App_update: Add skip update 2017-01-06 19:36:36 -05:00
gnosygnu
0ef1a82a16 App_update: Add app-update check to startup 2017-01-06 13:22:19 -05:00
gnosygnu
3c1898b9ef Html_dump: Update title to redirected page 2017-01-05 09:51:31 -05:00
gnosygnu
fed89cd89b Html: If MediaWiki:Sidebar does not exist, use language's message 'sidebar', not null 2017-01-05 09:17:21 -05:00
gnosygnu
2dc6d8c20b File_shrink: Add initial classes for file_shrink 2017-01-04 12:10:20 -05:00
gnosygnu
063cc43047 Mass_parse: Refactor log_tbl 2017-01-04 09:23:37 -05:00
gnosygnu
c869327a63 Release: v4.0.0.1701 2017-01-03 20:28:38 -05:00
gnosygnu
1bcd12a74e Gui: Support Command key on Mac OS X for keyboard shortcuts 2017-01-03 17:15:15 -05:00
gnosygnu
3fdea0ec50 Xtn: Change extensions to be wiki-specific instead of app-specific 2017-01-03 14:45:40 -05:00
gnosygnu
e69c557595 Math: Add math.log_check command 2017-01-03 11:27:48 -05:00
gnosygnu
87ee507220 Cfg: Adjust whitespace for two lines 2017-01-03 10:14:34 -05:00
gnosygnu
eee0a7de1d Cfg: Fix multiple mis-mapped gui shortcut keys 2017-01-03 01:32:32 -05:00
gnosygnu
ab4d7de36d Cfg: Uncomment debug code 2017-01-02 23:05:27 -05:00
gnosygnu
cb5cf6f8a1 Cfg: Fix bind.load failure b/c browser.html_focus was base-2 instead of base-1 2017-01-02 23:04:42 -05:00
gnosygnu
86ff9e361c Cfg: Fix redirect to special pages not working when query arguments are available 2017-01-02 22:35:35 -05:00
gnosygnu
758248b6a4 Cfg: Change converter to use gfs parser; other minor changes 2017-01-02 21:45:44 -05:00
gnosygnu
562c5b5a56 Cfg: Add transaction to upgrader; handle pre-existing back file; add try / catch 2017-01-01 14:21:05 -05:00
gnosygnu
360129b7de Gui: Add hand cursor 2017-01-01 10:49:14 -05:00
gnosygnu
1b6eaca401 Cfg: Change os.default paths 2017-01-01 10:43:38 -05:00
gnosygnu
5ae70ac947 Cfg: Make minor HTML tweaks 2016-12-31 22:13:25 -05:00
gnosygnu
6df5c40b45 Cfg: Add clear for shortcut window 2016-12-31 16:55:27 -05:00
gnosygnu
0668808214 Cfg: Add gfs api for run 2016-12-31 16:44:33 -05:00
gnosygnu
1f292d96a9 Cfg: Add configure icon to io.cmd 2016-12-31 16:23:19 -05:00
gnosygnu
cdcb4eca89 Cfg: Add shortcut win; Remove keypad bindings; Change shortut box from input to select 2016-12-31 08:37:34 -05:00
gnosygnu
c3d4f520de Gui: Refactor IptKey; in particular, use SWING and SWT constants where possible; also handle modifers 2016-12-31 00:36:12 -05:00
gnosygnu
5c3e4287f0 Mass_parse: Refactor make cmd to merge other wkr tables such as log_basic_temp 2016-12-30 12:22:43 -05:00
gnosygnu
62c81e6d77 Math: Refactor Math classes 2016-12-29 15:00:08 -05:00
gnosygnu
32fdbc6fbe Cfg: Update cfg keys; Fix dynamic scribunto updates 2016-12-28 22:47:16 -05:00
gnosygnu
5a36b112b2 Cfg: Fix nav not working for explicit grps 2016-12-28 19:28:14 -05:00
gnosygnu
4c3ea9890d Redirect: Allow redirects to Special pages 2016-12-28 17:51:12 -05:00
gnosygnu
982cd2b848 Cfg: Rename revert / load to delete / select 2016-12-28 15:58:18 -05:00
gnosygnu
da74bc6d87 Cfg: Update os_script_list 2016-12-28 15:32:52 -05:00
gnosygnu
276c884681 Cfg: Fix broken test 2016-12-28 12:47:22 -05:00
gnosygnu
15504c03a7 Cfg: Consolidate data_type and gui_type; Add some basic error validation 2016-12-28 12:45:15 -05:00
gnosygnu
fd12ed88a4 Cfg: Standardize rest of cfg keys 2016-12-27 15:16:46 -05:00
gnosygnu
50092ae60a Cfg: Add gui_cls 2016-12-27 11:25:45 -05:00
gnosygnu
7da2d853a2 Cfg: Standardize some cfg keys 2016-12-27 10:42:06 -05:00
gnosygnu
f04047e584 Mass_parse: Improve performance when returning Keyvals from Scribunto function 2016-12-27 09:31:10 -05:00
gnosygnu
6849ede461 Cfg: Add os_default logic for cfg defaults 2016-12-27 00:26:51 -05:00
gnosygnu
f0296305d5 Cfg: Add upgrade code for old cfg system 2016-12-26 23:24:32 -05:00
gnosygnu
fd2f01eb94 Cfg: Remove other old cfg classes 2016-12-26 15:36:49 -05:00
gnosygnu
08dda6a82d Cfg: Remove cfg_mgr and more of old cfg system 2016-12-26 14:48:44 -05:00
gnosygnu
1c00d41b06 Cfg: Convert 'app.setup_completed' 2016-12-26 13:00:42 -05:00
gnosygnu
ac9e79bfa0 Cfg: Convert 'lang - variants' 2016-12-26 12:48:31 -05:00
gnosygnu
dad76714d5 Cfg: Remove more of old cfg system 2016-12-26 10:49:43 -05:00
gnosygnu
6f3500d129 Cfg: Add better escaping for val and dflt 2016-12-26 10:15:40 -05:00
gnosygnu
460f4a323b Cfg: Convert 'toggle_mgr' 2016-12-25 22:31:58 -05:00
gnosygnu
3a4ef523dc Cfg: Add prev_version 2016-12-25 20:53:26 -05:00
gnosygnu
1ea75765d7 Cfg: Remove old prefs system 2016-12-25 20:16:58 -05:00
gnosygnu
b876e4a680 Cfg: Remove parts of old config system 2016-12-25 19:52:07 -05:00
gnosygnu
345402b393 Cfg: Load defaults through gfs file not json file 2016-12-25 16:47:19 -05:00
gnosygnu
8db63bbbce Cfg: Make gfs calls temporary; also, fix layout cfg leading to bad builds 2016-12-25 13:30:21 -05:00
gnosygnu
e698b1667f Cfg: Add gfs calls 2016-12-25 11:43:48 -05:00
gnosygnu
afd19c1619 Cfg: Fix updating shortcut not working if shortcut is part of group 2016-12-25 11:11:26 -05:00
gnosygnu
a96a239449 Scribunto: Fix extension libraries like ParserFunctions and FlaggedRevs not working 2016-12-24 22:38:16 -05:00
gnosygnu
bc9633f87f Cfg: Add 'Gui - Shortcuts' 2016-12-24 10:35:22 -05:00
gnosygnu
1ffc4191a8 Cfg: Add 'Gui - Menus' 2016-12-23 13:48:41 -05:00
gnosygnu
3177979558 Cfg: Add dynamic default text feature 2016-12-23 10:18:01 -05:00
gnosygnu
d380278390 Cfg: Remove 'Gui - Url bar' Symbols 2016-12-23 10:00:24 -05:00
gnosygnu
b6c8b31186 Cfg: Fix 'Addon - Scribunto' 2016-12-23 09:36:38 -05:00
gnosygnu
c2b4d8523f Cfg: Fix 'tidy' binary cmd 2016-12-22 22:21:38 -05:00
gnosygnu
7fd6b6c254 Cfg: Fix page_sync.manual_enabled 2016-12-22 20:59:16 -05:00
gnosygnu
af21fe50ff Cfg: Fix async_db parameter 2016-12-22 20:43:20 -05:00
gnosygnu
5304e80353 Cfg: Fix default_arg for url_search 2016-12-22 18:06:39 -05:00
gnosygnu
8f1c693ec6 Search: Change Search_suggest to use auto-wildcard behavior of Special_search; Remove 'simple_search' url_arg 2016-12-22 13:23:46 -05:00
gnosygnu
7a2364d12d Cfg: Change Files - Cache from bytes to MB 2016-12-22 11:59:49 -05:00
gnosygnu
c8df704385 Category: Show Hidden Categories in Hidden section 2016-12-22 10:29:09 -05:00
gnosygnu
d47538e62e Cfg: Fix Category Missing Class not working 2016-12-22 10:17:07 -05:00
gnosygnu
f12e3f5318 Cfg: Refactor 'Gui - Url bar'; Add better support for buttons 2016-12-21 23:29:44 -05:00
gnosygnu
74fefed754 Cfg: Refactor 'Import - General' 2016-12-21 20:45:07 -05:00
gnosygnu
ba2e59fd94 Cfg: Add gui-args and readonly 2016-12-21 11:02:28 -05:00
gnosygnu
93fcec3457 Cfg: Convert rest of pages 2016-12-21 03:07:38 -05:00
gnosygnu
68674ace83 Gui: Do not override Ctrl+Insert with Ctrl+Minus 2016-12-17 20:14:00 -05:00
gnosygnu
2b5b238bc1 Wikibase: Do not cast 'numeric-id' to 'string'; leave as 'int' 2016-12-17 15:29:05 -05:00
gnosygnu
873968b27f Cfg: Convert 'GUI - Window' 2016-12-17 11:01:37 -05:00
gnosygnu
7f97487721 Cfg: Convert 'CSS - General' 2016-12-17 01:12:09 -05:00
gnosygnu
66e1c3ecc2 Cfg: Convert 'App - Startup' (finished) 2016-12-16 17:51:43 -05:00
gnosygnu
5b42a90cd5 Mass_parse: Refactor ifexist_mgr into separate class; Load more titles into ifexist_mgr 2016-12-16 13:23:48 -05:00
gnosygnu
bfc5c5b68e Cfg: Convert 'App - Startup' (start) 2016-12-15 22:01:54 -05:00
gnosygnu
2f3a3a7a16 Mass_parse: Add separate ifexists cache 2016-12-15 14:08:38 -05:00
gnosygnu
38f5f6de7c Cfg: Convert 'App - Security' 2016-12-15 11:25:22 -05:00
gnosygnu
5073db8044 Cfg: Convert 'App - Debug' 2016-12-15 09:45:58 -05:00
gnosygnu
5fbf168fb7 Cfg: Convert 'App - Content Apps' 2016-12-15 02:10:09 -05:00
gnosygnu
ad5d608ba5 Cfg: Standardize Xoitm_gui_tid; add support for io.cmd 2016-12-14 16:29:13 -05:00
gnosygnu
ce36e1e76a Cfg: Add id to maint parser 2016-12-14 09:49:39 -05:00
gnosygnu
3395b22d57 Cfg: Convert 'Addon - Popups' (whitespace change) 2016-12-13 21:43:31 -05:00
gnosygnu
3ebc5aa2cd Cfg: Convert 'Addon - Popups' 2016-12-13 21:42:48 -05:00
gnosygnu
42e7f5f2c6 Cfg: Convert 'Import - Dansguardian' 2016-12-13 14:15:52 -05:00
gnosygnu
200707b1c6 Cfg: Convert 'Wiki - HTML databases' 2016-12-13 12:49:05 -05:00
gnosygnu
c73c917c48 Wikibase: Add fiwikivoyage to list of known wikis 2016-12-13 11:23:19 -05:00
gnosygnu
22a173ae0b Cfg: Convert Gui - Tabs 2016-12-13 10:26:56 -05:00
gnosygnu
317880d083 Mass_parse: Fix caching behavior when multiple threads attempt to add same page 2016-12-12 11:56:22 -05:00
gnosygnu
f6b4d5f153 Cfg: Auto-load previous section; better upsert behavior for items 2016-12-12 10:26:21 -05:00
gnosygnu
5e159233ab Mass_parse: Fix memory leak / slow performance due to over-zealous page caching 2016-12-12 09:25:06 -05:00
gnosygnu
8f68854513 Section_edit: Add lead paragraph edit 2016-12-11 19:51:12 -05:00
gnosygnu
4882262bed Cfg: Add more support for dynamic upsert / revert 2016-12-11 18:39:52 -05:00
gnosygnu
f1396e13c7 Cfg: Add defaults loader 2016-12-11 10:04:40 -05:00
gnosygnu
c10e34d26e Cfg: Change Xoedit_root to handle weird java.lang.VerifyError on Android 2016-12-10 14:37:27 -05:00
gnosygnu
d7636457bd Cfg: Add support for lists 2016-12-10 10:14:53 -05:00
gnosygnu
0c3dbd4b4d Section_edit: Translate 'edit' and 'Edit section' labels 2016-12-09 13:39:24 -05:00
gnosygnu
780062ebb4 Section_edit: Support headers with covering behavior, dupes, xml, math, and templates 2016-12-09 12:23:02 -05:00
gnosygnu
998937ca26 Section_edit: Fail when clicking on transcluded headers 2016-12-08 19:53:59 -05:00
gnosygnu
fd79415b53 Cfg: Split db into app and usr and overhaul db objects 2016-12-08 12:24:15 -05:00
gnosygnu
9dfbd472ac Cfg: Refactor to maint and edit 2016-12-07 13:38:32 -05:00
gnosygnu
ceaae41b57 Cfg: Add mutliple sections and groups 2016-12-06 20:54:07 -05:00
gnosygnu
5d27bff298 Section_edit: Add basic merge support 2016-12-05 20:59:45 -05:00
gnosygnu
150454fd67 Section_edit: Show section when section_key is passed 2016-12-05 17:43:00 -05:00
gnosygnu
d64136ab9d Release: v3.12.1.1 2016-12-04 20:56:13 -05:00
gnosygnu
585ef1c2ce Cfg: Add more implementation for cfg_cache and pub / sub 2016-12-04 11:40:47 -05:00
gnosygnu
f7558a6761 Wbase: Add lock to pid_mgr else multi-threaded issues 2016-12-03 23:15:42 -05:00
gnosygnu
265388a889 Cfg: Add Xocfg_mgr 2016-12-03 23:14:27 -05:00
gnosygnu
364e72e869 Wbase: Do not fail if null quantity.lbound or quantity.ubound 2016-12-03 17:52:41 -05:00
gnosygnu
9fd328ac8f Wbase: Load prop datatype table as P123 instead of p123 2016-12-03 13:59:31 -05:00
gnosygnu
496068e9aa Section_edit: Add parse / intermediate html form 2016-12-03 10:49:33 -05:00
gnosygnu
5eaaae0749 Cfg: Remove nde_tid; convert checkbox yes to bool 2016-12-02 14:44:31 -05:00
gnosygnu
26ad5db8e9 Section_edit: Add initial groundwork for generating html 2016-12-02 11:32:23 -05:00
gnosygnu
1e28aa6e79 Xtn.Math: Swap out math tags with UNIQ 2016-12-01 19:55:43 -05:00
gnosygnu
2a0b5769ad Wikibase: Uniquefy items in wbase_prop table 2016-12-01 14:35:47 -05:00
gnosygnu
da18f05d9f Wikibase: Infer datatype from cached table not from JSON doc 2016-12-01 11:07:33 -05:00
gnosygnu
b3566def7e Wikibase: Add wbase_prop table for datatype 2016-11-29 16:03:56 -05:00
gnosygnu
b1ad1411e4 Wikibase: Fix Wikibase json-entities loader not working 2016-11-28 11:52:21 -05:00
gnosygnu
83cf992f48 Core: Refactor base classes 2016-11-28 08:28:00 -05:00
gnosygnu
12459429b4 Import: Expand index on temp category table to include cl_type 2016-11-27 19:13:12 -05:00
gnosygnu
9e1bbe0235 App_update: Move constants to config 2016-11-26 10:03:36 -05:00
gnosygnu
cea5072c2a Import: Add index to cl_from 2016-11-25 23:16:51 -05:00
gnosygnu
73872cf5ff Gui.Url_bar: Set page url to actual chars, not url-decoded chars 2016-11-25 15:54:21 -05:00
gnosygnu
720668ad63 App_update: Add more implementation for standalone update app 2016-11-25 13:32:45 -05:00
gnosygnu
e0ee9a952d Parser.Lnke: Handle xwiki links to history pages 2016-11-24 22:16:39 -05:00
gnosygnu
468b9b6ed5 Wikibase: Convert globecoordinate's precision of '0' to precision of '1' 2016-11-24 21:39:40 -05:00
gnosygnu
dd8cff9838 Embeddable: Fix if_exists test 2016-11-24 19:26:35 -05:00
gnosygnu
81dc7ea4ea Embeddable: Fix if_exists (restore) 2016-11-24 08:58:55 -05:00
gnosygnu
fcbdf8bbd8 Embeddable: Fix if_exists 2016-11-24 08:53:07 -05:00
gnosygnu
dae3be97ec App_update: Add standalone updater 2016-11-24 08:52:12 -05:00
gnosygnu
910b5d66d3 Embeddable: Add Free_memory method 2016-11-23 14:29:34 -05:00
gnosygnu
a6540d6200 Scribunto: Do not convert zero padded numbers to integer 2016-11-23 13:47:24 -05:00
gnosygnu
eb5173b3a0 Scribunto: Use local language's namespace name not canonical 2016-11-23 12:18:20 -05:00
gnosygnu
6e39f9979d Wikibase: Return 'property' not 'item' if wikidata page is Property: 2016-11-23 11:25:59 -05:00
gnosygnu
fc55d0e2f9 App_update: Add replace worker; add db auto-update 2016-11-23 09:35:26 -05:00
gnosygnu
103d005e62 App_update: Add download and unzip workers 2016-11-22 11:54:03 -05:00
gnosygnu
1c37d4e599 Table_of_contents: Ignore TOC magic word on transcluded pages (comment) 2016-11-21 10:50:44 -05:00
gnosygnu
2382c4a535 Table_of_contents: Ignore TOC magic word on transcluded pages 2016-11-21 10:43:14 -05:00
gnosygnu
8f1c368ffe App_update: Add version_id and version_url; also add json_bridge 2016-11-21 09:45:56 -05:00
gnosygnu
55b81d4a60 ParserFunctions: Fix missing headers from several dozen ru.s Slavik pages 2016-11-21 08:29:36 -05:00
gnosygnu
82ade50f5e App_update: Add more changes for special page 2016-11-20 12:57:03 -05:00
gnosygnu
c9748a6f44 Embeddable: Load modules from load_worker 2016-11-19 13:58:04 -05:00
gnosygnu
42dfdcdac2 Import: Convert null category sortkeys to empty array 2016-11-19 13:41:12 -05:00
gnosygnu
7ea0b39553 App_update: Add db table and object 2016-11-19 10:55:49 -05:00
gnosygnu
6459d990a5 App_update: Add addon and special page 2016-11-18 09:10:16 -05:00
gnosygnu
c233214e42 Page_sync: Allow 'always sync' by setting sync interval to '0' 2016-11-17 23:06:51 -05:00
gnosygnu
fb7c675117 Import.offline: Do not re-download category dump files when importing wiki (redux) 2016-11-17 18:13:39 -05:00
gnosygnu
9aa3902265 Page_sync: Fix page_sync failing when (a) page has math and (b) math has '~{' 2016-11-17 16:10:24 -05:00
gnosygnu
a38c0e834e Page_sync: Implement 'Pages to sync' filter 2016-11-17 10:02:54 -05:00
gnosygnu
d216562fba Cfg: Save items when changed 2016-11-16 09:51:47 -05:00
gnosygnu
2cc39bf6bc Core: Fix null-ref error in disposing connection when fatal error occurs during download 2016-11-15 17:06:40 -05:00
gnosygnu
ab209ef91e Page_sync: Do not fail if page doesn't exist 2016-11-15 15:00:41 -05:00
gnosygnu
cba205baf3 Cfg: Add more implementation for show items 2016-11-15 14:59:14 -05:00
gnosygnu
bc04443812 Cfg: Show items 2016-11-15 12:13:27 -05:00
gnosygnu
21102d846f Image: Call 'cmd /c start' correctly by forcibly including quotes 2016-11-14 15:48:27 -05:00
gnosygnu
bca989898e Image: Handle image paths with spaces and other URL-encoding 2016-11-14 15:25:31 -05:00
gnosygnu
419367ad9f Test: Do not print warnings during test 2016-11-14 10:17:32 -05:00
gnosygnu
40ee795c29 Cfg: Add create / edit screen 2016-11-14 10:11:25 -05:00
gnosygnu
7f31d49848 Release: v3.11.2.1 2016-11-13 21:39:46 -05:00
gnosygnu
69c97838ea Image: Show mockup of commons.wikimedia.org page when clicking on image 2016-11-13 13:47:26 -05:00
gnosygnu
306001f311 Cfg: Add initial implementation for special 2016-11-13 10:59:51 -05:00
gnosygnu
d8dca8f9c2 Cfg: Add more implementation to loader 2016-11-13 10:14:08 -05:00
gnosygnu
dd9f65f14f Import.offline: Fix incorrect detection of offline category dump files (.sql.gz2) 2016-11-12 16:15:22 -05:00
gnosygnu
68b51fbad1 Cfg: Add initial implementation to load items 2016-11-12 12:48:34 -05:00
gnosygnu
08d6cc3eb9 Embeddable: Add page loader 2016-11-10 15:41:24 -05:00
gnosygnu
9c95e2d470 Wikibase: Do not automatically convert dates to julian 2016-11-10 12:27:46 -05:00
gnosygnu
d2d58f2b7e Wikibase: Do not escape and repeat calendar data 2016-11-10 12:00:45 -05:00
gnosygnu
0f8d0257c9 Wikibase: Consolidate quantity output formatting in Wdata_prop_val_visitor and Wdata_visitor__html_wtr 2016-11-10 10:43:54 -05:00
gnosygnu
130aacc4d7 Wikibase: Add olo.wikipedia.org to list of known wikis 2016-11-10 09:29:09 -05:00
gnosygnu
bc10e474c2 Wikibase: Show {{#property}} geo-coordinates in degrees, not raw numbers 2016-11-09 16:10:14 -05:00
gnosygnu
653c36895f Lang.Variants: Add initialization assertion to variant rule parser 2016-11-09 15:18:20 -05:00
gnosygnu
88332f68a2 ParserFunctions: Change {{NUMBEROFPAGES}} to read from site_stats.ss_total_pages and {{NUMBEROFARTICLES}} to read from site_stats.ss_good_articles 2016-11-09 15:10:47 -05:00
gnosygnu
7e5af96548 Wikibase: Do not output quantity.unit if it is not a wikidata url 2016-11-08 11:00:02 -05:00
gnosygnu
21e90cd479 Wikibase: Parse numbers with fractions correctly; do not convert to zero 2016-11-08 10:23:23 -05:00
gnosygnu
85a1c123b4 Cfg: Add gui type enum 2016-11-08 09:28:18 -05:00
gnosygnu
323aba310c Cfg: Add more implementation for create grp / itm 2016-11-07 09:20:05 -05:00
gnosygnu
fd712c16f3 Release: v3.10.4.6 2016-11-06 22:33:55 -05:00
gnosygnu
a056a5b2e6 Embeddable: Add basic parse wikitext function 2016-11-06 14:09:00 -05:00
gnosygnu
f04cb73679 Cfg: Add get and set functions 2016-11-06 09:39:52 -05:00
gnosygnu
887724b536 Http_server: Ignore Accept-charset header 2016-11-05 08:42:26 -04:00
gnosygnu
5ff9b8d08a Page_history: Add option to log all page visits to a separate file 2016-11-05 07:33:37 -04:00
gnosygnu
e346afeea1 App_cfg: Add db layer 2016-11-05 06:40:02 -04:00
gnosygnu
25918b139b Html_dump: Always reload page when going back / forward on wikinews (use new_wiki, not cur_wiki) 2016-11-04 13:32:41 -04:00
gnosygnu
03a428ec4b DownloadCentral.Package: Add option to manually specify wiki date for new packages 2016-11-04 09:58:16 -04:00
gnosygnu
6ad12f4df9 Html_dump: Always reload page when going back / forward on wikinews (do not use cached html) 2016-11-04 09:57:57 -04:00
gnosygnu
578ede9b1c Html_dump: If {{#pagebanner}} and __TOC__ are on same page, do not have __TOC__ overwrite {{#pagebanner}} 2016-11-03 19:49:01 -04:00
gnosygnu
6d92c3cfbf User_wiki: Add list of user wikis page 2016-11-03 10:03:41 -04:00
gnosygnu
0fb6fea11a DownloadCentral: Hide outdated wikis in Imported table 2016-11-03 09:03:23 -04:00
gnosygnu
a5bdc07406 User_wiki: Add delete wiki 2016-11-02 09:57:17 -04:00
gnosygnu
ff869ecfc3 User_wiki: Change input from file to folder 2016-11-02 09:09:42 -04:00
gnosygnu
6d327749fc User_wiki: Differentiate Edit versus Create 2016-10-31 10:23:30 -04:00
gnosygnu
8016846cd9 User_wiki: Simplify creation of wiki database file and tables 2016-10-31 12:16:25 -04:00
gnosygnu
ae0fb89745 DownloadCentral: Move list of languages from UI to DB 2016-10-30 09:29:20 -04:00
gnosygnu
2c023c2c54 User_wiki: Add dirty implementation for creating user wiki 2016-10-29 10:20:11 -04:00
gnosygnu
2abefa1ab9 Hzip: Use canonical name, not local name, for images linking to namespaces in other wikis 2016-10-28 12:09:04 -04:00
gnosygnu
02a289dc80 Table_of_contents: Handle unknown tags: dl 2016-10-28 09:29:44 -04:00
gnosygnu
4e3df30cc0 Wikibase: Return timezone as integer, not string 2016-10-28 09:24:28 -04:00
gnosygnu
e10aace5f9 User_wikis: Add edit capability 2016-10-27 11:45:08 -04:00
gnosygnu
169f972019 User_wikis: Refactor xo js includes 2016-10-26 17:08:07 -04:00
gnosygnu
76e2750b5c Bookmarks: Fix Bookmarks not loading (more) 2016-10-26 11:06:29 -04:00
gnosygnu
c8e9a3d60f Bookmarks: Fix Bookmarks not loading 2016-10-26 11:05:47 -04:00
gnosygnu
69f9f3b048 User_wikis: Add special page for editing user wiki 2016-10-26 10:13:29 -04:00
gnosygnu
1711d52985 User_wikis: Add dirty implementation to load existing user wiki 2016-10-25 12:48:21 -04:00
gnosygnu
1f7a54c1e6 User_wikis: Add database table 2016-10-25 10:46:56 -04:00
gnosygnu
b4e89a47c2 Release: v3.10.4.1 2016-10-24 22:24:04 -04:00
gnosygnu
89473d795f Mass_parse: Fix compile error 2016-10-24 10:00:30 -04:00
gnosygnu
9f2863c953 Mass_parse: Do not return null if MACHINENAME / HOSTNAME is not available 2016-10-24 09:36:30 -04:00
gnosygnu
69b5678350 DownloadCentral: Preserve lang / type choices next time page is opened 2016-10-24 09:16:24 -04:00
gnosygnu
2720fdae1e Import.offline: Change message to warn that some data may not be imported 2016-10-22 17:30:40 -04:00
gnosygnu
c44b1ae658 Html_dump: Fix 'Refresh' not working for html_dumps 2016-10-22 17:24:59 -04:00
gnosygnu
9fba6afe6e Import.offline: Do not fail if category files are not available 2016-10-22 17:24:59 -04:00
gnosygnu
749d355545 Import: Use the directory of offline dump files for category files 2016-10-22 17:24:58 -04:00
gnosygnu
568060e820 Import: Do not fail at category for non-WMF wikis (Wikia) 2016-10-22 17:24:58 -04:00
gnosygnu
ac2b4a4038 Category: Change 'category not found' errors to log, not warn 2016-10-22 17:24:47 -04:00
gnosygnu
985c87efbf Table_of_contents: Handle unknown tags: ruby, rb, rp, rt 2016-10-22 08:58:40 -04:00
gnosygnu
df45117d43 Import: Do not assume same database schema for all Wikimedia wikis 2016-10-21 21:30:23 -04:00
gnosygnu
50a063c8de DownloadCentral: Do not pack text files in html package 2016-10-21 18:46:16 -04:00
gnosygnu
bd6576b716 DownloadCentral: Cleanup filter_by_lang 2016-10-21 10:00:14 -04:00
gnosygnu
55ea1fa39a Kartographer: Hide markup from mapframe / maplink tags 2016-10-20 21:29:59 -04:00
gnosygnu
3971182fff DownloadCentral: Add basic implementation for filter_by_lang 2016-10-20 16:45:00 -04:00
gnosygnu
059e49b1bc DownloadCentral: Do not show outdated wikis 2016-10-20 15:40:57 -04:00
gnosygnu
c1100c6d66 Wikibase: Refactor wbase prop_writer to static functions 2016-10-20 14:45:11 -04:00
gnosygnu
6748463711 Wikibase: Centralize rendering of claim values ({{#property}} and JSON vs renderSnak and Keyval) 2016-10-20 10:06:14 -04:00
gnosygnu
c598d1a218 Mass_parse: Fix some pages being detected incorrectly as redirects 2016-10-19 21:47:22 -04:00
gnosygnu
64328be25c Dansguardian: Delete search_links from search_link database, not search_core database 2016-10-19 17:40:13 -04:00
gnosygnu
74e84fd758 DownloadCentral: Fix archive.org url and task name for wikidata 2016-10-19 16:22:30 -04:00
gnosygnu
e55e3971d9 DownloadCentral: Add option to generate text packages (for wikidata) 2016-10-19 15:19:03 -04:00
gnosygnu
37a72e6ad4 Add option to include patch files 2016-10-19 12:44:24 -04:00
gnosygnu
af8306ae9b Add option to make_cmd to not delete all html databases 2016-10-19 09:56:11 -04:00
gnosygnu
9165ceef79 Ignore assessment function tag 2016-10-19 09:37:15 -04:00
gnosygnu
06c877f36c Fix thread-safe issues with Hash_of_ints 2016-10-19 00:00:25 -04:00
gnosygnu
8fc07752e9 Switch img_src and img_trg when loading from imglnk_reg 2016-10-18 23:50:17 -04:00
gnosygnu
d983a32397 Reuse quantity.unit code for renderSnake 2016-10-18 16:29:22 -04:00
gnosygnu
f17aadfcba Implement entity for renderSnak 2016-10-18 14:32:59 -04:00
gnosygnu
83fc18ad03 Do not write page banner img.src else hzip_diff will complain for every page 2016-10-18 12:06:58 -04:00
gnosygnu
1f10cb2155 Cache category link pages 2016-10-18 11:24:40 -04:00
gnosygnu
7f4549d27a Skip invalid category titles; do not treat them as empty category titles 2016-10-18 11:16:11 -04:00
gnosygnu
2565cb9821 Do not show null ref error in log when invalid category is used 2016-10-18 09:44:28 -04:00
gnosygnu
c032eba49c Add page title to log message when category does not exist in page (dynamicPageList) 2016-10-18 09:29:51 -04:00
gnosygnu
01e45caa5a Fix build error for English Wikibooks 2016-10-17 20:37:50 -04:00
gnosygnu
62ff87350b If multiple caption arguments, take last, not all of them 2016-10-17 18:18:48 -04:00
gnosygnu
7fc776aee9 v3.10.3.1 2016-10-16 23:03:56 -04:00
gnosygnu
d07b3e1493 Clean up luaj scripting engine; allow multiple lua library files 2016-10-16 13:00:37 -04:00
gnosygnu
c1d84249e1 Simplify scripting api; add support for multiple extensions; support lua extensions 2016-10-15 18:21:46 -04:00
gnosygnu
7ccea7ac7a Clean up custom javascript injection code; add helper method Add_tag 2016-10-14 10:53:55 -04:00
gnosygnu
48cb88f655 Evaluate optional args of missing templates 2016-10-13 14:30:45 -04:00
gnosygnu
d6aeb2e177 Evaluate template args for missing templates else en.w flags will sometimes be large 2016-10-13 14:14:50 -04:00
gnosygnu
c98404a8fe Add dirty implementation of custom javascript scripting 2016-10-13 12:09:43 -04:00
gnosygnu
b7f089a3ab Add builder command to create customized deletion_db for dansguardian wikis 2016-10-12 22:12:00 -04:00
gnosygnu
3e21b4e4db if option is set to use wikitext, but no wikitext is available, and html is available, just use html 2016-10-12 20:01:51 -04:00
gnosygnu
18e8f475ff add test / comment for 'index out of range error' for 0-argument parser functions 2016-10-12 19:15:39 -04:00
gnosygnu
d6e055de30 fix test for 'Next' / 'Previous' not working on Search 2016-10-12 17:21:11 -04:00
gnosygnu
2bbdff3ca6 fix 'Next' / 'Previous' not working on Search 2016-10-12 17:16:55 -04:00
gnosygnu
c1c7829d02 fix unique constraint error when generating html databases for few / lot wikis 2016-10-12 15:55:30 -04:00
gnosygnu
ab3bedcc9f if catpage link is missing, output page_id not ~{itm_text} 2016-10-12 15:47:47 -04:00
gnosygnu
1342a16269 load catpage header from html database and merge catpage data; also, load catpage async 2016-10-12 15:42:06 -04:00
gnosygnu
6b1ec09296 do not fail with null ref if subcategory does not exist in catpage 2016-10-12 14:06:43 -04:00
gnosygnu
bc2c83fa8f don't show sortkey_handle else hzip_diff will complain a lot 2016-10-12 13:38:42 -04:00
gnosygnu
ee1b2bfbd8 fix null-ref error when zth page does not exist in catpage 2016-10-12 12:45:03 -04:00
gnosygnu
e1f599ec1d clean up code for making sortkey of zth item 2016-10-12 11:53:43 -04:00
gnosygnu
9a28378d50 truncate category urls with \n else page history will not load correctly 2016-10-12 11:42:37 -04:00
gnosygnu
e18a0ac82f created collation wkr for wikis specified by wgCategoryCollation 2016-10-12 10:58:37 -04:00
gnosygnu
d0769c32b4 parse wgCategoryCollation to create cfg lines in bin\any\xowa\cfg\wiki 2016-10-12 10:02:08 -04:00
gnosygnu
3fc2e0741f uca category support and other changes 2016-10-12 08:57:22 -04:00
gnosygnu
e3b393650d 'v3.9.4.1' 2016-09-25 22:05:47 -04:00
11615 changed files with 1578244 additions and 84207 deletions

View File

@ -1,4 +0,0 @@
[Dolphin]
Timestamp=2015,7,12,21,9,46
Version=3
ViewMode=1

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.iml
**/.idea/**

View File

@ -3,7 +3,9 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tst"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/commons-compress-1.5.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.18.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/xz-1.5.jar"/>
<classpathentry kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.lang.reflect.Array;
@ -56,6 +54,15 @@ public class Array_ {
Copy_to(src, 0, trg, 0, copy_len);
return trg;
}
public static Object Extract_by_pos(Object src, int src_bgn) {
return Extract_by_pos(src, src_bgn, Array.getLength(src));
}
public static Object Extract_by_pos(Object src, int src_bgn, int src_end) {
int trg_len = src_end - src_bgn;
Object trg = Create(Component_type(src), trg_len);
Copy_to(src, src_bgn, trg, 0, src_end - src_bgn);
return trg;
}
public static List_adp To_list(Object ary) {
int aryLen = Array_.Len(ary);
List_adp rv = List_adp_.New();
@ -72,7 +79,7 @@ public class Array_ {
int len = Len(ary);
for (int i = 0; i < len; i++) {
Object itm = Get_at(ary, i);
if (itm != null && Type_adp_.Is_array(itm.getClass()))
if (itm != null && Type_.Is_array(itm.getClass()))
To_str_nested_ary(bfr, (Object)itm, indent + 1);
else {
if (indent > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);
@ -114,4 +121,9 @@ public class Array_ {
Set_at(trg, i, Get_at(add, i - srcLen));
return trg;
}
public static Object Clone(Object src) {
Object trg = Create(Component_type(src), Len(src));
Copy(src, trg);
return trg;
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,64 +1,65 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.langs.gfs.*;
public class Bool_ implements Gfo_invk {
public static final String Cls_val_name = "boolean";
public class Bool_ {//RF:2017-10-08
public static final String Cls_val_name = "bool";
public static final Class<?> Cls_ref_type = Boolean.class;
public static final boolean N = false , Y = true;
public static final byte N_byte = 0 , Y_byte = 1 , __byte = 127;
public static final int N_int = 0 , Y_int = 1 , __int = -1;
public static final byte[] N_bry = new byte[] {Byte_ascii.Ltr_n}, Y_bry = new byte[] {Byte_ascii.Ltr_y};
public static final String True_str = "true", False_str = "false";
public static final byte[] True_bry = Bry_.new_a7(True_str), False_bry = Bry_.new_a7(False_str);
public static boolean cast(Object obj) {try {return (Boolean)obj;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, boolean.class, obj);}}
public static boolean cast_or(Object obj, boolean v) {try {return (Boolean)obj;} catch (Exception e) {Err_.Noop(e); return v;}}
public static boolean parse(String raw) {
if ( String_.Eq(raw, True_str)
|| String_.Eq(raw, "True") // needed for Store_Wtr(){boolVal.toString();}
)
return true;
else if ( String_.Eq(raw, "false")
|| String_.Eq(raw, False_str)
)
return false;
throw Err_.new_parse_type(boolean.class, raw);
}
public static int Compare(boolean lhs, boolean rhs) {
if ( lhs == rhs) return CompareAble_.Same;
else if (!lhs && rhs) return CompareAble_.Less;
else /*lhs && !rhs*/ return CompareAble_.More;
}
public static boolean By_int(int v) {return v == Y_int;}
public static int To_int(boolean v) {return v ? Y_int : N_int;}
public static byte To_byte(boolean v) {return v ? Y_byte : N_byte;}
public static String To_str_lower(boolean v) {return v ? True_str : False_str;}
public static final Bool_ Gfs = new Bool_();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_to_str)) {
boolean v = m.ReadBool(GfsCore_.Arg_primitive);
String fmt = m.ReadStrOr("fmt", null);
if (fmt == null) return v ? "true" : "false";
else if (String_.Eq(fmt, "yn")) return v ? "y" : "n";
else if (String_.Eq(fmt, "yes_no")) return v ? "yes" : "no";
else return v ? "true" : "false";
}
else return Gfo_invk_.Rv_unhandled;
} public static final String Invk_to_str = "to_str";
public static boolean Cast(Object obj) {try {return (Boolean)obj;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, boolean.class, obj);}}
public static boolean Cast_or(Object obj, boolean or) {try {return (Boolean)obj;} catch (Exception e) {Err_.Noop(e); return or;}}
public static boolean Parse(String raw) {
if ( String_.Eq(raw, True_str)
|| String_.Eq(raw, "True") // needed for Store_Wtr(){boolVal.toString();}
)
return true;
else if ( String_.Eq(raw, False_str)
|| String_.Eq(raw, "False")
)
return false;
throw Err_.new_parse_type(boolean.class, raw);
}
public static boolean Parse_or(String raw, boolean or) {
if ( String_.Eq(raw, True_str)
|| String_.Eq(raw, "True") // needed for Store_Wtr(){boolVal.toString();}
)
return true;
else if ( String_.Eq(raw, False_str)
|| String_.Eq(raw, "False")
)
return false;
return or;
}
public static int Compare(boolean lhs, boolean rhs) {
if ( lhs == rhs) return CompareAble_.Same;
else if (!lhs && rhs) return CompareAble_.Less;
else /*lhs && !rhs*/ return CompareAble_.More;
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

File diff suppressed because it is too large Load Diff

View File

@ -1,295 +1,321 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2020 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.primitives.*; import gplx.core.brys.*;
public class Bry__tst {
private final Bry__fxt fxt = new Bry__fxt();
@Test public void new_ascii_() {
fxt.Test_new_a7("a" , Bry_.New_by_ints(97)); // one
fxt.Test_new_a7("abc" , Bry_.New_by_ints(97, 98, 99)); // many
fxt.Test_new_a7("" , Bry_.Empty); // none
fxt.Test_new_a7("¢€𤭢" , Bry_.New_by_ints(63, 63, 63, 63)); // non-ascii -> ?
}
@Test public void new_u8() {
fxt.Test_new_u8("a" , Bry_.New_by_ints(97)); // one
fxt.Test_new_u8("abc" , Bry_.New_by_ints(97, 98, 99)); // many
fxt.Test_new_u8("¢" , Bry_.New_by_ints(194, 162)); // bry_len=2; cent
fxt.Test_new_u8("" , Bry_.New_by_ints(226, 130, 172)); // bry_len=3; euro
fxt.Test_new_u8("𤭢" , Bry_.New_by_ints(240, 164, 173, 162)); // bry_len=3; example from en.w:UTF-8
}
@Test public void Add__bry_plus_byte() {
fxt.Test_add("a" , Byte_ascii.Pipe , "a|"); // basic
fxt.Test_add("" , Byte_ascii.Pipe , "|"); // empty String
}
@Test public void Add__byte_plus_bry() {
fxt.Test_add(Byte_ascii.Pipe , "a" , "|a"); // basic
fxt.Test_add(Byte_ascii.Pipe , "" , "|"); // empty String
}
@Test public void Add_w_dlm() {
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", "b", "c") , "a|b|c"); // basic
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a") , "a"); // one item
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", null, "c") , "a||c"); // null
}
@Test public void Add_w_dlm_bry() {
fxt.Test_add_w_dlm("<>", String_.Ary("a","b","c"), "a<>b<>c");
}
@Test public void MidByPos() {
tst_MidByPos("abcba", 0, 1, "a");
tst_MidByPos("abcba", 0, 2, "ab");
tst_MidByPos("abcba", 1, 4, "bcb");
} void tst_MidByPos(String src, int bgn, int end, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Mid(Bry_.new_u8(src), bgn, end)));}
@Test public void Replace_one() {
tst_ReplaceOne("a" , "b" , "c" , "a");
tst_ReplaceOne("b" , "b" , "c" , "c");
tst_ReplaceOne("bb" , "b" , "c" , "cb");
tst_ReplaceOne("abcd" , "bc" , "" , "ad");
tst_ReplaceOne("abcd" , "b" , "ee" , "aeecd");
} void tst_ReplaceOne(String src, String find, String repl, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Replace_one(Bry_.new_u8(src), Bry_.new_u8(find), Bry_.new_u8(repl))));}
@Test public void XtoStrBytesByInt() {
tst_XtoStrBytesByInt(0, 0);
tst_XtoStrBytesByInt(9, 9);
tst_XtoStrBytesByInt(10, 1, 0);
tst_XtoStrBytesByInt(321, 3, 2, 1);
tst_XtoStrBytesByInt(-321, Bry_.Byte_NegSign, 3, 2, 1);
tst_XtoStrBytesByInt(Int_.Max_value, 2,1,4,7,4,8,3,6,4,7);
}
void tst_XtoStrBytesByInt(int val, int... expdAryAsInt) {
byte[] expd = new byte[expdAryAsInt.length];
for (int i = 0; i < expd.length; i++) {
int expdInt = expdAryAsInt[i];
expd[i] = expdInt == Bry_.Byte_NegSign ? Bry_.Byte_NegSign : Byte_ascii.To_a7_str(expdAryAsInt[i]);
}
Tfds.Eq_ary(expd, Bry_.To_a7_bry(val, Int_.DigitCount(val)));
}
@Test public void Has_at_end() {
tst_HasAtEnd("a|bcd|e", "d" , 2, 5, true); // y_basic
tst_HasAtEnd("a|bcd|e", "bcd" , 2, 5, true); // y_many
tst_HasAtEnd("a|bcd|e", "|bcd" , 2, 5, false); // n_long
tst_HasAtEnd("a|bcd|e", "|bc" , 2, 5, false); // n_pos
tst_HasAtEnd("abc", "bc", true); // y
tst_HasAtEnd("abc", "bd", false); // n
tst_HasAtEnd("a", "ab", false); // exceeds_len
}
void tst_HasAtEnd(String src, String find, int bgn, int end, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_end(Bry_.new_u8(src), Bry_.new_u8(find), bgn, end));}
void tst_HasAtEnd(String src, String find, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_end(Bry_.new_u8(src), Bry_.new_u8(find)));}
@Test public void Has_at_bgn() {
tst_HasAtBgn("y_basic" , "a|bcd|e", "b" , 2, 5, true);
tst_HasAtBgn("y_many" , "a|bcd|e", "bcd" , 2, 5, true);
tst_HasAtBgn("n_long" , "a|bcd|e", "bcde" , 2, 5, false);
tst_HasAtBgn("n_pos" , "a|bcd|e", "|bc" , 2, 5, false);
} void tst_HasAtBgn(String tst, String src, String find, int bgn, int end, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_bgn(Bry_.new_u8(src), Bry_.new_u8(find), bgn, end), tst);}
@Test public void Match() {
tst_Match("abc", 0, "abc", true);
tst_Match("abc", 2, "c", true);
tst_Match("abc", 0, "cde", false);
tst_Match("abc", 2, "abc", false); // bounds check
tst_Match("abc", 0, "abcd", false);
tst_Match("a" , 0, "", false);
tst_Match("" , 0, "a", false);
tst_Match("" , 0, "", true);
tst_Match("ab", 0, "a", false); // FIX: "ab" should not match "a" b/c .length is different
} void tst_Match(String src, int srcPos, String find, boolean expd) {Tfds.Eq(expd, Bry_.Match(Bry_.new_u8(src), srcPos, Bry_.new_u8(find)));}
@Test public void ReadCsvStr() {
tst_ReadCsvStr("a|" , "a");
tst_ReadCsvStr("|a|", 1 , "a");
Int_obj_ref bgn = Int_obj_ref.New_zero(); tst_ReadCsvStr("a|b|c|", bgn, "a"); tst_ReadCsvStr("a|b|c|", bgn, "b"); tst_ReadCsvStr("a|b|c|", bgn, "c");
tst_ReadCsvStr("|", "");
tst_ReadCsvStr_err("a");
tst_ReadCsvStr("'a'|" , "a");
tst_ReadCsvStr("'a''b'|" , "a'b");
tst_ReadCsvStr("'a|b'|" , "a|b");
tst_ReadCsvStr("''|", "");
tst_ReadCsvStr_err("''");
tst_ReadCsvStr_err("'a'b'");
tst_ReadCsvStr_err("'a");
tst_ReadCsvStr_err("'a|");
tst_ReadCsvStr_err("'a'");
}
@Test public void XtoIntBy4Bytes() { // test len=1, 2, 3, 4
tst_XtoIntBy4Bytes(32, (byte)32); // space
tst_XtoIntBy4Bytes(8707, (byte)34, (byte)3); // &exist;
tst_XtoIntBy4Bytes(6382179, Byte_ascii.Ltr_a, Byte_ascii.Ltr_b, Byte_ascii.Ltr_c);
tst_XtoIntBy4Bytes(1633837924, Byte_ascii.Ltr_a, Byte_ascii.Ltr_b, Byte_ascii.Ltr_c, Byte_ascii.Ltr_d);
}
@Test public void XtoInt() {
tst_XtoInt("1", 1);
tst_XtoInt("123", 123);
tst_XtoInt("a", Int_.Min_value, Int_.Min_value);
tst_XtoInt("-1", Int_.Min_value, -1);
tst_XtoInt("-123", Int_.Min_value, -123);
tst_XtoInt("123-1", Int_.Min_value, Int_.Min_value);
tst_XtoInt("+123", Int_.Min_value, 123);
tst_XtoInt("", -1);
}
void tst_XtoInt(String val, int expd) {tst_XtoInt(val, -1, expd);}
void tst_XtoInt(String val, int or, int expd) {Tfds.Eq(expd, Bry_.To_int_or(Bry_.new_u8(val), or));}
void tst_XtoIntBy4Bytes(int expd, byte... ary) {Tfds.Eq(expd, Bry_.To_int_by_a7(ary), "XtoInt"); Tfds.Eq_ary(ary, Bry_.new_by_int(expd), "XbyInt");}
void tst_ReadCsvStr(String raw, String expd) {tst_ReadCsvStr(raw, Int_obj_ref.New_zero() , expd);}
void tst_ReadCsvStr(String raw, int bgn, String expd) {tst_ReadCsvStr(raw, Int_obj_ref.New(bgn), expd);}
void tst_ReadCsvStr(String raw, Int_obj_ref bgnRef, String expd) {
int bgn = bgnRef.Val();
boolean rawHasQuotes = String_.CharAt(raw, bgn) == '\'';
String actl = String_.Replace(Bry_.ReadCsvStr(Bry_.new_u8(String_.Replace(raw, "'", "\"")), bgnRef, (byte)'|'), "\"", "'");
Tfds.Eq(expd, actl, "rv");
if (rawHasQuotes) {
int quoteAdj = String_.Count(actl, "'");
Tfds.Eq(bgn + 1 + String_.Len(actl) + 2 + quoteAdj, bgnRef.Val(), "pos_quote"); // +1=lkp.Len; +2=bgn/end quotes
}
else
Tfds.Eq(bgn + 1 + String_.Len(actl), bgnRef.Val(), "pos"); // +1=lkp.Len
}
void tst_ReadCsvStr_err(String raw) {
try {Bry_.ReadCsvStr(Bry_.new_u8(String_.Replace(raw, "'", "\"")), Int_obj_ref.New_zero(), (byte)'|');}
catch (Exception e) {Err_.Noop(e); return;}
Tfds.Fail_expdError();
}
@Test public void ReadCsvDte() {
tst_ReadCsvDte("20110801 221435.987");
} void tst_ReadCsvDte(String raw) {Tfds.Eq_date(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte), Bry_.ReadCsvDte(Bry_.new_u8(raw + "|"), Int_obj_ref.New_zero(), (byte)'|'));}
@Test public void ReadCsvInt() {
tst_ReadCsvInt("1234567890");
} void tst_ReadCsvInt(String raw) {Tfds.Eq(Int_.parse(raw), Bry_.ReadCsvInt(Bry_.new_u8(raw + "|"), Int_obj_ref.New_zero(), (byte)'|'));}
@Test public void Trim() {
Trim_tst("a b c", 1, 4, "b");
Trim_tst("a c", 1, 3, "");
Trim_tst(" ", 0, 2, "");
} void Trim_tst(String raw, int bgn, int end, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Trim(Bry_.new_u8(raw), bgn, end)));}
@Test public void Xto_int_lax() {
tst_Xto_int_lax("12a", 12);
tst_Xto_int_lax("1", 1);
tst_Xto_int_lax("123", 123);
tst_Xto_int_lax("a", 0);
tst_Xto_int_lax("-1", -1);
}
private void tst_Xto_int_lax(String val, int expd) {Tfds.Eq(expd, Bry_.To_int_or__lax(Bry_.new_u8(val), 0, String_.Len(val), 0));}
@Test public void To_int_or__trim_ws() {
tst_Xto_int_trim("123 " , 123);
tst_Xto_int_trim(" 123" , 123);
tst_Xto_int_trim(" 123 " , 123);
tst_Xto_int_trim(" 1 3 " , -1);
}
private void tst_Xto_int_trim(String val, int expd) {Tfds.Eq(expd, Bry_.To_int_or__trim_ws(Bry_.new_u8(val), 0, String_.Len(val), -1));}
@Test public void Compare() {
tst_Compare("abcde", 0, 1, "abcde", 0, 1, CompareAble_.Same);
tst_Compare("abcde", 0, 1, "abcde", 1, 2, CompareAble_.Less);
tst_Compare("abcde", 1, 2, "abcde", 0, 1, CompareAble_.More);
tst_Compare("abcde", 0, 1, "abcde", 0, 2, CompareAble_.Less);
tst_Compare("abcde", 0, 2, "abcde", 0, 1, CompareAble_.More);
tst_Compare("abcde", 2, 3, "abçde", 2, 3, CompareAble_.Less);
} void tst_Compare(String lhs, int lhs_bgn, int lhs_end, String rhs, int rhs_bgn, int rhs_end, int expd) {Tfds.Eq(expd, Bry_.Compare(Bry_.new_u8(lhs), lhs_bgn, lhs_end, Bry_.new_u8(rhs), rhs_bgn, rhs_end));}
@Test public void Increment_last() {
tst_IncrementLast(ary_(0), ary_(1));
tst_IncrementLast(ary_(0, 255), ary_(1, 0));
tst_IncrementLast(ary_(104, 111, 112, 101), ary_(104, 111, 112, 102));
}
byte[] ary_(int... ary) {
byte[] rv = new byte[ary.length];
for (int i = 0; i < ary.length; i++)
rv[i] = Byte_.By_int(ary[i]);
return rv;
}
void tst_IncrementLast(byte[] ary, byte[] expd) {Tfds.Eq_ary(expd, Bry_.Increment_last(Bry_.Copy(ary)));}
@Test public void Replace_between() {
tst_Replace_between("a[0]b" , "[", "]", "0", "a0b");
tst_Replace_between("a[0]b[1]c" , "[", "]", "0", "a0b0c");
tst_Replace_between("a[0b" , "[", "]", "0", "a[0b");
} public void tst_Replace_between(String src, String bgn, String end, String repl, String expd) {Tfds.Eq(expd, String_.new_a7(Bry_.Replace_between(Bry_.new_a7(src), Bry_.new_a7(bgn), Bry_.new_a7(end), Bry_.new_a7(repl))));}
@Test public void Replace() {
Bry_bfr tmp_bfr = Bry_bfr_.New();
tst_Replace(tmp_bfr, "a0b" , "0", "00", "a00b"); // 1 -> 1
tst_Replace(tmp_bfr, "a0b0c" , "0", "00", "a00b00c"); // 1 -> 2
tst_Replace(tmp_bfr, "a00b00c" , "00", "0", "a0b0c"); // 2 -> 1
tst_Replace(tmp_bfr, "a0b0" , "0", "00", "a00b00"); // 1 -> 2; EOS
tst_Replace(tmp_bfr, "a00b00" , "00", "0", "a0b0"); // 2 -> 1; EOS
tst_Replace(tmp_bfr, "a0b0" , "1", "2", "a0b0"); // no match
tst_Replace(tmp_bfr, "a0b0" , "b1", "b2", "a0b0"); // false match; EOS
}
public void tst_Replace(Bry_bfr tmp_bfr, String src, String bgn, String repl, String expd) {
Tfds.Eq(expd, String_.new_a7(Bry_.Replace(tmp_bfr, Bry_.new_a7(src), Bry_.new_a7(bgn), Bry_.new_a7(repl))));
}
@Test public void Split_bry() {
Split_bry_tst("a|b|c|" , "|" , String_.Ary("a", "b", "c"));
Split_bry_tst("a|" , "|" , String_.Ary("a"));
}
void Split_bry_tst(String src, String dlm, String[] expd) {
String[] actl = String_.Ary(Bry_split_.Split(Bry_.new_a7(src), Bry_.new_a7(dlm)));
Tfds.Eq_ary_str(expd, actl);
}
@Test public void Split_lines() {
Tst_split_lines("a\nb" , "a", "b"); // basic
Tst_split_lines("a\nb\n" , "a", "b"); // do not create empty trailing lines
Tst_split_lines("a\r\nb" , "a", "b"); // crlf
Tst_split_lines("a\rb" , "a", "b"); // cr only
}
void Tst_split_lines(String src, String... expd) {
Tfds.Eq_ary(expd, New_ary(Bry_split_.Split_lines(Bry_.new_a7(src))));
}
String[] New_ary(byte[][] lines) {
int len = lines.length;
String[] rv = new String[len];
for (int i = 0; i < len; i++)
rv[i] = String_.new_u8(lines[i]);
return rv;
}
@Test public void Match_bwd_any() {
Tst_match_bwd_any("abc", 2, 0, "c", true);
Tst_match_bwd_any("abc", 2, 0, "b", false);
Tst_match_bwd_any("abc", 2, 0, "bc", true);
Tst_match_bwd_any("abc", 2, 0, "abc", true);
Tst_match_bwd_any("abc", 2, 0, "zabc", false);
Tst_match_bwd_any("abc", 1, 0, "ab", true);
}
void Tst_match_bwd_any(String src, int src_end, int src_bgn, String find, boolean expd) {
Tfds.Eq(expd, Bry_.Match_bwd_any(Bry_.new_a7(src), src_end, src_bgn, Bry_.new_a7(find)));
}
@Test public void Trim_end() {
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.one
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.many
fxt.Test_trim_end("a" , Byte_ascii.Space, "a"); // trim.none
fxt.Test_trim_end("" , Byte_ascii.Space, ""); // empty
}
@Test public void Mid_w_trim() {
fxt.Test_Mid_w_trim("abc", "abc"); // no ws
fxt.Test_Mid_w_trim(" a b c ", "a b c"); // ws at bgn and end
fxt.Test_Mid_w_trim("\r\n\t a\r\n\t b \r\n\t ", "a\r\n\t b"); // space at bgn and end
fxt.Test_Mid_w_trim("", ""); // handle 0 bytes
fxt.Test_Mid_w_trim(" ", ""); // handle all ws
}
@Test public void New_u8_nl_apos() {
fxt.Test__new_u8_nl_apos(String_.Ary("a"), "a");
fxt.Test__new_u8_nl_apos(String_.Ary("a", "b"), "a\nb");
fxt.Test__new_u8_nl_apos(String_.Ary("a", "b'c", "d"), "a\nb\"c\nd");
}
}
class Bry__fxt {
public void Test_trim_end(String raw, byte trim, String expd) {
byte[] raw_bry = Bry_.new_a7(raw);
Tfds.Eq(expd, String_.new_u8(Bry_.Trim_end(raw_bry, trim, raw_bry.length)));
}
public void Test_new_u8(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_u8(raw));}
public void Test_new_a7(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_a7(raw));}
public void Test_add(String s, byte b, String expd) {Tfds.Eq_str(expd, String_.new_u8(Bry_.Add(Bry_.new_u8(s), b)));}
public void Test_add(byte b, String s, String expd) {Tfds.Eq_str(expd, String_.new_u8(Bry_.Add(b, Bry_.new_u8(s))));}
public void Test_add_w_dlm(String dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Add_w_dlm(Bry_.new_u8(dlm), Bry_.Ary(itms))));}
public void Test_add_w_dlm(byte dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Add_w_dlm(dlm, Bry_.Ary(itms))));}
public void Test_Mid_w_trim(String src, String expd) {byte[] bry = Bry_.new_u8(src); Tfds.Eq(expd, String_.new_u8(Bry_.Mid_w_trim(bry, 0, bry.length)));}
public void Test__new_u8_nl_apos(String[] ary, String expd) {
Tfds.Eq_str_lines(expd, String_.new_u8(Bry_.New_u8_nl_apos(ary)));
}
}
package gplx;
import gplx.core.primitives.Int_obj_ref;
import gplx.core.tests.Gftest;
import org.junit.Test;
public class Bry__tst {
private final Bry__fxt fxt = new Bry__fxt();
@Test public void new_ascii_() {
fxt.Test_new_a7("a" , Bry_.New_by_ints(97)); // one
fxt.Test_new_a7("abc" , Bry_.New_by_ints(97, 98, 99)); // many
fxt.Test_new_a7("" , Bry_.Empty); // none
fxt.Test_new_a7("¢€𤭢" , Bry_.New_by_ints(63, 63, 63, 63)); // non-ascii -> ?
}
@Test public void new_u8() {
fxt.Test_new_u8("a" , Bry_.New_by_ints(97)); // one
fxt.Test_new_u8("abc" , Bry_.New_by_ints(97, 98, 99)); // many
fxt.Test_new_u8("¢" , Bry_.New_by_ints(194, 162)); // bry_len=2; cent
fxt.Test_new_u8("" , Bry_.New_by_ints(226, 130, 172)); // bry_len=3; euro
fxt.Test_new_u8("𤭢" , Bry_.New_by_ints(240, 164, 173, 162)); // bry_len=4; example from en.w:UTF-8
}
@Test public void Add__bry_plus_byte() {
fxt.Test_add("a" , Byte_ascii.Pipe , "a|"); // basic
fxt.Test_add("" , Byte_ascii.Pipe , "|"); // empty String
}
@Test public void Add__byte_plus_bry() {
fxt.Test_add(Byte_ascii.Pipe , "a" , "|a"); // basic
fxt.Test_add(Byte_ascii.Pipe , "" , "|"); // empty String
}
@Test public void Add_w_dlm() {
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", "b", "c") , "a|b|c"); // basic
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a") , "a"); // one item
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", null, "c") , "a||c"); // null
}
@Test public void Add_w_dlm_bry() {
fxt.Test_add_w_dlm("<>", String_.Ary("a","b","c"), "a<>b<>c");
}
@Test public void MidByPos() {
tst_MidByPos("abcba", 0, 1, "a");
tst_MidByPos("abcba", 0, 2, "ab");
tst_MidByPos("abcba", 1, 4, "bcb");
} void tst_MidByPos(String src, int bgn, int end, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Mid(Bry_.new_u8(src), bgn, end)));}
@Test public void Replace_one() {
tst_ReplaceOne("a" , "b" , "c" , "a");
tst_ReplaceOne("b" , "b" , "c" , "c");
tst_ReplaceOne("bb" , "b" , "c" , "cb");
tst_ReplaceOne("abcd" , "bc" , "" , "ad");
tst_ReplaceOne("abcd" , "b" , "ee" , "aeecd");
} void tst_ReplaceOne(String src, String find, String repl, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Replace_one(Bry_.new_u8(src), Bry_.new_u8(find), Bry_.new_u8(repl))));}
@Test public void XtoStrBytesByInt() {
tst_XtoStrBytesByInt(0, 0);
tst_XtoStrBytesByInt(9, 9);
tst_XtoStrBytesByInt(10, 1, 0);
tst_XtoStrBytesByInt(321, 3, 2, 1);
tst_XtoStrBytesByInt(-321, Bry_.Byte_NegSign, 3, 2, 1);
tst_XtoStrBytesByInt(Int_.Max_value, 2,1,4,7,4,8,3,6,4,7);
}
void tst_XtoStrBytesByInt(int val, int... expdAryAsInt) {
byte[] expd = new byte[expdAryAsInt.length];
for (int i = 0; i < expd.length; i++) {
int expdInt = expdAryAsInt[i];
expd[i] = expdInt == Bry_.Byte_NegSign ? Bry_.Byte_NegSign : Byte_ascii.To_a7_str(expdAryAsInt[i]);
}
Tfds.Eq_ary(expd, Bry_.To_a7_bry(val, Int_.DigitCount(val)));
}
@Test public void Has_at_end() {
tst_HasAtEnd("a|bcd|e", "d" , 2, 5, true); // y_basic
tst_HasAtEnd("a|bcd|e", "bcd" , 2, 5, true); // y_many
tst_HasAtEnd("a|bcd|e", "|bcd" , 2, 5, false); // n_long
tst_HasAtEnd("a|bcd|e", "|bc" , 2, 5, false); // n_pos
tst_HasAtEnd("abc", "bc", true); // y
tst_HasAtEnd("abc", "bd", false); // n
tst_HasAtEnd("a", "ab", false); // exceeds_len
}
void tst_HasAtEnd(String src, String find, int bgn, int end, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_end(Bry_.new_u8(src), Bry_.new_u8(find), bgn, end));}
void tst_HasAtEnd(String src, String find, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_end(Bry_.new_u8(src), Bry_.new_u8(find)));}
@Test public void Has_at_bgn() {
tst_HasAtBgn("y_basic" , "a|bcd|e", "b" , 2, 5, true);
tst_HasAtBgn("y_many" , "a|bcd|e", "bcd" , 2, 5, true);
tst_HasAtBgn("n_long" , "a|bcd|e", "bcde" , 2, 5, false);
tst_HasAtBgn("n_pos" , "a|bcd|e", "|bc" , 2, 5, false);
} void tst_HasAtBgn(String tst, String src, String find, int bgn, int end, boolean expd) {Tfds.Eq(expd, Bry_.Has_at_bgn(Bry_.new_u8(src), Bry_.new_u8(find), bgn, end), tst);}
@Test public void Match() {
tst_Match("abc", 0, "abc", true);
tst_Match("abc", 2, "c", true);
tst_Match("abc", 0, "cde", false);
tst_Match("abc", 2, "abc", false); // bounds check
tst_Match("abc", 0, "abcd", false);
tst_Match("a" , 0, "", false);
tst_Match("" , 0, "a", false);
tst_Match("" , 0, "", true);
tst_Match("ab", 0, "a", false); // FIX: "ab" should not match "a" b/c .length is different
} void tst_Match(String src, int srcPos, String find, boolean expd) {Tfds.Eq(expd, Bry_.Match(Bry_.new_u8(src), srcPos, Bry_.new_u8(find)));}
@Test public void ReadCsvStr() {
tst_ReadCsvStr("a|" , "a");
tst_ReadCsvStr("|a|", 1 , "a");
Int_obj_ref bgn = Int_obj_ref.New_zero(); tst_ReadCsvStr("a|b|c|", bgn, "a"); tst_ReadCsvStr("a|b|c|", bgn, "b"); tst_ReadCsvStr("a|b|c|", bgn, "c");
tst_ReadCsvStr("|", "");
tst_ReadCsvStr_err("a");
tst_ReadCsvStr("'a'|" , "a");
tst_ReadCsvStr("'a''b'|" , "a'b");
tst_ReadCsvStr("'a|b'|" , "a|b");
tst_ReadCsvStr("''|", "");
tst_ReadCsvStr_err("''");
tst_ReadCsvStr_err("'a'b'");
tst_ReadCsvStr_err("'a");
tst_ReadCsvStr_err("'a|");
tst_ReadCsvStr_err("'a'");
}
@Test public void XtoIntBy4Bytes() { // test len=1, 2, 3, 4
tst_XtoIntBy4Bytes(32, (byte)32); // space
tst_XtoIntBy4Bytes(8707, (byte)34, (byte)3); // &exist;
tst_XtoIntBy4Bytes(6382179, Byte_ascii.Ltr_a, Byte_ascii.Ltr_b, Byte_ascii.Ltr_c);
tst_XtoIntBy4Bytes(1633837924, Byte_ascii.Ltr_a, Byte_ascii.Ltr_b, Byte_ascii.Ltr_c, Byte_ascii.Ltr_d);
}
@Test public void XtoInt() {
tst_XtoInt("1", 1);
tst_XtoInt("123", 123);
tst_XtoInt("a", Int_.Min_value, Int_.Min_value);
tst_XtoInt("-1", Int_.Min_value, -1);
tst_XtoInt("-123", Int_.Min_value, -123);
tst_XtoInt("123-1", Int_.Min_value, Int_.Min_value);
tst_XtoInt("+123", Int_.Min_value, 123);
tst_XtoInt("", -1);
}
void tst_XtoInt(String val, int expd) {tst_XtoInt(val, -1, expd);}
void tst_XtoInt(String val, int or, int expd) {Tfds.Eq(expd, Bry_.To_int_or(Bry_.new_u8(val), or));}
void tst_XtoIntBy4Bytes(int expd, byte... ary) {Tfds.Eq(expd, Bry_.To_int_by_a7(ary), "XtoInt"); Tfds.Eq_ary(ary, Bry_.new_by_int(expd), "XbyInt");}
void tst_ReadCsvStr(String raw, String expd) {tst_ReadCsvStr(raw, Int_obj_ref.New_zero() , expd);}
void tst_ReadCsvStr(String raw, int bgn, String expd) {tst_ReadCsvStr(raw, Int_obj_ref.New(bgn), expd);}
void tst_ReadCsvStr(String raw, Int_obj_ref bgnRef, String expd) {
int bgn = bgnRef.Val();
boolean rawHasQuotes = String_.CharAt(raw, bgn) == '\'';
String actl = String_.Replace(Bry_.ReadCsvStr(Bry_.new_u8(String_.Replace(raw, "'", "\"")), bgnRef, (byte)'|'), "\"", "'");
Tfds.Eq(expd, actl, "rv");
if (rawHasQuotes) {
int quoteAdj = String_.Count(actl, "'");
Tfds.Eq(bgn + 1 + String_.Len(actl) + 2 + quoteAdj, bgnRef.Val(), "pos_quote"); // +1=lkp.Len; +2=bgn/end quotes
}
else
Tfds.Eq(bgn + 1 + String_.Len(actl), bgnRef.Val(), "pos"); // +1=lkp.Len
}
void tst_ReadCsvStr_err(String raw) {
try {Bry_.ReadCsvStr(Bry_.new_u8(String_.Replace(raw, "'", "\"")), Int_obj_ref.New_zero(), (byte)'|');}
catch (Exception e) {Err_.Noop(e); return;}
Tfds.Fail_expdError();
}
@Test public void ReadCsvDte() {
tst_ReadCsvDte("20110801 221435.987");
} void tst_ReadCsvDte(String raw) {Tfds.Eq_date(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte), Bry_.ReadCsvDte(Bry_.new_u8(raw + "|"), Int_obj_ref.New_zero(), (byte)'|'));}
@Test public void ReadCsvInt() {
tst_ReadCsvInt("1234567890");
} void tst_ReadCsvInt(String raw) {Tfds.Eq(Int_.Parse(raw), Bry_.ReadCsvInt(Bry_.new_u8(raw + "|"), Int_obj_ref.New_zero(), (byte)'|'));}
@Test public void Trim() {
Trim_tst("a b c", 1, 4, "b");
Trim_tst("a c", 1, 3, "");
Trim_tst(" ", 0, 2, "");
} void Trim_tst(String raw, int bgn, int end, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Trim(Bry_.new_u8(raw), bgn, end)));}
@Test public void Xto_int_lax() {
tst_Xto_int_lax("12a", 12);
tst_Xto_int_lax("1", 1);
tst_Xto_int_lax("123", 123);
tst_Xto_int_lax("a", 0);
tst_Xto_int_lax("-1", -1);
}
private void tst_Xto_int_lax(String val, int expd) {Tfds.Eq(expd, Bry_.To_int_or__lax(Bry_.new_u8(val), 0, String_.Len(val), 0));}
@Test public void To_int_or__trim_ws() {
tst_Xto_int_trim("123 " , 123);
tst_Xto_int_trim(" 123" , 123);
tst_Xto_int_trim(" 123 " , 123);
tst_Xto_int_trim(" 1 3 " , -1);
}
private void tst_Xto_int_trim(String val, int expd) {Tfds.Eq(expd, Bry_.To_int_or__trim_ws(Bry_.new_u8(val), 0, String_.Len(val), -1));}
@Test public void Compare() {
tst_Compare("abcde", 0, 1, "abcde", 0, 1, CompareAble_.Same);
tst_Compare("abcde", 0, 1, "abcde", 1, 2, CompareAble_.Less);
tst_Compare("abcde", 1, 2, "abcde", 0, 1, CompareAble_.More);
tst_Compare("abcde", 0, 1, "abcde", 0, 2, CompareAble_.Less);
tst_Compare("abcde", 0, 2, "abcde", 0, 1, CompareAble_.More);
tst_Compare("abcde", 2, 3, "abçde", 2, 3, CompareAble_.Less);
} void tst_Compare(String lhs, int lhs_bgn, int lhs_end, String rhs, int rhs_bgn, int rhs_end, int expd) {Tfds.Eq(expd, Bry_.Compare(Bry_.new_u8(lhs), lhs_bgn, lhs_end, Bry_.new_u8(rhs), rhs_bgn, rhs_end));}
@Test public void Increment_last() {
tst_IncrementLast(ary_(0), ary_(1));
tst_IncrementLast(ary_(0, 255), ary_(1, 0));
tst_IncrementLast(ary_(104, 111, 112, 101), ary_(104, 111, 112, 102));
}
byte[] ary_(int... ary) {
byte[] rv = new byte[ary.length];
for (int i = 0; i < ary.length; i++)
rv[i] = Byte_.By_int(ary[i]);
return rv;
}
void tst_IncrementLast(byte[] ary, byte[] expd) {Tfds.Eq_ary(expd, Bry_.Increment_last(Bry_.Copy(ary)));}
@Test public void Replace_between() {
tst_Replace_between("a[0]b" , "[", "]", "0", "a0b");
tst_Replace_between("a[0]b[1]c" , "[", "]", "0", "a0b0c");
tst_Replace_between("a[0b" , "[", "]", "0", "a[0b");
} public void tst_Replace_between(String src, String bgn, String end, String repl, String expd) {Tfds.Eq(expd, String_.new_a7(Bry_.Replace_between(Bry_.new_a7(src), Bry_.new_a7(bgn), Bry_.new_a7(end), Bry_.new_a7(repl))));}
@Test public void Replace() {
Bry_bfr tmp_bfr = Bry_bfr_.New();
tst_Replace(tmp_bfr, "a0b" , "0", "00", "a00b"); // 1 -> 1
tst_Replace(tmp_bfr, "a0b0c" , "0", "00", "a00b00c"); // 1 -> 2
tst_Replace(tmp_bfr, "a00b00c" , "00", "0", "a0b0c"); // 2 -> 1
tst_Replace(tmp_bfr, "a0b0" , "0", "00", "a00b00"); // 1 -> 2; EOS
tst_Replace(tmp_bfr, "a00b00" , "00", "0", "a0b0"); // 2 -> 1; EOS
tst_Replace(tmp_bfr, "a0b0" , "1", "2", "a0b0"); // no match
tst_Replace(tmp_bfr, "a0b0" , "b1", "b2", "a0b0"); // false match; EOS
}
public void tst_Replace(Bry_bfr tmp_bfr, String src, String bgn, String repl, String expd) {
Tfds.Eq(expd, String_.new_a7(Bry_.Replace(tmp_bfr, Bry_.new_a7(src), Bry_.new_a7(bgn), Bry_.new_a7(repl))));
}
@Test public void Split_bry() {
Split_bry_tst("a|b|c|" , "|" , String_.Ary("a", "b", "c"));
Split_bry_tst("a|" , "|" , String_.Ary("a"));
}
void Split_bry_tst(String src, String dlm, String[] expd) {
String[] actl = String_.Ary(Bry_split_.Split(Bry_.new_a7(src), Bry_.new_a7(dlm)));
Tfds.Eq_ary_str(expd, actl);
}
@Test public void Split_lines() {
Tst_split_lines("a\nb" , "a", "b"); // basic
Tst_split_lines("a\nb\n" , "a", "b"); // do not create empty trailing lines
Tst_split_lines("a\r\nb" , "a", "b"); // crlf
Tst_split_lines("a\rb" , "a", "b"); // cr only
}
void Tst_split_lines(String src, String... expd) {
Tfds.Eq_ary(expd, New_ary(Bry_split_.Split_lines(Bry_.new_a7(src))));
}
String[] New_ary(byte[][] lines) {
int len = lines.length;
String[] rv = new String[len];
for (int i = 0; i < len; i++)
rv[i] = String_.new_u8(lines[i]);
return rv;
}
@Test public void Match_bwd_any() {
Tst_match_bwd_any("abc", 2, 0, "c", true);
Tst_match_bwd_any("abc", 2, 0, "b", false);
Tst_match_bwd_any("abc", 2, 0, "bc", true);
Tst_match_bwd_any("abc", 2, 0, "abc", true);
Tst_match_bwd_any("abc", 2, 0, "zabc", false);
Tst_match_bwd_any("abc", 1, 0, "ab", true);
}
void Tst_match_bwd_any(String src, int src_end, int src_bgn, String find, boolean expd) {
Tfds.Eq(expd, Bry_.Match_bwd_any(Bry_.new_a7(src), src_end, src_bgn, Bry_.new_a7(find)));
}
@Test public void Trim_bgn() {
fxt.Test_trim_bgn(" a" , Byte_ascii.Space, "a"); // trim.one
fxt.Test_trim_bgn(" a" , Byte_ascii.Space, "a"); // trim.many
fxt.Test_trim_bgn("a" , Byte_ascii.Space, "a"); // trim.none
fxt.Test_trim_bgn("" , Byte_ascii.Space, ""); // empty
}
@Test public void Trim_end() {
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.one
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.many
fxt.Test_trim_end("a" , Byte_ascii.Space, "a"); // trim.none
fxt.Test_trim_end("" , Byte_ascii.Space, ""); // empty
}
@Test public void Mid_w_trim() {
fxt.Test_Mid_w_trim("abc", "abc"); // no ws
fxt.Test_Mid_w_trim(" a b c ", "a b c"); // ws at bgn and end
fxt.Test_Mid_w_trim("\r\n\t a\r\n\t b \r\n\t ", "a\r\n\t b"); // space at bgn and end
fxt.Test_Mid_w_trim("", ""); // handle 0 bytes
fxt.Test_Mid_w_trim(" ", ""); // handle all ws
}
@Test public void New_u8_nl_apos() {
fxt.Test__new_u8_nl_apos(String_.Ary("a"), "a");
fxt.Test__new_u8_nl_apos(String_.Ary("a", "b"), "a\nb");
fxt.Test__new_u8_nl_apos(String_.Ary("a", "b'c", "d"), "a\nb\"c\nd");
}
@Test public void Repeat_bry() {
fxt.Test__repeat_bry("abc" , 3, "abcabcabc");
}
@Test public void Xcase__build__all() {
fxt.Test__xcase__build__all(Bool_.N, "abc", "abc");
fxt.Test__xcase__build__all(Bool_.N, "aBc", "abc");
}
}
class Bry__fxt {
private final Bry_bfr tmp = Bry_bfr_.New();
public void Test_trim_end(String raw, byte trim, String expd) {
byte[] raw_bry = Bry_.new_a7(raw);
Tfds.Eq(expd, String_.new_u8(Bry_.Trim_end(raw_bry, trim, raw_bry.length)));
}
public void Test_trim_bgn(String raw, byte trim, String expd) {
byte[] raw_bry = Bry_.new_a7(raw);
Tfds.Eq(expd, String_.new_u8(Bry_.Trim_bgn(raw_bry, trim, 0)));
}
public void Test_new_u8(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_u8(raw));}
public void Test_new_a7(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_a7(raw));}
public void Test_add(String s, byte b, String expd) {Tfds.Eq_str(expd, String_.new_u8(Bry_.Add(Bry_.new_u8(s), b)));}
public void Test_add(byte b, String s, String expd) {Tfds.Eq_str(expd, String_.new_u8(Bry_.Add(b, Bry_.new_u8(s))));}
public void Test_add_w_dlm(String dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Add_w_dlm(Bry_.new_u8(dlm), Bry_.Ary(itms))));}
public void Test_add_w_dlm(byte dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_u8(Bry_.Add_w_dlm(dlm, Bry_.Ary(itms))));}
public void Test_Mid_w_trim(String src, String expd) {byte[] bry = Bry_.new_u8(src); Tfds.Eq(expd, String_.new_u8(Bry_.Mid_w_trim(bry, 0, bry.length)));}
public void Test__new_u8_nl_apos(String[] ary, String expd) {
Tfds.Eq_str_lines(expd, String_.new_u8(Bry_.New_u8_nl_apos(ary)));
}
public void Test__repeat_bry(String s, int count, String expd) {
Gftest.Eq__str(expd, Bry_.Repeat_bry(Bry_.new_u8(s), count));
}
public void Test__xcase__build__all(boolean upper, String src, String expd) {
Gftest.Eq__str(expd, Bry_.Xcase__build__all(tmp, upper, Bry_.new_u8(src)));
}
}

View File

@ -1,22 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.encoders.*;
import gplx.langs.htmls.entitys.*;
public class Bry_bfr {
private Bry_bfr_mkr_mgr mkr_mgr; private int reset;
public byte[] Bfr() {return bfr;} private byte[] bfr;
@ -80,7 +79,7 @@ public class Bry_bfr {
public Bry_bfr Add(byte[] val) {
int val_len = val.length;
if (bfr_len + val_len > bfr_max) Resize((bfr_max + val_len) * 2);
Bry_.Copy_by_pos(val, 0, val_len, bfr, bfr_len);
Bry_.Copy_to(val, 0, val_len, bfr, bfr_len);
// Array_.Copy_to(val, 0, bfr, bfr_len, val_len);
bfr_len += val_len;
return this;
@ -89,7 +88,16 @@ public class Bry_bfr {
int len = end - bgn;
if (len < 0) throw Err_.new_wo_type("negative len", "bgn", bgn, "end", end, "excerpt", String_.new_u8__by_len(val, bgn, bgn + 16)); // NOTE: check for invalid end < bgn, else difficult to debug errors later; DATE:2014-05-11
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
Bry_.Copy_by_pos(val, bgn, end, bfr, bfr_len);
Bry_.Copy_to(val, bgn, end, bfr, bfr_len);
// Array_.Copy_to(val, bgn, bfr, bfr_len, len);
bfr_len += len;
return this;
}
public Bry_bfr Add_reverse_mid(byte[] val, int bgn, int end) {
int len = end - bgn;
if (len < 0) throw Err_.new_wo_type("negative len", "bgn", bgn, "end", end, "excerpt", String_.new_u8__by_len(val, bgn, bgn + 16)); // NOTE: check for invalid end < bgn, else difficult to debug errors later; DATE:2014-05-11
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
Bry_.Copy_to_reversed(val, bgn, end, bfr, bfr_len);
// Array_.Copy_to(val, bgn, bfr, bfr_len, len);
bfr_len += len;
return this;
@ -110,7 +118,7 @@ public class Bry_bfr {
public Bry_bfr Add_bfr_and_preserve(Bry_bfr src) {
int len = src.bfr_len;
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
Bry_.Copy_by_pos(src.bfr, 0, len, bfr, bfr_len);
Bry_.Copy_to(src.bfr, 0, len, bfr, bfr_len);
// Array_.Copy_to(src.bfr, 0, bfr, bfr_len, len);
bfr_len += len;
return this;
@ -155,7 +163,7 @@ public class Bry_bfr {
if (all_ws) return this;
}
src_len = src_end - src_bgn;
Bry_.Copy_by_pos(src.bfr, src_bgn, src_end, bfr, bfr_len);
Bry_.Copy_to(src.bfr, src_bgn, src_end, bfr, bfr_len);
// Array_.Copy_to(src.bfr, src_bgn, bfr, bfr_len, src_len);
bfr_len += src_len;
src.Clear();
@ -293,7 +301,28 @@ public class Bry_bfr {
}
}
if (clean)
Add(val);
Add_mid(val, bgn, end);
return this;
}
public Bry_bfr Add_bry_many(byte[]... val) {
int len = val.length;
for (int i = 0; i < len; i++) {
byte[] bry = val[i];
if (bry != null && bry.length > 0)
this.Add(bry);
}
return this;
}
public Bry_bfr Add_bry_escape_html(byte[] val) {
if (val == null) return this;
return Add_bry_escape_html(val, 0, val.length);
}
public Bry_bfr Add_bry_escape_html(byte[] val, int bgn, int end) {
Bry_.Escape_html(this, Bool_.N, val, bgn, end);
return this;
}
public Bry_bfr Add_bry_escape_xml(byte[] val, int bgn, int end) {
Bry_.Escape_html(this, Bool_.Y, val, bgn, end);
return this;
}
public Bry_bfr Add_str_u8_w_nl(String s) {Add_str_u8(s); return Add_byte_nl();}
@ -309,10 +338,10 @@ public class Bry_bfr {
}
catch (Exception e) {throw Err_.new_exc(e, "core", "invalid UTF-8 sequence", "s", str);}
}
public Bry_bfr Add_str_u8_many(String... ary) {
int len = ary.length;
public Bry_bfr Add_str_u8_many(String... val) {
int len = val.length;
for (int i = 0; i < len; ++i)
Add_str_u8(ary[i]);
Add_str_u8(val[i]);
return this;
}
public Bry_bfr Add_str_u8_fmt(String fmt, Object... args) {
@ -335,6 +364,10 @@ public class Bry_bfr {
}
catch (Exception e) {throw Err_.new_exc(e, "core", "invalid UTF-8 sequence", "s", str);}
}
public Bry_bfr Add_str_mid(String src, int bgn, int end) {
this.Add_str_u8(String_.Mid(src, bgn, end));
return this;
}
public Bry_bfr Add_kv_dlm(boolean line, String key, Object val) {
this.Add_str_a7(key).Add_byte_colon().Add_byte_space();
this.Add(Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(val)));
@ -343,8 +376,9 @@ public class Bry_bfr {
}
public Bry_bfr Add_float(float f) {Add_str_a7(Float_.To_str(f)); return this;}
public Bry_bfr Add_double(double v) {Add_str_a7(Double_.To_str(v)); return this;}
public Bry_bfr Add_dte(DateAdp val) {return Add_dte_segs(val.Year(), val.Month(),val.Day(), val.Hour(), val.Minute(), val.Second(), val.Frac());}
public Bry_bfr Add_dte_segs(int y, int M, int d, int H, int m, int s, int f) { // yyyyMMdd HHmmss.fff
public Bry_bfr Add_dte(DateAdp val) {return Add_dte_segs(Byte_ascii.Space , val.Year(), val.Month(),val.Day(), val.Hour(), val.Minute(), val.Second(), val.Frac());}
public Bry_bfr Add_dte_under(DateAdp val) {return Add_dte_segs(Byte_ascii.Underline, val.Year(), val.Month(),val.Day(), val.Hour(), val.Minute(), val.Second(), val.Frac());}
private Bry_bfr Add_dte_segs(byte spr, int y, int M, int d, int H, int m, int s, int f) { // yyyyMMdd HHmmss.fff
if (bfr_len + 19 > bfr_max) Resize((bfr_len + 19) * 2);
bfr[bfr_len + 0] = (byte)((y / 1000) + Bry_.Ascii_zero); y %= 1000;
bfr[bfr_len + 1] = (byte)((y / 100) + Bry_.Ascii_zero); y %= 100;
@ -354,7 +388,7 @@ public class Bry_bfr {
bfr[bfr_len + 5] = (byte)( M + Bry_.Ascii_zero);
bfr[bfr_len + 6] = (byte)((d / 10) + Bry_.Ascii_zero); d %= 10;
bfr[bfr_len + 7] = (byte)( d + Bry_.Ascii_zero);
bfr[bfr_len + 8] = Byte_ascii.Space;
bfr[bfr_len + 8] = spr;
bfr[bfr_len + 9] = (byte)((H / 10) + Bry_.Ascii_zero); H %= 10;
bfr[bfr_len + 10] = (byte)( H + Bry_.Ascii_zero);
bfr[bfr_len + 11] = (byte)((m / 10) + Bry_.Ascii_zero); m %= 10;
@ -424,14 +458,14 @@ public class Bry_bfr {
if (o == null) return this; // treat null as empty String;
Class<?> o_type = o.getClass();
if (o_type == byte[].class) Add((byte[])o);
else if (o_type == Integer.class) Add_int_variable(Int_.cast(o));
else if (o_type == Byte.class) Add_byte(Byte_.cast(o));
else if (o_type == Integer.class) Add_int_variable(Int_.Cast(o));
else if (o_type == Byte.class) Add_byte(Byte_.Cast(o));
else if (o_type == Long.class) Add_long_variable(Long_.cast(o));
else if (o_type == String.class) Add_str_u8((String)o);
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
else if (o_type == Boolean.class) Add_yn(Bool_.cast(o));
else if (o_type == Boolean.class) Add_yn(Bool_.Cast(o));
else if (o_type == Double.class) Add_double(Double_.cast(o));
else if (o_type == Float.class) Add_float(Float_.cast(o));
else ((Bfr_arg)o).Bfr_arg__add(this);
@ -441,14 +475,14 @@ public class Bry_bfr {
if (o == null) return this; // treat null as empty String;
Class<?> o_type = o.getClass();
if (o_type == byte[].class) Add((byte[])o);
else if (o_type == Integer.class) Add_int_variable(Int_.cast(o));
else if (o_type == Byte.class) Add_byte(Byte_.cast(o));
else if (o_type == Integer.class) Add_int_variable(Int_.Cast(o));
else if (o_type == Byte.class) Add_byte(Byte_.Cast(o));
else if (o_type == Long.class) Add_long_variable(Long_.cast(o));
else if (o_type == String.class) Add_str_u8((String)o);
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
else if (o_type == Boolean.class) Add_bool(Bool_.cast(o));
else if (o_type == Boolean.class) Add_bool(Bool_.Cast(o));
else if (o_type == Double.class) Add_double(Double_.cast(o));
else if (o_type == Float.class) Add_float(Float_.cast(o));
else ((Bfr_arg)o).Bfr_arg__add(this);
@ -465,16 +499,16 @@ public class Bry_bfr {
}
public boolean Match_end_byt(byte b) {return bfr_len == 0 ? false : bfr[bfr_len - 1] == b;}
public boolean Match_end_byt_nl_or_bos() {return bfr_len == 0 ? true : bfr[bfr_len - 1] == Byte_ascii.Nl;}
public boolean Match_end_ary(byte[] ary) {return Bry_.Match(bfr, bfr_len - ary.length, bfr_len, ary);}
public boolean Match_end_ary(byte[] val) {return Bry_.Match(bfr, bfr_len - val.length, bfr_len, val);}
public Bry_bfr Insert_at(int add_pos, byte[] add_bry) {return Insert_at(add_pos, add_bry, 0, add_bry.length);}
public Bry_bfr Insert_at(int add_pos, byte[] add_bry, int add_bgn, int add_end) {
int add_len = add_end - add_bgn;
int new_max = bfr_max + add_len;
byte[] new_bfr = new byte[new_max];
if (add_pos > 0)
Bry_.Copy_by_pos (bfr , 0, add_pos, new_bfr, 0);
Bry_.Copy_by_pos (add_bry, add_bgn, add_end, new_bfr, add_pos);
Bry_.Copy_by_pos (bfr , add_pos, bfr_len, new_bfr, add_pos + add_len);
Bry_.Copy_to (bfr , 0, add_pos, new_bfr, 0);
Bry_.Copy_to (add_bry, add_bgn, add_end, new_bfr, add_pos);
Bry_.Copy_to (bfr , add_pos, bfr_len, new_bfr, add_pos + add_len);
bfr = new_bfr;
bfr_len += add_len;
bfr_max = new_max;
@ -484,7 +518,7 @@ public class Bry_bfr {
public Bry_bfr Delete_rng_to_end(int pos) {return Delete_rng(pos, bfr_len);}
public Bry_bfr Delete_rng(int rng_bgn, int rng_end) {
int rng_len = rng_end - rng_bgn;
Bry_.Copy_by_pos(bfr, rng_end, bfr_len, bfr, rng_bgn);
Bry_.Copy_to(bfr, rng_end, bfr_len, bfr, rng_bgn);
bfr_len -= rng_len;
return this;
}
@ -510,10 +544,34 @@ public class Bry_bfr {
this.Del_by(count);
return this;
}
public Bry_bfr Concat_skip_empty(byte[] dlm, byte[]... ary) {
int ary_len = ary.length;
for (int i = 0; i < ary_len; i++) {
byte[] itm = ary[i];
public Bry_bfr Trim_end_ws() {
if (bfr_len == 0) return this;
int count = 0;
for (int i = bfr_len - 1; i > -1; --i) {
byte b = bfr[i];
if (Trim_end_ws_ary[b])
++count;
else
break;
}
if (count > 0)
this.Del_by(count);
return this;
}
private static final boolean[] Trim_end_ws_ary = Trim_end_ws_new();
private static boolean[] Trim_end_ws_new() {
boolean[] rv = new boolean[256];
rv[32] = true;
rv[ 9] = true;
rv[10] = true;
rv[13] = true;
rv[11] = true;
return rv;
}
public Bry_bfr Concat_skip_empty(byte[] dlm, byte[]... val) {
int val_len = val.length;
for (int i = 0; i < val_len; i++) {
byte[] itm = val[i];
boolean itm_has_bytes = Bry_.Len_gt_0(itm);
if ( i != 0
&& itm_has_bytes
@ -530,7 +588,7 @@ public class Bry_bfr {
public byte[] To_bry() {return bfr_len == 0 ? Bry_.Empty : Bry_.Mid(bfr, 0, bfr_len);}
public byte[] To_bry_and_clear_and_trim() {return To_bry_and_clear_and_trim(true, true, Bry_.Trim_ary_ws);}
public byte[] To_bry_and_clear_and_trim(boolean trim_bgn, boolean trim_end, byte[] trim_bry) {
byte[] rv = Bry_.Trim(bfr, 0, bfr_len, trim_bgn, trim_end, trim_bry);
byte[] rv = Bry_.Trim(bfr, 0, bfr_len, trim_bgn, trim_end, trim_bry, false); // NOTE: must not reuse bry; ISSUE#:562; DATE:2019-09-02
this.Clear();
return rv;
}
@ -545,6 +603,16 @@ public class Bry_bfr {
this.Mkr_rls();
return rv;
}
public byte[] To_reversed_bry_and_clear() {
int len = this.Len();
byte[] rv = new byte[len];
for (int i = 0; i < len; i++) {
rv[len - i - 1] = bfr[i];
}
this.Clear();
if (reset > 0) Reset_if_gt(reset);
return rv;
}
public String To_str() {return String_.new_u8(To_bry());}
public String To_str_by_pos(int bgn, int end) {return String_.new_u8(To_bry(), bgn, end);}
public String To_str_and_clear() {return String_.new_u8(To_bry_and_clear());}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.brys.*;

View File

@ -1,22 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
import org.junit.*; import gplx.core.tests.*;
public class Bry_bfr_tst {
private Bry_bfr bb = Bry_bfr_.New();
@Before public void setup() {bb.Clear();} private ByteAryBfr_fxt fxt = new ByteAryBfr_fxt();
@ -69,7 +67,7 @@ public class Bry_bfr_tst {
void Add_int_variable(int val) {
bb.Clear();
bb.Add_int_variable(val);
Tfds.Eq(val, Int_.parse(String_.new_u8(bb.To_bry())));
Tfds.Eq(val, Int_.Parse(String_.new_u8(bb.To_bry())));
}
@Test public void Add_int_fixed_len3() {tst_Add_int_fixed(123, 3, "123");}
@Test public void Add_int_fixed_pad_1() {tst_Add_int_fixed(2, 1, "2");}
@ -187,9 +185,16 @@ public class Bry_bfr_tst {
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 1000, "1000");
}
@Test public void Add_bry_escape() {
fxt.Test_Add_bry_escape("abc" , "abc"); // nothing to escape
fxt.Test_Add_bry_escape("a'bc" , "a''bc"); // single escape (code handles first quote differently)
fxt.Test_Add_bry_escape("a'b'c" , "a''b''c"); // double escape (code handles subsequent quotes different than first)
fxt.Test__add_bry_escape("abc" , "abc"); // nothing to escape
fxt.Test__add_bry_escape("a'bc" , "a''bc"); // single escape (code handles first quote differently)
fxt.Test__add_bry_escape("a'b'c" , "a''b''c"); // double escape (code handles subsequent quotes different than first)
fxt.Test__add_bry_escape("abc", 1, 2 , "b"); // nothing to escape
}
@Test public void Add_bry_escape_html() {
fxt.Test__add_bry_escape_html("abc" , "abc"); // escape=none
fxt.Test__add_bry_escape_html("a&\"'<>b" , "a&amp;&quot;&#39;&lt;&gt;b"); // escape=all; code handles first escape differently
fxt.Test__add_bry_escape_html("a&b&c" , "a&amp;b&amp;c"); // staggered; code handles subsequent escapes differently
fxt.Test__add_bry_escape_html("abc", 1, 2 , "b"); // by index; fixes bug in initial implementation
}
@Test public void Insert_at() {
fxt.Test_Insert_at("abcd", 0, "xyz" , "xyzabcd"); // bgn
@ -214,16 +219,32 @@ public class Bry_bfr_tst {
fxt.Test__to_bry_ary_and_clear("a\nb\nc" , "a", "b", "c"); // lines=n
fxt.Test__to_bry_ary_and_clear("a\n" , "a"); // nl at end
}
@Test public void To_bry_ary_and_clear_and_trim__memory_reference_bug() {// PURPOSE:test that bry isn't reused; ISSUE#:562; DATE:2019-09-02
String str_a = "aaaaaaaaaaaaaaaa" // NOTE: length is 16 b/c bry_bfr init's to 16 len
, str_b = "bbbbbbbbbbbbbbbb";
Bry_bfr bfr = Bry_bfr_.New();
bfr.Add_str_a7(str_a);
byte[] bry_a = bfr.To_bry_and_clear_and_trim();
Gftest.Eq__str(str_a, String_.new_u8(bry_a));
bfr.Add_str_a7(str_b);
byte[] bry_b = bfr.To_bry_and_clear_and_trim();
Gftest.Eq__str(str_b, String_.new_u8(bry_b));
Gftest.Eq__str(str_a, String_.new_u8(bry_a)); // fais if bry_b
}
}
class ByteAryBfr_fxt {
private final Bry_bfr bfr = Bry_bfr_.Reset(16);
public Bry_bfr Bfr() {return bfr;}
public void Clear() {
bfr.ClearAndReset();
}
public void Test_Add_int_pad_bgn(byte pad_byte, int str_len, int val, String expd) {Tfds.Eq(expd, bfr.Add_int_pad_bgn(pad_byte, str_len, val).To_str_and_clear());}
public void Test_Add_bry_escape(String val, String expd) {
byte[] val_bry = Bry_.new_u8(val);
Tfds.Eq(expd, bfr.Add_bry_escape(Byte_ascii.Apos, Byte_.Ary(Byte_ascii.Apos, Byte_ascii.Apos), val_bry, 0, val_bry.length).To_str_and_clear());
public void Test__add_bry_escape(String src, String expd) {Test__add_bry_escape(src, 0, String_.Len(src), expd);}
public void Test__add_bry_escape(String src, int src_bgn, int src_end, String expd) {
byte[] val_bry = Bry_.new_u8(src);
Tfds.Eq(expd, bfr.Add_bry_escape(Byte_ascii.Apos, Byte_.Ary(Byte_ascii.Apos, Byte_ascii.Apos), val_bry, src_bgn, src_end).To_str_and_clear());
}
public void Test_Insert_at(String init, int pos, String val, String expd) {Tfds.Eq(expd, bfr.Add_str_u8(init).Insert_at(pos, Bry_.new_u8(val)).To_str_and_clear());}
public void Test_Insert_at(String init, int pos, String val, int val_bgn, int val_end, String expd) {Tfds.Eq(expd, bfr.Add_str_u8(init).Insert_at(pos, Bry_.new_u8(val), val_bgn, val_end).To_str_and_clear());}
@ -233,4 +254,8 @@ class ByteAryBfr_fxt {
public void Test__to_bry_ary_and_clear(String bfr_str, String... expd) {
Tfds.Eq_ary(expd, String_.Ary(bfr.Add_str_u8(bfr_str).To_bry_ary_and_clear()));
}
public void Test__add_bry_escape_html(String src, String expd) {Test__add_bry_escape_html(src, 0, String_.Len(src), expd);}
public void Test__add_bry_escape_html(String src, int src_bgn, int src_end, String expd) {
Gftest.Eq__bry(Bry_.new_u8(expd), bfr.Add_bry_escape_html(Bry_.new_u8(src), src_bgn, src_end).To_bry_and_clear());
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Bry_find_ {
@ -29,6 +27,10 @@ public class Bry_find_ {
int rv = Find_fwd(src, lkp, cur, end);
return rv == Bry_find_.Not_found ? or : rv;
}
public static int Find_fwd_or(byte[] src, byte[] lkp, int cur, int end, int or) {
int rv = Find_fwd(src, lkp, cur, end);
return rv == Bry_find_.Not_found ? or : rv;
}
public static int Find_bwd(byte[] src, byte lkp) {return Find_bwd(src, lkp, src.length, 0);}
public static int Find_bwd(byte[] src, byte lkp, int cur) {return Find_bwd(src, lkp, cur , 0);}
public static int Find_bwd(byte[] src, byte lkp, int cur, int end) {
@ -38,6 +40,10 @@ public class Bry_find_ {
if (src[i] == lkp) return i;
return Bry_find_.Not_found;
}
public static int Find_bwd_or(byte[] src, byte lkp, int cur, int end, int or) {
int rv = Find_bwd(src, lkp, cur, end);
return rv == Bry_find_.Not_found ? or : rv;
}
public static int Move_fwd(byte[] src, byte lkp, int cur, int end) {
int rv = Find_fwd(src, lkp, cur, src.length);
return rv == Bry_find_.Not_found ? rv : rv + 1;
@ -50,16 +56,17 @@ public class Bry_find_ {
public static int Find_fwd(byte[] src, byte[] lkp) {return Find(src, lkp, 0 , src.length, true);}
public static int Find_fwd(byte[] src, byte[] lkp, int cur) {return Find(src, lkp, cur , src.length, true);}
public static int Find_fwd(byte[] src, byte[] lkp, int cur, int end) {return Find(src, lkp, cur , end, true);}
private static final int OffsetCompare = 1;// handle srcPos >= 1 -> srcPosChk > 0
public static int Find(byte[] src, byte[] lkp, int src_bgn, int src_end, boolean fwd) {
if (src_bgn < 0 || src.length == 0) return Bry_find_.Not_found;
int dif, lkp_len = lkp.length, lkp_bgn, lkp_end, src_end_chk;
if (fwd) {
if (src_bgn > src_end) return Bry_find_.Not_found;
dif = 1; lkp_bgn = 0; lkp_end = lkp_len; src_end_chk = src_end - CompareAble_.OffsetCompare;
dif = 1; lkp_bgn = 0; lkp_end = lkp_len; src_end_chk = src_end - OffsetCompare;
}
else {
if (src_bgn < src_end) return Bry_find_.Not_found;
dif = -1; lkp_bgn = lkp_len - 1; lkp_end = -1; src_end_chk = src.length - CompareAble_.OffsetCompare; // src_end_chk needed when going bwd, b/c lkp_len may be > 1
dif = -1; lkp_bgn = lkp_len - 1; lkp_end = -1; src_end_chk = src.length - OffsetCompare; // src_end_chk needed when going bwd, b/c lkp_len may be > 1
}
while (src_bgn != src_end) { // while src is not done;
int lkp_cur = lkp_bgn;
@ -153,6 +160,19 @@ public class Bry_find_ {
}
return Bry_find_.Not_found;
}
public static int Find_bwd__while_space_or_tab(byte[] src, int cur, int end) { // get pos of 1st char that is not \t or \s
if (cur < 0 || cur > src.length) return Bry_find_.Not_found;
for (int i = cur - 1; i >= end; i--) {
byte b = src[i];
switch (b) {
case Byte_ascii.Space: case Byte_ascii.Tab:
break;
default:
return i + 1;
}
}
return Bry_find_.Not_found;
}
public static int Find_bwd_non_ws_or_end(byte[] src, int cur, int end) {
if (cur >= src.length) return Bry_find_.Not_found;
for (int i = cur; i >= end; i--) {
@ -210,6 +230,14 @@ public class Bry_find_ {
--cur;
}
}
public static int Find_bwd_while_v2(byte[] src, int cur, int end, byte while_byte) {
--cur;
while (true) {
if ( cur < end
|| src[cur] != while_byte) return cur + 1;
--cur;
}
}
public static int Find_fwd_while(byte[] src, int cur, int end, byte while_byte) {
while (true) {
if ( cur == end
@ -217,6 +245,32 @@ public class Bry_find_ {
cur++;
}
}
public static int Find_fwd_while(byte[] src, int cur, int end, byte[] while_bry) {
int while_len = while_bry.length;
while (true) {
if (cur == end) return cur;
for (int i = 0; i < while_len; i++) {
if (while_bry[i] != src[i + cur]) return cur;
}
cur += while_len;
}
}
public static int Find_fwd_while_in(byte[] src, int cur, int end, boolean[] while_ary) {
while (cur < end) {
if (cur == end || !while_ary[src[cur]]) return cur;
cur++;
}
return end;
}
public static boolean[] Find_fwd_while_in_gen(byte... ary) {
boolean[] rv = new boolean[256];
int len = ary.length;
for (int i = 0; i < len; i++) {
rv[ary[i]] = true;
}
return rv;
}
public static int Find_fwd_until(byte[] src, int cur, int end, byte until_byte) {
while (true) {
if ( cur == end

View File

@ -1,22 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
import org.junit.*; import gplx.core.tests.*;
public class Bry_find__tst {
private Bry_find__fxt fxt = new Bry_find__fxt();
@Test public void Find_fwd() {
@ -59,6 +57,10 @@ public class Bry_find__tst {
fxt.Test_Trim_bwd_space_tab("" , 0);
fxt.Test_Trim_bwd_space_tab(" \t" , 0);
}
@Test public void Find_fwd_while_in() {
boolean[] while_ary = fxt.Init__find_fwd_while_in(Byte_ascii.Space, Byte_ascii.Tab, Byte_ascii.Nl);
fxt.Test__find_fwd_while_in(" \t\na", while_ary, 3);
}
}
class Bry_find__fxt {
public void Test_Find_fwd(String src, String lkp, int bgn, int expd) {Tfds.Eq(expd, Bry_find_.Find_fwd(Bry_.new_u8(src), Bry_.new_u8(lkp), bgn));}
@ -74,4 +76,15 @@ class Bry_find__fxt {
int actl = Bry_find_.Trim_fwd_space_tab(raw_bry, 0, raw_bry.length);
Tfds.Eq(expd, actl, raw_str);
}
public boolean[] Init__find_fwd_while_in(byte... ary) {
boolean[] rv = new boolean[256];
int len = ary.length;
for (int i = 0; i < len; i++)
rv[ary[i]] = true;
return rv;
}
public void Test__find_fwd_while_in(String src, boolean[] ary, int expd) {
byte[] src_bry = Bry_.new_u8(src);
Gftest.Eq__int(expd, Bry_find_.Find_fwd_while_in(src_bry, 0, src_bry.length, ary));
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.brys.*; import gplx.core.brys.fmts.*;
@ -30,7 +28,8 @@ public class Bry_fmt {
this.src = src; this.keys = keys; this.args = args;
}
public byte[] Fmt() {return src;}
public Bry_fmt Fmt_(String v) {dirty = true; src = Bry_.new_u8(v); return this;}
public Bry_fmt Fmt_(String v) {return Fmt_(Bry_.new_u8(v));}
public Bry_fmt Fmt_(byte[] v) {dirty = true; src = v; return this;}
public Bry_fmt Args_(Bfr_fmt_arg... v) {dirty = true; args = v; return this;}
public Bry_fmt Keys_(String... v) {return Keys_(Bry_.Ary(v));}
public Bry_fmt Keys_(byte[]... v) {dirty = true; keys = v; return this;}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.brys.*;
@ -48,7 +46,7 @@ public class Bry_split_ {
boolean reset = true;
if (itm_bgn == -1) {
if (pos_is_last) {} // skip dlm at bgn / end; EX: "a,"
else {wkr.Split(src, itm_bgn, itm_end);} // else, process "empty" dlm; EX: ",a"
else {wkr.Split(src, pos, pos );} // else, process "empty" dlm; EX: ",a"
}
else {
int rv = wkr.Split(src, itm_bgn, itm_end);
@ -116,6 +114,45 @@ public class Bry_split_ {
}
return (byte[][])rv.To_ary(byte[].class);
}
public static byte[][] Split_w_max(byte[] src, byte dlm, int max) {
byte[][] rv = new byte[max][];
int src_len = src.length;
int rv_idx = 0;
int itm_bgn = 0;
int src_pos = 0;
while (true) {
boolean is_last = src_pos == src_len;
byte b = is_last ? dlm : src[src_pos];
if (b == dlm) {
rv[rv_idx++] = Bry_.Mid(src, itm_bgn, src_pos);
itm_bgn = src_pos + 1;
}
if (is_last || rv_idx == max)
break;
else
src_pos++;
}
return rv;
}
public static byte[][] Split_ws(byte[] src) {// REF.PHP: preg_split('/\s+/', $text)
int len = src.length;
if (len == 0) return Bry_.Ary_empty;
List_adp list = List_adp_.New();
int pos = 0;
while (true) {
int bgn = Bry_find_.Find_fwd_while_ws(src, pos, len);
if (bgn == len) break; // EOS
int end = Bry_find_.Find_fwd_until_ws(src, bgn + 1, len);
if (end == -1) end = len;
list.Add(Bry_.Mid(src, bgn, end));
pos = end + 1;
if (pos >= len) break;
}
return (byte[][])list.To_ary_and_clear(byte[].class);
}
public static final int Rv__ok = 0, Rv__extend = 1, Rv__cancel = 2;
}
class Bry_split_wkr__to_ary implements gplx.core.brys.Bry_split_wkr {

View File

@ -1,22 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
import org.junit.*; import gplx.core.tests.*;
public class Bry_split__tst {
private final Bry_split__fxt fxt = new Bry_split__fxt();
@Test public void Split() {
@ -43,6 +41,19 @@ public class Bry_split__tst {
fxt.Test_split("a|b|c|d" , 2, 6, "|", "b", "c");
fxt.Test_split("a|b|c|d" , 2, 4, "|", "b");
}
@Test public void Empty() {
fxt.Test_split("a\n\nb" , Byte_ascii.Nl, Bool_.N, "a", "", "b");
}
@Test public void Split_w_max() {
fxt.Test__split_w_max("a|b|c|d" , Byte_ascii.Pipe, 2, "a", "b"); // max is less
fxt.Test__split_w_max("a" , Byte_ascii.Pipe, 2, "a", null); // max is more
fxt.Test__split_w_max("|" , Byte_ascii.Pipe, 2, "", ""); // empty itms
}
@Test public void Split_ws() {
fxt.Test__split_ws("a b", "a", "b");
fxt.Test__split_ws(" a ", "a");
fxt.Test__split_ws(" abc def ", "abc", "def");
}
}
class Bry_split__fxt {
private final Bry_split_wkr__example wkr = new Bry_split_wkr__example();
@ -55,6 +66,13 @@ class Bry_split__fxt {
public void Test_split(String src, int src_bgn, int src_end, String dlm, String... expd) {
Tfds.Eq_ary_str(Bry_.Ary(expd), Bry_split_.Split(Bry_.new_u8(src), src_bgn, src_end, Bry_.new_u8(dlm)));
}
public void Test__split_w_max(String src, byte dlm, int max, String... expd) {
Gftest.Eq__ary(expd, String_.Ary(Bry_split_.Split_w_max(Bry_.new_u8(src), dlm, max)));
}
public void Test__split_ws(String raw, String... expd) {
byte[][] actl = Bry_split_.Split_ws(Bry_.new_u8(raw));
Gftest.Eq__ary(Bry_.Ary(expd), actl, raw);
}
}
class Bry_split_wkr__example implements gplx.core.brys.Bry_split_wkr {
private final List_adp list = List_adp_.New();

View File

@ -1,63 +1,68 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Byte_ {
public class Byte_ {//RF:2017-10-08
public static final String Cls_val_name = "byte";
public static final Class<?> Cls_ref_type = Byte.class;
public static final byte
Zero = 0
, Min_value = Byte.MIN_VALUE
, Max_value_127 = 127
, Val_128 = -128
, Val_255 = -1
;
public static byte cast(Object o) {try {return (Byte)o;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, byte.class, o);}}
public static byte parse(String raw) {return Byte.parseByte(raw);}
public static byte parse_or(String raw, byte or) {
if (raw == null) return or;
try {return parse(raw);}
catch (Exception e) {Err_.Noop(e); return or;}
}
;
public static byte By_int(int v) {return v > 127 ? (byte)(v - 256) : (byte)v;} // PERF?: (byte)(v & 0xff)
public static int To_int(byte v) {return v < 0 ? (int)v + 256 : v;}
public static String To_str(byte v) {return new Byte(v).toString();}
public static byte[] To_bry(byte v) {return new byte[] {v};}
public static boolean In(byte v, byte... ary) {
public static byte Cast(Object o) {try {return (Byte)o;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, byte.class, o);}}
public static byte Parse(String raw) {return Byte.parseByte(raw);}
public static byte Parse_or(String raw, byte or) {
if (raw == null) return or;
try {return Parse(raw);}
catch (Exception e) {Err_.Noop(e); return or;}
}
public static boolean Match_any(byte v, byte... ary) {
for (byte itm : ary)
if (v == itm) return true;
return false;
}
public static boolean Eq_many(byte v, byte... ary) {
public static boolean Match_all(byte v, byte... ary) {
for (byte itm : ary)
if (v != itm) return false;
return true;
}
public static int Compare(byte lhs, byte rhs) {
if (lhs == rhs) return CompareAble_.Same;
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
public static byte[] Ary(byte... ary) {return ary;}
public static byte[] Ary_by_ints(int... ary) {
int ary_len = ary.length;
byte[] rv = new byte[ary_len];
for (int i = 0; i < ary_len; i++)
for (int i = 0; i < ary_len; i++) {
rv[i] = By_int(ary[i]);
}
return rv;
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,25 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Byte_ascii {
public static final byte
Null = 0 , Backfeed = 8, Tab = 9
, Nl = 10, Formfeed = 12, Cr = 13
, Nl = 10, Vertical_tab = 11, Formfeed = 12, Cr = 13
, Escape = 27
, Space = 32, Bang = 33, Quote = 34
, Hash = 35, Dollar = 36, Percent = 37, Amp = 38, Apos = 39
@ -40,11 +38,13 @@ public class Byte_ascii {
, Ltr_n = 110, Ltr_o = 111, Ltr_p = 112, Ltr_q = 113, Ltr_r = 114
, Ltr_s = 115, Ltr_t = 116, Ltr_u = 117, Ltr_v = 118, Ltr_w = 119
, Ltr_x = 120, Ltr_y = 121, Ltr_z = 122, Curly_bgn = 123, Pipe = 124
, Curly_end = 125, Tilde = 126
, Curly_end = 125, Tilde = 126, Delete = 127
;
public static final byte
Angle_bgn = Lt, Angle_end = Gt
;
public static final int Len_1 = 1;
public static final byte Max_7_bit = (byte)127, Ascii_min = 0, Ascii_max = 127;
public static boolean Is_sym(byte b) {
switch (b) {
@ -114,6 +114,7 @@ public class Byte_ascii {
, Lt_bry = new byte[] {Byte_ascii.Lt}
, Gt_bry = new byte[] {Byte_ascii.Gt}
, Question_bry = new byte[] {Byte_ascii.Question}
, Backslash_bry = new byte[] {Byte_ascii.Backslash}
, Brack_bgn_bry = new byte[] {Byte_ascii.Brack_bgn}
, Brack_end_bry = new byte[] {Byte_ascii.Brack_end}
, Apos_bry = new byte[] {Byte_ascii.Apos}
@ -127,3 +128,11 @@ public class Byte_ascii {
, Num_1_bry = new byte[] {Byte_ascii.Num_1}
;
}
/*
SYMBOLS
-------
Byte_ascii.Bang | Byte_ascii.Slash | 33 -> 47 | !"#$%&'()*+,-./
Byte_ascii.Colon | Byte_ascii.At | 58 -> 64 | :;<=>?@
Byte_ascii.Brack_bgn | Byte_ascii.Tick | 91 -> 96 | [\]^_`
Byte_ascii.Curly_bgn | Byte_ascii.Tilde | 123 -> 126 | {|}~
*/

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Cancelable {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Cancelable_ {

View File

@ -1,23 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Char_ {
public static final Class<?> Cls_ref_type = Character.class;
public static final String Cls_val_name = "char";
public static final Class<?> Cls_ref_type = Character.class;
public static final char Null = '\0', NewLine = '\n';
public static boolean IsCaseLower(char c) {return Character.isLowerCase(c);}
public static boolean IsLetterOrDigit(char c) {return Character.isLetterOrDigit(c);}
@ -57,13 +56,14 @@ public class Char_ {
if (itm == match) return true;
return false;
}
public static int To_int_or(char c, int or) {
public static int To_digit_or(char c, int or) {
switch (c) {
case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9;
default: return or;
}
}
public static int To_int(char c) {return (int)c;}
public static String To_str(char[] ary, int pos, int length) {return new String(ary, pos, length);}
public static String To_str(int b) {return To_str((char)b);}
public static String To_str(char c) {return String.valueOf(c);}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface CompareAble extends Comparable {} // URL:/doc/gplx/CompareAble_.txt

View File

@ -1,78 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.*;
public class CompareAble_ {
public static Comparable as_(Object obj) {return obj instanceof Comparable ? (Comparable)obj : null;}
public static int Compare_obj(Object lhs, Object rhs) {return CompareComparables(as_(lhs), as_(rhs));}
public static int CompareComparables(Comparable lhs, Comparable rhs) {
public static int Compare_obj(Object lhs, Object rhs) {return Compare_comp(as_(lhs), as_(rhs));}
public static int Compare_comp(Comparable lhs, Comparable rhs) {
if (lhs == null && rhs == null) return CompareAble_.Same;
else if (lhs == null) return CompareAble_.More;
else if (rhs == null) return CompareAble_.Less;
else return Compare(lhs, rhs);
}
public static boolean Is_more(Comparable lhs, Comparable rhs) {return Is(More, lhs, rhs);}
public static boolean Is_moreOrSame(Comparable lhs, Comparable rhs) {return Is(MoreOrSame, lhs, rhs);}
public static boolean Is_less(Comparable lhs, Comparable rhs) {return Is(Less, lhs, rhs);}
public static boolean Is_lessOrSame(Comparable lhs, Comparable rhs) {return Is(LessOrSame, lhs, rhs);}
public static boolean Is_same(Comparable lhs, Comparable rhs) {return Is(Same, lhs, rhs);}
public static boolean Is(int expt, Comparable lhs, Comparable rhs) {
int actl = CompareComparables(lhs, rhs);
if (actl == Same && expt % 2 == Same) // actl=Same and expt=(Same||MoreOrSame||LessOrSame)
return true;
else
return (actl * expt) > 0; // actl=More||Less; expd will match if on same side of 0 (ex: expt=Less; actl=Less; -1 * -1 = 1)
}
// public static int FindSlot(ComparerAble comparer, Object[] ary, Object itm) {return FindSlot(comparer, ary, itm, false);}
public static int FindSlot(ComparerAble comparer, Object[] ary, Object itm) {if (itm == null) throw Err_.new_null();
int aryLen = ary.length;
switch (aryLen) {
case 0: throw Err_.new_wo_type("ary cannot have 0 itms");
case 1: return 0;
}
int lo = -1, hi = aryLen - 1; // NOTE: -1 is necessary; see test
int curPos = (hi - lo) / 2;
int delta = 1;
while (true) {
Object curSeg = ary[curPos];
int comp = curSeg == null ? CompareAble_.More : comparer.compare(itm, curSeg); // nulls should only happen for lastAry
// if (dbg) {
// Tfds.Write(curPos, itm.toString(), comp, comp.toString(), curSeg.toString());
// }
if (comp == CompareAble_.Same) return curPos;
else if (comp > CompareAble_.Same) {lo = curPos; delta = 1;}
else if (comp < CompareAble_.Same) {hi = curPos; delta = -1;}
int dif = hi - lo;
if (dif == 1 || dif == 0) return hi; // NOTE: can be 0 when ary.length == 1 || 2; also, sometimes 0 in some situations
else curPos += (dif / 2) * delta;
}
}
public static int Compare(Comparable lhs, Comparable rhs) {return lhs.compareTo(rhs);}
public static boolean Is(int expd, Comparable lhs, Comparable rhs) {
int actl = Compare_comp(lhs, rhs);
if (actl == Same && expd % 2 == Same) // actl=Same and expd=(Same||MoreOrSame||LessOrSame)
return true;
else
return (actl * expd) > 0; // actl=More||Less; expd will match if on same side of 0 (ex: expd=Less; actl=Less; -1 * -1 = 1)
}
public static final int
More = 1
, Less = -1
, Same = 0
, MoreOrSame = 2
, LessOrSame = -2
, ReverseMult = -1
, OffsetCompare = 1 // handle srcPos >= 1 -> srcPosChk > 0
;
public static int Multiplier(boolean v) {return v ? 1 : -1;}
More = 1
, Less = -1
, Same = 0
, More_or_same = 2
, Less_or_same = -2
;
}

View File

@ -1,38 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx;
import org.junit.*;
import gplx.core.lists.*;
public class CompareAble_tst implements ComparerAble {
@Test public void Basic() {
String[] slotAry = new String[] {"b", "e", "h"}; // 0=b 1=e 2=h
tst_FindSlot(slotAry, "f", "h"); // f -> 1 2 -> 2
tst_FindSlot(slotAry, "c", "e"); // c -> -1 1 -> 0 -> 0 1 -> 1
tst_FindSlot(slotAry, "a", "b"); // a -> -1 1 -> 0 -> -1 0 -> 0
}
@Test public void Null() {
String[] slotAry = new String[] {"b", "g", "l", "q", "v", null};
tst_FindSlot(slotAry, "a", "b");
tst_FindSlot(slotAry, "b", "b");
tst_FindSlot(slotAry, "c", "g");
tst_FindSlot(slotAry, "v", "v");
tst_FindSlot(slotAry, "w", null);
}
public int compare(Object lhsObj, Object rhsObj) {return CompareAble_.Compare_obj(lhsObj, rhsObj);}
void tst_FindSlot(String[] slotAry, String s, String expd) {Tfds.Eq(expd, slotAry[CompareAble_.FindSlot(this, slotAry, s)]);}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.util.Calendar;
@ -87,6 +85,9 @@ public class DateAdp implements CompareAble, Gfo_invk {
: Timezone_offset_test
;
}
public String Timezone_id() {
return "UTC"; // under.getTimeZone().getID(); // NOTE: timezone is always UTC, unless over-ridden by tests
}
public DateAdp XtoUtc() {
java.util.Date date = under.getTime();
java.util.TimeZone tz = under.getTimeZone();
@ -111,6 +112,7 @@ public class DateAdp implements CompareAble, Gfo_invk {
long dst_adj = dst ? 3600000 : 0;
return (under.getTimeInMillis() + offsetFromUTC + dst_adj) / 1000;
}
public int WeekOfYear() {return under.get(Calendar.WEEK_OF_YEAR);}
public int Frac() {return under.get(Calendar.MILLISECOND);}
public DateAdp Add_frac(int val) {return CloneAndAdd(Calendar.MILLISECOND, val);}
@ -149,5 +151,17 @@ public class DateAdp implements CompareAble, Gfo_invk {
this.under = new GregorianCalendar(year, month - Month_base0adj, day, hour, minute, second);
under.set(Calendar.MILLISECOND, frac);
}
protected DateAdp(int year, int month, int day, int hour, int minute, int second, int frac, TimeZone timeZone) {
this.under = new GregorianCalendar(timeZone);
under.set(year, month - Month_base0adj, day, hour, minute, second);
under.set(Calendar.MILLISECOND, frac);
}
public void SetTzOffset(int offset) {
java.util.Date date = under.getTime();
long msFromEpochGmt = date.getTime();
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(msFromEpochGmt - offset*1000);
under = cal;
}
public static final int Month_base0adj = 1;
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.sql.Timestamp;
@ -68,11 +66,13 @@ public class DateAdp_ implements Gfo_invk {
public static DateAdp dateTime_obj_(Object v) {return new DateAdp((GregorianCalendar)v);}
public static final DateAdp_ Gfs = new DateAdp_();
public static int DaysInMonth(DateAdp date) {
int rv = DaysInMonth_ary[date.Month() - Int_.Base1];
if (rv == 28 && IsLeapYear(date.Year())) rv = 29;
public static int DaysInMonth(DateAdp date) {return DaysInMonth(date.Month(), date.Year());}
public static int DaysInMonth(int month, int year) {
int rv = DaysInMonth_ary[month - Int_.Base1];
if (rv == 28 && IsLeapYear(year)) rv = 29;
return rv;
} static int [] DaysInMonth_ary = {31,28,31,30,31,30,31,31,30,31,30,31};
}
private static int [] DaysInMonth_ary = {31,28,31,30,31,30,31,31,30,31,30,31};
public static boolean IsLeapYear(int year) {
if (year % 4 != 0) return false;
else if (year % 400 == 0) return true;
@ -116,10 +116,29 @@ public class DateAdp_ implements Gfo_invk {
c.setTimeInMillis(v);
return new DateAdp(c);
}
public static final int SegIdx_year = 0, SegIdx_month = 1, SegIdx_day = 2, SegIdx_hour = 3, SegIdx_minute = 4, SegIdx_second = 5, SegIdx_frac = 6, SegIdx_dayOfWeek = 7, SegIdx_weekOfYear = 8, SegIdx_dayOfYear = 9, SegIdx__max = 10;
public static DateAdp New_w_tz(int y, int m, int d, int h, int i, int s, int us, String tz_id) {
TimeZone tz = String_.Eq(tz_id, "UTC") ? TIME_ZONE__UTC : TimeZone.getTimeZone(tz_id);
return new DateAdp(y, m, d, h, i, s, us/1000, tz);
}
private static TimeZone TIME_ZONE__UTC = TimeZone.getTimeZone("UTC");
public static final int
SegIdx_year = 0, SegIdx_month = 1, SegIdx_day = 2, SegIdx_hour = 3, SegIdx_minute = 4, SegIdx_second = 5
, SegIdx_frac = 6, SegIdx_dayOfWeek = 7, SegIdx_weekOfYear = 8, SegIdx_dayOfYear = 9, SegIdx_tz = 10, SegIdx__max = 11;
public static String Xto_str_fmt_or(DateAdp v, String fmt, String or) {
return v == null ? or : v.XtoStr_fmt(fmt);
}
public static DateAdp FirstDayofYear(int year) {
return new DateAdp(year, 1, 1, 0, 0, 0, 0);
}
public static DateAdp DateByDayofYear(int year, int day) {
return new DateAdp(year, 1, day, 0, 0, 0, 0);
}
public static DateAdp DateByBits(int y, int m, int d, int h, int i, int s, int us, int tz_ofs, byte[] tz_abbr) {
DateAdp dte = new DateAdp(y, m, d, h, i, s, us/1000);
if (tz_ofs != 0)
dte.SetTzOffset(tz_ofs);
return dte;
}
public static final String
Fmt_iso8561_date_time = "yyyy-MM-dd HH:mm:ss"
, Fmt__yyyyMMdd = "yyyyMMdd";

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
@ -62,6 +60,9 @@ public class DateAdp__tst {
@Test public void XtoUtc() {
fxt.Test__to_utc("2012-01-01 00:00", "2012-01-01 05:00"); //4=Wed
}
@Test public void Timezone_id() {
fxt.Test__timezone_id("2015-12-26T10:03:53Z", "UTC");
}
}
class DateAdp__fxt {
public void Test__parse_gplx(String raw, String expd) {
@ -85,4 +86,7 @@ class DateAdp__fxt {
public void Test__to_utc(String raw, String expd) {
Tfds.Eq(expd, DateAdp_.parse_gplx(raw).XtoUtc().XtoStr_fmt_yyyy_MM_dd_HH_mm());
}
public void Test__timezone_id(String raw, String expd) {
Gftest.Eq__str(expd, DateAdp_.parse_gplx(raw).XtoUtc().Timezone_id());
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.util.GregorianCalendar;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.math.BigDecimal;
@ -22,6 +20,7 @@ import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Decimal_adp implements CompareAble {
public int compareTo(Object obj) {Decimal_adp comp = (Decimal_adp)obj; return under.compareTo(comp.under);}
public Decimal_adp Floor() {return Decimal_adp_.int_(this.To_int());}
protected Decimal_adp(BigDecimal v) {this.under = v;} private final BigDecimal under;
protected Decimal_adp(int v) {this.under = new BigDecimal(v);}
public Object Under() {return under;}
@ -81,6 +80,9 @@ public class Decimal_adp implements CompareAble {
}
return new Decimal_adp(new_val);
}
public Decimal_adp Round_to_default_precision() {
return new Decimal_adp(under.round(Decimal_adp_.Gplx_rounding_context));
}
public boolean Comp_gte(Decimal_adp v) {return under.doubleValue() >= v.under.doubleValue();}
public boolean Comp_gte(int v) {return under.doubleValue() >= v;}
public boolean Comp_lte(Decimal_adp v) {return under.doubleValue() <= v.under.doubleValue();}

View File

@ -1,70 +1,91 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2021 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class Decimal_adp_ {
public static final Class<?> Cls_ref_type = Decimal_adp.class;
public static Decimal_adp as_(Object obj) {return obj instanceof Decimal_adp ? (Decimal_adp)obj : null;}
public static final Decimal_adp Zero = new Decimal_adp(0);
public static final Decimal_adp One = new Decimal_adp(1);
public static final Decimal_adp Neg1 = new Decimal_adp(-1);
public static final Decimal_adp Const_e = Decimal_adp_.double_(Math_.E);
public static final Decimal_adp Const_pi = Decimal_adp_.double_(Math_.Pi);
public static Decimal_adp base1000_(long v) {return divide_(v, 1000);}
public static Decimal_adp parts_1000_(long num, int frc) {return divide_((num * (1000)) + frc, 1000);}
public static Decimal_adp parts_(long num, int frc) {
// int log10 = frc == 0 ? 0 : (Math_.Log10(frc) + 1);
// int pow10 = (int)Math_.Pow(10, log10);
int pow10 = XtoPow10(frc);
return divide_((num * (pow10)) + frc, pow10);
}
public static Decimal_adp cast(Object obj) {return (Decimal_adp)obj;}
static int XtoPow10(int v) {
if (v > -1 && v < 10) return 10;
else if (v > 9 && v < 100) return 100;
else if (v > 99 && v < 1000) return 1000;
else if (v > 999 && v < 10000) return 10000;
else if (v > 9999 && v < 100000) return 100000;
else if (v > 99999 && v < 1000000) return 1000000;
else if (v > 999999 && v < 10000000) return 10000000;
else if (v > 9999999 && v < 100000000) return 100000000;
else if (v > 99999999 && v < 1000000000) return 1000000000;
else throw Err_.new_wo_type("value must be between 0 and 1 billion", "v", v);
}
public static String CalcPctStr(long dividend, long divisor, String fmt) {
if (divisor == 0) return "%ERR";
return Decimal_adp_.float_(Float_.Div(dividend, divisor) * 100).To_str(fmt) + "%";
}
public static Decimal_adp divide_safe_(long lhs, long rhs) {return rhs == 0 ? Zero : divide_(lhs, rhs);}
public static Decimal_adp divide_(long lhs, long rhs) { return new Decimal_adp(new BigDecimal(lhs).divide(new BigDecimal(rhs), Gplx_rounding_context)); } public static Decimal_adp int_(int v) {return new Decimal_adp(new BigDecimal(v));} public static Decimal_adp long_(long v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp float_(float v) {return new Decimal_adp(new BigDecimal(v));} public static Decimal_adp double_(double v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_thru_str_(double v) {return new Decimal_adp(BigDecimal.valueOf(v));}
public static Decimal_adp db_(Object v) {return new Decimal_adp((BigDecimal)v);} public static Decimal_adp parse(String raw) {
try {
DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance(Locale.US); // always parse as US format; EX:".9" should not be ",9" in german; DATE:2016-01-31
nf.setParseBigDecimal(true);
BigDecimal bd = (BigDecimal)nf.parse(raw);
return new Decimal_adp(bd);
} catch (ParseException e) {
throw Err_.new_("Decimal_adp_", "parse to decimal failed", "raw", raw);
}
} public static Decimal_adp pow_10_(int v) {return new Decimal_adp(new BigDecimal(1).scaleByPowerOfTen(v));}
public static final MathContext RoundDownContext = new MathContext(0, RoundingMode.DOWN); public static final MathContext Gplx_rounding_context = new MathContext(14, RoundingMode.HALF_UP); // changed from 28 to 14; DATE:2015-07-31 }
package gplx;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class Decimal_adp_ {
public static final String Cls_val_name = "decimal";
public static final Class<?> Cls_ref_type = Decimal_adp.class;
public static Decimal_adp as_(Object obj) {return obj instanceof Decimal_adp ? (Decimal_adp)obj : null;}
public static final Decimal_adp Zero = new Decimal_adp(0);
public static final Decimal_adp One = new Decimal_adp(1);
public static final Decimal_adp Neg1 = new Decimal_adp(-1);
public static final Decimal_adp Const_e = Decimal_adp_.double_(Math_.E);
public static final Decimal_adp Const_pi = Decimal_adp_.double_(Math_.Pi);
public static Decimal_adp base1000_(long v) {return divide_(v, 1000);}
public static Decimal_adp parts_1000_(long num, int frc) {return divide_((num * (1000)) + frc, 1000);}
public static Decimal_adp parts_(long num, int frc) {
// int log10 = frc == 0 ? 0 : (Math_.Log10(frc) + 1);
// int pow10 = (int)Math_.Pow(10, log10);
int pow10 = XtoPow10(frc);
return divide_((num * (pow10)) + frc, pow10);
}
public static Decimal_adp cast(Object obj) {return (Decimal_adp)obj;}
static int XtoPow10(int v) {
if (v > -1 && v < 10) return 10;
else if (v > 9 && v < 100) return 100;
else if (v > 99 && v < 1000) return 1000;
else if (v > 999 && v < 10000) return 10000;
else if (v > 9999 && v < 100000) return 100000;
else if (v > 99999 && v < 1000000) return 1000000;
else if (v > 999999 && v < 10000000) return 10000000;
else if (v > 9999999 && v < 100000000) return 100000000;
else if (v > 99999999 && v < 1000000000) return 1000000000;
else throw Err_.new_wo_type("value must be between 0 and 1 billion", "v", v);
}
public static String CalcPctStr(long dividend, long divisor, String fmt) {
if (divisor == 0) return "%ERR";
return Decimal_adp_.float_(Float_.Div(dividend, divisor) * 100).To_str(fmt) + "%";
}
public static Decimal_adp divide_safe_(long lhs, long rhs) {return rhs == 0 ? Zero : divide_(lhs, rhs);}
public static Decimal_adp divide_(long lhs, long rhs) {
return new Decimal_adp(new BigDecimal(lhs).divide(new BigDecimal(rhs), Gplx_rounding_context));
}
public static Decimal_adp int_(int v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp long_(long v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp float_(float v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_(double v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_thru_str_(double v) {return new Decimal_adp(BigDecimal.valueOf(v));}
public static Decimal_adp db_(Object v) {return new Decimal_adp((BigDecimal)v);}
public static Decimal_adp parse(String raw) {
try {
DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance(Locale.US); // always parse as US format; EX:".9" should not be ",9" in german; DATE:2016-01-31
nf.setParseBigDecimal(true);
// 2020-08-27|ISSUE#:565|Parse 'e' as 'E'; PAGE:en.w:Huntington_Plaza
if (raw.contains("e")) {
raw = raw.replace("e", "E");
}
// 2021-02-13|ISSUE#:838|Parse '.' as '0.'; PAGE:en.w:2019_FIVB_Volleyball_Women%27s_Challenger_Cup#Pool_A
if (raw.startsWith(".")) {
raw = "0" + raw;
}
BigDecimal bd = (BigDecimal)nf.parse(raw);
return new Decimal_adp(bd);
} catch (ParseException e) {
throw Err_.new_("Decimal_adp_", "parse to decimal failed", "raw", raw);
}
}
public static Decimal_adp pow_10_(int v) {return new Decimal_adp(new BigDecimal(1).scaleByPowerOfTen(v));}
public static final MathContext RoundDownContext = new MathContext(0, RoundingMode.DOWN);
public static final MathContext Gplx_rounding_context = new MathContext(14, RoundingMode.HALF_UP); // changed from 28 to 14; DATE:2015-07-31
}

View File

@ -1,88 +1,93 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2021 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Decimal_adp__tst {
private final Decimal_adp__fxt fxt = new Decimal_adp__fxt();
@Test public void divide_() {
fxt.Test_divide(1, 1000, "0.001");
fxt.Test_divide(1, 3, "0.33333333333333");
fxt.Test_divide(1, 7, "0.14285714285714");
}
@Test public void base1000_() {
fxt.Test_base_1000(1000, "1");
fxt.Test_base_1000(1234, "1.234");
fxt.Test_base_1000(123, "0.123");
}
@Test public void parts_() {
fxt.Test_parts(1, 0, "1");
fxt.Test_parts(1, 2, "1.2");
fxt.Test_parts(1, 23, "1.23");
fxt.Test_parts(123, 4567, "123.4567");
}
@Test public void parse() {
fxt.Test_parse("1", "1");
fxt.Test_parse("1.2", "1.2");
fxt.Test_parse("0.1", "0.1");
}
@Test public void Truncate_decimal() {
fxt.Test_truncate_decimal("1", "1");
fxt.Test_truncate_decimal("1.1", "1");
fxt.Test_truncate_decimal("1.9", "1");
}
@Test public void Fraction1000() {
fxt.Test_frac_1000(1, 1000, 1); // 0.001
fxt.Test_frac_1000(1, 3, 333); // 0.33333333
fxt.Test_frac_1000(1234, 1000, 234); // 1.234
fxt.Test_frac_1000(12345, 10000, 234); // 1.2345
}
@Test public void Lt() {
fxt.Test_comp_lt(1,123, 2, true);
fxt.Test_comp_lt(1,99999999, 2, true);
}
@Test public void To_str_fmt() {
fxt.Test_to_str_fmt(1, 2, "0.0", "0.5");
fxt.Test_to_str_fmt(1, 3, "0.0", "0.3");
fxt.Test_to_str_fmt(10000, 7, "0,000.000", "1,428.571");
fxt.Test_to_str_fmt(1, 2, "00.00", "00.50");
}
@Test public void Round() {
fxt.Test_round("123.456", 3, "123.456");
fxt.Test_round("123.456", 2, "123.46");
fxt.Test_round("123.456", 1, "123.5");
fxt.Test_round("123.456", 0, "123");
fxt.Test_round("123.456", -1, "120");
fxt.Test_round("123.456", -2, "100");
fxt.Test_round("123.456", -3, "0");
fxt.Test_round("6", -1, "10");
fxt.Test_round("5", -1, "10");
fxt.Test_round("6", -2, "0");
}
}
class Decimal_adp__fxt {
public void Test_divide(int lhs, int rhs, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).To_str());}
public void Test_base_1000(int val, String expd) {Tfds.Eq(expd, Decimal_adp_.base1000_(val).To_str());}
public void Test_parts(int num, int fracs, String expd) {Tfds.Eq(expd, Decimal_adp_.parts_(num, fracs).To_str());}
public void Test_parse(String raw, String expd) {Tfds.Eq(expd, Decimal_adp_.parse(raw).To_str());}
public void Test_truncate_decimal(String raw, String expd) {Tfds.Eq(Decimal_adp_.parse(expd).To_str(), Decimal_adp_.parse(raw).Truncate().To_str());}
public void Test_frac_1000(int lhs, int rhs, int expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).Frac_1000());}
public void Test_comp_lt(int lhsNum, int lhsFrc, int rhs, boolean expd) {Tfds.Eq(expd, Decimal_adp_.parts_(lhsNum, lhsFrc).Comp_lt(rhs));}
public void Test_to_str_fmt(int l, int r, String fmt, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(l, r).To_str(fmt));}
public void Test_round(String raw, int places, String expd) {Tfds.Eq_str(expd, Decimal_adp_.parse(raw).Round(places).To_str(), "round");}
}
package gplx;
import org.junit.*;
public class Decimal_adp__tst {
private final Decimal_adp__fxt fxt = new Decimal_adp__fxt();
@Test public void divide_() {
fxt.Test_divide(1, 1000, "0.001");
fxt.Test_divide(1, 3, "0.33333333333333");
fxt.Test_divide(1, 7, "0.14285714285714");
}
@Test public void base1000_() {
fxt.Test_base_1000(1000, "1");
fxt.Test_base_1000(1234, "1.234");
fxt.Test_base_1000(123, "0.123");
}
@Test public void parts_() {
fxt.Test_parts(1, 0, "1");
fxt.Test_parts(1, 2, "1.2");
fxt.Test_parts(1, 23, "1.23");
fxt.Test_parts(123, 4567, "123.4567");
}
@Test public void parse() {
fxt.Test_parse("1", "1");
fxt.Test_parse("1.2", "1.2");
fxt.Test_parse("0.1", "0.1");
fxt.Test_parse("1.2E1", "12");
fxt.Test_parse("1.2e1", "12"); // 2020-08-27|ISSUE#:565|Parse 'e' as 'E'; PAGE:en.w:Huntington_Plaza
}
@Test public void parse_dot() {
fxt.Test_parse(".", "0"); // 2021-02-13|ISSUE#:838|Parse '.' as '0.'; PAGE:en.w:2019_FIVB_Volleyball_Women%27s_Challenger_Cup#Pool_A
}
@Test public void Truncate_decimal() {
fxt.Test_truncate_decimal("1", "1");
fxt.Test_truncate_decimal("1.1", "1");
fxt.Test_truncate_decimal("1.9", "1");
}
@Test public void Fraction1000() {
fxt.Test_frac_1000(1, 1000, 1); // 0.001
fxt.Test_frac_1000(1, 3, 333); // 0.33333333
fxt.Test_frac_1000(1234, 1000, 234); // 1.234
fxt.Test_frac_1000(12345, 10000, 234); // 1.2345
}
@Test public void Lt() {
fxt.Test_comp_lt(1,123, 2, true);
fxt.Test_comp_lt(1,99999999, 2, true);
}
@Test public void To_str_fmt() {
fxt.Test_to_str_fmt(1, 2, "0.0", "0.5");
fxt.Test_to_str_fmt(1, 3, "0.0", "0.3");
fxt.Test_to_str_fmt(10000, 7, "0,000.000", "1,428.571");
fxt.Test_to_str_fmt(1, 2, "00.00", "00.50");
}
@Test public void Round() {
fxt.Test_round("123.456", 3, "123.456");
fxt.Test_round("123.456", 2, "123.46");
fxt.Test_round("123.456", 1, "123.5");
fxt.Test_round("123.456", 0, "123");
fxt.Test_round("123.456", -1, "120");
fxt.Test_round("123.456", -2, "100");
fxt.Test_round("123.456", -3, "0");
fxt.Test_round("6", -1, "10");
fxt.Test_round("5", -1, "10");
fxt.Test_round("6", -2, "0");
}
}
class Decimal_adp__fxt {
public void Test_divide(int lhs, int rhs, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).To_str());}
public void Test_base_1000(int val, String expd) {Tfds.Eq(expd, Decimal_adp_.base1000_(val).To_str());}
public void Test_parts(int num, int fracs, String expd) {Tfds.Eq(expd, Decimal_adp_.parts_(num, fracs).To_str());}
public void Test_parse(String raw, String expd) {Tfds.Eq(expd, Decimal_adp_.parse(raw).To_str());}
public void Test_truncate_decimal(String raw, String expd) {Tfds.Eq(Decimal_adp_.parse(expd).To_str(), Decimal_adp_.parse(raw).Truncate().To_str());}
public void Test_frac_1000(int lhs, int rhs, int expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).Frac_1000());}
public void Test_comp_lt(int lhsNum, int lhsFrc, int rhs, boolean expd) {Tfds.Eq(expd, Decimal_adp_.parts_(lhsNum, lhsFrc).Comp_lt(rhs));}
public void Test_to_str_fmt(int l, int r, String fmt, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(l, r).To_str(fmt));}
public void Test_round(String raw, int places, String expd) {Tfds.Eq_str(expd, Decimal_adp_.parse(raw).Round(places).To_str(), "round");}
}

View File

@ -1,54 +1,55 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2020 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
package gplx;
public class Double_ {
public static final String Cls_val_name = "double";
public static final Class<?> Cls_ref_type = Double.class;
public static final double
MinValue = Double.MIN_VALUE
, NaN = Double.NaN
, Inf_pos = Double.POSITIVE_INFINITY
;
public static final byte[]
NaN_bry = Bry_.new_a7("NaN")
, Inf_pos_bry = Bry_.new_a7("INF")
;
public static boolean IsNaN(double v) {return Double.isNaN(v);}
public static double cast(Object o) {try {return (Double)o;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, double.class, o);}}
public static double parse(String raw) {try {return Double.parseDouble(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, double.class, raw);}}
public static double parse_or(String raw, double v) {try {return Double.parseDouble(raw);} catch(Exception e) {Err_.Noop(e); return v;}}
public static double coerce_(Object v) {
try {String s = String_.as_(v); return s == null ? Double_.cast(v) : Double_.parse(s);}
catch (Exception e) {throw Err_.new_cast(e, double.class, v);}
}
public static String To_str(double v) {
int v_int = (int)v;
return v - v_int == 0 ? Int_.To_str(v_int) : Double.toString(v);
}
public static String To_str_loose(double v) {
int v_as_int = (int)v;
return v == v_as_int
? Int_.To_str(v_as_int) // convert to int, and call print String to eliminate any trailing decimal places
: Float_.To_str((float)v); // calling ((float)v).toString is better at removing trailing 0s than String.format("%g", v). note that .net .toString() handles it better; EX:2449.600000000000d; DATE:2014-07-29
}
public static int Compare(double lhs, double rhs) {
if (lhs == rhs) return CompareAble_.Same;
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
}
public static final String Cls_val_name = "double";
public static final Class<?> Cls_ref_type = Double.class;
public static final double
MinValue = Double.MIN_VALUE
, NaN = Double.NaN
, Inf_pos = Double.POSITIVE_INFINITY
;
public static final byte[]
NaN_bry = Bry_.new_a7("NaN")
, Inf_pos_bry = Bry_.new_a7("INF")
;
public static boolean IsNaN(double v) {return Double.isNaN(v);}
public static double cast(Object o) {try {return (Double)o;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, double.class, o);}}
public static double parse(String raw) {try {return Double.parseDouble(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, double.class, raw);}}
public static double parse_or(String raw, double v) {try {return Double.parseDouble(raw);} catch(Exception e) {Err_.Noop(e); return v;}}
public static double coerce_(Object v) {
try {String s = String_.as_(v); return s == null ? Double_.cast(v) : Double_.parse(s);}
catch (Exception e) {throw Err_.new_cast(e, double.class, v);}
}
public static String To_str(double v) {
int v_int = (int)v;
return v - v_int == 0 ? Int_.To_str(v_int) : Double.toString(v);
}
public static String To_str_loose(double v) {
int v_as_int = (int)v;
return v == v_as_int
? Int_.To_str(v_as_int) // convert to int, and call print String to eliminate any trailing decimal places
// DATE:2014-07-29; calling ((float)v).toString is better at removing trailing 0s than String.format("%g", v). note that .net .toString() handles it better; EX:2449.600000000000d
// DATE:2020-08-12; calling ToStrByPrintF b/c better at removing trailing 0s; ISSUE#:697;
: gplx.objects.primitives.Double_.ToStrByPrintF(v);
}
public static int Compare(double lhs, double rhs) {
if (lhs == rhs) return CompareAble_.Same;
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Enm_ {

View File

@ -1,51 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.errs.*;
public class Err extends RuntimeException {
private final boolean is_gplx;
private final String trace;
private final boolean is_gplx;
private final String trace;
private Err_msg[] msgs_ary = new Err_msg[8]; private int msgs_len = 8, msgs_idx = 0;
public Err(boolean is_gplx, String trace, String type, String msg, Object... args) {
this.is_gplx = is_gplx;
this.trace = is_gplx ? Err_.Trace_lang(this) : trace; // NOTE: Err_ factory methods pass in null stack trace for gplx excs; call Stack_trace here, note that trace will not show constructor
// NOTE: Err_ factory methods pass in null stack trace for gplx excs; call Stack_trace here, note that trace will not show constructor
this.trace = is_gplx ? Err_.Trace_lang(this) : trace;
Msgs_add(type, msg, args);
}
// marks messages logged so they can be ignored; used by Gfh_utl
public boolean Logged() {return logged;} public Err Logged_y_() {logged = true; return this;} private boolean logged;
// ignores current frame for reporting messages
public int Trace_ignore() {return trace_ignore;} public Err Trace_ignore_add_1_() {++trace_ignore; return this;} private int trace_ignore = 0;
public Err Args_add(Object... args) {msgs_ary[msgs_idx - 1].Args_add(args); return this;} // i - 1 to get current
@gplx.Internal protected boolean Type_match(String type) {
for (int i = 0; i < msgs_len; ++i) {
if (String_.Eq(type, msgs_ary[i].Type())) return true;
}
return false;
}
@gplx.Internal protected void Msgs_add(String type, String msg, Object[] args) {
if (msgs_idx == msgs_len) {
int new_len = msgs_len * 2;
Err_msg[] new_ary = new Err_msg[new_len];
Array_.Copy_to(msgs_ary, new_ary, 0);
this.msgs_ary = new_ary;
this.msgs_len = new_len;
}
msgs_ary[msgs_idx] = new Err_msg(type, msg, args);
++msgs_idx;
}
public String To_str__full() {return To_str(Bool_.N, Bool_.Y);}
public String To_str__log() {return To_str(Bool_.Y, Bool_.Y);}
public String To_str__msg_only(){
@ -56,7 +46,7 @@ public class Err extends RuntimeException {
}
private String To_str(boolean called_by_log, boolean include_trace) {
String nl_str = called_by_log ? "\t" : "\n";
String rv = ""; //nl_str + "----------------------------------------------------------------------" + nl_str;
String rv = "";
for (int i = 0; i < msgs_idx; ++i) {
rv += "[err " + Int_.To_str(i) + "] " + String_.Replace(msgs_ary[i].To_str(), "\n", nl_str) + nl_str;
}
@ -84,4 +74,16 @@ public class Err extends RuntimeException {
rv += line_bgn_dlm + lines[i];
return rv;
}
@gplx.Internal protected void Msgs_add(String type, String msg, Object[] args) {
if (msgs_idx == msgs_len) {
int new_len = msgs_len * 2;
Err_msg[] new_ary = new Err_msg[new_len];
Array_.Copy_to(msgs_ary, new_ary, 0);
this.msgs_ary = new_ary;
this.msgs_len = new_len;
}
msgs_ary[msgs_idx] = new Err_msg(type, msg, args);
++msgs_idx;
}
}

View File

@ -1,40 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Err_ {
private static String Type__gplx = "gplx"; @gplx.Internal protected static String Trace_null = null;
private static String Type__gplx = "gplx", Trace_null = null;
public static void Noop(Exception e) {}
public static Err as_(Object obj) {return obj instanceof Err ? (Err)obj : null;}
public static Err New(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, "", String_.Format(msg, args));}
public static Err new_(String type, String msg, Object... args) {return new Err(Bool_.Y, Trace_null, type, msg, args);}
public static Err new_wo_type(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
public static Err new_exc(Exception e, String type, String msg, Object... args) {
Err rv = cast_or_make(e);
Err rv = Cast_or_make(e);
rv.Msgs_add(type, msg, args);
return rv;
}
public static Err new_unhandled(Object val) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch/if", "val", val);}
public static Err new_unhandled_default(Object val) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch", "val", val);}
public static Err new_unhandled_default_w_msg(Object val, String msg) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch", "val", val, "msg", msg);}
public static Err new_unsupported() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not supported");}
public static Err new_unimplemented() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not implemented");}
public static Err new_unimplemented_w_msg(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
public static Err new_deprecated(String s) {return new Err(Bool_.Y, Trace_null, Type__gplx, "deprecated", "method", s);}
public static Err new_parse_type(Class<?> c, String raw) {return new_parse(Type_adp_.FullNameOf_type(c), raw);}
public static Err new_parse_exc(Exception e, Class<?> c, String raw) {return new_parse(Type_adp_.FullNameOf_type(c), raw).Args_add("e", Err_.Message_lang(e));}
public static Err new_parse_type(Class<?> c, String raw) {return new_parse(Type_.Canonical_name(c), raw);}
public static Err new_parse_exc(Exception e, Class<?> c, String raw) {return new_parse(Type_.Canonical_name(c), raw).Args_add("e", Err_.Message_lang(e));}
public static Err new_parse(String type, String raw) {return new Err(Bool_.Y, Trace_null, Type__gplx, "parse failed", "type", type, "raw", raw);}
public static Err new_null() {return new Err(Bool_.Y, Trace_null, Type__gplx, "null obj");}
public static Err new_null(String arg) {return new Err(Bool_.Y, Trace_null, Type__gplx, "null obj", "arg", arg);}
@ -44,17 +45,23 @@ public class Err_ {
public static Err new_invalid_arg(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
public static Err new_op_canceled() {return new Err(Bool_.Y, Trace_null, Type__op_canceled, "canceled by usr");}
public static Err new_type_mismatch_w_exc(Exception ignore, Class<?> t, Object o) {return new_type_mismatch(t, o);}
public static Err new_type_mismatch(Class<?> t, Object o) {return new Err(Bool_.Y, Trace_null, Type__gplx, "type mismatch", "expdType", Type_adp_.FullNameOf_type(t), "actlType", Type_adp_.NameOf_obj(o), "actlObj", Object_.Xto_str_strict_or_null_mark(o));}
public static Err new_type_mismatch(Class<?> t, Object o) {return new Err(Bool_.Y, Trace_null, Type__gplx, "type mismatch", "expdType", Type_.Canonical_name(t), "actlType", Type_.Name_by_obj(o), "actlObj", Object_.Xto_str_strict_or_null_mark(o));}
public static Err new_cast(Exception ignore, Class<?> t, Object o) {
String o_str = "";
try {o_str = Object_.Xto_str_strict_or_null_mark(o);}
catch (Exception e) {o_str = "<ERROR>"; Err_.Noop(e);}
return new Err(Bool_.Y, Trace_null, Type__gplx, "cast failed", "type", Type_adp_.NameOf_type(t), "obj", o_str);
return new Err(Bool_.Y, Trace_null, Type__gplx, "cast failed", "type", Type_.Name(t), "obj", o_str);
}
public static String Message_lang(Throwable e) {return e.getMessage();}
public static String To_str(Exception e) {return e.toString();} // e.getMessage() is sometimes null?
public static String Trace_lang(Throwable e) {return Trace_lang_exec(e.getStackTrace());}
public static String Message_gplx_full(Exception e) {return Cast_or_make(e).To_str__full();}
public static String Message_gplx_log(Exception e) {return Cast_or_make(e).To_str__log();}
public static String Message_lang(Throwable e) {
return Error.class.isAssignableFrom(e.getClass())
? e.toString() // error has null for "getMessage()" return "toString()" instead
: e.getMessage();
}
public static String Trace_lang(Throwable e) {return Trace_lang_exec(e.getStackTrace());}
private static String Trace_lang_exec(StackTraceElement[] ary) {
String rv = "";
int len = ary.length;
@ -64,12 +71,8 @@ public class Err_ {
}
return rv;
}
public static boolean Type_match(Exception e, String type) {
Err exc = Err_.as_(e);
return exc == null ? false : exc.Type_match(type);
}
public static String Message_gplx_full(Exception e) {return cast_or_make(e).To_str__full();}
public static String Message_gplx_log(Exception e) {return cast_or_make(e).To_str__log();}
public static Err cast_or_make(Throwable e) {return Type_adp_.Eq_typeSafe(e, Err.class) ? (Err)e : new Err(Bool_.N, Err_.Trace_lang(e), Type_adp_.NameOf_obj(e), Err_.Message_lang(e));}
public static final String Type__op_canceled = "gplx.op_canceled";
public static Err Cast_or_null(Exception e) {return Type_.Eq_by_obj(e, Err.class) ? (Err)e : null;}
public static Err Cast_or_make(Throwable e) {return Type_.Eq_by_obj(e, Err.class) ? (Err)e : new Err(Bool_.N, Err_.Trace_lang(e), Type_.Name_by_obj(e), Err_.Message_lang(e));}
public static final String Type__op_canceled = "gplx.op_canceled";
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Float_ {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.interfaces.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class GfoMsgUtl {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*; import gplx.core.strings.*; import gplx.core.brys.*; import gplx.core.interfaces.*;
@ -74,6 +72,16 @@ public class GfoMsg_ {
rv.Add("", vals[i]);
return rv;
}
public static Hash_adp Read_str_ary_as_hash(GfoMsg m, String k) {
String[] ary = m.ReadStrAry(k, "|");
int ary_len = ary.length;
if (ary_len == 0) return Hash_adp_.Noop;
Hash_adp rv = Hash_adp_.New();
for (int i = 0; i < ary_len; i++) {
rv.Add_if_dupe_use_1st(ary[i], ary[i]);
}
return rv;
}
}
class GfoMsg_wtr extends GfoMsg_base {
@Override protected Object ReadOr(String k, Object defaultOr) {
@ -132,9 +140,9 @@ class GfoMsg_base implements GfoMsg {
args.Add(Keyval_.new_(k, v));
return this;
}
public boolean ReadBool(String k) {Object rv = ReadOr(k,false); if (rv == Nil) ThrowNotFound(k); return parse ? Yn.parse_or((String)rv, false) : Bool_.cast(rv);}
public int ReadInt(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Int_.parse((String)rv) : Int_.cast(rv);}
public byte ReadByte(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Byte_.parse((String)rv) : Byte_.cast(rv);}
public boolean ReadBool(String k) {Object rv = ReadOr(k,false); if (rv == Nil) ThrowNotFound(k); return parse ? Yn.parse_or((String)rv, false) : Bool_.Cast(rv);}
public int ReadInt(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Int_.Parse((String)rv) : Int_.Cast(rv);}
public byte ReadByte(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Byte_.Parse((String)rv) : Byte_.Cast(rv);}
public long ReadLong(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Long_.parse((String)rv) : Long_.cast(rv);}
public float ReadFloat(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Float_.parse((String)rv) : Float_.cast(rv);}
public double ReadDouble(String k) {Object rv = ReadOr(k, 0) ; if (rv == Nil) ThrowNotFound(k); return parse ? Double_.parse((String)rv) : Double_.cast(rv);}
@ -143,8 +151,8 @@ class GfoMsg_base implements GfoMsg {
public DateAdp ReadDate(String k) {Object rv = ReadOr(k, null); if (rv == Nil) ThrowNotFound(k); return parse ? DateAdp_.parse_gplx((String)rv) : DateAdp_.cast(rv);}
public Io_url ReadIoUrl(String k) {Object rv = ReadOr(k, null); if (rv == Nil) ThrowNotFound(k); return parse ? Io_url_.new_any_((String)rv) : Io_url_.cast(rv);}
public Object CastObj(String k) {Object rv = ReadOr(k, null); if (rv == Nil) ThrowNotFound(k); return rv;}
public boolean ReadBoolOr(String k, boolean or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Yn.parse_or((String)rv, or) : Bool_.cast(rv);}
public int ReadIntOr(String k, int or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Int_.parse((String)rv) : Int_.cast(rv);}
public boolean ReadBoolOr(String k, boolean or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Yn.parse_or((String)rv, or) : Bool_.Cast(rv);}
public int ReadIntOr(String k, int or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Int_.Parse((String)rv) : Int_.Cast(rv);}
public long ReadLongOr(String k, long or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Long_.parse((String)rv) : Long_.cast(rv);}
public float ReadFloatOr(String k, float or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Float_.parse((String)rv) : Float_.cast(rv);}
public double ReadDoubleOr(String k,double or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Double_.parse((String)rv) : Double_.cast(rv);}
@ -152,9 +160,9 @@ class GfoMsg_base implements GfoMsg {
public String ReadStrOr(String k, String or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return (String)rv;}
public DateAdp ReadDateOr(String k, DateAdp or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? DateAdp_.parse_gplx((String)rv) : DateAdp_.cast(rv);}
public Io_url ReadIoUrlOr(String k, Io_url or) {Object rv = ReadOr(k, or) ; if (rv == Nil) return or ; return parse ? Io_url_.new_any_((String)rv) : Io_url_.cast(rv);}
public boolean ReadBoolOrFalse(String k) {Object rv = ReadOr(k,false); if (rv == Nil) return false ; return parse ? Yn.parse_or((String)rv, false) : Bool_.cast(rv);}
public boolean ReadBoolOrTrue(String k) {Object rv = ReadOr(k, true); if (rv == Nil) return true ; return parse ? Yn.parse_or((String)rv, true) : Bool_.cast(rv);}
public boolean ReadYnOrY(String k) {Object rv = ReadOr(k, true); if (rv == Nil) return true ; return parse ? Yn.parse_or((String)rv, true) : Bool_.cast(rv);}
public boolean ReadBoolOrFalse(String k) {Object rv = ReadOr(k,false); if (rv == Nil) return false ; return parse ? Yn.parse_or((String)rv, false) : Bool_.Cast(rv);}
public boolean ReadBoolOrTrue(String k) {Object rv = ReadOr(k, true); if (rv == Nil) return true ; return parse ? Yn.parse_or((String)rv, true) : Bool_.Cast(rv);}
public boolean ReadYnOrY(String k) {Object rv = ReadOr(k, true); if (rv == Nil) return true ; return parse ? Yn.parse_or((String)rv, true) : Bool_.Cast(rv);}
public boolean ReadYn(String k) {Object rv = ReadOr(k,false); if (rv == Nil) ThrowNotFound(k); return parse ? Yn.parse_or((String)rv, false) : Yn.coerce_(rv);}
public boolean ReadYn_toggle(String k, boolean cur) {
Object rv = ReadOr(k, "!");
@ -258,13 +266,13 @@ interface XtoStrWkr {
class XtoStrWkr_gplx implements XtoStrWkr {
public String To_str(Object o) {
if (o == null) return "<<NULL>>";
Class<?> type = Type_adp_.ClassOf_obj(o);
Class<?> type = Type_.Type_by_obj(o);
String rv = null;
if (type == String.class) rv = String_.cast(o);
else if (Int_.TypeMatch(type)) return Int_.To_str(Int_.cast(o));
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) return Yn.To_str(Bool_.cast(o));
else if (type == DateAdp.class) return DateAdp_.cast(o).XtoStr_gplx();
else rv = Object_.Xto_str_strict_or_empty(o);
if (Type_.Eq(type, String_.Cls_ref_type)) rv = String_.cast(o);
else if (Type_.Eq(type, Int_.Cls_ref_type)) return Int_.To_str(Int_.Cast(o));
else if (Type_.Eq(type, Bool_.Cls_ref_type)) return Yn.To_str(Bool_.Cast(o));
else if (Type_.Eq(type, DateAdp_.Cls_ref_type)) return DateAdp_.cast(o).XtoStr_gplx();
else rv = Object_.Xto_str_strict_or_empty(o);
return String_.Replace(rv, "'", "''");
}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.langs.gfs.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface GfoTemplate {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class GfoTemplateFactory implements Gfo_invk {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_evt_itm extends Gfo_invk, Gfo_evt_mgr_owner {}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_evt_mgr_ {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_evt_mgr_owner {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_invk {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_invk_cmd {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_invk_cmd_mgr_owner {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_invk_root_wkr {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.langs.gfs.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_log {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.logs.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_log_bfr {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_usr_dlg extends Cancelable {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_usr_dlg_ {
@ -29,7 +27,7 @@ public class Gfo_usr_dlg_ {
}
public static String Test__list__term__get_1st() {
Instance = Noop;
String[] rv = ((Gfo_usr_dlg__gui_test)test__list.Gui_wkr()).Warns().To_str_ary_and_clear();
String[] rv = ((Gfo_usr_dlg__gui_mock)test__list.Gui_wkr()).Warns().To_str_ary_and_clear();
return rv.length == 0 ? "" : rv[0];
}
public static void Test__show__init() {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.rings.*;

View File

@ -1,26 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.consoles.*; import gplx.core.lists.rings.*;
public class Gfo_usr_dlg__gui_ {
public static final Gfo_usr_dlg__gui Noop = new Gfo_usr_dlg__gui_noop();
public static final Gfo_usr_dlg__gui Console = new Gfo_usr_dlg__gui_console();
public static final Gfo_usr_dlg__gui Test = new Gfo_usr_dlg__gui_test();
public static final Gfo_usr_dlg__gui Test = new Gfo_usr_dlg__gui_mock();
public static final Gfo_usr_dlg__gui Mem = new Gfo_usr_dlg__gui_mem_string();
public static String Mem_file() {return ((Gfo_usr_dlg__gui_mem_string)Mem).file;}
}

View File

@ -0,0 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.rings.*;
public class Gfo_usr_dlg__gui_mock implements Gfo_usr_dlg__gui {
public List_adp Warns() {return warns;} private final List_adp warns = List_adp_.New();
public List_adp Msgs() {return msgs;} private final List_adp msgs = List_adp_.New();
public Ring__string Prog_msgs() {return ring;} private final Ring__string ring = new Ring__string().Max_(0);
public void Clear() {msgs.Clear(); warns.Clear();}
public void Write_prog(String text) {msgs.Add(text);}
public void Write_note(String text) {msgs.Add(text);}
public void Write_warn(String text) {warns.Add(text);}
public void Write_stop(String text) {msgs.Add(text);}
}

View File

@ -1,29 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx;
import gplx.core.lists.rings.*;
public class Gfo_usr_dlg__gui_test implements Gfo_usr_dlg__gui {
public List_adp Warns() {return warns;} private final List_adp warns = List_adp_.New();
public List_adp Msgs() {return msgs;} private final List_adp msgs = List_adp_.New();
public Ring__string Prog_msgs() {return ring;} private final Ring__string ring = new Ring__string().Max_(0);
public void Clear() {msgs.Clear(); warns.Clear();}
public void Write_prog(String text) {msgs.Add(text);}
public void Write_note(String text) {msgs.Add(text);}
public void Write_warn(String text) {warns.Add(text);}
public void Write_stop(String text) {msgs.Add(text);}
}

View File

@ -1,25 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Gfo_usr_dlg__log extends Gfo_invk {
boolean Enabled(); void Enabled_(boolean v);
boolean Queue_enabled(); void Queue_enabled_(boolean v);
Io_url Log_dir(); void Log_dir_(Io_url v);
void Queue_enabled_(boolean v);
Io_url Log_dir();
void Log_dir_(Io_url v);
Io_url Session_dir();
Io_url Session_fil();
void Log_msg_to_url_fmt(Io_url url, String fmt, Object... args);

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_usr_dlg__log_ {

View File

@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*; import gplx.core.consoles.*; import gplx.core.brys.fmtrs.*;
public class Gfo_usr_dlg__log_base implements Gfo_usr_dlg__log {
private final Object thread_lock = new Object();
private int archive_dirs_max = 8;
private Io_url log_dir, err_fil;
private Ordered_hash queued_list = Ordered_hash_.New();
private Bry_fmtr fmtr = Bry_fmtr.New__tmp(); private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
private final Ordered_hash queued_list = Ordered_hash_.New();
private final Bry_fmtr fmtr = Bry_fmtr.New__tmp();
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
public boolean Queue_enabled() {return queue_enabled;} public void Queue_enabled_(boolean v) {queue_enabled = v; if (!v) this.Flush();} private boolean queue_enabled;
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public Io_url Session_dir() {return session_dir;} private Io_url session_dir;
@ -33,18 +33,23 @@ public class Gfo_usr_dlg__log_base implements Gfo_usr_dlg__log {
if (fil.Url() == null) {
fil.Url_(session_dir.GenSubFil("session.txt"));
}
fil.Flush();
fil.Flush(enabled);
}
}
public Io_url Log_dir() {return log_dir;}
public void Log_dir_(Io_url log_dir) {
this.log_dir = log_dir;
session_dir = log_dir.GenSubDir(Dir_name_current);
session_fil = session_dir.GenSubFil("session.txt");
err_fil = session_dir.GenSubFil("err.txt");
if (enabled) {
session_dir = log_dir.GenSubDir(Datetime_now.Get().XtoStr_fmt_yyyyMMdd_HHmmss_fff());
session_fil = session_dir.GenSubFil("session.txt");
err_fil = session_dir.GenSubFil("err.txt");
}
}
public void Log_term() {
if (!enabled) return;
if (!enabled) {
Io_mgr.Instance.DeleteDirDeep(log_dir);
return;
}
Io_url[] archive_dirs = Io_mgr.Instance.QueryDir_args(log_dir).DirInclude_().DirOnly_().ExecAsUrlAry();
int archive_dirs_len = archive_dirs.length;
int session_cutoff = archive_dirs_len - archive_dirs_max;
@ -54,9 +59,7 @@ public class Gfo_usr_dlg__log_base implements Gfo_usr_dlg__log {
this.Log_to_session("archive dir del: " + session_dir.Raw());
}
this.Log_to_session("app term");
MoveCurrentToArchive(session_dir);
}
private void MoveCurrentToArchive(Io_url dir) {Io_mgr.Instance.MoveDirDeep(dir, dir.OwnerDir().GenSubDir(Datetime_now.Get().XtoStr_fmt_yyyyMMdd_HHmmss_fff()));}
public void Log_info(boolean warn, String s) {if (warn) Log_to_err(s); else Log_to_session(s);}
public void Log_msg_to_url_fmt(Io_url url, String fmt, Object... args) {
if (!enabled) return;
@ -83,8 +86,13 @@ public class Gfo_usr_dlg__log_base implements Gfo_usr_dlg__log {
}
catch (Exception e) {Err_.Noop(e);} // java.lang.StringBuilder can throw exceptions in some situations when called on a different thread; ignore errors
} private String_bldr sb = String_bldr_.new_thread(); // NOTE: use java.lang.StringBuffer to try to avoid random exceptions when called on a different thread
private String Bld_msg(String s) {return sb.Add(Datetime_now.Get_force().XtoUtc().XtoStr_fmt_yyyyMMdd_HHmmss_fff()).Add(" ").Add(s).Add_char_nl().To_str_and_clear();}
private String Bld_msg(String s) {
synchronized (thread_lock) { // THREAD:synchronized neded b/c multiple threads can still mutate the same sb; ISSUE#:646; DATE:2020-03-16
return sb.Add(Datetime_now.Get_force().XtoUtc().XtoStr_fmt_yyyyMMdd_HHmmss_fff()).Add(" ").Add(s).Add_char_nl().To_str_and_clear();
}
}
private void Log_msg(Io_url url, String txt) {
synchronized (thread_lock) { // THREAD:synchronized neded b/c queued_list can be accessible by multiple threads; ISSUE#:646; DATE:2020-01-09
if (queue_enabled) {
String url_raw = url == null ? "mem" : url.Raw();
Usr_log_fil fil = (Usr_log_fil)queued_list.Get_by(url_raw);
@ -94,24 +102,30 @@ public class Gfo_usr_dlg__log_base implements Gfo_usr_dlg__log {
}
fil.Add(txt);
}
else
Io_mgr.Instance.AppendFilStr(url, txt);
else {
if (enabled)
Io_mgr.Instance.AppendFilStr(url, txt);
}
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_archive_dirs_max_)) archive_dirs_max = m.ReadInt("v");
else if (ctx.Match(k, Invk_log_dir_)) log_dir = m.ReadIoUrl("v");
if (ctx.Match(k, "enabled_")) enabled = m.ReadYn("v");
else if (ctx.Match(k, "archive_dirs_max_")) archive_dirs_max = m.ReadInt("v");
else if (ctx.Match(k, "log_dir_")) log_dir = m.ReadIoUrl("v");
else return Gfo_invk_.Rv_unhandled;
return this;
} public static final String Invk_enabled_ = "enabled_", Invk_archive_dirs_max_ = "archive_dirs_max_", Invk_log_dir_ = "log_dir_";
static final String Dir_name_log = "log", Dir_name_current = "current";
}
public static final Gfo_usr_dlg__log_base Instance = new Gfo_usr_dlg__log_base();
}
class Usr_log_fil {
public Usr_log_fil(Io_url url) {this.url = url;}
public Io_url Url() {return url;} public Usr_log_fil Url_(Io_url v) {url = v; return this;} Io_url url;
public void Add(String text) {sb.Add(text);} String_bldr sb = String_bldr_.new_();
public void Flush() {
private final String_bldr sb = String_bldr_.new_();
public Usr_log_fil(Io_url url) {
this.url = url;
}
public Io_url Url() {return url;} public Usr_log_fil Url_(Io_url v) {url = v; return this;} private Io_url url;
public void Add(String text) {sb.Add(text);}
public void Flush(boolean enabled) {
if (!enabled) return;
if (sb.Count() == 0) return;
try {
Io_mgr.Instance.AppendFilStr(url, sb.To_str_and_clear());

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.brys.fmtrs.*;
@ -46,8 +44,14 @@ public class Gfo_usr_dlg_base implements Gfo_usr_dlg {
}
private String Bld_msg_many(String grp_key, String msg_key, String fmt, Object[] args) {
synchronized (tmp_fmtr) {
tmp_fmtr.Fmt_(fmt).Bld_bfr_many(tmp_bfr, args);
return tmp_bfr.To_str_and_clear();
try {
tmp_fmtr.Fmt_(fmt).Bld_bfr_many(tmp_bfr, args);
return tmp_bfr.To_str_and_clear();
}
catch (Exception e) { // NOTE: can fail if fmt has ~{}; callers should proactively remove, but for now, just return fmt if fails; EX:Page_sync and en.w:Web_crawler; DATE:2016-11-17
Err_.Noop(e);
return fmt;
}
}
}
private String Bld_msg_one(String grp_key, String msg_key, String fmt, Object val) {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class GfsCtx {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Guid_adp {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Guid_adp_ {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,30 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public interface Hash_adp extends gplx.core.lists.EnumerAble {
int Count();
boolean Has(Object key);
Object Get_by(Object key);
Object Get_by_or_fail(Object key);
void Add(Object key, Object val);
void Add_as_key_and_val(Object val);
boolean Add_if_dupe_use_1st(Object key, Object val);
void Add_if_dupe_use_nth(Object key, Object val);
void Del(Object key);
void Clear();
int Count();
boolean Has(Object key);
Object Get_by(Object key);
Object Get_by_or_fail(Object key);
void Add(Object key, Object val);
Hash_adp Add_and_more(Object key, Object val);
Hash_adp Add_many_as_key_and_val(Object... ary);
void Add_as_key_and_val(Object val);
boolean Add_if_dupe_use_1st(Object key, Object val);
void Add_if_dupe_use_nth(Object key, Object val);
void Del(Object key);
void Clear();
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*;
@ -28,6 +26,8 @@ class Hash_adp_noop implements Hash_adp {
public Object Get_by(Object key) {return null;}
public Object Get_by_or_fail(Object key) {throw Err_.new_missing_key(Object_.Xto_str_strict_or_null_mark(key));}
public void Add(Object key, Object val) {}
public Hash_adp Add_and_more(Object key, Object val) {return this;}
public Hash_adp Add_many_as_key_and_val(Object... ary) {return this;}
public void Add_as_key_and_val(Object val) {}
public void Add_if_dupe_use_nth(Object key, Object val) {}
public boolean Add_if_dupe_use_1st(Object key, Object val) {return false;}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,120 +1,84 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*; import gplx.langs.gfs.*;
public class Int_ implements Gfo_invk {
public class Int_ {
// -------- BASELIB_COPY --------
public static final String Cls_val_name = "int";
public static final Class<?> Cls_ref_type = Integer.class;
public static final int Base1 = 1;
public static final int Const_dlm_len = 1;
public static final int Const_position_after_char = 1;
public static final int Null = Int_.Min_value;
public static int coerce_(Object v) {
try {String s = String_.as_(v); return s == null ? Int_.cast(v) : Int_.parse(s);}
catch (Exception e) {throw Err_.new_cast(e, int.class, v);}
}
public static int[] Ary_empty = new int[0];
public static int[] Ary(int... v) {return v;}
public static int[] Ary_copy(int[] ary) {return Ary_copy(ary, ary.length);}
public static int[] Ary_copy(int[] ary, int new_len) {
int old_len = ary.length;
int[] rv = new int[new_len];
for (int i = 0; i < old_len; i++)
rv[i] = ary[i];
return rv;
}
public static void Ary_copy_to(int[] src, int src_len, int[] trg) {
for (int i = 0; i < src_len; ++i)
trg[i] = src[i];
}
public static String Ary_concat(String spr, int... ary) {
Bry_bfr bfr = Bry_bfr_.New();
int len = ary.length;
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_str_u8(spr);
int itm = ary[i];
bfr.Add_int_variable(itm);
public static final int
Min_value = Integer.MIN_VALUE
, Max_value = Integer.MAX_VALUE
, Max_value__31 = 2147483647
, Neg1 = -1
, Null = Int_.Min_value
, Base1 = 1 // for super 1 lists / arrays; EX: PHP; [a, b, c]; [1] => a
, Offset_1 = 1 // common symbol for + 1 after current pos; EX: String_.Mid(lhs + Offset_1, rhs)
, Zero = 0
;
public static int Cast(Object obj) {
try {
return (Integer)obj;
}
catch(Exception exc) {
throw Err_.new_type_mismatch_w_exc(exc, int.class, obj);
}
return bfr.To_str_and_clear();
}
public static int[] AryRng(int bgn, int end) {
int len = end - bgn + 1;
int[] rv = new int[len];
for (int i = 0; i < len; i++)
rv[i] = bgn + i;
return rv;
}
public static boolean Bounds_chk(int bgn, int end, int len) {return bgn > -1 && end < len;}
public static int parse_or(String raw, int or) {
public static String To_str(int v) {return new Integer(v).toString();}
public static int Parse_or(String raw, int or) {
// process args
if (raw == null) return or;
int rawLen = String_.Len(raw); if (rawLen == 0) return or;
int rv = 0, tmp = 0, factor = 1;
for (int i = rawLen; i > 0; i--) {
char c = String_.CharAt(raw, i - 1);
switch (c) {
case '0': tmp = 0; break; case '1': tmp = 1; break; case '2': tmp = 2; break; case '3': tmp = 3; break; case '4': tmp = 4; break;
case '5': tmp = 5; break; case '6': tmp = 6; break; case '7': tmp = 7; break; case '8': tmp = 8; break; case '9': tmp = 9; break;
case '-': rv *= -1; continue; // NOTE: note continue
default: return or;
int raw_len = String_.Len(raw);
if (raw_len == 0) return or;
// loop backwards from nth to 0th char
int rv = 0, power_of_10 = 1;
for (int idx = raw_len - 1; idx >= 0; idx--) {
char cur = String_.CharAt(raw, idx);
int digit = -1;
switch (cur) {
// numbers -> assign digit
case '0': digit = 0; break; case '1': digit = 1; break; case '2': digit = 2; break; case '3': digit = 3; break; case '4': digit = 4; break;
case '5': digit = 5; break; case '6': digit = 6; break; case '7': digit = 7; break; case '8': digit = 8; break; case '9': digit = 9; break;
// negative sign
case '-':
if (idx != 0) { // invalid if not 1st
return or;
}
else { // is first; multiply by -1
rv *= -1;
continue;
}
// anything else
default:
return or;
}
rv += (tmp * factor);
factor *= 10;
rv += (digit * power_of_10);
power_of_10 *= 10;
}
return rv;
}
public static int EnsureLessThan(int v, int max) {return v >= max ? max : v;}
public static boolean In(int v, int comp0, int comp1) {return v == comp0 || v == comp1;}
public static boolean In(int v, int... ary) {
for (int itm : ary)
if (v == itm) return true;
return false;
}
public static int BoundEnd(int v, int end) {return v >= end ? end - 1 : v;}
public static int Min(int lhs, int rhs) {return lhs < rhs ? lhs : rhs;}
public static int Max(int lhs, int rhs) {return lhs > rhs ? lhs : rhs;}
public static int ModIfNeg1(int v, int or) {return v == -1 ? or : v;}
public static boolean RangeCheck(int v, int max) {return v >= 0 && v < max;}
public static void RangeCheckOrFail_list(int v, int max, String s) {if (v < 0 || v >= max) throw Err_.new_wo_type("bounds check failed", "msg", s, "v", v, "min", 0, "max", max - 1);}
public static void RangeCheckOrFail(int v, int min, int max, String s) {if (v < min || v >= max) throw Err_.new_wo_type("bounds check failed", "msg", s, "v", v, "min", min, "max", max);}
public static boolean Between(int v, int lhs, int rhs) {
int lhsCompare = v == lhs ? 0 : (v < lhs ? -1 : 1);
int rhsCompare = v == rhs ? 0 : (v < rhs ? -1 : 1);
return (lhsCompare * rhsCompare) != 1; // 1 when v is (a) greater than both or (b) less than both
}
public static int Div(int v, float divisor) {return (int)((float)v / divisor);}
public static int DivAndRoundUp(int v, int divisor) {
int whole = v / divisor;
int partial = v % divisor == 0 ? 0 : 1;
return whole + partial;
}
public static int Mult(int v, float multiplier) {
float product = ((float)v * multiplier); // WORKAROUND (DotNet): (int)((float)v * multiplier) returns 0 for 100 and .01f
return (int)product;
}
public static int Compare(int lhs, int rhs) {
if (lhs == rhs) return CompareAble_.Same;
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
public static int DigitCount(int v) {
int log10 = Log10(v);
return v > -1 ? log10 + 1 : log10 * -1 + 2;
}
public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.Max_value};
public static int Log10AryLen = 11;
public static int Log10(int v) {
if (v == 0) return 0;
int sign = 1;
@ -133,63 +97,46 @@ public class Int_ implements Gfo_invk {
if (v < Log10Ary[i]) {rv = i - 1; break;}
}
return rv * sign;
} public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.Max_value}; public static int Log10AryLen = 11;
public Int_ FailIfNeg1(String key, int val) {
if (val < 0) throw Err_.new_wo_type("key must be >= 0", "key", key, "val", val);
return this;
}
public static String To_str_pad_bgn_space(int v, int reqdPlaces) {return To_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Space, true);} // EX: 1, 3 returns " 1"
public static String To_str_pad_bgn_zero(int v, int reqdPlaces) {return To_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Num_0, true);} // EX: 1, 3 returns "001"
static String To_str_pad_bgn_zero(int val, int places, byte pad_chr, boolean bgn) {
int len = DigitCount(val);
int pad_len = places - len; if (pad_len < 0) return Int_.To_str(val);
Bry_bfr bfr = Bry_bfr_.New();
boolean neg = val < 0;
if (bgn) { // special logic to handle negative numbers; EX: -1 -> "-001", not "00-1"
if (neg) {
bfr.Add_byte(Byte_ascii.Dash);
val *= -1;
--len;
}
}
else
bfr.Add_int_fixed(val, len);
bfr.Add_byte_repeat(pad_chr, pad_len);
if (bgn) bfr.Add_int_fixed(val, len); // NOTE: neg handled above
return bfr.To_str();
public static int DigitCount(int v) {
int log10 = Log10(v);
return v > -1 ? log10 + 1 : log10 * -1 + 2;
}
public static int read_(Object o) {String s = String_.as_(o); return s != null ? Int_.parse(s) : Int_.cast(o);}
public static int parse(String raw) {try {return Integer.parseInt(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, int.class, raw);}}
public static int cast(Object obj) {try {return (Integer)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, int.class, obj);}}
public static int cast_or(Object obj, int or) {try {return (Integer)obj;} catch(Exception e) {Err_.Noop(e); return or;}}
public static int Xby_double_(double v) {return (int)v;}
public static String To_str(int v) {return new Integer(v).toString();}
public static String To_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
public static boolean TypeMatch(Class<?> type) {return type == int.class || type == Integer.class;}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_XtoStr_PadBgn)) {
int v = m.ReadInt(GfsCore_.Arg_primitive), pad = m.ReadInt("pad");
return ctx.Deny() ? (Object)this : To_str_pad_bgn_zero(v, pad);
// -------- TO_MIGRATE --------
public static int Cast_or(Object obj, int or) {
try {
return (Integer)obj;
}
else if (ctx.Match(k, "Add")) {
int v = m.ReadInt(GfsCore_.Arg_primitive), operand = m.ReadInt("operand");
return ctx.Deny() ? (Object)this : v + operand;
catch(Exception e) {
Err_.Noop(e);
return or;
}
else return Gfo_invk_.Rv_unhandled;
} public static final String Invk_XtoStr_PadBgn = "XtoStr_PadBgn";
public static final Int_ Gfs = new Int_();
public static int To_int_hex(byte[] src) {return To_int_hex(src, 0, src.length);}
public static int To_int_hex(byte[] src, int bgn, int end) {
}
public static int Coerce(Object v) {
try {
String s = String_.as_(v);
return s == null ? Int_.Cast(v) : Int_.Parse(s);
}
catch (Exception e) {throw Err_.new_cast(e, int.class, v);}
}
public static int Parse(String raw) {try {return Integer.parseInt(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, int.class, raw);}}
public static int By_double(double v) {return (int)v;}
public static int By_hex_bry(byte[] src) {return By_hex_bry(src, 0, src.length);}
public static int By_hex_bry(byte[] src, int bgn, int end) {
int rv = 0; int factor = 1;
for (int i = end - 1; i >= bgn; i--) {
int val = To_int_hex(src[i]);
int val = By_hex_byte(src[i]);
rv += (val * factor);
factor *= 16;
}
return rv;
}
public static int Subtract_long(long lhs, long rhs) {return (int)(lhs - rhs);}
public static int To_int_hex(byte b) {
public static int By_hex_byte(byte b) {
switch (b) {
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
@ -202,6 +149,37 @@ public class Int_ implements Gfo_invk {
return -1;
}
}
public static byte[] To_bry(int v) {return Bry_.new_a7(To_str(v));}
public static String To_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
public static String To_str_pad_bgn_space(int val, int reqd_len) {return To_str_pad(val, reqd_len, Bool_.Y, Byte_ascii.Space);} // EX: 1, 3 returns " 1"
public static String To_str_pad_bgn_zero (int val, int reqd_len) {return To_str_pad(val, reqd_len, Bool_.Y, Byte_ascii.Num_0);} // EX: 1, 3 returns "001"
private static String To_str_pad(int val, int reqd_len, boolean bgn, byte pad_chr) {
// get val_len and pad_len; exit early, if no padding needed
int val_len = DigitCount(val);
int pad_len = reqd_len - val_len;
if (pad_len < 0)
return Int_.To_str(val);
// padding needed
Bry_bfr bfr = Bry_bfr_.New();
// handle negative numbers; EX: -1 -> "-001", not "00-1"
if (val < 0) {
bfr.Add_byte(Byte_ascii.Dash);
val *= -1;
--val_len;
}
// build outpt
if (!bgn)
bfr.Add_int_fixed(val, val_len);
bfr.Add_byte_repeat(pad_chr, pad_len);
if (bgn)
bfr.Add_int_fixed(val, val_len);
return bfr.To_str();
}
public static String To_str_hex(int v) {return To_str_hex(Bool_.Y, Bool_.Y, v);}
public static String To_str_hex(boolean zero_pad, boolean upper, int v) {
String rv = Integer.toHexString(v);
@ -209,64 +187,58 @@ public class Int_ implements Gfo_invk {
if (zero_pad && rv_len < 8) rv = String_.Repeat("0", 8 - rv_len) + rv;
return upper ? String_.Upper(rv) : rv;
}
public static String To_str(int[] ary) {return To_str(ary, " ");}
public static String To_str(int[] ary, String dlm) {
String_bldr sb = String_bldr_.new_();
for (int i = 0; i < ary.length; i++)
sb.Add_spr_unless_first(Int_.To_str(ary[i]), dlm, i);
return sb.To_str();
public static int Compare(int lhs, int rhs) {
if (lhs == rhs) return CompareAble_.Same;
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
public static int[] Ary_parse(String raw_str, int reqd_len, int[] or) {
byte[] raw_bry = Bry_.new_a7(raw_str);
int raw_bry_len = raw_bry.length;
int[] rv = new int[reqd_len];
int cur_val = 0, cur_mult = 1, cur_idx = reqd_len - 1; boolean signed = false;
for (int i = raw_bry_len - 1; i > -2; i--) {
byte b = i == -1 ? Byte_ascii.Comma : raw_bry[i];
switch (b) {
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
if (signed) return or;
cur_val += (b - Byte_ascii.Num_0) * cur_mult;
cur_mult *= 10;
break;
case Byte_ascii.Space: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Tab:
break;
case Byte_ascii.Comma:
if (cur_idx < 0) return or;
rv[cur_idx--] = cur_val;
cur_val = 0; cur_mult = 1;
signed = false;
break;
case Byte_ascii.Dash:
if (signed) return or;
cur_val *= -1;
signed = true;
break;
case Byte_ascii.Plus: // noop; all values positive by default
if (signed) return or;
signed = true;
break;
default:
return or;
public static boolean In(int v, int comp0, int comp1) {return v == comp0 || v == comp1;}
public static boolean In(int v, int... ary) {
for (int itm : ary)
if (v == itm) return true;
return false;
}
public static boolean Between(int v, int lhs, int rhs) {
int lhsCompare = v == lhs ? 0 : (v < lhs ? -1 : 1);
int rhsCompare = v == rhs ? 0 : (v < rhs ? -1 : 1);
return (lhsCompare * rhsCompare) != 1; // 1 when v is (a) greater than both or (b) less than both
}
public static boolean RangeCheck(int v, int max) {return v >= 0 && v < max;}
public static void RangeCheckOrFail_list(int v, int max, String s) {if (v < 0 || v >= max) throw Err_.new_wo_type("bounds check failed", "msg", s, "v", v, "min", 0, "max", max - 1);}
public static boolean Bounds_chk(int bgn, int end, int len) {return bgn > -1 && end < len;}
public static int BoundEnd(int v, int end) {return v >= end ? end - 1 : v;}
public static int EnsureLessThan(int v, int max) {return v >= max ? max : v;}
public static int Min(int lhs, int rhs) {return lhs < rhs ? lhs : rhs;}
public static int Max(int lhs, int rhs) {return lhs > rhs ? lhs : rhs;}
public static int Min_many(int... ary) {
int len = ary.length; if (len == 0) throw Err_.new_wo_type("Min_many requires at least 1 value");
boolean init = true;
int min = Int_.Min_value;
for (int i = 0; i < len; ++i) {
int val = ary[i];
if (init) {
min = val;
init = false;
}
else {
if (val < min)
min = val;
}
}
return cur_idx == -1 ? rv : or; // cur_idx == -1 checks for unfilled; EX: Ary_parse("1,2", 3, null) is unfilled
return min;
}
public static int[] Ary_parse(String raw_str, String spr) {
String[] ary = String_.Split(raw_str, spr);
int len = ary.length;
int[] rv = new int[len];
for (int i = 0; i < len; i++)
rv[i] = Int_.parse(ary[i]);
return rv;
public static int Subtract_long(long lhs, long rhs) {return (int)(lhs - rhs);}
public static int Div(int v, float divisor) {return (int)((float)v / divisor);}
public static int DivAndRoundUp(int v, int divisor) {
int whole = v / divisor;
int partial = v % divisor == 0 ? 0 : 1;
return whole + partial;
}
public static int Mult(int v, float multiplier) {
float product = ((float)v * multiplier); // WORKAROUND (DotNet): (int)((float)v * multiplier) returns 0 for 100 and .01f
return (int)product;
}
public static byte[] To_bry(int v) {return Bry_.new_a7(To_str(v));}
public static final int
Min_value = Integer.MIN_VALUE
, Max_value = Integer.MAX_VALUE
, Max_value__31 = 2147483647
, Neg1 = -1
, Neg1_count = -1
;
}

View File

@ -1,115 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Int__tst {
@Test public void XtoStr_PadBgn() {
// tst_XtoStr_PadLeft_Zeroes(1 , 3, "001"); // pad
// tst_XtoStr_PadLeft_Zeroes(123 , 3, "123"); // no pad
// tst_XtoStr_PadLeft_Zeroes(1234 , 3, "1234"); // val exceeds pad; confirm noop
tst_XtoStr_PadLeft_Zeroes(1 , 3, "001"); // pad
tst_XtoStr_PadLeft_Zeroes(123 , 3, "123"); // no pad
tst_XtoStr_PadLeft_Zeroes(1234 , 3, "1234"); // val exceeds pad; confirm noop
tst_XtoStr_PadLeft_Zeroes(-1 , 3, "-01"); // negative
tst_XtoStr_PadLeft_Zeroes(-12 , 3, "-12"); // negative
tst_XtoStr_PadLeft_Zeroes(-123 , 3, "-123"); // negative
tst_XtoStr_PadLeft_Zeroes(-1234 , 3, "-1234"); // negative
} void tst_XtoStr_PadLeft_Zeroes(int val, int zeros, String expd) {Tfds.Eq(expd, Int_.To_str_pad_bgn_zero(val, zeros));}
@Test public void parseOr_() {
tst_ParseOr("", -1); // empty
tst_ParseOr("123", 123); // single
tst_ParseOr("1a", -1); // fail
} void tst_ParseOr(String raw, int expd) {Tfds.Eq(expd, Int_.parse_or(raw, -1));}
@Test public void Between() {
tst_Between(1, 0, 2, true); // simple true
tst_Between(3, 0, 2, false); // simple false
tst_Between(0, 0, 2, true); // bgn true
tst_Between(2, 0, 2, true); // end true
} void tst_Between(int val, int lhs, int rhs, boolean expd) {Tfds.Eq(expd, Int_.Between(val, lhs, rhs));}
@Test public void Xto_fmt() {
tst_XtoStr_fmt(1, "1");
tst_XtoStr_fmt(1000, "1,000");
} void tst_XtoStr_fmt(int v, String expd) {Tfds.Eq(expd, Int_.To_str_fmt(v, "#,###"));}
@Test public void AryRng() {
tst_AryRng(1, 3, Int_.Ary(1, 2, 3));
} void tst_AryRng(int bgn, int end, int[] expd) {Tfds.Eq_ary(expd, Int_.AryRng(bgn, end));}
@Test public void Log10_pos() {
tst_Log10(0, 0);
tst_Log10(1, 0);
tst_Log10(9, 0);
tst_Log10(10, 1);
tst_Log10(100, 2);
tst_Log10(1000000, 6);
tst_Log10(1000000000, 9);
tst_Log10(Int_.Max_value, 9);
}
@Test public void Log10_neg() {
tst_Log10(-1, 0);
tst_Log10(-10, -1);
tst_Log10(-100, -2);
tst_Log10(-1000000, -6);
tst_Log10(-1000000000, -9);
tst_Log10(Int_.Min_value, -9);
tst_Log10(Int_.Min_value + 1, -9);
}
void tst_Log10(int val, int expd) {Tfds.Eq(expd, Int_.Log10(val));}
@Test public void DigitCount() {
tst_DigitCount(0, 1);
tst_DigitCount(9, 1);
tst_DigitCount(100, 3);
tst_DigitCount(-1, 2);
tst_DigitCount(-100, 4);
} void tst_DigitCount(int val, int expd) {Tfds.Eq(expd, Int_.DigitCount(val), Int_.To_str(val));}
@Test public void Log10() {
tst_Log10( 0, 0);
tst_Log10( 1, 0);
tst_Log10( 2, 0);
tst_Log10( 10, 1);
tst_Log10( 12, 1);
tst_Log10( 100, 2);
tst_Log10( 123, 2);
tst_Log10( 1000, 3);
tst_Log10( 1234, 3);
tst_Log10( 10000, 4);
tst_Log10( 12345, 4);
tst_Log10( 100000, 5);
tst_Log10( 123456, 5);
tst_Log10( 1000000, 6);
tst_Log10( 1234567, 6);
tst_Log10( 10000000, 7);
tst_Log10( 12345678, 7);
tst_Log10( 100000000, 8);
tst_Log10( 123456789, 8);
tst_Log10( 1000000000, 9);
tst_Log10( 1234567890, 9);
tst_Log10(Int_.Max_value, 9);
}
@Test public void Xto_int_hex_tst() {
Xto_int_hex("007C", 124);
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.To_int_hex(Bry_.new_a7(raw)));}
@Test public void Ary_parse() {
Ary_parse__tst("1,2,3" , 3, Int_.Ary_empty, 1, 2, 3);
Ary_parse__tst("123,321,213" , 3, Int_.Ary_empty, 123, 321, 213);
Ary_parse__tst(" 1, 2,3" , 3, Int_.Ary_empty, 1, 2, 3);
Ary_parse__tst("-1,+2,-3" , 3, Int_.Ary_empty, -1, 2, -3);
Ary_parse__tst(Int_.To_str(Int_.Min_value) , 1, Int_.Ary_empty, Int_.Min_value);
Ary_parse__tst(Int_.To_str(Int_.Max_value) , 1, Int_.Ary_empty, Int_.Max_value);
Ary_parse__tst("1,2" , 1, Int_.Ary_empty);
Ary_parse__tst("1" , 2, Int_.Ary_empty);
Ary_parse__tst("a" , 1, Int_.Ary_empty);
Ary_parse__tst("1-2," , 1, Int_.Ary_empty);
}
void Ary_parse__tst(String raw, int reqd_len, int[] or, int... expd) {Tfds.Eq_ary(expd, Int_.Ary_parse(raw, reqd_len, or));}
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.By_hex_bry(Bry_.new_a7(raw)));}
}

View File

@ -0,0 +1,172 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*;
public class Int_ary_ {//RF:DATE:2017-10-09
public static int[] Empty = new int[0];
public static int[] New(int... v) {return v;}
public static void Copy_to(int[] src, int src_len, int[] trg) {
for (int i = 0; i < src_len; ++i)
trg[i] = src[i];
}
public static int[] Mid(int[] src, int bgn, int end) {
int len = end - bgn + 1;
int[] rv = new int[len];
for (int i = 0; i < len; i++) {
rv[i] = src[i + bgn];
}
return rv;
}
public static String To_str(String spr, int... ary) {
Bry_bfr bfr = Bry_bfr_.New();
int len = ary.length;
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_str_u8(spr);
int itm = ary[i];
bfr.Add_int_variable(itm);
}
return bfr.To_str_and_clear();
}
public static int[] Parse(String raw, String spr) {
String[] ary = String_.Split(raw, spr);
int len = ary.length;
int[] rv = new int[len];
for (int i = 0; i < len; i++)
rv[i] = Int_.Parse(ary[i]);
return rv;
}
// parses to a reqd len; EX: "1" -> "[1, 0]"
public static int[] Parse(String raw_str, int reqd_len, int[] or) {
byte[] raw_bry = Bry_.new_a7(raw_str);
int raw_bry_len = raw_bry.length;
int[] rv = new int[reqd_len];
int cur_val = 0, cur_mult = 1, cur_idx = reqd_len - 1; boolean signed = false;
for (int i = raw_bry_len - 1; i > -2; i--) {
byte b = i == -1 ? Byte_ascii.Comma : raw_bry[i];
switch (b) {
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
if (signed) return or;
cur_val += (b - Byte_ascii.Num_0) * cur_mult;
cur_mult *= 10;
break;
case Byte_ascii.Space: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Tab:
break;
case Byte_ascii.Comma:
if (cur_idx < 0) return or;
rv[cur_idx--] = cur_val;
cur_val = 0; cur_mult = 1;
signed = false;
break;
case Byte_ascii.Dash:
if (signed) return or;
cur_val *= -1;
signed = true;
break;
case Byte_ascii.Plus: // noop; all values positive by default
if (signed) return or;
signed = true;
break;
default:
return or;
}
}
return cur_idx == -1 ? rv : or; // cur_idx == -1 checks for unfilled; EX: Ary_parse("1,2", 3, null) is unfilled
}
// optimizes parse
public static int[] Parse_or(byte[] src, int[] or) {
try {
if (Bry_.Len_eq_0(src)) return or; // null, "" should return [0]
int raw_len = src.length;
int[] rv = null; int rv_idx = 0, rv_len = 0;
int pos = 0;
int num_bgn = -1, num_end = -1;
boolean itm_done = false, itm_is_rng = false;
int rng_bgn = Int_.Min_value;
while (true) {
boolean pos_is_last = pos == raw_len;
if ( itm_done
|| pos_is_last
) {
if (num_bgn == -1) return or; // empty itm; EX: "1,"; "1,,2"
int num = Bry_.To_int_or(src, num_bgn, num_end, Int_.Min_value);
if (num == Int_.Min_value) return or; // not a number; parse failed
if (rv_len == 0) { // rv not init'd
rv_len = (raw_len / 2) + 1; // default rv_len to len of String / 2; + 1 to avoid fraction rounding down
rv = new int[rv_len];
}
int add_len = 1;
if (itm_is_rng) {
add_len = num - rng_bgn + List_adp_.Base1;
if (add_len == 0) return or; // bgn >= end;
}
if (add_len + rv_idx > rv_len) { // ary out of space; resize
rv_len = (add_len + rv_idx) * 2;
rv = (int[])Array_.Resize(rv, rv_len);
}
if (itm_is_rng) {
for (int i = rng_bgn; i <= num; i++)
rv[rv_idx++] = i;
}
else {
rv[rv_idx++] = num;
}
num_bgn = num_end = -1;
itm_done = itm_is_rng = false;
rng_bgn = Int_.Min_value;
if (pos_is_last) break;
}
byte b = src[pos];
switch (b) {
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
if (num_bgn == -1) // num_bgn not set
num_bgn = pos;
num_end = pos + 1; // num_end is always after pos; EX: "9": num_end = 1; "98,7": num_end=2
break;
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: // NOTE: parseNumList replaces ws with '', so "1 1" will become "11"
break;
case Byte_ascii.Comma:
if (pos == raw_len -1) return or; // eos; EX: "1,"
if (num_bgn == -1) return or; // empty itm; EX: ","; "1,,2"
itm_done = true;
break;
case Byte_ascii.Dash:
if (pos == raw_len -1) return or; // eos; EX: "1-"
if (num_bgn == -1) return or; // no rng_bgn; EX: "-2"
rng_bgn = Bry_.To_int_or(src, num_bgn, pos, Int_.Min_value);
if (rng_bgn == Int_.Min_value) return or;
num_bgn = -1;
itm_is_rng = true;
break;
default:
return or;
}
++pos;
}
return (rv_idx == rv_len) // on the off-chance that rv_len == rv_idx; EX: "1"
? rv
: (int[])Array_.Resize(rv, rv_idx);
} catch (Exception e) {Err_.Noop(e); return or;}
}
}

View File

@ -0,0 +1,58 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class Int_ary__tst {
private Int_ary__fxt fxt = new Int_ary__fxt();
@Test public void Parse() {
fxt.Test__Parse("1,2,3" , 3, Int_ary_.Empty, 1, 2, 3);
fxt.Test__Parse("123,321,213" , 3, Int_ary_.Empty, 123, 321, 213);
fxt.Test__Parse(" 1, 2,3" , 3, Int_ary_.Empty, 1, 2, 3);
fxt.Test__Parse("-1,+2,-3" , 3, Int_ary_.Empty, -1, 2, -3);
fxt.Test__Parse(Int_.To_str(Int_.Min_value) , 1, Int_ary_.Empty, Int_.Min_value);
fxt.Test__Parse(Int_.To_str(Int_.Max_value) , 1, Int_ary_.Empty, Int_.Max_value);
fxt.Test__Parse("1,2" , 1, Int_ary_.Empty);
fxt.Test__Parse("1" , 2, Int_ary_.Empty);
fxt.Test__Parse("a" , 1, Int_ary_.Empty);
fxt.Test__Parse("1-2," , 1, Int_ary_.Empty);
}
@Test public void Parse_list_or_() {
fxt.Test__Parse_or("1", 1);
fxt.Test__Parse_or("123", 123);
fxt.Test__Parse_or("1,2,123", 1, 2, 123);
fxt.Test__Parse_or("1,2,12,123", 1, 2, 12, 123);
fxt.Test__Parse_or("1-5", 1, 2, 3, 4, 5);
fxt.Test__Parse_or("1-1", 1);
fxt.Test__Parse_or("1-3,7,11-13,21", 1, 2, 3, 7, 11, 12, 13, 21);
fxt.Test__Parse_or__empty("1 2"); // NOTE: MW would gen 12; treat as invalid
fxt.Test__Parse_or__empty("1,"); // eos
fxt.Test__Parse_or__empty("1,,2"); // empty comma
fxt.Test__Parse_or__empty("1-"); // eos
fxt.Test__Parse_or__empty("3-1"); // bgn > end
fxt.Test__Parse_or__empty("1,a,2");
fxt.Test__Parse_or__empty("a-1,2");
fxt.Test__Parse_or__empty("-1"); // no rng bgn
}
}
class Int_ary__fxt {
public void Test__Parse_or__empty(String raw) {Tfds.Eq_ary(Int_ary_.Empty, Int_ary_.Parse_or(Bry_.new_a7(raw), Int_ary_.Empty));}
public void Test__Parse_or(String raw, int... expd) {Tfds.Eq_ary(expd, Int_ary_.Parse_or(Bry_.new_a7(raw), Int_ary_.Empty));}
public void Test__Parse(String raw, int reqd_len, int[] or, int... expd) {Gftest.Eq__ary(expd, Int_ary_.Parse(raw, reqd_len, or), "failed to parse: {0}", raw);}
}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public @interface Internal {}

View File

@ -1,22 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*; import gplx.core.ios.*; /*IoItmFil, IoItmDir..*/ import gplx.core.ios.streams.*; import gplx.core.ios.loaders.*;
import gplx.core.primitives.*;
import gplx.core.ios.*; /*IoItmFil, IoItmDir..*/ import gplx.core.ios.streams.*; import gplx.core.ios.loaders.*; import gplx.core.ios.atrs.*;
public class Io_mgr implements Gfo_evt_mgr_owner { // exists primarily to gather all cmds under gplx namespace; otherwise need to use gplx.core.ios whenever copying/deleting file
public Io_mgr() {evt_mgr = new Gfo_evt_mgr(this);}
public Gfo_evt_mgr Evt_mgr() {return evt_mgr;} private final Gfo_evt_mgr evt_mgr;
@ -59,6 +58,7 @@ public class Io_mgr implements Gfo_evt_mgr_owner { // exists primarily to gather
}
public Io_url[] QueryDir_fils(Io_url dir) {return QueryDir_args(dir).ExecAsUrlAry();}
public IoEngine_xrg_queryDir QueryDir_args(Io_url dir) {return IoEngine_xrg_queryDir.new_(dir);}
public Io_itm_atr_req Query_itm_atrs(Io_url url, Io_itm_atr_req req) {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).Query_itm_atrs(url, req);}
public void DeleteDirSubs(Io_url url) {IoEngine_xrg_deleteDir.new_(url).Exec();}
public IoEngine_xrg_deleteDir DeleteDir_cmd(Io_url url) {return IoEngine_xrg_deleteDir.new_(url);}
public void DeleteDirDeep(Io_url url) {IoEngine_xrg_deleteDir.new_(url).Recur_().Exec();}
@ -151,11 +151,13 @@ public class Io_mgr implements Gfo_evt_mgr_owner { // exists primarily to gather
}
public boolean DownloadFil(String src, Io_url trg) {return IoEngine_xrg_downloadFil.new_(src, trg).Exec();}
public IoEngine_xrg_downloadFil DownloadFil_args(String src, Io_url trg) {return IoEngine_xrg_downloadFil.new_(src, trg);}
public boolean Query_read_only(Io_url url, int read_only_type) {return IoEngineUtl.Query_read_only(IoEnginePool.Instance.Get_by(url.Info().EngineKey()), url, read_only_type);}
public static final Io_mgr Instance = new Io_mgr();
public static final int Len_kb = 1024, Len_mb = 1048576, Len_gb = 1073741824, Len_gb_2 = 2147483647;
public static final long Len_mb_long = Len_mb;
public static final long Len_null = -1;
public static final String Evt__fil_created = "fil_created";
public static final int Read_only__basic__file = 1, Read_only__basic__file_and_dirs = 2, Read_only__perms__file = 3;
}
class Io_mgr_ {
public static int Delete_dir_empty(Io_url url) {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*; import gplx.core.ios.*; /*IoUrlInfo*/ import gplx.core.envs.*; import gplx.langs.htmls.*; import gplx.core.interfaces.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.ios.*; /*IoUrlInfo_*/ import gplx.core.stores.*; import gplx.core.envs.*;
@ -47,6 +45,7 @@ public class Io_url_ {
public static Io_url lnx_dir_(String raw) {return new_inf_(EndsWith_or_add(raw, Op_sys.Lnx.Fsys_dir_spr_str()), IoUrlInfo_.Lnx);}
public static Io_url new_fil_(String raw) {return new_any_(raw);}
public static Io_url new_dir_(String raw) {return new_any_(raw);} // NOTE: for now, same as new_fil; stack overflow when doing new_dir
public static Io_url new_dir_infer(String raw) {return Op_sys.Cur().Tid_is_wnt() ? wnt_dir_(raw) : lnx_dir_(raw);}
public static Io_url new_any_(String raw) {return new_inf_(raw, IoUrlInfoRegy.Instance.Match(raw));}
public static Io_url new_inf_(String raw, IoUrlInfo info) {return String_.Eq(raw, "") ? Io_url_.Empty : new Io_url(raw, info);}
public static Io_url New__http_or_fail(String raw) {return New__http_or_fail(Bry_.new_u8(raw));}

View File

@ -1,32 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Io_url__tst {
@Before public void init() {fxt.Clear();} private final Io_url__fxt fxt = new Io_url__fxt();
@Test public void Basic__lnx() {fxt.Test__New__http_or_null(Bool_.N, "file:///C:/a.txt", "C:/a.txt");}
@Test public void Basic__wnt() {fxt.Test__New__http_or_null(Bool_.Y, "file:///C:/a.txt", "C:\\a.txt");}
@Test public void Null() {fxt.Test__New__http_or_null(Bool_.N, "C:/a.txt", null);}
}
class Io_url__fxt {
public void Clear() {Io_mgr.Instance.InitEngine_mem();}
public void Test__New__http_or_null(boolean os_is_wnt, String raw, String expd) {
Op_sys.Cur_(os_is_wnt ? Op_sys.Tid_wnt : Op_sys.Tid_lnx);
Gftest.Eq__obj_or_null(expd, Io_url_.New__http_or_null(raw));
}
}
package gplx;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Io_url__tst {
@Before public void init() {fxt.Clear();} private final Io_url__fxt fxt = new Io_url__fxt();
@Test public void Basic__lnx() {fxt.Test__New__http_or_null(Bool_.N, "file:///C:/a.txt", "C:/a.txt");}
@Test public void Basic__wnt() {fxt.Test__New__http_or_null(Bool_.Y, "file:///C:/a.txt", "C:\\a.txt");}
@Test public void Null() {fxt.Test__New__http_or_null(Bool_.N, "C:/a.txt", null);}
}
class Io_url__fxt {
public void Clear() {Io_mgr.Instance.InitEngine_mem();}
public void Test__New__http_or_null(boolean os_is_wnt, String raw, String expd) {
int curTid = Op_sys.Cur().Tid();
Op_sys.Cur_(os_is_wnt ? Op_sys.Tid_wnt : Op_sys.Tid_lnx);
Gftest.Eq__obj_or_null(expd, Io_url_.New__http_or_null(raw));
Op_sys.Cur_(curTid);
}
}

View File

@ -1,32 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx;
public class Keyval implements To_str_able {
@gplx.Internal protected Keyval(int key_tid, Object key, Object val) {this.key_tid = key_tid; this.key = key; this.val = val;}
public String Key() {return Object_.Xto_str_strict_or_null(key);}
public Object Key_as_obj() {return key;} private Object key;
public int Key_tid() {return key_tid;} private int key_tid;
public Object Val() {return val;} private Object val;
public String Val_to_str_or_empty() {return Object_.Xto_str_strict_or_empty(val);}
public String Val_to_str_or_null() {return Object_.Xto_str_strict_or_null(val);}
public byte[] Val_to_bry() {return Bry_.new_u8(Object_.Xto_str_strict_or_null(val));}
public Keyval Key_(Object v) {this.key = v; return this;}
public Keyval Val_(Object v) {this.val = v; return this;}
public String To_str() {return Key() + "=" + Object_.Xto_str_strict_or_null_mark(val);}
@Override public String toString() {return To_str();}
}

View File

@ -1,103 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx;
import gplx.core.strings.*;
public class Keyval_ {
public static final Keyval[] Ary_empty = new Keyval[0];
public static Keyval[] Ary(Keyval... ary) {return ary;}
public static Keyval[] Ary_cast_(Object o) {
try {return (Keyval[])o;}
catch (Exception e) {throw Err_.new_cast(e, Keyval.class, o);}
}
public static Keyval[] Ary_insert(Keyval[] orig, boolean insert_at_end, Keyval... vals) {
int orig_len = orig.length, vals_len = vals.length;
int rv_len = orig_len + vals_len;
Keyval[] rv = new Keyval[rv_len];
int vals_bgn = 0 , vals_end = vals_len;
int orig_bgn = vals_len , orig_end = rv_len;
if (insert_at_end) {
orig_bgn = 0 ; orig_end = orig_len;
vals_bgn = orig_len ; vals_end = rv_len;
}
for (int i = orig_bgn; i < orig_end; i++)
rv[i] = orig[i - orig_bgn];
for (int i = vals_bgn; i < vals_end; i++)
rv[i] = vals[i - vals_bgn];
return rv;
}
public static String Ary_to_str(Keyval... ary) {
String_bldr sb = String_bldr_.new_();
int len = ary.length;
for (int i = 0; i < len; i++) {
Keyval itm = ary[i];
sb.Add(itm.Key()).Add("=");
Object itm_val = itm.Val();
if (Type_adp_.Eq_typeSafe(itm_val, Keyval[].class))
sb.Add(Ary_to_str((Keyval[])itm_val));
else
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
sb.Add_char_nl();
}
return sb.To_str();
}
public static Object Ary_get_by_key_or_null(Keyval[] ary, String key) {
int len = ary.length;
for (int i = 0; i < len; i++) {
Keyval kv = ary[i];
if (String_.Eq(kv.Key(), key)) return kv.Val();
}
return null;
}
public static String Ary__to_str__nest(Keyval... ary) {
Bry_bfr bfr = Bry_bfr_.New();
Ary__to_str__nest(bfr, 0, ary);
return bfr.To_str_and_clear();
}
private static void Ary__to_str__nest(Bry_bfr bfr, int indent, Keyval[] ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Keyval itm = ary[i];
if (indent > 0)
bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2); // add indent : " "
bfr.Add_str_u8(Object_.Xto_str_strict_or_empty(itm.Key())).Add_byte_eq();// add key + eq : "key="
Object val = itm.Val();
if (val == null)
bfr.Add_str_a7(String_.Null_mark);
else {
Class<?> val_type = Type_adp_.ClassOf_obj(val);
if (Type_adp_.Eq(val_type, Keyval[].class)) { // val is Keyval[]; recurse
bfr.Add_byte_nl(); // add nl : "\n"
Ary__to_str__nest(bfr, indent + 1, (Keyval[])val);
continue; // don't add \n below
}
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
boolean val_as_bool = Bool_.cast(val);
bfr.Add(val_as_bool ? Bool_.True_bry : Bool_.False_bry); // add "true" or "false"; don't call toString
}
else
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(val)); // call toString()
}
bfr.Add_byte_nl();
}
}
public static Keyval as_(Object obj) {return obj instanceof Keyval ? (Keyval)obj : null;}
public static Keyval new_(String key) {return new Keyval(Type_adp_.Tid__str, key, key);}
public static Keyval new_(String key, Object val) {return new Keyval(Type_adp_.Tid__str, key, val);}
public static Keyval int_(int key, Object val) {return new Keyval(Type_adp_.Tid__int, key, val);}
public static Keyval obj_(Object key, Object val) {return new Keyval(Type_adp_.Tid__obj, key, val);}
}

View File

@ -0,0 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Keyval implements To_str_able {
@gplx.Internal protected Keyval(int key_tid, Object key, Object val) {this.key_tid = key_tid; this.key = key; this.val = val;}
public String Key() {return Object_.Xto_str_strict_or_null(key);}
public Object Key_as_obj() {return key;} private Object key;
public int Key_tid() {return key_tid;} private int key_tid;
public Object Val() {return val;} private Object val;
public String Val_to_str_or_empty() {return Object_.Xto_str_strict_or_empty(val);}
public String Val_to_str_or_null() {return Object_.Xto_str_strict_or_null(val);}
public byte[] Val_to_bry() {return Bry_.new_u8(Object_.Xto_str_strict_or_null(val));}
public Keyval Key_(Object v) {this.key = v; return this;}
public Keyval Val_(Object v) {this.val = v; return this;}
public String To_str() {return Key() + "=" + Object_.Xto_str_strict_or_null_mark(val);}
@Override public String toString() {return To_str();}
}

View File

@ -0,0 +1,133 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*;
public class Keyval_ {
public static final Keyval[] Ary_empty = new Keyval[0];
public static Keyval[] Ary(Keyval... ary) {return ary;}
public static Keyval[] Ary_cast_(Object o) {
try {return (Keyval[])o;}
catch (Exception e) {throw Err_.new_cast(e, Keyval.class, o);}
}
public static Keyval[] Ary_insert(Keyval[] orig, boolean insert_at_end, Keyval... vals) {
int orig_len = orig.length, vals_len = vals.length;
int rv_len = orig_len + vals_len;
Keyval[] rv = new Keyval[rv_len];
int vals_bgn = 0 , vals_end = vals_len;
int orig_bgn = vals_len , orig_end = rv_len;
if (insert_at_end) {
orig_bgn = 0 ; orig_end = orig_len;
vals_bgn = orig_len ; vals_end = rv_len;
}
for (int i = orig_bgn; i < orig_end; i++)
rv[i] = orig[i - orig_bgn];
for (int i = vals_bgn; i < vals_end; i++)
rv[i] = vals[i - vals_bgn];
return rv;
}
public static String Ary_to_str(Keyval... ary) {
String_bldr sb = String_bldr_.new_();
int len = ary.length;
for (int i = 0; i < len; i++) {
Keyval itm = ary[i];
if (itm == null) {
sb.Add("<<NULL>>");
continue;
}
sb.Add(itm.Key()).Add("=");
Object itm_val = itm.Val();
if (Type_.Eq_by_obj(itm_val, Keyval[].class))
sb.Add(Ary_to_str((Keyval[])itm_val));
else
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
sb.Add_char_nl();
}
return sb.To_str();
}
public static Object Ary_get_by_key_or_null(Keyval[] ary, String key) {
int len = ary.length;
for (int i = 0; i < len; i++) {
Keyval kv = ary[i];
if (String_.Eq(kv.Key(), key)) return kv.Val();
}
return null;
}
public static String Ary__to_str__nest(Keyval... ary) {
Bry_bfr bfr = Bry_bfr_.New();
Ary__to_str__nest__ary(bfr, 0, true, ary);
return bfr.To_str_and_clear();
}
public static Object[] Ary__to_objary__val(Keyval[] ary) {
int ary_len = ary.length;
Object[] rv = new Object[ary_len];
for (int i = 0; i < ary_len; i++) {
rv[i] = ary[i].Val();
}
return rv;
}
private static void Ary__to_str__nest__ary(Bry_bfr bfr, int indent, boolean is_kv, Object[] ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Ary__to_str__nest__val(bfr, indent, is_kv, i, ary[i]);
}
}
private static void Ary__to_str__nest__val(Bry_bfr bfr, int indent, boolean is_kv, int idx, Object val) {
if (indent > 0)
bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2); // add indent; EX: " "
String key = null;
if (is_kv) {
Keyval kv = (Keyval)val;
key = Object_.Xto_str_strict_or_empty(kv.Key());
val = kv.Val();
}
else {
key = Int_.To_str(idx + 1);
}
bfr.Add_str_u8(key).Add_byte_eq(); // add key + eq : "key="
if (val == null)
bfr.Add_str_a7(String_.Null_mark);
else {
Class<?> val_type = Type_.Type_by_obj(val);
if (Type_.Eq(val_type, Keyval[].class)) { // val is Keyval[]; recurse
bfr.Add_byte_nl(); // add nl: "\n"
Ary__to_str__nest__ary(bfr, indent + 1, true, (Keyval[])val);
return; // don't add \n below
}
else if (Type_.Eq(val_type, Keyval.class)) { // val is Keyval; recurse
bfr.Add_byte_nl(); // add nl: "\n"
Ary__to_str__nest__val(bfr, indent + 1, true, 1, (Keyval)val);
return; // don't add \n below
}
else if (Type_.Eq(val_type, Object[].class)) { // val is Object[]
bfr.Add_byte_nl();
Ary__to_str__nest__ary(bfr, indent + 1, false, (Object[])val);
return; // don't add \n below
}
else if (Type_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
boolean val_as_bool = Bool_.Cast(val);
bfr.Add(val_as_bool ? Bool_.True_bry : Bool_.False_bry); // add "true" or "false"; don't call toString
}
else
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(val)); // call toString()
}
bfr.Add_byte_nl();
}
public static Keyval as_(Object obj) {return obj instanceof Keyval ? (Keyval)obj : null;}
public static Keyval new_(String key) {return new Keyval(Type_ids_.Id__str, key, key);}
public static Keyval new_(String key, Object val) {return new Keyval(Type_ids_.Id__str, key, val);}
public static Keyval int_(int key, Object val) {return new Keyval(Type_ids_.Id__int, key, val);}
public static Keyval obj_(Object key, Object val) {return new Keyval(Type_ids_.Id__obj, key, val);}
}

View File

@ -1,24 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Keyval_hash {
private final Ordered_hash hash = Ordered_hash_.New();
private final Ordered_hash hash = Ordered_hash_.New();
public int Count() {return hash.Count();}
public int Len() {return hash.Count();}
public Keyval_hash Clear() {hash.Clear(); return this;}
public boolean Has(String key) {return hash.Has(key);}
public Keyval Get_at(int i) {return (Keyval)hash.Get_at(i);}

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Keyval_list {

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.*; /*EnumerAble,ComparerAble*/

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.strings.*; import gplx.core.lists.*;

View File

@ -1,19 +1,17 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
@ -161,7 +159,7 @@ public class List_adp_tst {
list.Shuffle();
int hasMovedCount = 0;
for (int i = 0; i < list.Count(); i++) {
int val = Int_.cast(list.Get_at(i));
int val = Int_.Cast(list.Get_at(i));
if (val != i) hasMovedCount++;
}
Tfds.Eq_true(hasMovedCount > 0, "all documents have the same index"); // NOTE: may still fail occasionally (1%)

View File

@ -1,24 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
Copyright (C) 2012-2017 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Long_ {
public static final String Cls_val_name = "long";
public static final Class<?> Cls_ref_type = Long.class;
public static final Class<?> Cls_ref_type = Long.class;
public static final int Log10Ary_len = 21;
public static long[] Log10Ary = new long[]
{ 1, 10, 100, 1000, 10000
@ -42,7 +40,7 @@ public class Long_ {
if (raw == null || rawLen == 0) return or;
long rv = 0, factor = 1; int tmp = 0;
for (int i = rawLen; i > 0; i--) {
tmp = Char_.To_int_or(String_.CharAt(raw, i - 1), Int_.Min_value);
tmp = Char_.To_digit_or(String_.CharAt(raw, i - 1), Int_.Min_value);
if (tmp == Int_.Min_value) return or;
rv += (tmp * factor);
factor *= 10;
@ -55,7 +53,7 @@ public class Long_ {
else if (lhs < rhs) return CompareAble_.Less;
else return CompareAble_.More;
}
public static int FindIdx(long[] ary, long find_val) {
private static int FindIdx(long[] ary, long find_val) {
int ary_len = ary.length;
int adj = 1;
int prv_pos = 0;

Some files were not shown because too many files have changed in this diff Show More