2 * Portions Copyright 2001 Sun Microsystems, Inc.
3 * Portions Copyright 1999-2001 Language Technologies Institute,
4 * Carnegie Mellon University.
5 * All Rights Reserved. Use is subject to license terms.
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package com.sun.speech.freetts;
14 * Contains a parsed token from a Tokenizer.
18 private String token = null;
19 private String whitespace = null;
20 private String prepunctuation = null;
21 private String postpunctuation = null;
22 private int position = 0; // position in the original input text
23 private int lineNumber = 0;
26 * Returns the whitespace characters of this Token.
28 * @return the whitespace characters of this Token;
29 * null if this Token does not use whitespace characters
31 public String getWhitespace() {
36 * Returns the prepunctuation characters of this Token.
38 * @return the prepunctuation characters of this Token;
39 * null if this Token does not use prepunctuation characters
41 public String getPrepunctuation() {
42 return prepunctuation;
46 * Returns the postpunctuation characters of this Token.
48 * @return the postpunctuation characters of this Token;
49 * null if this Token does not use postpunctuation characters
51 public String getPostpunctuation() {
52 return postpunctuation;
56 * Returns the position of this token in the original input text.
58 * @return the position of this token in the original input text
60 public int getPosition() {
65 * Returns the line of this token in the original text.
67 * @return the line of this token in the original text
69 public int getLineNumber() {
74 * Sets the whitespace characters of this Token.
76 * @param whitespace the whitespace character for this token
78 public void setWhitespace(String whitespace) {
79 this.whitespace = whitespace;
83 * Sets the prepunctuation characters of this Token.
85 * @param prepunctuation the prepunctuation characters
87 public void setPrepunctuation(String prepunctuation) {
88 this.prepunctuation = prepunctuation;
92 * Sets the postpunctuation characters of this Token.
94 * @param postpunctuation the postpunctuation characters
96 public void setPostpunctuation(String postpunctuation) {
97 this.postpunctuation = postpunctuation;
101 * Sets the position of the token in the original input text.
103 * @param position the position of the input text
105 public void setPosition(int position) {
106 this.position = position;
110 * Set the line of this token in the original text.
112 * @param lineNumber the line of this token in the original text
114 public void setLineNumber(int lineNumber) {
115 this.lineNumber = lineNumber;
119 * Returns the string associated with this token.
121 * @return the token if it exists; otherwise null
123 public String getWord() {
128 * Sets the string of this Token.
130 * @param word the word for this token
132 public void setWord(String word) {
137 * Converts this token to a string.
139 * @return the string representation of this object
141 public String toString() {
142 StringBuffer fullToken = new StringBuffer();
144 if (whitespace != null) {
145 fullToken.append(whitespace);
147 if (prepunctuation != null) {
148 fullToken.append(prepunctuation);
151 fullToken.append(token);
153 if (postpunctuation != null) {
154 fullToken.append(postpunctuation);
156 return fullToken.toString();