Index: src/java/org/apache/lucene/analysis/Token.java =================================================================== --- src/java/org/apache/lucene/analysis/Token.java (revision 290949) +++ src/java/org/apache/lucene/analysis/Token.java (working copy) @@ -30,7 +30,7 @@ belongs to. For example an end of sentence marker token might be implemented with type "eos". The default token type is "word". */ -public final class Token { +public class Token implements Cloneable { String termText; // the text of the term int startOffset; // start in source text int endOffset; // end in source text @@ -91,6 +91,11 @@ */ public int getPositionIncrement() { return positionIncrement; } + /** Sets the Token's term text. */ + public void setTermText(String text) { + termText = text; + } + /** Returns the Token's term text. */ public final String termText() { return termText; } @@ -109,7 +114,7 @@ /** Returns this Token's lexical type. Defaults to "word". */ public final String type() { return type; } - public final String toString() { + public String toString() { StringBuffer sb = new StringBuffer(); sb.append("(" + termText + "," + startOffset + "," + endOffset); if (!type.equals("word")) @@ -119,4 +124,12 @@ sb.append(")"); return sb.toString(); } + + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(); // won't happen since we implement Cloneable + } + } }