- Timestamp:
- 2012-09-18T15:17:35+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GS2MacroResolver.java
r25672 r26196 34 34 35 35 protected SimpleCollectionDatabase coll_db = null; 36 36 protected ClassLoader class_loader = null; 37 37 private static Pattern p_back_slash = Pattern.compile("\\\"");// create a pattern "\\\"", but it matches both " and \" 38 38 39 39 // need to make it not add macros if they are already present 40 public GS2MacroResolver(SimpleCollectionDatabase db)40 public GS2MacroResolver(SimpleCollectionDatabase db, ClassLoader class_loader) 41 41 { 42 42 super(); 43 43 coll_db = db; 44 this.class_loader = class_loader; 44 45 } 45 46 … … 53 54 this.coll_db = db; 54 55 } 55 56 public String resolve(String text, String lang, String scope, String doc_oid) 56 public void setClassLoader(ClassLoader class_loader) { 57 this.class_loader = class_loader; 58 } 59 60 public String resolve(String text, String lang, String scope, String doc_oid) 57 61 { 58 62 if (text == null || text.equals("")) … … 103 107 { 104 108 case TYPE_DICT: 105 if (m.text == null || new_lang) 106 { 107 Dictionary dict = new Dictionary(m.bundle, lang); 108 m.text = dict.get(m.key, null); 109 } 109 if (text.contains(m.macro)) 110 111 { 112 // if we change the lang, then do a metadata resolve, then a text resolve, the lang hasn't changed, but the text might be leftover from the last language. 113 // if (m.text == null || new_lang) 114 // { 115 Dictionary dict = new Dictionary(m.bundle, lang, this.class_loader); 116 m.text = dict.get(m.key, null); 117 // } 110 118 // we assume that dictionary entries will contain no macros 111 119 // otherwise we can't cache the answer because it might be 112 120 // document specific 113 text = StringUtils.replace(text, m.macro, m.text);121 text = StringUtils.replace(text, m.macro, m.text);} 114 122 break; 115 123 case TYPE_TEXT: … … 131 139 if (m.resolve) 132 140 { 133 141 new_text = this.resolve(m.text, lang, scope, doc_oid); 134 142 } 135 143 else … … 191 199 if (m.resolve) 192 200 { 193 201 new_text = this.resolve(new_text, lang, scope, doc_oid); 194 202 } 195 203 text = StringUtils.replace(text, m.macro, new_text);
Note:
See TracChangeset
for help on using the changeset viewer.