- Timestamp:
- 2003-10-17T09:48:14+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionConfiguration.java
r5581 r5677 6 6 import org.greenstone.gatherer.msm.MSMUtils; 7 7 import org.greenstone.gatherer.util.Codec; 8 import org.greenstone.gatherer.util.StaticStrings; 8 9 import org.greenstone.gatherer.util.Utility; 9 10 import org.w3c.dom.*; … … 72 73 } 73 74 else if(temp.equalsIgnoreCase("collectionextra")) { 74 temp = tokenizer.nextToken(); 75 ///ystem.err.println("Read: " + temp); 76 if(temp.startsWith("[") && temp.endsWith("]")) { 77 String language = temp.substring(temp.indexOf("=") + 1, temp.length() - 1); 78 ///ystem.err.println("Try to match " + language + " to " + Gatherer.dictionary.getLanguage()); 79 if(description == null || language.equalsIgnoreCase(Gatherer.dictionary.getLanguage())) { 80 description = Utility.decodeGreenstone(tokenizer.nextToken()); 81 ///ystem.err.println("Found language match, or first match: " + description); 82 } 83 } 84 else if(description == null) { 85 description = Codec.transform(temp, Codec.GREENSTONE_TO_TEXT); 86 ///ystem.err.println("Found first match: " + description); 87 } 88 if(description != null && description.startsWith("\"") && description.endsWith("\"")) { 89 description = description.substring(1, description.length() - 1); 90 } 75 // Normal case 76 temp = tokenizer.nextToken(); 77 ///ystem.err.println("Read: " + temp); 78 if(temp.startsWith("[") && temp.endsWith("]")) { 79 String language = temp.substring(temp.indexOf("=") + 1, temp.length() - 1); 80 ///ystem.err.println("Try to match " + language + " to " + Gatherer.dictionary.getLanguage()); 81 if(description == null || language.equalsIgnoreCase(Gatherer.dictionary.getLanguage())) { 82 description = Utility.decodeGreenstone(tokenizer.nextToken()); 83 ///ystem.err.println("Found language match, or first match: " + description); 84 } 85 } 86 else if(description == null){ 87 // Some of the collections floating around have collection extras which contain normal newlines, and so their initial description starts with " (the Command Tokenizer hasn't found a closing speech mark). This will cause an error message to be displayed for the collection. If we have read a collectionextra tag, but we have run out of tokens then we do a sneaky and start reading lines until we encounter a closing " 88 if(temp.startsWith(StaticStrings.SPEECH_CHARACTER) && (!temp.endsWith(StaticStrings.SPEECH_CHARACTER) || temp.length() ==1 )) { 89 ///ystem.err.println("Encountered a strange Collection Description. Doing my best to parse a sensible text block!"); 90 StringBuffer description_raw = new StringBuffer(""); 91 while(description_raw.indexOf(StaticStrings.SPEECH_CHARACTER) == -1) { 92 String next_line = br.readLine(); 93 if(next_line != null) { 94 description_raw.append(next_line); 95 description_raw.append(StaticStrings.NEW_LINE_CHAR); 96 } 97 next_line = null; 98 } 99 description = description_raw.substring(0, description_raw.lastIndexOf(StaticStrings.SPEECH_CHARACTER)); 100 description_raw = null; 101 } 102 else { 103 description = Codec.transform(temp, Codec.GREENSTONE_TO_TEXT); 104 } 105 } 106 if(description != null && description.startsWith(StaticStrings.SPEECH_CHARACTER) && description.endsWith(StaticStrings.SPEECH_CHARACTER)) { 107 description = description.substring(1, description.length() - 1); 108 } 91 109 } 92 110 } … … 163 181 164 182 public String getName() { 165 String result = "Error";183 String result = StaticStrings.ERROR_STR; 166 184 if(name_element != null) { 167 185 result = MSMUtils.getValue(name_element);
Note:
See TracChangeset
for help on using the changeset viewer.