Changeset 18405 for greenstone3/trunk/src/java/org/greenstone/gsdl3/util
- Timestamp:
- 2009-01-19T15:15:38+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/util/Dictionary.java
r13989 r18405 118 118 // convert to unicode, copied from gatherer dictionary 119 119 String initial = new String(initial_raw.getBytes("ISO-8859-1"), "UTF-8"); 120 121 // Remove any comments from the string 122 if (initial.indexOf("#") != -1) { 123 initial = initial.substring(0, initial.indexOf("#")); 124 } 120 125 // If the string contains arguments we have to insert them. 121 String complete = "";126 StringBuffer complete = new StringBuffer(); 122 127 // While we still have initial string left. 123 128 while(initial.length() > 0 && initial.indexOf('{') != -1 && initial.indexOf('}') != -1) { … … 125 130 int opening = initial.indexOf('{'); 126 131 int closing = initial.indexOf('}'); 127 complete = complete + initial.substring(0, opening); 132 int comment_mark = initial.indexOf('-', opening); // May not exist 133 if (comment_mark > closing) { // May also be detecting a later comment 134 comment_mark = -1; 135 } 136 complete.append(initial.substring(0, opening)); 137 128 138 // Parse arg_num 129 String arg_str = initial.substring(opening + 1, closing); 130 int arg_num = Integer.parseInt(arg_str); 139 String arg_str = null; 140 if (comment_mark != -1) { 141 arg_str = initial.substring(opening + 1, comment_mark); 142 } else { 143 arg_str = initial.substring(opening + 1, closing); 144 } 131 145 if(closing + 1 < initial.length()) { 132 146 initial = initial.substring(closing + 1); … … 135 149 initial = ""; 136 150 } 151 int arg_num = Integer.parseInt(arg_str); 137 152 // Insert argument 138 153 if(args != null && 0 <= arg_num && arg_num < args.length) { 139 complete = complete + args[arg_num];154 complete.append(args[arg_num]); 140 155 } 141 156 } 142 return complete + initial; 157 complete.append(initial); 158 return complete.toString(); 143 159 } 144 160 catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.