mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-13 12:54:14 +00:00
Compare commits
1096 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a4abd8f75 | ||
|
|
17a3b4e7b3 | ||
|
|
659bca3660 | ||
|
|
8684783139 | ||
|
|
7e53c8462d | ||
|
|
559503786b | ||
|
|
e117823e60 | ||
|
|
ff0f92b950 | ||
|
|
4187dc4a76 | ||
|
|
1a6a203cfd | ||
|
|
814e85ea70 | ||
|
|
0ef5058cfd | ||
|
|
aeef520228 | ||
|
|
4a7bd19056 | ||
|
|
7d357540c7 | ||
|
|
b1c52aa2b2 | ||
|
|
845253af79 | ||
|
|
541f5f6524 | ||
|
|
067e62dd03 | ||
|
|
19a315b8cd | ||
|
|
5c3d6a173b | ||
|
|
c801e3a20b | ||
|
|
59d8a42b22 | ||
|
|
567e03dc1d | ||
|
|
7550894dda | ||
|
|
caad4145d5 | ||
|
|
de841f8ff2 | ||
|
|
5f2e9c7514 | ||
|
|
d3896bf547 | ||
|
|
316c6c6a58 | ||
|
|
72051f4ce9 | ||
|
|
f19228c886 | ||
|
|
1b6324938c | ||
|
|
9b4ea48753 | ||
|
|
6ed7659b4d | ||
|
|
1eea3682ca | ||
|
|
4f87d1a195 | ||
|
|
ea9b592cfd | ||
|
|
3c9fd50ddc | ||
|
|
619d2f9844 | ||
|
|
bdae819908 | ||
|
|
f122a8d8a3 | ||
|
|
174e93cbfa | ||
|
|
0aced904a5 | ||
|
|
dc374fa7fc | ||
|
|
95e833d70c | ||
|
|
afed865c84 | ||
|
|
7b6b3ed09a | ||
|
|
a0c0b5b2fd | ||
|
|
062d308128 | ||
|
|
ad607d952c | ||
|
|
6592eaf8de | ||
|
|
45adc036a2 | ||
|
|
6b2e120fc1 | ||
|
|
7c0a8c5064 | ||
|
|
35475d631c | ||
|
|
efe415d3a3 | ||
|
|
97b1055b4e | ||
|
|
b51d224f09 | ||
|
|
b87e4d07cb | ||
|
|
b4516f5060 | ||
|
|
49e18a2255 | ||
|
|
026288f809 | ||
|
|
1103674d88 | ||
|
|
27756f8056 | ||
|
|
398a1c854a | ||
|
|
35f2027b20 | ||
|
|
be072de8d9 | ||
|
|
f760fd9cd0 | ||
|
|
3d5ec47aa8 | ||
|
|
53762288d7 | ||
|
|
7a0247417d | ||
|
|
0cdfa0992c | ||
|
|
dc66b926d3 | ||
|
|
8c7c9f88ff | ||
|
|
94b757682a | ||
|
|
1ebc9d3488 | ||
|
|
654810d56c | ||
|
|
b551c1875b | ||
|
|
ba1d4e0b7c | ||
|
|
a2fe75f402 | ||
|
|
a6331f5c89 | ||
|
|
43866163b9 | ||
|
|
49f8d4b000 | ||
|
|
994d405a26 | ||
|
|
04c499ce3e | ||
|
|
ebe82bea6a | ||
|
|
a9367eaca8 | ||
|
|
ee68162a4a | ||
|
|
6663b769d5 | ||
|
|
2dab6a90be | ||
|
|
b0e02979ac | ||
|
|
f9cf49c160 | ||
|
|
0d917bccc7 | ||
|
|
d1345bf724 | ||
|
|
3d74406a3e | ||
|
|
a6b128422e | ||
|
|
0c3cb1ba3d | ||
|
|
105446f5ca | ||
|
|
db73b4302d | ||
|
|
bd71db3ed6 | ||
|
|
a4b5f5de5d | ||
|
|
ecbcf1e707 | ||
|
|
7b00918941 | ||
|
|
8807dcfbeb | ||
|
|
a6ac592212 | ||
|
|
b05e3cd188 | ||
|
|
9c8650a4d9 | ||
|
|
73a56ffab3 | ||
|
|
e9e5724a2a | ||
|
|
c3c9d4ad1e | ||
|
|
5a35f3b05b | ||
|
|
7ad1291768 | ||
|
|
17d7a7ebed | ||
|
|
9809dfd6c7 | ||
|
|
b56673c56e | ||
|
|
8629292960 | ||
|
|
bc30fd8526 | ||
|
|
c47820b1a9 | ||
|
|
292726bd13 | ||
|
|
23eefef91a | ||
|
|
89d0ba1271 | ||
|
|
b2a6f7bbf1 | ||
|
|
ed010f76a8 | ||
|
|
bc65e9fa61 | ||
|
|
db01707032 | ||
|
|
7b3d6e5271 | ||
|
|
c3d524c493 | ||
|
|
f33f9c4ae9 | ||
|
|
02f9b9dae3 | ||
|
|
891cf53228 | ||
|
|
f73164d55e | ||
|
|
3355d03c44 | ||
|
|
bae9ba9e7a | ||
|
|
a5cbc4ede9 | ||
|
|
da87b17902 | ||
|
|
bfce37f0ba | ||
|
|
3e9bc6d93a | ||
|
|
775bff3bac | ||
|
|
bc2beba148 | ||
|
|
af337493af | ||
|
|
ca8afe657e | ||
|
|
57ad8e459a | ||
|
|
763c7b52b7 | ||
|
|
9cb60f2540 | ||
|
|
c6bca54d90 | ||
|
|
374de22699 | ||
|
|
2dee585fc1 | ||
|
|
898701131d | ||
|
|
c1b8911a7d | ||
|
|
f384d40e56 | ||
|
|
278d55cd62 | ||
|
|
11447820f2 | ||
|
|
5e2ce08abb | ||
|
|
5aec368f8d | ||
|
|
5f1d9c6f15 | ||
|
|
e0de779e1d | ||
|
|
bc5947507f | ||
|
|
7e2f832c33 | ||
|
|
357c725798 | ||
|
|
694c3bb133 | ||
|
|
3285a3c87d | ||
|
|
520a73537f | ||
|
|
9d8ab5d206 | ||
|
|
d49eda32a8 | ||
|
|
eca943d7a6 | ||
|
|
a7114ecb5a | ||
|
|
ad5613265d | ||
|
|
734206fbd6 | ||
|
|
605038d8c6 | ||
|
|
ae484a8234 | ||
|
|
cb3b78895c | ||
|
|
38f670649b | ||
|
|
9e97a7ea9f | ||
|
|
966b0eed59 | ||
|
|
59985227fb | ||
|
|
c307946bd2 | ||
|
|
b2864f8c6a | ||
|
|
41a521850b | ||
|
|
20c1e32ff2 | ||
|
|
90363fb9fa | ||
|
|
46aab7944d | ||
|
|
5ddf50d5b5 | ||
|
|
e2aa551feb | ||
|
|
11810c4fff | ||
|
|
e9024e057f | ||
|
|
9483b56121 | ||
|
|
8653e665cc | ||
|
|
dbdc558ed5 | ||
|
|
bdb1945d4f | ||
|
|
af9d6c3a92 | ||
|
|
de1b9a3991 | ||
|
|
d908d4f8b5 | ||
|
|
79bdab7946 | ||
|
|
0f8dd4a1f8 | ||
|
|
cb3f915cb2 | ||
|
|
a453ebd4cb | ||
|
|
7971f71dc3 | ||
|
|
f8bbdb1727 | ||
|
|
bc976ac300 | ||
|
|
c67970b5b9 | ||
|
|
eac055214c | ||
|
|
866debd51d | ||
|
|
9f0cfc27bb | ||
|
|
a10c2cd1dc | ||
|
|
4955748f6d | ||
|
|
73eb42c0ba | ||
|
|
fca507568f | ||
|
|
1bffdadbaf | ||
|
|
bb86b026fe | ||
|
|
88e0398696 | ||
|
|
e82641f341 | ||
|
|
597c138b56 | ||
|
|
fdd05c99a9 | ||
|
|
742e61b718 | ||
|
|
1caeea5705 | ||
|
|
24ea3793a2 | ||
|
|
ec9b3ee442 | ||
|
|
ea28172885 | ||
|
|
d362597d8f | ||
|
|
924b5fd17b | ||
|
|
b980351989 | ||
|
|
518605ece1 | ||
|
|
115ae8139e | ||
|
|
b17cb05edf | ||
|
|
a082e3cf5d | ||
|
|
5b2db5badf | ||
|
|
32cb332b18 | ||
|
|
23cbefdeb8 | ||
|
|
620f196d4e | ||
|
|
75105c8397 | ||
|
|
b67e528088 | ||
|
|
9e302b19b5 | ||
|
|
ce5fd232d8 | ||
|
|
cda21d987f | ||
|
|
8f029f479b | ||
|
|
d61fd33a87 | ||
|
|
1873c7c5f8 | ||
|
|
88dfc857bd | ||
|
|
9bc0c2c75d | ||
|
|
2598dee844 | ||
|
|
42842f0bcc | ||
|
|
a7029f8cf1 | ||
|
|
8c55d2406a | ||
|
|
0295d816fd | ||
|
|
80f4a0fbf5 | ||
|
|
227f7943ff | ||
|
|
7f3ab5f381 | ||
|
|
5ac949e8c0 | ||
|
|
1e254caa79 | ||
|
|
41e9fc1287 | ||
|
|
be5c65c24c | ||
|
|
87163c5104 | ||
|
|
e213d123f8 | ||
|
|
dee491a684 | ||
|
|
2ef6211e87 | ||
|
|
6449368800 | ||
|
|
06afe7a7b1 | ||
|
|
6559a2b858 | ||
|
|
a421703fb1 | ||
|
|
a94279c922 | ||
|
|
19c50b94be | ||
|
|
55a4891064 | ||
|
|
b350d95206 | ||
|
|
f5abfa11da | ||
|
|
66039fc9b3 | ||
|
|
a1da02a99f | ||
|
|
a51906bf4b | ||
|
|
f38930b63a | ||
|
|
0854cf9ba1 | ||
|
|
0280254e8a | ||
|
|
9dcc571fc5 | ||
|
|
dea0556df5 | ||
|
|
436f219477 | ||
|
|
5c8b70fd76 | ||
|
|
4547fa541f | ||
|
|
9bc2bd400c | ||
|
|
877b305136 | ||
|
|
0181a42d3d | ||
|
|
3b5a1f8ffc | ||
|
|
34dcfdde7d | ||
|
|
989ccde83a | ||
|
|
7f76d8128d | ||
|
|
b65fda764f | ||
|
|
5055f82d21 | ||
|
|
e3dce04680 | ||
|
|
0bfacb2ea5 | ||
|
|
9b51a7c660 | ||
|
|
9da8b4dde8 | ||
|
|
5d886501e8 | ||
|
|
d4a28d3ffe | ||
|
|
2526b677fa | ||
|
|
334bb0a6d0 | ||
|
|
cbae5d55bb | ||
|
|
a01e7409eb | ||
|
|
0cfb0b19ad | ||
|
|
d812b21dec | ||
|
|
70d845f438 | ||
|
|
8ab9bc5444 | ||
|
|
c459454da3 | ||
|
|
3b6efe4274 | ||
|
|
c7f54287af | ||
|
|
3852d4762b | ||
|
|
43cc4b15e8 | ||
|
|
641a17621f | ||
|
|
a6ce48fffa | ||
|
|
491d1905c9 | ||
|
|
3d9491e2de | ||
|
|
fbe158537e | ||
|
|
17da6dc17f | ||
|
|
b48b6def4e | ||
|
|
ee03d79536 | ||
|
|
cca043dff6 | ||
|
|
05e8c11338 | ||
|
|
b74ca77786 | ||
|
|
42dbaff1d2 | ||
|
|
648cd4944a | ||
|
|
c07e6e25b5 | ||
|
|
ba35901865 | ||
|
|
4d9072830c | ||
|
|
c94090cd09 | ||
|
|
31c6576b50 | ||
|
|
3a748eea32 | ||
|
|
cf94f252e9 | ||
|
|
5db81504fb | ||
|
|
4e920af183 | ||
|
|
0f75a625db | ||
|
|
f860edf064 | ||
|
|
4a1b2e25c0 | ||
|
|
f895259be6 | ||
|
|
42953aaa0f | ||
|
|
74b63d5f08 | ||
|
|
1cde843264 | ||
|
|
5204d33af7 | ||
|
|
bc9e017906 | ||
|
|
a5644dea07 | ||
|
|
bbbc14eb34 | ||
|
|
022d551760 | ||
|
|
73cb63c493 | ||
|
|
4909799a67 | ||
|
|
367a3a94b9 | ||
|
|
f22a0cca43 | ||
|
|
42b158c165 | ||
|
|
09d9f93d20 | ||
|
|
623c7a129e | ||
|
|
cc8b9810a7 | ||
|
|
31c7604f03 | ||
|
|
2fc03f6211 | ||
|
|
581aa5123c | ||
|
|
8c1f30039b | ||
|
|
61cc5e89a7 | ||
|
|
7bcbdabbfc | ||
|
|
04c7326b1d | ||
|
|
2dfa751958 | ||
|
|
ef0300dfeb | ||
|
|
14d978e2af | ||
|
|
9b5d585750 | ||
|
|
71232e4402 | ||
|
|
ab4cbbd3c1 | ||
|
|
ca8c4ce5a4 | ||
|
|
82bee2e877 | ||
|
|
4f22548121 | ||
|
|
ad317bd90e | ||
|
|
a94a9f0c7f | ||
|
|
41deb3c0c1 | ||
|
|
8ef5854eb7 | ||
|
|
4cd23b9827 | ||
|
|
92927687a5 | ||
|
|
7d747b6d28 | ||
|
|
bafa4e31dd | ||
|
|
91a100f154 | ||
|
|
dd750c6c4e | ||
|
|
0eabd9efc2 | ||
|
|
992cde7e71 | ||
|
|
f40f227454 | ||
|
|
790e82ac9e | ||
|
|
beab14117e | ||
|
|
a70131254f | ||
|
|
5c724dc93d | ||
|
|
3488084eca | ||
|
|
3fd759b020 | ||
|
|
91cbb34fa5 | ||
|
|
c383f2a231 | ||
|
|
e744c5123a | ||
|
|
81ea765714 | ||
|
|
b822997638 | ||
|
|
be4d2fdfb4 | ||
|
|
a5f8b6e482 | ||
|
|
21309d66be | ||
|
|
298c83a806 | ||
|
|
2fa5d9bc03 | ||
|
|
78e8db95b9 | ||
|
|
e80dfc6adc | ||
|
|
571f0a2388 | ||
|
|
ba40cf6c69 | ||
|
|
cde0163ae7 | ||
|
|
ebfd7a8352 | ||
|
|
cd56234e28 | ||
|
|
4c47bb8793 | ||
|
|
739d302850 | ||
|
|
5daf74516a | ||
|
|
6b5c014e75 | ||
|
|
c32a4ae253 | ||
|
|
8b13930d30 | ||
|
|
46ec06986e | ||
|
|
29d82a5b88 | ||
|
|
560e3c9685 | ||
|
|
5fa8c20561 | ||
|
|
4626203f16 | ||
|
|
f44a1874a8 | ||
|
|
0ecb31575f | ||
|
|
aaa402119b | ||
|
|
5d8a139903 | ||
|
|
b3120bab39 | ||
|
|
a08f7f362d | ||
|
|
1517fcd585 | ||
|
|
bc60e09823 | ||
|
|
c4682aad9c | ||
|
|
f1c8fb3404 | ||
|
|
8412119902 | ||
|
|
2f3f84fba3 | ||
|
|
8cd39534a6 | ||
|
|
85478ad7e7 | ||
|
|
42d15b726c | ||
|
|
2b4320b302 | ||
|
|
9e5a13f54f | ||
|
|
e250331e97 | ||
|
|
cc502c872f | ||
|
|
e65d9268d6 | ||
|
|
b86228d6f2 | ||
|
|
87cb6b5a01 | ||
|
|
1f2b73699b | ||
|
|
1d54b8a756 | ||
|
|
54ad1d697d | ||
|
|
43ec6a8163 | ||
|
|
64cd27e9fe | ||
|
|
166963d767 | ||
|
|
089661a0bc | ||
|
|
af19381e3c | ||
|
|
3935d10b45 | ||
|
|
f151d7babf | ||
|
|
225959160c | ||
|
|
51e42d65ad | ||
|
|
333c507720 | ||
|
|
68fe39f5e1 | ||
|
|
8abb2cd0ee | ||
|
|
38bdc95acf | ||
|
|
2e5994788f | ||
|
|
50d1fbfed1 | ||
|
|
41773e586b | ||
|
|
dca2357067 | ||
|
|
6e361414f5 | ||
|
|
5137eda4fb | ||
|
|
9a81e1b593 | ||
|
|
5721913241 | ||
|
|
a672fd8340 | ||
|
|
0f89d3aa3a | ||
|
|
4cadd6b89b | ||
|
|
62f41ebbd3 | ||
|
|
a8f6fd0fb0 | ||
|
|
e78382a8ac | ||
|
|
be3979c5af | ||
|
|
fe0d1abde5 | ||
|
|
d35adffa31 | ||
|
|
d98639c18a | ||
|
|
f85cf8ad77 | ||
|
|
eb9cca66ed | ||
|
|
070eb3c53a | ||
|
|
372cd3958d | ||
|
|
10c39e4c76 | ||
|
|
341d2e13a4 | ||
|
|
6348aa6177 | ||
|
|
29a8fb7824 | ||
|
|
fbe19f4614 | ||
|
|
24aefd43e4 | ||
|
|
3923df5e19 | ||
|
|
5e668b96c7 | ||
|
|
93bac15244 | ||
|
|
54d74b0acd | ||
|
|
8967ca810a | ||
|
|
af3e8aef00 | ||
|
|
2550a87a60 | ||
|
|
f999febe6d | ||
|
|
8332509b60 | ||
|
|
4182c18b1d | ||
|
|
e30828a270 | ||
|
|
539a6fad6a | ||
|
|
698ee7451d | ||
|
|
3126b46faf | ||
|
|
66877212bf | ||
|
|
1336d44f34 | ||
|
|
dc22c15895 | ||
|
|
ecc27daec8 | ||
|
|
3157551d1d | ||
|
|
d270cce881 | ||
|
|
209601744e | ||
|
|
e9381c9b38 | ||
|
|
ea3f0ffbcc | ||
|
|
4ca98f7333 | ||
|
|
131c2f696c | ||
|
|
5e7263ec5c | ||
|
|
a50031b261 | ||
|
|
4705592259 | ||
|
|
b101b356ad | ||
|
|
9f6ef68bfa | ||
|
|
7c2e3f7295 | ||
|
|
1db737405f | ||
|
|
1dbe526051 | ||
|
|
c1e66a7e7d | ||
|
|
df63a6ff6b | ||
|
|
807c911cdf | ||
|
|
0eabb64abc | ||
|
|
f1da174c5c | ||
|
|
67fc90d43f | ||
|
|
31bc573a29 | ||
|
|
abe79be6cb | ||
|
|
0765beb04a | ||
|
|
e2e68342e0 | ||
|
|
a439f53c1a | ||
|
|
c2dca930f3 | ||
|
|
e687f23586 | ||
|
|
d521299987 | ||
|
|
f129344506 | ||
|
|
c4a2bbcd95 | ||
|
|
633fb2979f | ||
|
|
2776790369 | ||
|
|
3b4a3a5af5 | ||
|
|
ffe4c0d094 | ||
|
|
bee71c22fe | ||
|
|
417fd8b990 | ||
|
|
af2d0c51db | ||
|
|
b43ec6d2e2 | ||
|
|
efae8aff51 | ||
|
|
ea3cb238fd | ||
|
|
0e3af23c87 | ||
|
|
4a1546b9a2 | ||
|
|
1d6b3779a0 | ||
|
|
eaa83db644 | ||
|
|
53c3400366 | ||
|
|
fb934457f9 | ||
|
|
80f572a06c | ||
|
|
d9377b5162 | ||
|
|
60d752723b | ||
|
|
aaa8ebadd7 | ||
|
|
00318ce8cf | ||
|
|
be0d09aaff | ||
|
|
ea46354cf8 | ||
|
|
680e6b88d6 | ||
|
|
5fef0af3a5 | ||
|
|
0d1b478aa2 | ||
|
|
1ba6f094e3 | ||
|
|
26a56950cd | ||
|
|
8501ec6fd8 | ||
|
|
3674dcf8de | ||
|
|
8cda46bef9 | ||
|
|
83c40c8771 | ||
|
|
145635b6c7 | ||
|
|
f57fd74e13 | ||
|
|
3441135fad | ||
|
|
3023353154 | ||
|
|
67787c720a | ||
|
|
ff3b65c438 | ||
|
|
e5beacf7c4 | ||
|
|
541b6e461d | ||
|
|
62d7e6adfe | ||
|
|
04b798483e | ||
|
|
b01b85fcc1 | ||
|
|
27e582441a | ||
|
|
9e53bfdb05 | ||
|
|
dfde355703 | ||
|
|
909a715332 | ||
|
|
13002e5efb | ||
|
|
36cb2c22f6 | ||
|
|
c964eedd58 | ||
|
|
968e8917c2 | ||
|
|
f8f8fa3c3b | ||
|
|
7e476fde06 | ||
|
|
39830cfa4f | ||
|
|
e6ae41d9fd | ||
|
|
a43c0d17ba | ||
|
|
f2520ef81f | ||
|
|
176ac30b0e | ||
|
|
25945ed072 | ||
|
|
022cb2684e | ||
|
|
dcdc69e374 | ||
|
|
0b762933b2 | ||
|
|
688f276552 | ||
|
|
66f744b11d | ||
|
|
7269befb14 | ||
|
|
477929e559 | ||
|
|
879ef3a7d0 | ||
|
|
c3eca52574 | ||
|
|
ab1b9f7509 | ||
|
|
4360e42e95 | ||
|
|
a9afa7a827 | ||
|
|
49924110f4 | ||
|
|
7924e26522 | ||
|
|
e486d139e0 | ||
|
|
c84cdf13b3 | ||
|
|
96d1299273 | ||
|
|
cc8c120982 | ||
|
|
67548465fc | ||
|
|
a1d2e69211 | ||
|
|
5967c75433 | ||
|
|
a4380b6d48 | ||
|
|
10d13a3cd9 | ||
|
|
6ccee10526 | ||
|
|
8524120a14 | ||
|
|
66eeef6ab1 | ||
|
|
a214575391 | ||
|
|
2270a35c83 | ||
|
|
19b2d6226c | ||
|
|
8c31c8fd62 | ||
|
|
8f8e414c80 | ||
|
|
d53fe9628f | ||
|
|
c08ea3bb03 | ||
|
|
af6f7cf657 | ||
|
|
5fca68f9f0 | ||
|
|
3b6cc45084 | ||
|
|
77de7215ce | ||
|
|
ae9d0fccd3 | ||
|
|
c91416801b | ||
|
|
062d958ead | ||
|
|
37b78543af | ||
|
|
d0399d6b04 | ||
|
|
06acdd7335 | ||
|
|
d5d3c68350 | ||
|
|
e5baaaabc6 | ||
|
|
848496c51b | ||
|
|
5b2f3136a2 | ||
|
|
3ebc338797 | ||
|
|
7a8228c709 | ||
|
|
e92710483f | ||
|
|
2d415cb1d2 | ||
|
|
ae9a00fade | ||
|
|
e77916a02e | ||
|
|
98fb49687b | ||
|
|
3e39b2fe77 | ||
|
|
ef11577d08 | ||
|
|
a28ba26ca6 | ||
|
|
3e69a06434 | ||
|
|
96b3b0afb8 | ||
|
|
45d355454e | ||
|
|
7dd01b6e23 | ||
|
|
269a3c3f65 | ||
|
|
0e3ebac674 | ||
|
|
389726f219 | ||
|
|
1d509aa232 | ||
|
|
d672b829b9 | ||
|
|
fa9d2d4040 | ||
|
|
c60936f165 | ||
|
|
ca88091d90 | ||
|
|
8de3cf0cc6 | ||
|
|
9301973825 | ||
|
|
c702745bc0 | ||
|
|
8be6311cd6 | ||
|
|
c10cf2ca15 | ||
|
|
7f04fc5f74 | ||
|
|
1feb2b9877 | ||
|
|
27951c428d | ||
|
|
ece9e59145 | ||
|
|
1f10e61371 | ||
|
|
2416ccb7e9 | ||
|
|
ba4634919c | ||
|
|
1cab009d3c | ||
|
|
5a6ac3a335 | ||
|
|
a661f90ede | ||
|
|
26f786d4b9 | ||
|
|
e48a70860b | ||
|
|
2b2f93b766 | ||
|
|
4781529d12 | ||
|
|
0f92bb55db | ||
|
|
1328288cd2 | ||
|
|
e389bcbee9 | ||
|
|
a114880f2b | ||
|
|
af4e7ab6c4 | ||
|
|
35bbd888ae | ||
|
|
dc87cdcb5e | ||
|
|
d8c2eaba1d | ||
|
|
a8c7f27ff5 | ||
|
|
31fcfaf1bd | ||
|
|
09dbfc894e | ||
|
|
b6abbf2ffe | ||
|
|
12848b7cf5 | ||
|
|
5bd3371802 | ||
|
|
0e85cc90ff | ||
|
|
4a07fdf291 | ||
|
|
1d58dca0f4 | ||
|
|
319120364c | ||
|
|
8b6bda0b6d | ||
|
|
344e709552 | ||
|
|
ece168e960 | ||
|
|
7e6f26f740 | ||
|
|
fa056807d5 | ||
|
|
edb23bb47e | ||
|
|
1179e2848f | ||
|
|
1ba13dd5f7 | ||
|
|
1609fe6c8e | ||
|
|
17f3de3124 | ||
|
|
94a755124e | ||
|
|
b171592d77 | ||
|
|
c1559077cf | ||
|
|
dec8dbc713 | ||
|
|
7fe4ed59ac | ||
|
|
428f2837c9 | ||
|
|
b028228d3d | ||
|
|
7924a85b33 | ||
|
|
7894c6d6f4 | ||
|
|
704809e5b9 | ||
|
|
92c9fbddcc | ||
|
|
42c54e2029 | ||
|
|
665137d453 | ||
|
|
caa1eb2237 | ||
|
|
95632e0e98 | ||
|
|
1188122823 | ||
|
|
4ec913b807 | ||
|
|
04a58326e2 | ||
|
|
083ab133f7 | ||
|
|
c9e22b69f7 | ||
|
|
22b6d4dbde | ||
|
|
4593483522 | ||
|
|
a0dacdcf38 | ||
|
|
632fad62ae | ||
|
|
00ab87b1b5 | ||
|
|
451962a97f | ||
|
|
a8fa783c32 | ||
|
|
aee0d2a9e0 | ||
|
|
12c78cf89f | ||
|
|
b37b5ceddd | ||
|
|
faebc72c4f | ||
|
|
140351c2ed | ||
|
|
70cfdf0c44 | ||
|
|
dd6b3cabed | ||
|
|
935dda389a | ||
|
|
f7a7ba00f3 | ||
|
|
01fbd21c6e | ||
|
|
451c504166 | ||
|
|
8bc1a37531 | ||
|
|
b2781ffc9d | ||
|
|
0eee0f0207 | ||
|
|
0cdd3d437f | ||
|
|
4dba081399 | ||
|
|
9a19be675e | ||
|
|
fdf6c49a05 | ||
|
|
85f05bfd02 | ||
|
|
26527a8800 | ||
|
|
ff7952447d | ||
|
|
906bcdc6fe | ||
|
|
ffc112a085 | ||
|
|
e4e899f72a | ||
|
|
3b59ea50b0 | ||
|
|
c98344b5b3 | ||
|
|
3bfeb94b43 | ||
|
|
938beac9f9 | ||
|
|
6f9e92afff | ||
|
|
b30f10b647 | ||
|
|
8011f9e979 | ||
|
|
352238a9c5 | ||
|
|
909c96a1ff | ||
|
|
55f148480c | ||
|
|
c9d1193e7f | ||
|
|
42c7bc61fb | ||
|
|
911be09aef | ||
|
|
472f12e60d | ||
|
|
e7ae5d0435 | ||
|
|
9916c3efaf | ||
|
|
f60b94760d | ||
|
|
4ade9c71b1 | ||
|
|
bcd4bd46ef | ||
|
|
cf30fd140e | ||
|
|
9c700e4b34 | ||
|
|
ac13d00ef8 | ||
|
|
3581371d29 | ||
|
|
32b4fafe10 | ||
|
|
78526c00c6 | ||
|
|
ca8017a876 | ||
|
|
7bb09a8320 | ||
|
|
df45f141ca | ||
|
|
9a5c70b506 | ||
|
|
c77e8a4374 | ||
|
|
7e27b5415d | ||
|
|
e231df0ce1 | ||
|
|
31ade6aa5f | ||
|
|
aa1f1ec801 | ||
|
|
7bd176f51f | ||
|
|
ccd8b204c5 | ||
|
|
6b0dcffbca | ||
|
|
9ea81f3b26 | ||
|
|
27f6811e1f | ||
|
|
f683e272ee | ||
|
|
fddc6e2737 | ||
|
|
af5b7569ee | ||
|
|
6867cc23b4 | ||
|
|
99c968e1e2 | ||
|
|
3a3bc01e82 | ||
|
|
f138db17ca | ||
|
|
cef2d7e2f6 | ||
|
|
6a5c114998 | ||
|
|
32a857f062 | ||
|
|
f8fcb553d5 | ||
|
|
5f1609a869 | ||
|
|
d22c5e5f3d | ||
|
|
305c2f9762 | ||
|
|
b35a45657c | ||
|
|
086cdea9fb | ||
|
|
1c0f9f4555 | ||
|
|
40b520ecc6 | ||
|
|
46274e9b6a | ||
|
|
7fae7b832b | ||
|
|
2ad1be255c | ||
|
|
683481abbd | ||
|
|
3af333e563 | ||
|
|
75972fcff0 | ||
|
|
25f74d7d80 | ||
|
|
6ee274efd6 | ||
|
|
bac00076b5 | ||
|
|
7813e41e34 | ||
|
|
b989ff63df | ||
|
|
08eb098422 | ||
|
|
f7b088e7a8 | ||
|
|
9610db0cab | ||
|
|
d15630c433 | ||
|
|
006c14db4e | ||
|
|
4bcefa2621 | ||
|
|
ad646efb5c | ||
|
|
5840ebe592 | ||
|
|
19571facdd | ||
|
|
0cc664121a | ||
|
|
200356d8ff | ||
|
|
0ef1a82a16 | ||
|
|
3c1898b9ef | ||
|
|
fed89cd89b | ||
|
|
2dc6d8c20b | ||
|
|
063cc43047 | ||
|
|
c869327a63 | ||
|
|
1bcd12a74e | ||
|
|
3fdea0ec50 | ||
|
|
e69c557595 | ||
|
|
87ee507220 | ||
|
|
eee0a7de1d | ||
|
|
ab4d7de36d | ||
|
|
cb5cf6f8a1 | ||
|
|
86ff9e361c | ||
|
|
758248b6a4 | ||
|
|
562c5b5a56 | ||
|
|
360129b7de | ||
|
|
1b6eaca401 | ||
|
|
5ae70ac947 | ||
|
|
6df5c40b45 | ||
|
|
0668808214 | ||
|
|
1f292d96a9 | ||
|
|
cdcb4eca89 | ||
|
|
c3d4f520de | ||
|
|
5c3e4287f0 | ||
|
|
62c81e6d77 | ||
|
|
32fdbc6fbe | ||
|
|
5a36b112b2 | ||
|
|
4c3ea9890d | ||
|
|
982cd2b848 | ||
|
|
da74bc6d87 | ||
|
|
276c884681 | ||
|
|
15504c03a7 | ||
|
|
fd12ed88a4 | ||
|
|
50092ae60a | ||
|
|
7da2d853a2 | ||
|
|
f04047e584 | ||
|
|
6849ede461 | ||
|
|
f0296305d5 | ||
|
|
fd2f01eb94 | ||
|
|
08dda6a82d | ||
|
|
1c00d41b06 | ||
|
|
ac9e79bfa0 | ||
|
|
dad76714d5 | ||
|
|
6f3500d129 | ||
|
|
460f4a323b | ||
|
|
3a4ef523dc | ||
|
|
1ea75765d7 | ||
|
|
b876e4a680 | ||
|
|
345402b393 | ||
|
|
8db63bbbce | ||
|
|
e698b1667f | ||
|
|
afd19c1619 | ||
|
|
a96a239449 | ||
|
|
bc9633f87f | ||
|
|
1ffc4191a8 | ||
|
|
3177979558 | ||
|
|
d380278390 | ||
|
|
b6c8b31186 | ||
|
|
c2b4d8523f | ||
|
|
7fd6b6c254 | ||
|
|
af21fe50ff | ||
|
|
5304e80353 | ||
|
|
8f1c693ec6 | ||
|
|
7a2364d12d | ||
|
|
c8df704385 | ||
|
|
d47538e62e | ||
|
|
f12e3f5318 | ||
|
|
74fefed754 | ||
|
|
ba2e59fd94 | ||
|
|
93fcec3457 | ||
|
|
68674ace83 | ||
|
|
2b5b238bc1 | ||
|
|
873968b27f | ||
|
|
7f97487721 | ||
|
|
66e1c3ecc2 | ||
|
|
5b42a90cd5 | ||
|
|
bfc5c5b68e | ||
|
|
2f3a3a7a16 | ||
|
|
38f5f6de7c | ||
|
|
5073db8044 | ||
|
|
5fbf168fb7 | ||
|
|
ad5d608ba5 | ||
|
|
ce36e1e76a | ||
|
|
3395b22d57 | ||
|
|
3ebc5aa2cd | ||
|
|
42e7f5f2c6 | ||
|
|
200707b1c6 | ||
|
|
c73c917c48 | ||
|
|
22a173ae0b | ||
|
|
317880d083 | ||
|
|
f6b4d5f153 | ||
|
|
5e159233ab | ||
|
|
8f68854513 | ||
|
|
4882262bed | ||
|
|
f1396e13c7 | ||
|
|
c10e34d26e | ||
|
|
d7636457bd | ||
|
|
0c3dbd4b4d | ||
|
|
780062ebb4 | ||
|
|
998937ca26 | ||
|
|
fd79415b53 | ||
|
|
9dfbd472ac | ||
|
|
ceaae41b57 | ||
|
|
5d27bff298 | ||
|
|
150454fd67 | ||
|
|
d64136ab9d | ||
|
|
585ef1c2ce | ||
|
|
f7558a6761 | ||
|
|
265388a889 | ||
|
|
364e72e869 | ||
|
|
9fd328ac8f | ||
|
|
496068e9aa | ||
|
|
5eaaae0749 | ||
|
|
26ad5db8e9 | ||
|
|
1e28aa6e79 | ||
|
|
2a0b5769ad | ||
|
|
da18f05d9f | ||
|
|
b3566def7e | ||
|
|
b1ad1411e4 | ||
|
|
83cf992f48 | ||
|
|
12459429b4 | ||
|
|
9e1bbe0235 | ||
|
|
cea5072c2a | ||
|
|
73872cf5ff | ||
|
|
720668ad63 | ||
|
|
e0ee9a952d | ||
|
|
468b9b6ed5 | ||
|
|
dd8cff9838 | ||
|
|
81dc7ea4ea | ||
|
|
fcbdf8bbd8 | ||
|
|
dae3be97ec | ||
|
|
910b5d66d3 | ||
|
|
a6540d6200 | ||
|
|
eb5173b3a0 | ||
|
|
6e39f9979d | ||
|
|
fc55d0e2f9 | ||
|
|
103d005e62 | ||
|
|
1c37d4e599 | ||
|
|
2382c4a535 | ||
|
|
8f1c368ffe | ||
|
|
55b81d4a60 | ||
|
|
82ade50f5e | ||
|
|
c9748a6f44 | ||
|
|
42dfdcdac2 | ||
|
|
7ea0b39553 | ||
|
|
6459d990a5 | ||
|
|
c233214e42 | ||
|
|
fb7c675117 | ||
|
|
9aa3902265 | ||
|
|
a38c0e834e | ||
|
|
d216562fba | ||
|
|
2cc39bf6bc | ||
|
|
ab209ef91e | ||
|
|
cba205baf3 | ||
|
|
bc04443812 | ||
|
|
21102d846f | ||
|
|
bca989898e | ||
|
|
419367ad9f | ||
|
|
40ee795c29 | ||
|
|
7f31d49848 | ||
|
|
69c97838ea | ||
|
|
306001f311 | ||
|
|
d8dca8f9c2 | ||
|
|
dd9f65f14f | ||
|
|
68b51fbad1 | ||
|
|
08d6cc3eb9 | ||
|
|
9c95e2d470 | ||
|
|
d2d58f2b7e | ||
|
|
0f8d0257c9 | ||
|
|
130aacc4d7 | ||
|
|
bc10e474c2 | ||
|
|
653c36895f | ||
|
|
88332f68a2 | ||
|
|
7e5af96548 | ||
|
|
21e90cd479 | ||
|
|
85a1c123b4 | ||
|
|
323aba310c | ||
|
|
fd712c16f3 | ||
|
|
a056a5b2e6 | ||
|
|
f04cb73679 | ||
|
|
887724b536 | ||
|
|
5ff9b8d08a | ||
|
|
e346afeea1 | ||
|
|
25918b139b | ||
|
|
03a428ec4b | ||
|
|
6ad12f4df9 | ||
|
|
578ede9b1c | ||
|
|
6d92c3cfbf | ||
|
|
0fb6fea11a | ||
|
|
a5bdc07406 | ||
|
|
ff869ecfc3 | ||
|
|
6d327749fc | ||
|
|
8016846cd9 | ||
|
|
ae0fb89745 | ||
|
|
2c023c2c54 | ||
|
|
2abefa1ab9 | ||
|
|
02a289dc80 | ||
|
|
4e3df30cc0 | ||
|
|
e10aace5f9 | ||
|
|
169f972019 | ||
|
|
76e2750b5c | ||
|
|
c8e9a3d60f | ||
|
|
69f9f3b048 | ||
|
|
1711d52985 | ||
|
|
1f7a54c1e6 | ||
|
|
b4e89a47c2 | ||
|
|
89473d795f | ||
|
|
9f2863c953 | ||
|
|
69b5678350 | ||
|
|
2720fdae1e | ||
|
|
c44b1ae658 | ||
|
|
9fba6afe6e | ||
|
|
749d355545 | ||
|
|
568060e820 | ||
|
|
ac2b4a4038 | ||
|
|
985c87efbf | ||
|
|
df45117d43 | ||
|
|
50a063c8de | ||
|
|
bd6576b716 | ||
|
|
55ea1fa39a | ||
|
|
3971182fff | ||
|
|
059e49b1bc | ||
|
|
c1100c6d66 | ||
|
|
6748463711 | ||
|
|
c598d1a218 | ||
|
|
64328be25c | ||
|
|
74e84fd758 | ||
|
|
e55e3971d9 | ||
|
|
37a72e6ad4 | ||
|
|
af8306ae9b | ||
|
|
9165ceef79 | ||
|
|
06c877f36c | ||
|
|
8fc07752e9 | ||
|
|
d983a32397 | ||
|
|
f17aadfcba | ||
|
|
83fc18ad03 | ||
|
|
1f10cb2155 | ||
|
|
7f4549d27a | ||
|
|
2565cb9821 | ||
|
|
c032eba49c | ||
|
|
01e45caa5a | ||
|
|
62ff87350b | ||
|
|
7fc776aee9 | ||
|
|
d07b3e1493 | ||
|
|
c1d84249e1 | ||
|
|
7ccea7ac7a | ||
|
|
48cb88f655 | ||
|
|
d6aeb2e177 | ||
|
|
c98404a8fe | ||
|
|
b7f089a3ab | ||
|
|
3e21b4e4db | ||
|
|
18e8f475ff | ||
|
|
d6e055de30 | ||
|
|
2bbdff3ca6 | ||
|
|
c1c7829d02 | ||
|
|
ab3bedcc9f | ||
|
|
1342a16269 | ||
|
|
6b1ec09296 | ||
|
|
bc2c83fa8f | ||
|
|
ee1b2bfbd8 | ||
|
|
e1f599ec1d | ||
|
|
9a28378d50 | ||
|
|
e18a0ac82f | ||
|
|
d0769c32b4 | ||
|
|
3fc2e0741f | ||
|
|
e3b393650d |
@ -1,4 +0,0 @@
|
||||
[Dolphin]
|
||||
Timestamp=2015,7,12,21,9,46
|
||||
Version=3
|
||||
ViewMode=1
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.iml
|
||||
**/.idea/**
|
||||
@ -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>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
@ -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); // ∃
|
||||
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); // ∃
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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());}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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&"'<>b"); // escape=all; code handles first escape differently
|
||||
fxt.Test__add_bry_escape_html("a&b&c" , "a&b&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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 | {|}~
|
||||
*/
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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);}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
;
|
||||
}
|
||||
|
||||
@ -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)]);}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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");}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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";
|
||||
}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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, "'", "''");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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;}
|
||||
}
|
||||
|
||||
27
100_core/src/gplx/Gfo_usr_dlg__gui_mock.java
Normal file
27
100_core/src/gplx/Gfo_usr_dlg__gui_mock.java
Normal 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);}
|
||||
}
|
||||
@ -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);}
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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_ {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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;}
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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
|
||||
;
|
||||
}
|
||||
|
||||
@ -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)));}
|
||||
}
|
||||
|
||||
172
100_core/src/gplx/Int_ary_.java
Normal file
172
100_core/src/gplx/Int_ary_.java
Normal 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;}
|
||||
}
|
||||
}
|
||||
58
100_core/src/gplx/Int_ary__tst.java
Normal file
58
100_core/src/gplx/Int_ary__tst.java
Normal 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);}
|
||||
}
|
||||
@ -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 {}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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));}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();}
|
||||
}
|
||||
@ -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);}
|
||||
}
|
||||
30
100_core/src/gplx/Keyval.java
Normal file
30
100_core/src/gplx/Keyval.java
Normal 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();}
|
||||
}
|
||||
133
100_core/src/gplx/Keyval_.java
Normal file
133
100_core/src/gplx/Keyval_.java
Normal 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);}
|
||||
}
|
||||
@ -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);}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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*/
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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.*;
|
||||
|
||||
@ -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%)
|
||||
|
||||
@ -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
Loading…
Reference in New Issue
Block a user