upstream version 1.2.2
[debian/freetts] / com / sun / speech / freetts / Gender.java
1 /**
2  * Copyright 2001 Sun Microsystems, Inc.
3  * 
4  * See the file "license.terms" for information on usage and
5  * redistribution of this file, and for a DISCLAIMER OF ALL 
6  * WARRANTIES.
7  */
8 package com.sun.speech.freetts;
9
10 /**
11  * Provides an enumeration of Gender, following the JSAPI style.
12  * (http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-doc/)
13  *
14  * These are intended for use to define properties about FreeTTS
15  * voices.
16  *
17  * @see Voice
18  */
19 public class Gender implements Comparable {
20     private final String name;
21
22     // Ordinal of next created
23     private static int nextOrdinal = 0;
24
25     // Assign an ordinal to this gender
26     private final int ordinal = nextOrdinal++;
27
28     private Gender(String name) {this.name = name;}
29
30     /**
31      * Generates a human readable name describing the gender.
32      *
33      * @return the name of the gender
34      */
35     public String toString() {return name;}
36
37     /**
38      * Compare two genders.  If either is DONT_CARE, then returns 0.
39      */
40     public int compareTo(Object o) {
41         if ((o == DONT_CARE) || (this == DONT_CARE)) {
42             return 0;
43         } else {
44             return ordinal - ((Gender) o).ordinal;
45         }
46     }
47
48     /**
49      * Male.
50      */
51     public static final Gender MALE = new Gender("MALE");
52
53     /**
54      * Female.
55      */
56     public static final Gender FEMALE = new Gender("FEMALE");
57
58     /**
59      * Neutral such as a robot or artificial.
60      */
61     public static final Gender NEUTRAL = new Gender("NEUTRAL");
62
63     /**
64      * Match against all other genders.
65      */
66     public static final Gender DONT_CARE = new Gender("DONT_CARE");
67 }