Changeset 12277
- Timestamp:
- 2006-07-24T11:26:11+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Language.java
r9561 r12277 27 27 package org.greenstone.gatherer.cdm; 28 28 29 29 import java.util.ArrayList; 30 30 import org.w3c.dom.*; 31 31 … … 38 38 /** The Element this language entry is based upon. */ 39 39 private Element element = null; 40 /** The two character code for this language.*/40 /** A comma separated list of two character codes */ 41 41 private String code = null; 42 /** The name of this language.*/42 /** A comma separated list of language names */ 43 43 private String name = null; 44 44 … … 57 57 element.setAttribute(CollectionConfiguration.NAME_ATTRIBUTE, code); 58 58 element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.TRUE_STR); 59 } 60 61 /** Constructor which takes an ArrayList of codes */ 62 public Language(ArrayList codes) { 63 StringBuffer code_str = new StringBuffer(); 64 boolean first = true; 65 for (int i=0; i<codes.size(); i++) { 66 if (!first) { 67 code_str.append(","); 68 } else { 69 first = false; 70 } 71 code_str.append(codes.get(i)); 72 } 73 this.code = code_str.toString(); 74 element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.LANGUAGE_ELEMENT); 75 element.setAttribute(CollectionConfiguration.NAME_ATTRIBUTE, code); 76 element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.TRUE_STR); 77 59 78 } 60 79 … … 76 95 */ 77 96 public boolean equals(Object object) { 78 //return (compareTo(object) == 0);79 97 // two langs are equal if their codes are equal 80 98 if (object instanceof Language) { 81 99 return getCode().equals(((Language)object).getCode()); 100 } else if (object instanceof String) { 101 return getCode().equals((String)object); 82 102 } 83 103 return false; … … 100 120 public String getName() { 101 121 if(name == null) { 102 String code = getCode(); 103 name = CollectionDesignManager.language_manager.getLanguageName(code); 122 String code_str = getCode(); 123 String [] codes = code_str.split(","); 124 StringBuffer name_str = new StringBuffer(); 125 boolean first = true; 126 for (int i=0; i<codes.length; i++) { 127 if (!first) { 128 name_str.append(","); 129 } else { 130 first = false; 131 } 132 name_str.append(CollectionDesignManager.language_manager.getLanguageName(codes[i])); 133 } 134 name = name_str.toString(); 104 135 } 105 136 return name;
Note:
See TracChangeset
for help on using the changeset viewer.