mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
References: Do not make linkLabelMgr a global reference [#495]
This commit is contained in:
parent
02f9b9dae3
commit
f33f9c4ae9
@ -20,18 +20,11 @@ import gplx.langs.htmls.*;
|
|||||||
class Cite_mgr { // REF.MW:/extensions/Cite/includes/Cite.php
|
class Cite_mgr { // REF.MW:/extensions/Cite/includes/Cite.php
|
||||||
private final Xowe_wiki wiki;
|
private final Xowe_wiki wiki;
|
||||||
private final Hash_adp_bry messages_by_group = Hash_adp_bry.cs();
|
private final Hash_adp_bry messages_by_group = Hash_adp_bry.cs();
|
||||||
private Cite_xtn_data xtn_data;
|
private final Cite_link_label_mgr link_label_mgr = new Cite_link_label_mgr(); // used to be a global reference; ISSUE#:495 DATE:2020-03-07
|
||||||
private Cite_link_label_mgr link_label_mgr;
|
|
||||||
public Cite_mgr(Xowe_wiki wiki) {
|
public Cite_mgr(Xowe_wiki wiki) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
}
|
}
|
||||||
public byte[] getLinkLabel(int offset, byte[] group) {
|
public byte[] getLinkLabel(int offset, byte[] group) {
|
||||||
// get xtn_data; NOTE: should go in Init_by_wiki, but Init_by_wiki doesn't get called by tests
|
|
||||||
if (xtn_data == null) {
|
|
||||||
this.xtn_data = Cite_xtn_data.Get_or_make(wiki.Parser_mgr().Data_store());
|
|
||||||
this.link_label_mgr = xtn_data.Link_labels();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get message; use cache to avoid multiple concantenations; EX: "cite_link_label_group-" + "lower-roman";
|
// get message; use cache to avoid multiple concantenations; EX: "cite_link_label_group-" + "lower-roman";
|
||||||
byte[] message = (byte[])messages_by_group.Get_by_bry(group);
|
byte[] message = (byte[])messages_by_group.Get_by_bry(group);
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
@ -57,6 +50,7 @@ class Cite_mgr { // REF.MW:/extensions/Cite/includes/Cite.php
|
|||||||
: rv;
|
: rv;
|
||||||
}
|
}
|
||||||
private Cite_link_label_grp genLinkLabels(byte[] group, byte[] message) {
|
private Cite_link_label_grp genLinkLabels(byte[] group, byte[] message) {
|
||||||
|
// linkLabels are generally "a", "b", "c", etc.
|
||||||
Xol_msg_itm msg = wiki.Msg_mgr().Find_or_null(message);
|
Xol_msg_itm msg = wiki.Msg_mgr().Find_or_null(message);
|
||||||
byte[][] text = msg == null
|
byte[][] text = msg == null
|
||||||
? Bry_.Ary_empty
|
? Bry_.Ary_empty
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
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.xowa.xtns.cites; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
|
||||||
import gplx.core.data_stores.*;
|
|
||||||
class Cite_xtn_data implements Gfo_data_itm {
|
|
||||||
public String Key() {return KEY;}
|
|
||||||
public void Clear() {
|
|
||||||
link_labels.Clear();
|
|
||||||
}
|
|
||||||
public Cite_link_label_mgr Link_labels() {return link_labels;} private final Cite_link_label_mgr link_labels = new Cite_link_label_mgr();
|
|
||||||
|
|
||||||
private static final String KEY = "xtn.Cite";
|
|
||||||
public static Cite_xtn_data Get_or_make(Gfo_data_store data_store) {
|
|
||||||
Cite_xtn_data rv = (Cite_xtn_data)data_store.Get_or_null(KEY);
|
|
||||||
if (rv == null) {
|
|
||||||
rv = new Cite_xtn_data();
|
|
||||||
data_store.Set(rv);
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user