Changeset 11263 for trunk/gsdl3
- Timestamp:
- 2006-02-16T13:31:14+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/MacroResolver.java
r8962 r11263 44 44 this.metadata_macros = new ArrayList(); 45 45 } 46 46 47 47 public void addMacro(int type, String macro, String text_or_metadata, String scope) { 48 public void setSiteDetails(String site_address, String cluster_name) { 49 if (site_address != null) { 50 addMacro(TYPE_TEXT, "_httpsite_", site_address, SCOPE_ALL, false); 51 } 52 if (cluster_name != null) { 53 addMacro(TYPE_TEXT, "_clustername_", cluster_name, SCOPE_ALL, false); 54 } 55 } 56 57 public void addMacro(int type, String macro, String text_or_metadata, String scope, boolean resolve) { 48 58 Macro m = new Macro(); 49 59 m.type = type; 50 60 m.macro = macro; 51 61 m.text = text_or_metadata; 62 m.resolve = resolve; 52 63 addMacro(m, scope); 53 64 } 54 65 55 public void addMacro(int type, String macro, String bundle, String key, String scope ) {66 public void addMacro(int type, String macro, String bundle, String key, String scope, boolean resolve) { 56 67 Macro m = new Macro(); 57 68 m.type = type; … … 59 70 m.bundle = bundle; 60 71 m.key = key; 72 m.resolve = resolve; 61 73 addMacro(m, scope); 62 74 } … … 70 82 scope = SCOPE_ALL; 71 83 } 84 boolean resolve = true; 85 String resolve_str = e.getAttribute("resolve"); 86 if (resolve_str.equals("false")) { 87 resolve = false; 88 } 72 89 String from = e.getAttribute("macro"); 73 90 String to = e.getAttribute("text"); 74 91 if (!to.equals("")) { 75 addMacro(TYPE_TEXT, from, to, scope );92 addMacro(TYPE_TEXT, from, to, scope, resolve); 76 93 } else { 77 94 String meta = e.getAttribute("metadata"); 78 95 if (!meta.equals("")) { 79 addMacro(TYPE_META, from, meta, scope );96 addMacro(TYPE_META, from, meta, scope, resolve); 80 97 } else { 81 98 String key = e.getAttribute("key"); 82 99 String bundle = e.getAttribute("bundle"); 83 addMacro(TYPE_DICT, from, bundle, key, scope );100 addMacro(TYPE_DICT, from, bundle, key, scope, resolve); 84 101 } 85 }102 } 86 103 } 87 104 … … 109 126 protected class Macro { 110 127 128 /** type of replacement: TEXT, METADATA, DICTIONARY */ 111 129 public int type; 130 /** the macro to replace */ 112 131 public String macro = null; 113 public String text = null; 132 /** If text type, holds the text to replace with. If metadata type, holds the metadata name */ 133 public String text = null; 134 /** If dictionary type, holds the key to look up in the dictionary */ 114 135 public String key = null; 136 /** If dictionary type, holds the resource bundle name */ 115 137 public String bundle = null; 138 /** If true, will try to resolve macros in the replacement text */ 139 public boolean resolve = true; 116 140 117 141 }
Note:
See TracChangeset
for help on using the changeset viewer.