upstream version 1.2.2
[debian/freetts] / com / sun / speech / freetts / Age.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 Age, following JSAPI style.
12  * (http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-doc/)
13  *
14  * This is intended for use to define properties about FreeTTS voices.
15  *
16  * @see Voice
17  */
18 public class Age implements Comparable {
19     private final String name;
20
21     // Ordinal of next created
22     private static int nextOrdinal = 0;
23
24     // Assign an ordinal to this age
25     private final int ordinal = nextOrdinal++;
26
27     private Age(String name) {this.name = name;}
28
29     /**
30      * Provide a human readable string that describes the age.
31      *
32      * @return the name of the age
33      */
34     public String toString() {return name;}
35
36     /**
37      * Compare two ages.  CHILD is less than TEENAGER, and so on.  If
38      * either age is DONT_CARE, then they are equal.
39      */
40     public int compareTo(Object o) {
41         if ((o == DONT_CARE) || (this == DONT_CARE)) {
42             return 0;
43         } else {
44             return ordinal - ((Age) o).ordinal;
45         }
46     }
47
48     /**
49      * Age roughly up to 12 years.
50      */
51     public static final Age CHILD = new Age("CHILD");
52
53     /**
54      * Age roughly 13 to 19 years.
55      */
56     public static final Age TEENAGER = new Age("TEENAGER");
57
58     /**
59      * Age roughly 20 to 40 years.
60      */
61     public static final Age YOUNGER_ADULT = new Age("YOUNGER_ADULT");
62
63     /**
64      * Age roughly 40 to 60 years.
65      */
66     public static final Age MIDDLE_ADULT = new Age("MIDDLE_ADULT");
67
68     /**
69      * Age roughly 60 years and up.
70      */
71     public static final Age OLDER_ADULT = new Age("OLDER_ADULT");
72
73     /**
74      * An Age that is indeterminate.
75      */
76     public static final Age NEUTRAL = new Age("NEUTRAL");
77
78     /**
79      * Matches against any Age.
80      */
81     public static final Age DONT_CARE = new Age("DONT_CARE");
82 }