/** *######################################################################### * * A component of the Gatherer application, part of the Greenstone digital * library suite from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * *

* * Author: John Thompson, Greenstone Digital Library, University of Waikato * *

* * Copyright (C) 1999 New Zealand Digital Library Project * *

* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * *

* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * *

* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *######################################################################## */ package org.greenstone.gatherer.cdm; /************************************************************************************** * Title: Gatherer * Description: The Gatherer: a tool for gathering and enriching a digital collection. * Copyright: Copyright (c) 2001 * Company: The University of Waikato * Written: 08/05/02 * Revised: 17/11/02 - Commented **************************************************************************************/ /** A pretty unexciting extension of a two character string, in that it has a field which details if its the default language. * @author John Thompson, Greenstone Digital Library, University of Waikato * @version 2.1 */ public class Language implements Comparable { /** Is this language the default one. */ private boolean default_language = false; /** The name of this language. */ private String name = null; /** The two character code for this language. */ private String value = null; /** Constructor. * @param value A String representing the code for this language. * @param name A String representing the name of this language. * @param default_language A boolean which is true if this language is the default one. */ public Language(String value, String name, boolean default_language) { this.default_language = default_language; this.name = name; this.value = value.substring(0, 2); } /** Copy constructor. * @param language The Language we want to copy. */ public Language(Language language) { this.default_language = language.isDefault(); this.name = language.toString(); this.value = language.getCode(); } /** Method to compare two languages for ordering purposes. * @param object The other language as an Object. * @return An int which indicates order using the same values as in String.compareTo(). * @see java.lang.String#compareTo */ public int compareTo(Object object) { return toString().compareTo(object.toString()); } /** Method to test for the equality of two languages. * @param object The other language as an Object. * @return true if the languages are equal, false otherwise. */ public boolean equals(Object object) { if(compareTo(object) == 0) { return true; } return false; } /** Method to retrieve the code of this language. * @return A String representing the two letter code. */ public String getCode() { return value; } /** Method to determine if this language is the default one. * @return A boolean which is true if this language is the default one. */ public boolean isDefault() { return default_language; } /** Method to set the value of default. * @param value The new value of default as a boolean. */ public void setDefault(boolean value) { this.default_language = default_language; } /** Method to display the language code. * @return A String representing the language code. */ public String toString() { return name; } }