Changeset 4366 for trunk/gli/src/org/greenstone/gatherer/cdm/Language.java
- Timestamp:
- 2003-05-27T15:57:37+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Language.java
r4293 r4366 56 56 */ 57 57 public class Language 58 59 60 61 62 63 64 65 66 67 68 58 implements Comparable { 59 /** Is this language the default one. */ 60 private boolean default_language = false; 61 /** The name of this language. */ 62 private String name = null; 63 /** The two character code for this language. */ 64 private String value = null; 65 /** Constructor. 66 * @param value A <strong>String</strong> representing the code for this language. 67 * @param name A <strong>String</strong> representing the name of this language. 68 * @param default_language A <i>boolean</i> which is <i>true</i> if this language is the default one. 69 69 */ 70 71 72 73 74 75 70 public Language(String value, String name, boolean default_language) { 71 this.default_language = default_language; 72 this.name = name; 73 this.value = value.substring(0, 2); 74 } 75 /** Copy constructor. 76 76 * @param language The <strong>Language</strong> we want to copy. 77 77 */ 78 79 80 81 82 83 78 public Language(Language language) { 79 this.default_language = language.isDefault(); 80 this.name = language.toString(); 81 this.value = language.getCode(); 82 } 83 /** Method to compare two languages for ordering purposes. 84 84 * @param object The other language as an <strong>Object</strong>. 85 85 * @return An <i>int</i> which indicates order using the same values as in String.compareTo(). 86 86 * @see java.lang.String#compareTo 87 87 */ 88 89 90 91 88 public int compareTo(Object object) { 89 return toString().compareTo(object.toString()); 90 } 91 /** Method to test for the equality of two languages. 92 92 * @param object The other language as an <strong>Object</strong>. 93 93 * @return <i>true</i> if the languages are equal, <i>false</i> otherwise. 94 94 */ 95 96 97 98 99 100 101 95 public boolean equals(Object object) { 96 if(compareTo(object) == 0) { 97 return true; 98 } 99 return false; 100 } 101 /** Method to retrieve the code of this language. 102 102 * @return A <strong>String</strong> representing the two letter code. 103 103 */ 104 105 106 107 104 public String getCode() { 105 return value; 106 } 107 /** Method to determine if this language is the default one. 108 108 * @return A <i>boolean</i> which is <i>true</i> if this language is the default one. 109 109 */ 110 111 112 113 110 public boolean isDefault() { 111 return default_language; 112 } 113 /** Method to set the value of default. 114 114 * @param value The new value of default as a <i>boolean</i>. 115 115 */ 116 117 118 119 116 public void setDefault(boolean value) { 117 this.default_language = default_language; 118 } 119 /** Method to display the language code. 120 120 * @return A <strong>String</strong> representing the language code. 121 121 */ 122 123 124 122 public String toString() { 123 return name; 124 } 125 125 } 126 126
Note:
See TracChangeset
for help on using the changeset viewer.