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 Age, following JSAPI style.
012 * (http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-doc/)
013 *
014 * This is intended for use to define properties about FreeTTS voices.
015 *
016 * @see Voice
017 */
018public class Age implements Comparable<Age> {
019    private final String name;
020
021    // Ordinal of next created
022    private static int nextOrdinal = 0;
023
024    // Assign an ordinal to this age
025    private final int ordinal = nextOrdinal++;
026
027    private Age(String name) {this.name = name;}
028
029    /**
030     * Provide a human readable string that describes the age.
031     *
032     * @return the name of the age
033     */
034    public String toString() {return name;}
035
036    /**
037     * Compare two ages.  CHILD is less than TEENAGER, and so on.  If
038     * either age is DONT_CARE, then they are equal.
039     */
040    public int compareTo(Age age) {
041        if ((age == DONT_CARE) || (this == DONT_CARE)) {
042            return 0;
043        } else {
044            return ordinal - age.ordinal;
045        }
046    }
047
048    /**
049     * Age roughly up to 12 years.
050     */
051    public static final Age CHILD = new Age("CHILD");
052
053    /**
054     * Age roughly 13 to 19 years.
055     */
056    public static final Age TEENAGER = new Age("TEENAGER");
057
058    /**
059     * Age roughly 20 to 40 years.
060     */
061    public static final Age YOUNGER_ADULT = new Age("YOUNGER_ADULT");
062
063    /**
064     * Age roughly 40 to 60 years.
065     */
066    public static final Age MIDDLE_ADULT = new Age("MIDDLE_ADULT");
067
068    /**
069     * Age roughly 60 years and up.
070     */
071    public static final Age OLDER_ADULT = new Age("OLDER_ADULT");
072
073    /**
074     * An Age that is indeterminate.
075     */
076    public static final Age NEUTRAL = new Age("NEUTRAL");
077
078    /**
079     * Matches against any Age.
080     */
081    public static final Age DONT_CARE = new Age("DONT_CARE");
082}