mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Refactor: Refactor Dbmeta classes; Rename methods of list and hash classes
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
/*
|
||||
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.gfml; import gplx.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
public class GfmlBldr {
|
||||
public class GfmlBldr {
|
||||
@gplx.Internal protected GfmlDoc Doc() {return gdoc;} GfmlDoc gdoc = GfmlDoc.new_();
|
||||
@gplx.Internal protected GfmlFrame CurFrame() {return curFrame;} GfmlFrame curFrame;
|
||||
@gplx.Internal protected GfmlFrame_nde CurNdeFrame() {return curNdeFrame;} GfmlFrame_nde curNdeFrame;
|
||||
@@ -39,7 +39,7 @@ public class GfmlBldr {
|
||||
curNdeFrame.Build_end(this, GfmlFrame_nde_.OwnerRoot_);
|
||||
if (frameStack.Count() > 0) UsrMsgs_fail(GfmlUsrMsgs.fail_Frame_danglingBgn());
|
||||
}
|
||||
if (throwErrors && gdoc.UsrMsgs().Count() > 0) throw GfmlUsrMsgs.gfmlParseError(this);
|
||||
if (throwErrors && gdoc.UsrMsgs().Len() > 0) throw GfmlUsrMsgs.gfmlParseError(this);
|
||||
raw = "";
|
||||
return gdoc;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class GfmlBldrCmd_null implements GfmlBldrCmd {
|
||||
}
|
||||
class GfmlBldrCmdRegy {
|
||||
public void Add(GfmlBldrCmd cmd) {hash.Add(cmd.Key(), cmd);}
|
||||
public GfmlBldrCmd GetOrFail(String key) {return (GfmlBldrCmd)hash.Get_by_or_fail(key);}
|
||||
public GfmlBldrCmd GetOrFail(String key) {return (GfmlBldrCmd)hash.GetByOrFail(key);}
|
||||
Hash_adp hash = Hash_adp_.New();
|
||||
public static GfmlBldrCmdRegy new_() {
|
||||
GfmlBldrCmdRegy rv = new GfmlBldrCmdRegy();
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
/*
|
||||
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.gfml; import gplx.*;
|
||||
class GfmlBldrCmd_pendingTkns_add implements GfmlBldrCmd {
|
||||
public String Key() {return "gfml.pendingTkns_add";}
|
||||
@@ -111,12 +111,12 @@ class GfmlBldrCmd_frameEnd implements GfmlBldrCmd {
|
||||
class GfmlBldrCmd_whitespace implements GfmlBldrCmd {
|
||||
public String Key() {return "gfml.whitespace_exec";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {
|
||||
if (bldr.CurNdeFrame().waitingTkns.Count() > 0) {
|
||||
GfmlObj t = (GfmlObj)bldr.CurNdeFrame().waitingTkns.Get_at(bldr.CurNdeFrame().waitingTkns.Count() - 1);
|
||||
if (bldr.CurNdeFrame().waitingTkns.Len() > 0) {
|
||||
GfmlObj t = (GfmlObj)bldr.CurNdeFrame().waitingTkns.Get_at(bldr.CurNdeFrame().waitingTkns.Len() - 1);
|
||||
if (t.ObjType() == GfmlObj_.Type_nde)
|
||||
bldr.CurNdeFrame().IdxNdeBgn_set(bldr.CurNdeFrame().WaitingTkns().Count() + 1);
|
||||
bldr.CurNdeFrame().IdxNdeBgn_set(bldr.CurNdeFrame().WaitingTkns().Len() + 1);
|
||||
}
|
||||
if (bldr.CurFrame().WaitingTkns().Count() == 0) {
|
||||
if (bldr.CurFrame().WaitingTkns().Len() == 0) {
|
||||
bldr.CurNde().SubObjs_Add(tkn); // if curFrame begins with whitespace, add directly to node (whitespace should not belong to atr)
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
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.gfml; import gplx.*;
|
||||
/*
|
||||
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.gfml;
|
||||
class GfmlFrame_nde extends GfmlFrame_base {
|
||||
@Override public int FrameType() {return GfmlFrame_.Type_nde;}
|
||||
public GfmlNde CurNde() {return nde;} GfmlNde nde;
|
||||
@@ -105,7 +105,7 @@ class GfmlFrame_nde extends GfmlFrame_base {
|
||||
if (!frmHasParens) {
|
||||
bldr.Frames_end();
|
||||
GfmlFrame_nde frm = bldr.CurNdeFrame(); // get the current frm after all popped
|
||||
int idx = frm.waitingTkns.Count(); // NOTE: reset idxs b/c endFrame will automatically set to 0, and should be objCount
|
||||
int idx = frm.waitingTkns.Len(); // NOTE: reset idxs b/c endFrame will automatically set to 0, and should be objCount
|
||||
frm.tknMgr.IdxAtrBgn_setHack(idx);
|
||||
frm.tknMgr.IdxNdeBgn_set(idx);
|
||||
frm.nullArea = false; // NOTE: endFrame automatically sets nullArea to true; set to false
|
||||
@@ -114,7 +114,7 @@ class GfmlFrame_nde extends GfmlFrame_base {
|
||||
public void NdeProp_bgn(GfmlTkn symTkn) { // EX: < [ >
|
||||
int oldNdeBgn = tknMgr.IdxNdeBgn(); // get oldNdeBgn; needed for header atrs; EX: < a:b [d] > ndeBgn = 0 (a pos), but will start keyNde at 5 ([ pos)
|
||||
GfmlTkn keyTkn = tknMgr.KeyTkn_pop(); boolean keyTknExists = keyTkn != GfmlTkn_.Null;
|
||||
int newNdeBgn = keyTknExists ? tknMgr.IdxAtrBgn() : waitingTkns.Count(); // if there is a key, set ndeBgn end atrBgn (EX: a=[); else set end curIdx
|
||||
int newNdeBgn = keyTknExists ? tknMgr.IdxAtrBgn() : waitingTkns.Len(); // if there is a key, set ndeBgn end atrBgn (EX: a=[); else set end curIdx
|
||||
tknMgr.IdxNdeBgn_set(newNdeBgn);
|
||||
WaitingTkns_AddSym(symTkn, GfmlNdeSymType.PrpBgn);
|
||||
tknMgr.ConsumeWaitingDatTkn(nde);// NEEDED for KeydDefault
|
||||
@@ -156,7 +156,7 @@ class GfmlFrame_nde extends GfmlFrame_base {
|
||||
}
|
||||
else if (ndeType == GfmlNdeStartType.Prop) {}
|
||||
else {
|
||||
ownerNdeFrame.tknMgr.IdxNdeBgn_set(ownerNdeFrame.waitingTkns.Count());
|
||||
ownerNdeFrame.tknMgr.IdxNdeBgn_set(ownerNdeFrame.waitingTkns.Len());
|
||||
ownerNdeFrame.nullArea = true; // reset
|
||||
}
|
||||
}
|
||||
@@ -204,20 +204,20 @@ class GfmlFrame_nde_ {
|
||||
@gplx.Internal protected static GfmlFrame_nde root_(GfmlBldr bldr, GfmlNde newNde, GfmlLxr newLxr) {return GfmlFrame_nde.new_(bldr, newNde, newLxr);}
|
||||
@gplx.Internal protected static final GfmlFrame_nde OwnerRoot_ = null;
|
||||
@gplx.Internal protected static void TransferToNde(GfmlObjList waitingTkns, GfmlNde nde, int bgn) {
|
||||
int end = waitingTkns.Count();
|
||||
int end = waitingTkns.Len();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
GfmlObj tkn = waitingTkns.Get_at(i);
|
||||
nde.SubObjs_Add(tkn);
|
||||
}
|
||||
if (bgn != end) // ignore if bgn == end
|
||||
waitingTkns.Del_range(bgn, end - 1);
|
||||
waitingTkns.DelRange(bgn, end - 1);
|
||||
}
|
||||
@gplx.Internal protected static void TransferToAtr(GfmlObjList src, GfmlAtr trg, int bgn, int end) {
|
||||
int len = end - bgn;
|
||||
if (len <= 0 || end == -1) return; // -1 b/c calling proc passes end - 1, and end may be 0
|
||||
for (int i = 0; i < len; i++)
|
||||
trg.SubObjs_Add(src.Get_at(i + bgn));
|
||||
src.Del_range(bgn, end - 1);
|
||||
src.DelRange(bgn, end - 1);
|
||||
}
|
||||
}
|
||||
class GfmlNdeStartType {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
/*
|
||||
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.gfml; import gplx.*;
|
||||
class GfmlFrame_ndeTknMgr {
|
||||
public int IdxAtrBgn() {return idxAtrBgn;} int idxAtrBgn, idxAtrEnd;
|
||||
@@ -47,14 +47,14 @@ class GfmlFrame_ndeTknMgr {
|
||||
@gplx.Internal protected GfmlTkn DatTkn_pop() {GfmlTkn rv = datTkn; datTkn = GfmlTkn_.Null; return rv;} GfmlTkn datTkn = GfmlTkn_.Null;
|
||||
@gplx.Internal protected void DatTkn_set(GfmlTkn tkn) {
|
||||
this.ConsumeWaitingDatTkn(frame.CurNde());
|
||||
idxAtrBgn = frame.waitingTkns.Count();
|
||||
idxAtrBgn = frame.waitingTkns.Len();
|
||||
idxAtrEnd = idxAtrBgn + 1;
|
||||
frame.waitingTkns.Add(tkn);
|
||||
datTkn = tkn;
|
||||
}
|
||||
@gplx.Internal protected void ExecMakeAtr(GfmlTkn itmKeyTkn, GfmlTkn valTkn) {
|
||||
frame.waitingTkns.Add(valTkn);
|
||||
idxAtrEnd = frame.waitingTkns.Count();
|
||||
idxAtrEnd = frame.waitingTkns.Len();
|
||||
this.MakeAtr(itmKeyTkn, valTkn);
|
||||
}
|
||||
@gplx.Internal protected void ExecXferTkns_ndeAll(GfmlNde nde) {ExecXferTkns(nde, 0);}
|
||||
|
||||
@@ -32,8 +32,8 @@ class GfmlStringHighlighter {
|
||||
List_adp symList = List_adp_.New();
|
||||
int bgnPos = 0, endPos = 0;
|
||||
int rawLen = String_.Len(raw); int rawLenDigits = Int_.DigitCount(rawLen);
|
||||
int rawBfrBgn = -1, marksLastIdx = marks.Idx_last();
|
||||
for (int i = 0; i < marks.Count(); i++) {
|
||||
int rawBfrBgn = -1, marksLastIdx = marks.IdxLast();
|
||||
for (int i = 0; i < marks.Len(); i++) {
|
||||
GfmlStringHighlighterMarker curMark = (GfmlStringHighlighterMarker)marks.Get_at(i);
|
||||
GfmlStringHighlighterMarker nxtMark = i == marksLastIdx ? GfmlStringHighlighterMarker.Null : (GfmlStringHighlighterMarker)marks.Get_at(i + 1);
|
||||
// bgnPos
|
||||
@@ -81,11 +81,11 @@ class GfmlStringHighlighter {
|
||||
rv.Add(posBfr.To_str());
|
||||
rv.Add(rawBfr.To_str());
|
||||
rv.Add(symBfr.To_str());
|
||||
if (symList.Count() > 0)
|
||||
if (symList.Len() > 0)
|
||||
rv.Add("");
|
||||
for (int i = 0; i < symList.Count(); i++)
|
||||
for (int i = 0; i < symList.Len(); i++)
|
||||
rv.Add((String)symList.Get_at(i));
|
||||
return rv.To_str_ary();
|
||||
return rv.ToStrAry();
|
||||
}
|
||||
List_adp marks = List_adp_.New();
|
||||
public static GfmlStringHighlighter new_() {
|
||||
|
||||
Reference in New Issue
Block a user