001 /** 002 * =========================================== 003 * LibFonts : a free Java font reading library 004 * =========================================== 005 * 006 * Project Info: http://reporting.pentaho.org/libfonts/ 007 * 008 * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors. 009 * 010 * This library is free software; you can redistribute it and/or modify it under the terms 011 * of the GNU Lesser General Public License as published by the Free Software Foundation; 012 * either version 2.1 of the License, or (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 015 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 016 * See the GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License along with this 019 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 020 * Boston, MA 02111-1307, USA. 021 * 022 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 023 * in the United States and other countries.] 024 * 025 * ------------ 026 * $Id: LanguageCode.java 3523 2007-10-16 11:03:09Z tmorgner $ 027 * ------------ 028 * (C) Copyright 2006-2007, by Pentaho Corporation. 029 */ 030 package org.jfree.fonts; 031 032 /** 033 * Different language codes are defined for the mac and windows platform. 034 * The numbering schema is disjunct, so there are no conflicts between the codes 035 * assigned on the Windows platform and the codes assigned on the Macintosh 036 * platform. 037 * 038 * @author Thomas Morgner 039 */ 040 public class LanguageCode 041 { 042 public static class MacLanguageCode extends LanguageCode 043 { 044 public static final LanguageCode ENGLISH = new LanguageCode("english", 0); 045 046 public MacLanguageCode(final String name, final int code) 047 { 048 super(name, code); 049 } 050 } 051 052 public static class MicrosoftLanguageCode extends LanguageCode 053 { 054 public static final LanguageCode ENGLISH_US = new LanguageCode("en_US", 0x0409); 055 056 public MicrosoftLanguageCode(final String name, final int code) 057 { 058 super(name, code); 059 } 060 } 061 062 private int code; 063 private String name; 064 065 public LanguageCode(final String name, final int code) 066 { 067 if (name == null) 068 { 069 throw new NullPointerException("Name must not be null."); 070 } 071 this.name = name; 072 this.code = code; 073 } 074 075 public int getCode() 076 { 077 return code; 078 } 079 080 public String getName() 081 { 082 return name; 083 } 084 085 public boolean equals(final Object o) 086 { 087 if (this == o) 088 { 089 return true; 090 } 091 if (o == null || getClass() != o.getClass()) 092 { 093 return false; 094 } 095 096 final LanguageCode language = (LanguageCode) o; 097 return code == language.code; 098 } 099 100 public int hashCode() 101 { 102 return code; 103 } 104 }