Apache Solr open-source search software
remove final, implement Cloneable, setTermText(): LUCENE-438
Yonik Seeley1d6371df439b
diff --git a/CHANGES.txt b/CHANGES.txtindex edbf984fade..8e2f5e6cb8d 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -8,6 +8,11 @@ New features1.+API Changes++ 1. LUCENE-438: Remove "final" from Token, implement Cloneable, allow+ changing of termText via setTermText(). (Yonik Seeley)+Bug fixes1. Fixed the web application demo (built with "ant war-demo") whichdiff --git a/src/java/org/apache/lucene/analysis/Token.java b/src/java/org/apache/lucene/analysis/Token.javaindex a761bed7520..2d0e28af0b9 100644--- a/src/java/org/apache/lucene/analysis/Token.java+++ b/src/java/org/apache/lucene/analysis/Token.java@@ -30,7 +30,7 @@ package org.apache.lucene.analysis;belongs to. For example an end of sentence marker token might be implementedwith type "eos". The default token type is "word". */-public final class Token {+public class Token implements Cloneable {String termText; // the text of the termint startOffset; // start in source textint endOffset; // end in source text@@ -91,6 +91,11 @@ public final class Token {*/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 @@ public final class Token {/** 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 @@ public final class Token {sb.append(")");return sb.toString();}++ public Object clone() {+ try {+ return super.clone();+ } catch (CloneNotSupportedException e) {+ throw new RuntimeException(e); // shouldn't happen since we implement Cloneable+ }+ }}