source: trunk/gli/src/org/greenstone/gatherer/cdm/Language.java@ 4675

Last change on this file since 4675 was 4675, checked in by jmt12, 21 years ago

Sunday's work

  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37
38
39
40
41
42
43package org.greenstone.gatherer.cdm;
44/**************************************************************************************
45 * Title: Gatherer
46 * Description: The Gatherer: a tool for gathering and enriching a digital collection.
47 * Copyright: Copyright (c) 2001
48 * Company: The University of Waikato
49 * Written: 08/05/02
50 * Revised: 17/11/02 - Commented
51 **************************************************************************************/
52
53/** A pretty unexciting extension of a two character string, in that it has a field which details if its the default language.
54* @author John Thompson, Greenstone Digital Library, University of Waikato
55* @version 2.1
56*/
57public class Language
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 */
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 * @param language The <strong>Language</strong> we want to copy.
77 */
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 * @param object The other language as an <strong>Object</strong>.
85 * @return An <i>int</i> which indicates order using the same values as in String.compareTo().
86 * @see java.lang.String#compareTo
87 */
88 public int compareTo(Object object) {
89 return toString().compareTo(object.toString());
90 }
91 /** Method to test for the equality of two languages.
92 * @param object The other language as an <strong>Object</strong>.
93 * @return <i>true</i> if the languages are equal, <i>false</i> otherwise.
94 */
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 * @return A <strong>String</strong> representing the two letter code.
103 */
104 public String getCode() {
105 return value;
106 }
107 /** Method to determine if this language is the default one.
108 * @return A <i>boolean</i> which is <i>true</i> if this language is the default one.
109 */
110 public boolean isDefault() {
111 return default_language;
112 }
113 /** Method to set the value of default.
114 * @param value The new value of default as a <i>boolean</i>.
115 */
116 public void setDefault(boolean value) {
117 this.default_language = default_language;
118 }
119 /** Method to display the language code.
120 * @return A <strong>String</strong> representing the language code.
121 */
122 public String toString() {
123 return name;
124 }
125}
126
127
128
129
130
Note: See TracBrowser for help on using the repository browser.