mirror of https://github.com/apache/lucene.git
remove final, implement Cloneable, setTermText(): LUCENE-438
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@410954 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4944720897
commit
1d6371df43
|
@ -8,6 +8,11 @@ New features
|
||||||
|
|
||||||
1.
|
1.
|
||||||
|
|
||||||
|
API Changes
|
||||||
|
|
||||||
|
1. LUCENE-438: Remove "final" from Token, implement Cloneable, allow
|
||||||
|
changing of termText via setTermText(). (Yonik Seeley)
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
||||||
1. Fixed the web application demo (built with "ant war-demo") which
|
1. Fixed the web application demo (built with "ant war-demo") which
|
||||||
|
|
|
@ -30,7 +30,7 @@ package org.apache.lucene.analysis;
|
||||||
belongs to. For example an end of sentence marker token might be implemented
|
belongs to. For example an end of sentence marker token might be implemented
|
||||||
with type "eos". The default token type is "word". */
|
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
|
String termText; // the text of the term
|
||||||
int startOffset; // start in source text
|
int startOffset; // start in source text
|
||||||
int endOffset; // end in source text
|
int endOffset; // end in source text
|
||||||
|
@ -91,6 +91,11 @@ public final class Token {
|
||||||
*/
|
*/
|
||||||
public int getPositionIncrement() { return positionIncrement; }
|
public int getPositionIncrement() { return positionIncrement; }
|
||||||
|
|
||||||
|
/** Sets the Token's term text. */
|
||||||
|
public void setTermText(String text) {
|
||||||
|
termText = text;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the Token's term text. */
|
/** Returns the Token's term text. */
|
||||||
public final String termText() { return termText; }
|
public final String termText() { return termText; }
|
||||||
|
|
||||||
|
@ -109,7 +114,7 @@ public final class Token {
|
||||||
/** Returns this Token's lexical type. Defaults to "word". */
|
/** Returns this Token's lexical type. Defaults to "word". */
|
||||||
public final String type() { return type; }
|
public final String type() { return type; }
|
||||||
|
|
||||||
public final String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("(" + termText + "," + startOffset + "," + endOffset);
|
sb.append("(" + termText + "," + startOffset + "," + endOffset);
|
||||||
if (!type.equals("word"))
|
if (!type.equals("word"))
|
||||||
|
@ -119,4 +124,12 @@ public final class Token {
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e); // shouldn't happen since we implement Cloneable
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue