Index: src/java/org/apache/lucene/analysis/TokenStream.java =================================================================== --- src/java/org/apache/lucene/analysis/TokenStream.java (revision 806450) +++ src/java/org/apache/lucene/analysis/TokenStream.java (working copy) @@ -196,7 +196,7 @@ return ((TokenStream) input).tokenWrapper; } // check that all attributes are implemented by the same TokenWrapper instance - final AttributeImpl att = addAttribute(TermAttribute.class); + final Attribute att = addAttribute(TermAttribute.class); if (att instanceof TokenWrapper && addAttribute(TypeAttribute.class) == att && addAttribute(PositionIncrementAttribute.class) == att && Index: src/java/org/apache/lucene/util/AttributeImpl.java =================================================================== --- src/java/org/apache/lucene/util/AttributeImpl.java (revision 806450) +++ src/java/org/apache/lucene/util/AttributeImpl.java (working copy) @@ -28,7 +28,7 @@ * Attributes are used to add data in a dynamic, yet type-safe way to a source * of usually streamed objects, e. g. a {@link org.apache.lucene.analysis.TokenStream}. */ -public abstract class AttributeImpl implements Cloneable, Serializable { +public abstract class AttributeImpl implements Cloneable, Serializable, Attribute { /** * Clears the values in this AttributeImpl and resets it to its * default value. If this implementation implements more than one Attribute interface Index: src/java/org/apache/lucene/util/AttributeSource.java =================================================================== --- src/java/org/apache/lucene/util/AttributeSource.java (revision 806450) +++ src/java/org/apache/lucene/util/AttributeSource.java (working copy) @@ -44,6 +44,7 @@ public static abstract class AttributeFactory { /** * returns an {@link AttributeImpl} for the supplied {@link Attribute} interface class. + *
Signature for Java 1.5: public AttributeImpl createAttributeInstance(Class%lt;? extends Attribute> attClass)
*/
public abstract AttributeImpl createAttributeInstance(Class attClass);
@@ -128,16 +129,18 @@
/** Returns a new iterator that iterates the attribute classes
* in the same order they were added in.
+ *
Signature for Java 1.5: Signature for Java 1.5: Signature for Java 1.5: Signature for Java 1.5: Signature for Java 1.5: public Iterator<Class<? extends Attribute>> getAttributeClassesIterator()
*/
- public Iterator/*public Iterator<AttributeImpl> getAttributeImplsIterator()
*/
- public Iterator/*public <T extends Attribute> T addAttribute(Class<T>)
*/
- public AttributeImpl addAttribute(Class attClass) {
- AttributeImpl att = (AttributeImpl) attributes.get(attClass);
+ public Attribute addAttribute(Class attClass) {
+ final Attribute att = (Attribute) attributes.get(attClass);
if (att == null) {
- att = this.factory.createAttributeInstance(attClass);
- addAttributeImpl(att);
+ final AttributeImpl attImpl = this.factory.createAttributeInstance(attClass);
+ addAttributeImpl(attImpl);
+ return attImpl;
+ } else {
+ return att;
}
- return att;
}
/** Returns true, iff this AttributeSource has any attributes */
@@ -231,6 +237,7 @@
/**
* The caller must pass in a Class<? extends Attribute> value.
* Returns true, iff this AttributeSource contains the passed-in Attribute.
+ * public boolean hasAttribute(Class<? extends Attribute>)
*/
public boolean hasAttribute(Class attClass) {
return this.attributes.containsKey(attClass);
@@ -239,12 +246,13 @@
/**
* The caller must pass in a Class<? extends Attribute> value.
* Returns the instance of the passed in Attribute contained in this AttributeSource
+ * public <T extends Attribute> T getAttribute(Class<T>)
*
* @throws IllegalArgumentException if this AttributeSource does not contain the
* Attribute
*/
- public AttributeImpl getAttribute(Class attClass) {
- AttributeImpl att = (AttributeImpl) this.attributes.get(attClass);
+ public Attribute getAttribute(Class attClass) {
+ Attribute att = (Attribute) this.attributes.get(attClass);
if (att == null) {
throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass + "'.");
}