001/** 002 * Copyright 2001 Sun Microsystems, Inc. 003 * 004 * See the file "license.terms" for information on usage and 005 * redistribution of this file, and for a DISCLAIMER OF ALL 006 * WARRANTIES. 007 */ 008package com.sun.speech.freetts; 009 010/** 011 * Provides an enumeration of Gender, following the JSAPI style. 012 * (http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-doc/) 013 * 014 * These are intended for use to define properties about FreeTTS 015 * voices. 016 * 017 * @see Voice 018 */ 019public class Gender implements Comparable<Gender> { 020 private final String name; 021 022 // Ordinal of next created 023 private static int nextOrdinal = 0; 024 025 // Assign an ordinal to this gender 026 private final int ordinal = nextOrdinal++; 027 028 private Gender(String name) {this.name = name;} 029 030 /** 031 * Generates a human readable name describing the gender. 032 * 033 * @return the name of the gender 034 */ 035 public String toString() {return name;} 036 037 /** 038 * Compare two genders. If either is DONT_CARE, then returns 0. 039 */ 040 public int compareTo(Gender gender) { 041 if ((gender == DONT_CARE) || (this == DONT_CARE)) { 042 return 0; 043 } else { 044 return ordinal - gender.ordinal; 045 } 046 } 047 048 /** 049 * Male. 050 */ 051 public static final Gender MALE = new Gender("MALE"); 052 053 /** 054 * Female. 055 */ 056 public static final Gender FEMALE = new Gender("FEMALE"); 057 058 /** 059 * Neutral such as a robot or artificial. 060 */ 061 public static final Gender NEUTRAL = new Gender("NEUTRAL"); 062 063 /** 064 * Match against all other genders. 065 */ 066 public static final Gender DONT_CARE = new Gender("DONT_CARE"); 067}