Source for org.jfree.fonts.LanguageCode

   1: /**
   2:  * ===========================================
   3:  * LibFonts : a free Java font reading library
   4:  * ===========================================
   5:  *
   6:  * Project Info:  http://reporting.pentaho.org/libfonts/
   7:  *
   8:  * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors.
   9:  *
  10:  * This library is free software; you can redistribute it and/or modify it under the terms
  11:  * of the GNU Lesser General Public License as published by the Free Software Foundation;
  12:  * either version 2.1 of the License, or (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15:  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16:  * See the GNU Lesser General Public License for more details.
  17:  *
  18:  * You should have received a copy of the GNU Lesser General Public License along with this
  19:  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20:  * Boston, MA 02111-1307, USA.
  21:  *
  22:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  23:  * in the United States and other countries.]
  24:  *
  25:  * ------------
  26:  * $Id: LanguageCode.java 3523 2007-10-16 11:03:09Z tmorgner $
  27:  * ------------
  28:  * (C) Copyright 2006-2007, by Pentaho Corporation.
  29:  */
  30: package org.jfree.fonts;
  31: 
  32: /**
  33:  * Different language codes are defined for the mac and windows platform.
  34:  * The numbering schema is disjunct, so there are no conflicts between the codes
  35:  * assigned on the Windows platform and the codes assigned on the Macintosh
  36:  * platform.
  37:  *
  38:  * @author Thomas Morgner
  39:  */
  40: public class LanguageCode
  41: {
  42:   public static class MacLanguageCode extends LanguageCode
  43:   {
  44:     public static final LanguageCode ENGLISH = new LanguageCode("english", 0);
  45: 
  46:     public MacLanguageCode(final String name, final int code)
  47:     {
  48:       super(name, code);
  49:     }
  50:   }
  51: 
  52:   public static class MicrosoftLanguageCode extends LanguageCode
  53:   {
  54:     public static final LanguageCode ENGLISH_US = new LanguageCode("en_US", 0x0409);
  55: 
  56:     public MicrosoftLanguageCode(final String name, final int code)
  57:     {
  58:       super(name, code);
  59:     }
  60:   }
  61: 
  62:   private int code;
  63:   private String name;
  64: 
  65:   public LanguageCode(final String name, final int code)
  66:   {
  67:     if (name == null)
  68:     {
  69:       throw new NullPointerException("Name must not be null.");
  70:     }
  71:     this.name = name;
  72:     this.code = code;
  73:   }
  74: 
  75:   public int getCode()
  76:   {
  77:     return code;
  78:   }
  79: 
  80:   public String getName()
  81:   {
  82:     return name;
  83:   }
  84: 
  85:   public boolean equals(final Object o)
  86:   {
  87:     if (this == o)
  88:     {
  89:       return true;
  90:     }
  91:     if (o == null || getClass() != o.getClass())
  92:     {
  93:       return false;
  94:     }
  95: 
  96:     final LanguageCode language = (LanguageCode) o;
  97:     return code == language.code;
  98:   }
  99: 
 100:   public int hashCode()
 101:   {
 102:     return code;
 103:   }
 104: }