lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r820553 [3/4] - in /lucene/java/trunk: ./ contrib/analyzers/common/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/ contrib/analyzers/common/src/java/org/apac...
Date Thu, 01 Oct 2009 07:53:53 GMT
Modified: lucene/java/trunk/contrib/wikipedia/src/test/org/apache/lucene/wikipedia/analysis/WikipediaTokenizerTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wikipedia/src/test/org/apache/lucene/wikipedia/analysis/WikipediaTokenizerTest.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wikipedia/src/test/org/apache/lucene/wikipedia/analysis/WikipediaTokenizerTest.java (original)
+++ lucene/java/trunk/contrib/wikipedia/src/test/org/apache/lucene/wikipedia/analysis/WikipediaTokenizerTest.java Thu Oct  1 07:53:43 2009
@@ -128,8 +128,8 @@
     int numBoldItalics = 0;
     int numCategory = 0;
     int numCitation = 0;
-    TermAttribute termAtt = (TermAttribute) tf.addAttribute(TermAttribute.class);
-    TypeAttribute typeAtt = (TypeAttribute) tf.addAttribute(TypeAttribute.class);
+    TermAttribute termAtt = tf.addAttribute(TermAttribute.class);
+    TypeAttribute typeAtt = tf.addAttribute(TypeAttribute.class);
     
     while (tf.incrementToken()) {
       String tokText = termAtt.term();
@@ -164,8 +164,8 @@
   }
 
   private void checkLinkPhrases(WikipediaTokenizer tf) throws IOException {
-    TermAttribute termAtt = (TermAttribute) tf.addAttribute(TermAttribute.class);
-    PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) tf.addAttribute(PositionIncrementAttribute.class);
+    TermAttribute termAtt = tf.addAttribute(TermAttribute.class);
+    PositionIncrementAttribute posIncrAtt = tf.addAttribute(PositionIncrementAttribute.class);
     
     assertTrue(tf.incrementToken());
     assertTrue(termAtt.term() + " is not equal to " + "click", termAtt.term().equals("click") == true);
@@ -229,8 +229,8 @@
   public void testLinks() throws Exception {
     String test = "[http://lucene.apache.org/java/docs/index.html#news here] [http://lucene.apache.org/java/docs/index.html?b=c here] [https://lucene.apache.org/java/docs/index.html?b=c here]";
     WikipediaTokenizer tf = new WikipediaTokenizer(new StringReader(test));
-    TermAttribute termAtt = (TermAttribute) tf.addAttribute(TermAttribute.class);
-    TypeAttribute typeAtt = (TypeAttribute) tf.addAttribute(TypeAttribute.class);
+    TermAttribute termAtt = tf.addAttribute(TermAttribute.class);
+    TypeAttribute typeAtt = tf.addAttribute(TypeAttribute.class);
     
     assertTrue(tf.incrementToken());
     assertTrue(termAtt.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html#news",
@@ -262,9 +262,9 @@
     checkLinkPhrases(tf);
     String test = "[[Category:a b c d]] [[Category:e f g]] [[link here]] [[link there]] ''italics here'' something ''more italics'' [[Category:h   i   j]]";
     tf = new WikipediaTokenizer(new StringReader(test), WikipediaTokenizer.UNTOKENIZED_ONLY, untoks);
-    TermAttribute termAtt = (TermAttribute) tf.addAttribute(TermAttribute.class);
-    PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) tf.addAttribute(PositionIncrementAttribute.class);
-    OffsetAttribute offsetAtt = (OffsetAttribute) tf.addAttribute(OffsetAttribute.class);
+    TermAttribute termAtt = tf.addAttribute(TermAttribute.class);
+    PositionIncrementAttribute posIncrAtt = tf.addAttribute(PositionIncrementAttribute.class);
+    OffsetAttribute offsetAtt = tf.addAttribute(OffsetAttribute.class);
     
     assertTrue(tf.incrementToken());
     assertTrue(termAtt.term() + " is not equal to " + "a b c d",
@@ -338,11 +338,11 @@
     String test = "[[Category:a b c d]] [[Category:e f g]] [[link here]] [[link there]] ''italics here'' something ''more italics'' [[Category:h   i   j]]";
     //should output all the indivual tokens plus the untokenized tokens as well.  Untokenized tokens
     WikipediaTokenizer tf = new WikipediaTokenizer(new StringReader(test), WikipediaTokenizer.BOTH, untoks);
-    TermAttribute termAtt = (TermAttribute) tf.addAttribute(TermAttribute.class);
-    TypeAttribute typeAtt = (TypeAttribute) tf.addAttribute(TypeAttribute.class);
-    PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) tf.addAttribute(PositionIncrementAttribute.class);
-    OffsetAttribute offsetAtt = (OffsetAttribute) tf.addAttribute(OffsetAttribute.class);
-    FlagsAttribute flagsAtt = (FlagsAttribute) tf.addAttribute(FlagsAttribute.class);
+    TermAttribute termAtt = tf.addAttribute(TermAttribute.class);
+    TypeAttribute typeAtt = tf.addAttribute(TypeAttribute.class);
+    PositionIncrementAttribute posIncrAtt = tf.addAttribute(PositionIncrementAttribute.class);
+    OffsetAttribute offsetAtt = tf.addAttribute(OffsetAttribute.class);
+    FlagsAttribute flagsAtt = tf.addAttribute(FlagsAttribute.class);
     
     assertTrue(tf.incrementToken());
     assertTrue(termAtt.term() + " is not equal to " + "a b c d",

Modified: lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java Thu Oct  1 07:53:43 2009
@@ -114,7 +114,7 @@
 
 		// [1] Parse query into separate words so that when we expand we can avoid dups
 		TokenStream ts = a.tokenStream( field, new StringReader( query));
-		TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+		TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
 		
 		while (ts.incrementToken()) {
 		  String word = termAtt.term();

Modified: lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java Thu Oct  1 07:53:43 2009
@@ -101,7 +101,7 @@
 
 		// [1] Parse query into separate words so that when we expand we can avoid dups
 		TokenStream ts = a.tokenStream( field, new StringReader( query));
-    TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+    TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
     
 		while (ts.incrementToken()) {
 			String word = termAtt.term();

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java Thu Oct  1 07:53:43 2009
@@ -77,7 +77,7 @@
 		    for (int i = 0; i < fields.length; i++)
             {
                 TokenStream ts = analyzer.tokenStream(fields[i],new StringReader(stopWords));
-                TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+                TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
                 try
                 {
 	                while(ts.incrementToken()) {

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java Thu Oct  1 07:53:43 2009
@@ -56,7 +56,7 @@
 		{
 			ArrayList clausesList=new ArrayList();
 			TokenStream ts=analyzer.tokenStream(fieldName,new StringReader(value));
-			TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+			TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
 			
 	    while (ts.incrementToken()) {
 			    SpanTermQuery stq=new SpanTermQuery(new Term(fieldName, termAtt.term()));

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java Thu Oct  1 07:53:43 2009
@@ -57,7 +57,7 @@
 		String text = DOMUtils.getNonBlankTextOrFail(e);
 		String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
 		TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
-    TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+    TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
     
 		try
 		{

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsQueryBuilder.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsQueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsQueryBuilder.java Thu Oct  1 07:53:43 2009
@@ -57,7 +57,7 @@
 		TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
 		try
 		{
-		  TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
+		  TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
 			Term term = null;
 			while (ts.incrementToken()) {
 				if (term == null)

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java Thu Oct  1 07:53:43 2009
@@ -60,7 +60,7 @@
   public ASCIIFoldingFilter(TokenStream input)
   {
     super(input);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   private char[] output = new char[512];

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/CharTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/CharTokenizer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/CharTokenizer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/CharTokenizer.java Thu Oct  1 07:53:43 2009
@@ -28,20 +28,20 @@
 public abstract class CharTokenizer extends Tokenizer {
   public CharTokenizer(Reader input) {
     super(input);
-    offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    offsetAtt = addAttribute(OffsetAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   public CharTokenizer(AttributeSource source, Reader input) {
     super(source, input);
-    offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    offsetAtt = addAttribute(OffsetAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   public CharTokenizer(AttributeFactory factory, Reader input) {
     super(factory, input);
-    offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    offsetAtt = addAttribute(OffsetAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
   
   private int offset = 0, bufferIndex = 0, dataLen = 0;

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/ISOLatin1AccentFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/ISOLatin1AccentFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/ISOLatin1AccentFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/ISOLatin1AccentFilter.java Thu Oct  1 07:53:43 2009
@@ -32,7 +32,7 @@
 public class ISOLatin1AccentFilter extends TokenFilter {
   public ISOLatin1AccentFilter(TokenStream input) {
     super(input);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   private char[] output = new char[256];

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/KeywordTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/KeywordTokenizer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/KeywordTokenizer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/KeywordTokenizer.java Thu Oct  1 07:53:43 2009
@@ -57,8 +57,8 @@
   
   private void init(int bufferSize) {
     this.done = false;
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-    offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
+    offsetAtt = addAttribute(OffsetAttribute.class);
     termAtt.resizeTermBuffer(bufferSize);    
   }
   

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/LengthFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/LengthFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/LengthFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/LengthFilter.java Thu Oct  1 07:53:43 2009
@@ -43,7 +43,7 @@
     super(in);
     this.min = min;
     this.max = max;
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
   
   /**
@@ -58,7 +58,7 @@
       }
       // note: else we ignore it but should we index each part of it?
     }
-    // reached EOS -- return null
+    // reached EOS -- return false
     return false;
   }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/LowerCaseFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/LowerCaseFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/LowerCaseFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/LowerCaseFilter.java Thu Oct  1 07:53:43 2009
@@ -29,7 +29,7 @@
 public final class LowerCaseFilter extends TokenFilter {
   public LowerCaseFilter(TokenStream in) {
     super(in);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   private TermAttribute termAtt;

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java Thu Oct  1 07:53:43 2009
@@ -241,9 +241,9 @@
   }
 
   // members
-  private final TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-  private final TypeAttribute typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
-  private final PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
+  private final TermAttribute termAtt = addAttribute(TermAttribute.class);
+  private final TypeAttribute typeAtt = addAttribute(TypeAttribute.class);
+  private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
   
   private int shift = 0, valSize = 0; // valSize==0 means not initialized
   private final int precisionStep;

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/PorterStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/PorterStemFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/PorterStemFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/PorterStemFilter.java Thu Oct  1 07:53:43 2009
@@ -46,7 +46,7 @@
   public PorterStemFilter(TokenStream in) {
     super(in);
     stemmer = new PorterStemmer();
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
 
   public final boolean incrementToken() throws IOException {

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java Thu Oct  1 07:53:43 2009
@@ -163,8 +163,8 @@
   }
   
   public void init() {
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-    posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
+    posIncrAtt = addAttribute(PositionIncrementAttribute.class);
   }
 
   /**

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/TokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/TokenStream.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/TokenStream.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/TokenStream.java Thu Oct  1 07:53:43 2009
@@ -103,13 +103,13 @@
   private static final class MethodSupport {
     final boolean hasIncrementToken, hasReusableNext, hasNext;
 
-    MethodSupport(Class clazz) {
-      hasIncrementToken = isMethodOverridden(clazz, "incrementToken", METHOD_NO_PARAMS);
-      hasReusableNext = isMethodOverridden(clazz, "next", METHOD_TOKEN_PARAM);
-      hasNext = isMethodOverridden(clazz, "next", METHOD_NO_PARAMS);
+    MethodSupport(Class<? extends TokenStream> clazz) {
+      hasIncrementToken = isMethodOverridden(clazz, "incrementToken");
+      hasReusableNext = isMethodOverridden(clazz, "next", Token.class);
+      hasNext = isMethodOverridden(clazz, "next");
     }
     
-    private static boolean isMethodOverridden(Class clazz, String name, Class[] params) {
+    private static boolean isMethodOverridden(Class<? extends TokenStream> clazz, String name, Class... params) {
       try {
         return clazz.getMethod(name, params).getDeclaringClass() != TokenStream.class;
       } catch (NoSuchMethodException e) {
@@ -117,19 +117,17 @@
         throw new RuntimeException(e);
       }
     }
-    
-    private static final Class[] METHOD_NO_PARAMS = new Class[0];
-    private static final Class[] METHOD_TOKEN_PARAM = new Class[]{Token.class};
   }
       
   /** @deprecated Remove this when old API is removed! */
-  private static final IdentityHashMap/*<Class<? extends TokenStream>,MethodSupport>*/ knownMethodSupport = new IdentityHashMap();
+  private static final IdentityHashMap<Class<? extends TokenStream>,MethodSupport> knownMethodSupport =
+    new IdentityHashMap<Class<? extends TokenStream>,MethodSupport>();
   
   /** @deprecated Remove this when old API is removed! */
-  private static MethodSupport getSupportedMethods(Class clazz) {
+  private static MethodSupport getSupportedMethods(Class<? extends TokenStream> clazz) {
     MethodSupport supportedMethods;
     synchronized(knownMethodSupport) {
-      supportedMethods = (MethodSupport) knownMethodSupport.get(clazz);
+      supportedMethods = knownMethodSupport.get(clazz);
       if (supportedMethods == null) {
         knownMethodSupport.put(clazz, supportedMethods = new MethodSupport(clazz));
       }
@@ -145,7 +143,7 @@
       this.delegate = delegate;
     }
   
-    public AttributeImpl createAttributeInstance(Class attClass) {
+    public AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass) {
       return attClass.isAssignableFrom(TokenWrapper.class)
         ? new TokenWrapper()
         : delegate.createAttributeInstance(attClass);

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/package.html?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/package.html (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/package.html Thu Oct  1 07:53:43 2009
@@ -230,8 +230,8 @@
       public TokenStream tokenStream(final String fieldName, Reader reader) {
         final TokenStream ts = someAnalyzer.tokenStream(fieldName, reader);
         TokenStream res = new TokenStream() {
-          TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-          PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
+          TermAttribute termAtt = addAttribute(TermAttribute.class);
+          PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
         
           public boolean incrementToken() throws IOException {
             int extraIncrement = 0;
@@ -319,7 +319,7 @@
 <li>
 For performance reasons a TokenStream/-Filter should add/get Attributes during instantiation; i.e., create an attribute in the
 constructor and store references to it in an instance variable.  Using an instance variable instead of calling addAttribute()/getAttribute() 
-in incrementToken() will avoid expensive casting and attribute lookups for every token in the document.
+in incrementToken() will avoid attribute lookups for every token in the document.
 </li>
 <br>
 <li>
@@ -356,7 +356,7 @@
     TokenStream stream = analyzer.tokenStream("field", new StringReader(text));
     
     // get the TermAttribute from the TokenStream
-    TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.addAttribute(TermAttribute.class);
 
     stream.reset();
     
@@ -421,7 +421,7 @@
     super(in);
     this.min = min;
     this.max = max;
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
   }
   
   /**
@@ -448,7 +448,7 @@
 <code>addAttribute()</code> call in LengthFilter returns the TermAttribute that the WhitespaceTokenizer already added. The tokens
 are retrieved from the input stream in the <code>incrementToken()</code> method. By looking at the term text
 in the TermAttribute the length of the term can be determined and too short or too long tokens are skipped. 
-Note how <code>incrementToken()</code> can efficiently access the instance variable; no attribute lookup or downcasting
+Note how <code>incrementToken()</code> can efficiently access the instance variable; no attribute lookup
 is neccessary. The same is true for the consumer, which can simply use local references to the Attributes.
 
 <h4>Adding a custom Attribute</h4>
@@ -526,8 +526,8 @@
     
     protected PartOfSpeechTaggingFilter(TokenStream input) {
       super(input);
-      posAtt = (PartOfSpeechAttribute) addAttribute(PartOfSpeechAttribute.class);
-      termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+      posAtt = addAttribute(PartOfSpeechAttribute.class);
+      termAtt = addAttribute(TermAttribute.class);
     }
     
     public boolean incrementToken() throws IOException {
@@ -579,10 +579,10 @@
     TokenStream stream = analyzer.tokenStream("field", new StringReader(text));
     
     // get the TermAttribute from the TokenStream
-    TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.addAttribute(TermAttribute.class);
     
     // get the PartOfSpeechAttribute from the TokenStream
-    PartOfSpeechAttribute posAtt = (PartOfSpeechAttribute) stream.addAttribute(PartOfSpeechAttribute.class);
+    PartOfSpeechAttribute posAtt = stream.addAttribute(PartOfSpeechAttribute.class);
     
     stream.reset();
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardFilter.java Thu Oct  1 07:53:43 2009
@@ -31,8 +31,8 @@
   /** Construct filtering <i>in</i>. */
   public StandardFilter(TokenStream in) {
     super(in);
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-    typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
+    typeAtt = addAttribute(TypeAttribute.class);
   }
 
   private static final String APOSTROPHE_TYPE = StandardTokenizerImpl.TOKEN_TYPES[StandardTokenizerImpl.APOSTROPHE];

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardTokenizer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardTokenizer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/standard/StandardTokenizer.java Thu Oct  1 07:53:43 2009
@@ -148,10 +148,10 @@
   private void init(Reader input, boolean replaceInvalidAcronym) {
     this.replaceInvalidAcronym = replaceInvalidAcronym;
     this.input = input;    
-    termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-    offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
-    posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
-    typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
+    termAtt = addAttribute(TermAttribute.class);
+    offsetAtt = addAttribute(OffsetAttribute.class);
+    posIncrAtt = addAttribute(PositionIncrementAttribute.class);
+    typeAtt = addAttribute(TypeAttribute.class);
   }
   
   // this tokenizer generates three attributes:

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java Thu Oct  1 07:53:43 2009
@@ -139,8 +139,8 @@
 
             fieldState.attributeSource = stream;
 
-            OffsetAttribute offsetAttribute = (OffsetAttribute) fieldState.attributeSource.addAttribute(OffsetAttribute.class);
-            PositionIncrementAttribute posIncrAttribute = (PositionIncrementAttribute) fieldState.attributeSource.addAttribute(PositionIncrementAttribute.class);
+            OffsetAttribute offsetAttribute = fieldState.attributeSource.addAttribute(OffsetAttribute.class);
+            PositionIncrementAttribute posIncrAttribute = fieldState.attributeSource.addAttribute(PositionIncrementAttribute.class);
             
             consumer.start(field);
             

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java Thu Oct  1 07:53:43 2009
@@ -39,8 +39,8 @@
     OffsetAttribute offsetAttribute;
     
     SingleTokenTokenStream() {
-      termAttribute = (TermAttribute) addAttribute(TermAttribute.class);
-      offsetAttribute = (OffsetAttribute) addAttribute(OffsetAttribute.class);
+      termAttribute = addAttribute(TermAttribute.class);
+      offsetAttribute = addAttribute(OffsetAttribute.class);
     }
     
     public void reinit(String stringValue, int startOffset,  int endOffset) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java Thu Oct  1 07:53:43 2009
@@ -77,7 +77,7 @@
   
   void start(Fieldable f) {
     if (fieldState.attributeSource.hasAttribute(PayloadAttribute.class)) {
-      payloadAttribute = (PayloadAttribute) fieldState.attributeSource.getAttribute(PayloadAttribute.class);
+      payloadAttribute = fieldState.attributeSource.getAttribute(PayloadAttribute.class);
     } else {
       payloadAttribute = null;
     }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java Thu Oct  1 07:53:43 2009
@@ -196,7 +196,7 @@
   
   void start(Fieldable f) {
     if (doVectorOffsets) {
-      offsetAttribute = (OffsetAttribute) fieldState.attributeSource.addAttribute(OffsetAttribute.class);
+      offsetAttribute = fieldState.attributeSource.addAttribute(OffsetAttribute.class);
     } else {
       offsetAttribute = null;
     }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermsHashPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermsHashPerField.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermsHashPerField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermsHashPerField.java Thu Oct  1 07:53:43 2009
@@ -249,7 +249,7 @@
   private boolean doNextCall;
 
   void start(Fieldable f) {
-    termAtt = (TermAttribute) fieldState.attributeSource.addAttribute(TermAttribute.class);
+    termAtt = fieldState.attributeSource.addAttribute(TermAttribute.class);
     consumer.start(f);
     if (nextPerField != null) {
       nextPerField.start(f);

Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java Thu Oct  1 07:53:43 2009
@@ -559,10 +559,10 @@
     }
     if (success) {
       if (buffer.hasAttribute(TermAttribute.class)) {
-        termAtt = (TermAttribute) buffer.getAttribute(TermAttribute.class);
+        termAtt = buffer.getAttribute(TermAttribute.class);
       }
       if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
-        posIncrAtt = (PositionIncrementAttribute) buffer.getAttribute(PositionIncrementAttribute.class);
+        posIncrAtt = buffer.getAttribute(PositionIncrementAttribute.class);
       }
     }
 
@@ -759,7 +759,7 @@
       DateTools.Resolution resolution = getDateResolution(field);
       if (resolution == null) {
         // no default or field specific date resolution has been set,
-        // use deprecated DateField to maintain compatibilty with
+        // use deprecated DateField to maintain compatibility with
         // pre-1.9 Lucene versions.
         part1 = DateField.dateToString(d1);
         part2 = DateField.dateToString(d2);
@@ -1591,16 +1591,6 @@
     finally { jj_save(0, xla); }
   }
 
-  private boolean jj_3_1() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_2()) {
-    jj_scanpos = xsp;
-    if (jj_3R_3()) return true;
-    }
-    return false;
-  }
-
   private boolean jj_3R_3() {
     if (jj_scan_token(STAR)) return true;
     if (jj_scan_token(COLON)) return true;
@@ -1613,6 +1603,16 @@
     return false;
   }
 
+  private boolean jj_3_1() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_2()) {
+    jj_scanpos = xsp;
+    if (jj_3R_3()) return true;
+    }
+    return false;
+  }
+
   /** Generated Token Manager. */
   public QueryParserTokenManager token_source;
   /** Current token. */

Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj Thu Oct  1 07:53:43 2009
@@ -583,10 +583,10 @@
     }
     if (success) {
       if (buffer.hasAttribute(TermAttribute.class)) {
-        termAtt = (TermAttribute) buffer.getAttribute(TermAttribute.class);
+        termAtt = buffer.getAttribute(TermAttribute.class);
       }
       if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
-        posIncrAtt = (PositionIncrementAttribute) buffer.getAttribute(PositionIncrementAttribute.class);
+        posIncrAtt = buffer.getAttribute(PositionIncrementAttribute.class);
       }
     }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/QueryTermVector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/QueryTermVector.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/QueryTermVector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/QueryTermVector.java Thu Oct  1 07:53:43 2009
@@ -61,7 +61,7 @@
           boolean hasMoreTokens = false;
           
           stream.reset(); 
-          TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
+          TermAttribute termAtt = stream.addAttribute(TermAttribute.class);
 
           hasMoreTokens = stream.incrementToken();
           while (hasMoreTokens) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java Thu Oct  1 07:53:43 2009
@@ -49,7 +49,7 @@
    * This method may be overridden by subclasses.
    */
   public String toString() {
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     Class clazz = this.getClass();
     Field[] fields = clazz.getDeclaredFields();
     try {

Modified: lucene/java/trunk/src/java/org/apache/lucene/util/AttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/util/AttributeSource.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/util/AttributeSource.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/util/AttributeSource.java Thu Oct  1 07:53:43 2009
@@ -44,9 +44,8 @@
   public static abstract class AttributeFactory {
     /**
      * returns an {@link AttributeImpl} for the supplied {@link Attribute} interface class.
-     * <p>Signature for Java 1.5: <code>public AttributeImpl createAttributeInstance(Class%lt;? extends Attribute&gt; attClass)</code>
      */
-    public abstract AttributeImpl createAttributeInstance(Class attClass);
+    public abstract AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass);
     
     /**
      * This is the default factory that creates {@link AttributeImpl}s using the
@@ -55,13 +54,14 @@
     public static final AttributeFactory DEFAULT_ATTRIBUTE_FACTORY = new DefaultAttributeFactory();
     
     private static final class DefaultAttributeFactory extends AttributeFactory {
-      private static final IdentityHashMap/*<Class<? extends Attribute>,Class<? extends AttributeImpl>>*/ attClassImplMap = new IdentityHashMap();
+      private static final IdentityHashMap<Class<? extends Attribute>, Class<? extends AttributeImpl>> attClassImplMap =
+        new IdentityHashMap<Class<? extends Attribute>, Class<? extends AttributeImpl>>();
       
       private DefaultAttributeFactory() {}
     
-      public AttributeImpl createAttributeInstance(Class attClass) {
+      public AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass) {
         try {
-          return (AttributeImpl) getClassForInterface(attClass).newInstance();
+          return getClassForInterface(attClass).newInstance();
         } catch (InstantiationException e) {
           throw new IllegalArgumentException("Could not instantiate class " + attClass.getName());
         } catch (IllegalAccessException e) {
@@ -69,12 +69,12 @@
         }
       }
       
-      private static Class getClassForInterface(Class attClass) {
+      private static Class<? extends AttributeImpl> getClassForInterface(Class<? extends Attribute> attClass) {
         synchronized(attClassImplMap) {
-          Class clazz = (Class) attClassImplMap.get(attClass);
+          Class<? extends AttributeImpl> clazz = attClassImplMap.get(attClass);
           if (clazz == null) {
             try {
-              attClassImplMap.put(attClass, clazz = Class.forName(attClass.getName() + "Impl"));
+              attClassImplMap.put(attClass, clazz = Class.forName(attClass.getName() + "Impl").asSubclass(AttributeImpl.class));
             } catch (ClassNotFoundException e) {
               throw new IllegalArgumentException("Could not find implementing class for " + attClass.getName());
             }
@@ -87,8 +87,8 @@
       
   // These two maps must always be in sync!!!
   // So they are private, final and read-only from the outside (read-only iterators)
-  private final Map/*<Class<Attribute>,AttributeImpl>*/ attributes;
-  private final Map/*<Class<AttributeImpl>,AttributeImpl>*/ attributeImpls;
+  private final Map<Class<? extends Attribute>, AttributeImpl> attributes;
+  private final Map<Class<? extends AttributeImpl>, AttributeImpl> attributeImpls;
 
   private AttributeFactory factory;
   
@@ -115,8 +115,8 @@
    * An AttributeSource using the supplied {@link AttributeFactory} for creating new {@link Attribute} instances.
    */
   public AttributeSource(AttributeFactory factory) {
-    this.attributes = new LinkedHashMap();
-    this.attributeImpls = new LinkedHashMap();
+    this.attributes = new LinkedHashMap<Class<? extends Attribute>, AttributeImpl>();
+    this.attributeImpls = new LinkedHashMap<Class<? extends AttributeImpl>, AttributeImpl>();
     this.factory = factory;
   }
   
@@ -129,31 +129,29 @@
   
   /** Returns a new iterator that iterates the attribute classes
    * in the same order they were added in.
-   * <p>Signature for Java 1.5: <code>public Iterator&lt;Class&lt;? extends Attribute&gt;&gt; getAttributeClassesIterator()</code>
    */
-  public Iterator getAttributeClassesIterator() {
+  public Iterator<Class<? extends Attribute>> getAttributeClassesIterator() {
     return Collections.unmodifiableSet(attributes.keySet()).iterator();
   }
   
   /** Returns a new iterator that iterates all unique Attribute implementations.
    * This iterator may contain less entries that {@link #getAttributeClassesIterator},
    * if one instance implements more than one Attribute interface.
-   * <p>Signature for Java 1.5: <code>public Iterator&lt;AttributeImpl&gt; getAttributeImplsIterator()</code>
    */
-  public Iterator getAttributeImplsIterator() {
+  public Iterator<AttributeImpl> getAttributeImplsIterator() {
     if (hasAttributes()) {
       if (currentState == null) {
         computeCurrentState();
       }
       final State initState = currentState;
-      return new Iterator() {
+      return new Iterator<AttributeImpl>() {
         private State state = initState;
       
         public void remove() {
           throw new UnsupportedOperationException();
         }
         
-        public Object next() {
+        public AttributeImpl next() {
           if (state == null)
             throw new NoSuchElementException();
           final AttributeImpl att = state.attribute;
@@ -166,31 +164,30 @@
         }
       };
     } else {
-      return Collections.EMPTY_SET.iterator();
+      return Collections.<AttributeImpl>emptySet().iterator();
     }
   }
   
   /** a cache that stores all interfaces for known implementation classes for performance (slow reflection) */
-  private static final IdentityHashMap/*<Class<? extends AttributeImpl>,LinkedList<Class<? extends Attribute>>>*/ knownImplClasses = new IdentityHashMap();
+  private static final IdentityHashMap<Class<? extends AttributeImpl>,LinkedList<Class<? extends Attribute>>> knownImplClasses =
+    new IdentityHashMap<Class<? extends AttributeImpl>,LinkedList<Class<? extends Attribute>>>();
   
   /** Adds a custom AttributeImpl instance with one or more Attribute interfaces. */
   public void addAttributeImpl(final AttributeImpl att) {
-    final Class clazz = att.getClass();
+    final Class<? extends AttributeImpl> clazz = att.getClass();
     if (attributeImpls.containsKey(clazz)) return;
-    LinkedList foundInterfaces;
+    LinkedList<Class<? extends Attribute>> foundInterfaces;
     synchronized(knownImplClasses) {
-      foundInterfaces = (LinkedList) knownImplClasses.get(clazz);
+      foundInterfaces = knownImplClasses.get(clazz);
       if (foundInterfaces == null) {
-        knownImplClasses.put(clazz, foundInterfaces=new LinkedList());
+        knownImplClasses.put(clazz, foundInterfaces = new LinkedList<Class<? extends Attribute>>());
         // find all interfaces that this attribute instance implements
         // and that extend the Attribute interface
-        Class actClazz = clazz;
+        Class<?> actClazz = clazz;
         do {
-          Class[] interfaces = actClazz.getInterfaces();
-          for (int i = 0; i < interfaces.length; i++) {
-            final Class curInterface = interfaces[i];
+          for (Class<?> curInterface : actClazz.getInterfaces()) {
             if (curInterface != Attribute.class && Attribute.class.isAssignableFrom(curInterface)) {
-              foundInterfaces.add(curInterface);
+              foundInterfaces.add(curInterface.asSubclass(Attribute.class));
             }
           }
           actClazz = actClazz.getSuperclass();
@@ -199,8 +196,7 @@
     }
     
     // add all interfaces of this AttributeImpl to the maps
-    for (Iterator it = foundInterfaces.iterator(); it.hasNext(); ) {
-      final Class curInterface = (Class) it.next();
+    for (Class<? extends Attribute> curInterface : foundInterfaces) {
       // Attribute is a superclass of this interface
       if (!attributes.containsKey(curInterface)) {
         // invalidate state to force recomputation in captureState()
@@ -216,17 +212,13 @@
    * This method first checks if an instance of that class is 
    * already in this AttributeSource and returns it. Otherwise a
    * new instance is created, added to this AttributeSource and returned. 
-   * <p>Signature for Java 1.5: <code>public &lt;T extends Attribute&gt; T addAttribute(Class&lt;T&gt;)</code>
    */
-  public Attribute addAttribute(Class attClass) {
-    final Attribute att = (Attribute) attributes.get(attClass);
-    if (att == null) {
-      final AttributeImpl attImpl = this.factory.createAttributeInstance(attClass);
-      addAttributeImpl(attImpl);
-      return attImpl;
-    } else {
-      return att;
+  public <A extends Attribute> A addAttribute(Class<A> attClass) {
+    AttributeImpl attImpl = attributes.get(attClass);
+    if (attImpl == null) {
+      addAttributeImpl(attImpl = this.factory.createAttributeInstance(attClass));
     }
+    return attClass.cast(attImpl);
   }
   
   /** Returns true, iff this AttributeSource has any attributes */
@@ -237,16 +229,14 @@
   /**
    * The caller must pass in a Class&lt;? extends Attribute&gt; value. 
    * Returns true, iff this AttributeSource contains the passed-in Attribute.
-   * <p>Signature for Java 1.5: <code>public boolean hasAttribute(Class&lt;? extends Attribute&gt;)</code>
    */
-  public boolean hasAttribute(Class attClass) {
+  public boolean hasAttribute(Class<? extends Attribute> attClass) {
     return this.attributes.containsKey(attClass);
   }
 
   /**
    * The caller must pass in a Class&lt;? extends Attribute&gt; value. 
    * Returns the instance of the passed in Attribute contained in this AttributeSource
-   * <p>Signature for Java 1.5: <code>public &lt;T extends Attribute&gt; T getAttribute(Class&lt;T&gt;)</code>
    * 
    * @throws IllegalArgumentException if this AttributeSource does not contain the
    *         Attribute. It is recommended to always use {@link #addAttribute} even in consumers
@@ -255,13 +245,12 @@
    *         available. If you want to only use the attribute, if it is available (to optimize
    *         consuming), use {@link #hasAttribute}.
    */
-  public Attribute getAttribute(Class attClass) {
-    final Attribute att = (Attribute) this.attributes.get(attClass);
-    if (att == null) {
+  public <A extends Attribute> A getAttribute(Class<A> attClass) {
+    AttributeImpl attImpl = attributes.get(attClass);
+    if (attImpl == null) {
       throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
     }
-
-    return att;
+    return attClass.cast(attImpl);
   }
   
   /**
@@ -290,12 +279,12 @@
   private void computeCurrentState() {
     currentState = new State();
     State c = currentState;
-    Iterator it = attributeImpls.values().iterator();
-    c.attribute = (AttributeImpl) it.next();
+    final Iterator<AttributeImpl> it = attributeImpls.values().iterator();
+    c.attribute = it.next();
     while (it.hasNext()) {
       c.next = new State();
       c = c.next;
-      c.attribute = (AttributeImpl) it.next();
+      c.attribute = it.next();
     }        
   }
   
@@ -348,7 +337,7 @@
     if (state == null)  return;
     
     do {
-      AttributeImpl targetImpl = (AttributeImpl) attributeImpls.get(state.attribute.getClass());
+      AttributeImpl targetImpl = attributeImpls.get(state.attribute.getClass());
       if (targetImpl == null)
         throw new IllegalArgumentException("State contains an AttributeImpl that is not in this AttributeSource");
       state.attribute.copyTo(targetImpl);
@@ -412,9 +401,7 @@
   }
   
   public String toString() {
-    StringBuffer sb = new StringBuffer();
-    sb.append('(');
-    
+    StringBuilder sb = new StringBuilder().append('(');
     if (hasAttributes()) {
       if (currentState == null) {
         computeCurrentState();
@@ -424,8 +411,7 @@
         sb.append(state.attribute.toString());
       }
     }
-    sb.append(')');
-    return sb.toString();
+    return sb.append(')').toString();
   }
   
   /**
@@ -442,14 +428,12 @@
         computeCurrentState();
       }
       for (State state = currentState; state != null; state = state.next) {
-        clone.attributeImpls.put(state.attribute.getClass(), state.attribute.clone());
+        clone.attributeImpls.put(state.attribute.getClass(), (AttributeImpl) state.attribute.clone());
       }
     }
     
     // now the interfaces
-    Iterator/*<Entry<Class<Attribute>, AttributeImpl>>*/ attIt = this.attributes.entrySet().iterator(); 
-    while (attIt.hasNext()) {
-      Entry/*<Class<Attribute>, AttributeImpl>*/ entry = (Entry/*<Class<Attribute>, AttributeImpl>*/) attIt.next();
+    for (Entry<Class<? extends Attribute>, AttributeImpl> entry : this.attributes.entrySet()) {
       clone.attributes.put(entry.getKey(), clone.attributeImpls.get(entry.getValue().getClass()));
     }
     

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Thu Oct  1 07:53:43 2009
@@ -89,24 +89,24 @@
   public static void assertTokenStreamContents(TokenStream ts, String[] output, int startOffsets[], int endOffsets[], String types[], int posIncrements[]) throws IOException {
     assertNotNull(output);
     assertTrue("has TermAttribute", ts.hasAttribute(TermAttribute.class));
-    TermAttribute termAtt = (TermAttribute) ts.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = ts.getAttribute(TermAttribute.class);
     
     OffsetAttribute offsetAtt = null;
     if (startOffsets != null || endOffsets != null) {
       assertTrue("has OffsetAttribute", ts.hasAttribute(OffsetAttribute.class));
-      offsetAtt = (OffsetAttribute) ts.getAttribute(OffsetAttribute.class);
+      offsetAtt = ts.getAttribute(OffsetAttribute.class);
     }
     
     TypeAttribute typeAtt = null;
     if (types != null) {
       assertTrue("has TypeAttribute", ts.hasAttribute(TypeAttribute.class));
-      typeAtt = (TypeAttribute) ts.getAttribute(TypeAttribute.class);
+      typeAtt = ts.getAttribute(TypeAttribute.class);
     }
     
     PositionIncrementAttribute posIncrAtt = null;
     if (posIncrements != null) {
       assertTrue("has PositionIncrementAttribute", ts.hasAttribute(PositionIncrementAttribute.class));
-      posIncrAtt = (PositionIncrementAttribute) ts.getAttribute(PositionIncrementAttribute.class);
+      posIncrAtt = ts.getAttribute(PositionIncrementAttribute.class);
     }
     
     ts.reset();

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java Thu Oct  1 07:53:43 2009
@@ -34,7 +34,7 @@
       +" ð ñ ò ó ô õ ö ø œ ß þ ù ú û ü ý ÿ fi fl"));
     ASCIIFoldingFilter filter = new ASCIIFoldingFilter(stream);
 
-    TermAttribute termAtt = (TermAttribute) filter.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = filter.getAttribute(TermAttribute.class);
 
     assertTermEquals("Des", filter, termAtt);
     assertTermEquals("mot", filter, termAtt);
@@ -1891,7 +1891,7 @@
 
     TokenStream stream = new WhitespaceTokenizer(new StringReader(inputText.toString()));
     ASCIIFoldingFilter filter = new ASCIIFoldingFilter(stream);
-    TermAttribute termAtt = (TermAttribute) filter.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = filter.getAttribute(TermAttribute.class);
     Iterator expectedIter = expectedOutputTokens.iterator();
     while (expectedIter.hasNext()) {;
       assertTermEquals((String)expectedIter.next(), filter, termAtt);

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestAnalyzers.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestAnalyzers.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestAnalyzers.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestAnalyzers.java Thu Oct  1 07:53:43 2009
@@ -82,7 +82,7 @@
   }
 
   void verifyPayload(TokenStream ts) throws IOException {
-    PayloadAttribute payloadAtt = (PayloadAttribute) ts.getAttribute(PayloadAttribute.class);
+    PayloadAttribute payloadAtt = ts.getAttribute(PayloadAttribute.class);
     for(byte b=1;;b++) {
       boolean hasNext = ts.incrementToken();
       if (!hasNext) break;
@@ -139,7 +139,7 @@
   PayloadAttribute payloadAtt;
   public  PayloadSetter(TokenStream input) {
     super(input);
-    payloadAtt = (PayloadAttribute) addAttribute(PayloadAttribute.class);
+    payloadAtt = addAttribute(PayloadAttribute.class);
   }
 
   byte[] data = new byte[1];

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java Thu Oct  1 07:53:43 2009
@@ -41,8 +41,8 @@
     Document doc = new Document();
     TokenStream stream = new TokenStream() {
       private int index = 0;
-      private TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      private OffsetAttribute offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
+      private TermAttribute termAtt = addAttribute(TermAttribute.class);
+      private OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
       
       public boolean incrementToken() throws IOException {
         if (index == tokens.length) {
@@ -96,7 +96,7 @@
   private void checkTokens(TokenStream stream) throws IOException {
     int count = 0;
     
-    TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertNotNull(termAtt);
     while (stream.incrementToken()) {
       assertTrue(count < tokens.length);

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java Thu Oct  1 07:53:43 2009
@@ -25,7 +25,7 @@
   public void testU() throws Exception {
     TokenStream stream = new WhitespaceTokenizer(new StringReader("Des mot clés À LA CHAÎNE À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï IJ Ð Ñ Ò Ó Ô Õ Ö Ø Œ Þ Ù Ú Û Ü Ý Ÿ à á â ã ä å æ ç è é ê ë ì í î ï ij ð ñ ò ó ô õ ö ø œ ß þ ù ú û ü ý ÿ fi fl"));
     ISOLatin1AccentFilter filter = new ISOLatin1AccentFilter(stream);
-    TermAttribute termAtt = (TermAttribute) filter.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = filter.getAttribute(TermAttribute.class);
     assertTermEquals("Des", filter, termAtt);
     assertTermEquals("mot", filter, termAtt);
     assertTermEquals("cles", filter, termAtt);

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java Thu Oct  1 07:53:43 2009
@@ -88,7 +88,7 @@
   // LUCENE-1441
   public void testOffsets() throws Exception {
     TokenStream stream = new KeywordAnalyzer().tokenStream("field", new StringReader("abcd"));
-    OffsetAttribute offsetAtt = (OffsetAttribute) stream.addAttribute(OffsetAttribute.class);
+    OffsetAttribute offsetAtt = stream.addAttribute(OffsetAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals(0, offsetAtt.startOffset());
     assertEquals(4, offsetAtt.endOffset());

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestLengthFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestLengthFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestLengthFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestLengthFilter.java Thu Oct  1 07:53:43 2009
@@ -27,7 +27,7 @@
     TokenStream stream = new WhitespaceTokenizer(
         new StringReader("short toolong evenmuchlongertext a ab toolong foo"));
     LengthFilter filter = new LengthFilter(stream, 2, 6);
-    TermAttribute termAtt = (TermAttribute) filter.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = filter.getAttribute(TermAttribute.class);
 
     assertTrue(filter.incrementToken());
     assertEquals("short", termAtt.term());

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java Thu Oct  1 07:53:43 2009
@@ -29,8 +29,8 @@
   public void testLongStream() throws Exception {
     final NumericTokenStream stream=new NumericTokenStream().setLongValue(lvalue);
     // use getAttribute to test if attributes really exist, if not an IAE will be throwed
-    final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
-    final TypeAttribute typeAtt = (TypeAttribute) stream.getAttribute(TypeAttribute.class);
+    final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
+    final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
     for (int shift=0; shift<64; shift+=NumericUtils.PRECISION_STEP_DEFAULT) {
       assertTrue("New token is available", stream.incrementToken());
       assertEquals("Term is correctly encoded", NumericUtils.longToPrefixCoded(lvalue, shift), termAtt.term());
@@ -42,8 +42,8 @@
   public void testIntStream() throws Exception {
     final NumericTokenStream stream=new NumericTokenStream().setIntValue(ivalue);
     // use getAttribute to test if attributes really exist, if not an IAE will be throwed
-    final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
-    final TypeAttribute typeAtt = (TypeAttribute) stream.getAttribute(TypeAttribute.class);
+    final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
+    final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
     for (int shift=0; shift<32; shift+=NumericUtils.PRECISION_STEP_DEFAULT) {
       assertTrue("New token is available", stream.incrementToken());
       assertEquals("Term is correctly encoded", NumericUtils.intToPrefixCoded(ivalue, shift), termAtt.term());

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java Thu Oct  1 07:53:43 2009
@@ -30,7 +30,7 @@
 
     TokenStream tokenStream = analyzer.tokenStream("field",
                                             new StringReader(text));
-    TermAttribute termAtt = (TermAttribute) tokenStream.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = tokenStream.getAttribute(TermAttribute.class);
 
     assertTrue(tokenStream.incrementToken());
     assertEquals("WhitespaceAnalyzer does not lowercase",
@@ -39,7 +39,7 @@
 
     tokenStream = analyzer.tokenStream("special",
                                             new StringReader(text));
-    termAtt = (TermAttribute) tokenStream.getAttribute(TermAttribute.class);
+    termAtt = tokenStream.getAttribute(TermAttribute.class);
     assertTrue(tokenStream.incrementToken());
     assertEquals("SimpleAnalyzer lowercases",
                  "qwerty",

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java Thu Oct  1 07:53:43 2009
@@ -49,7 +49,7 @@
     StringReader reader = new StringReader("This is a test of the english stop analyzer");
     TokenStream stream = stop.tokenStream("test", reader);
     assertTrue(stream != null);
-    TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     
     while (stream.incrementToken()) {
       assertFalse(inValidTokens.contains(termAtt.term()));
@@ -65,8 +65,8 @@
     StringReader reader = new StringReader("This is a good test of the english stop analyzer");
     TokenStream stream = newStop.tokenStream("test", reader);
     assertNotNull(stream);
-    TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
-    PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) stream.addAttribute(PositionIncrementAttribute.class);
+    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
+    PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
     
     while (stream.incrementToken()) {
       String text = termAtt.term();
@@ -89,8 +89,8 @@
       TokenStream stream = newStop.tokenStream("test", reader);
       assertNotNull(stream);
       int i = 0;
-      TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
-      PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) stream.addAttribute(PositionIncrementAttribute.class);
+      TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
+      PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
 
       while (stream.incrementToken()) {
         String text = termAtt.term();

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java Thu Oct  1 07:53:43 2009
@@ -36,7 +36,7 @@
     StringReader reader = new StringReader("Now is The Time");
     String[] stopWords = new String[] { "is", "the", "Time" };
     TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords);
-    final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
     assertTrue(stream.incrementToken());
@@ -48,7 +48,7 @@
     StringReader reader = new StringReader("Now is The Time");
     String[] stopWords = new String[] { "is", "the", "Time" };
     TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords, true);
-    final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
     assertFalse(stream.incrementToken());
@@ -59,7 +59,7 @@
     String[] stopWords = new String[] { "is", "the", "Time" };
     Set stopSet = StopFilter.makeStopSet(stopWords);
     TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopSet);
-    final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
     assertTrue(stream.incrementToken());
@@ -116,8 +116,8 @@
   private void doTestStopPositons(StopFilter stpf, boolean enableIcrements) throws IOException {
     log("---> test with enable-increments-"+(enableIcrements?"enabled":"disabled"));
     stpf.setEnablePositionIncrements(enableIcrements);
-    TermAttribute termAtt = (TermAttribute) stpf.getAttribute(TermAttribute.class);
-    PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) stpf.getAttribute(PositionIncrementAttribute.class);
+    TermAttribute termAtt = stpf.getAttribute(TermAttribute.class);
+    PositionIncrementAttribute posIncrAtt = stpf.getAttribute(PositionIncrementAttribute.class);
     for (int i=0; i<20; i+=3) {
       assertTrue(stpf.incrementToken());
       log("Token "+i+": "+stpf);

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java Thu Oct  1 07:53:43 2009
@@ -59,14 +59,14 @@
 
   static final TeeSinkTokenFilter.SinkFilter theFilter = new TeeSinkTokenFilter.SinkFilter() {
     public boolean accept(AttributeSource a) {
-      TermAttribute termAtt = (TermAttribute) a.getAttribute(TermAttribute.class);
+      TermAttribute termAtt = a.getAttribute(TermAttribute.class);
       return termAtt.term().equalsIgnoreCase("The");
     }
   };
 
   static final TeeSinkTokenFilter.SinkFilter dogFilter = new TeeSinkTokenFilter.SinkFilter() {
     public boolean accept(AttributeSource a) {
-      TermAttribute termAtt = (TermAttribute) a.getAttribute(TermAttribute.class);
+      TermAttribute termAtt = a.getAttribute(TermAttribute.class);
       return termAtt.term().equalsIgnoreCase("Dogs");
     }
   };
@@ -77,7 +77,7 @@
     final TokenStream sink1 = source.newSinkTokenStream();
     final TokenStream sink2 = source.newSinkTokenStream(theFilter);
     int i = 0;
-    TermAttribute termAtt = (TermAttribute) source.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = source.getAttribute(TermAttribute.class);
     while (source.incrementToken()) {
       assertEquals(tokens1[i], termAtt.term());
       i++;
@@ -85,7 +85,7 @@
     assertEquals(tokens1.length, i);
     
     i = 0;
-    termAtt = (TermAttribute) sink1.getAttribute(TermAttribute.class);
+    termAtt = sink1.getAttribute(TermAttribute.class);
     while (sink1.incrementToken()) {
       assertEquals(tokens1[i], termAtt.term());
       i++;
@@ -93,7 +93,7 @@
     assertEquals(tokens1.length, i);
     
     i = 0;
-    termAtt = (TermAttribute) sink2.getAttribute(TermAttribute.class);
+    termAtt = sink2.getAttribute(TermAttribute.class);
     while (sink2.incrementToken()) {
       assertTrue(termAtt.term().equalsIgnoreCase("The"));
       i++;
@@ -113,28 +113,28 @@
     final TokenStream source2 = tee2;
 
     int i = 0;
-    TermAttribute termAtt = (TermAttribute) source1.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = source1.getAttribute(TermAttribute.class);
     while (source1.incrementToken()) {
       assertEquals(tokens1[i], termAtt.term());
       i++;
     }
     assertEquals(tokens1.length, i);
     i = 0;
-    termAtt = (TermAttribute) source2.getAttribute(TermAttribute.class);
+    termAtt = source2.getAttribute(TermAttribute.class);
     while (source2.incrementToken()) {
       assertEquals(tokens2[i], termAtt.term());
       i++;
     }
     assertEquals(tokens2.length, i);
     i = 0;
-    termAtt = (TermAttribute) theDetector.getAttribute(TermAttribute.class);
+    termAtt = theDetector.getAttribute(TermAttribute.class);
     while (theDetector.incrementToken()) {
       assertTrue("'" + termAtt.term() + "' is not equal to 'The'", termAtt.term().equalsIgnoreCase("The"));
       i++;
     }
     assertEquals("there must be 4 times 'The' in the stream", 4, i);
     i = 0;
-    termAtt = (TermAttribute) dogDetector.getAttribute(TermAttribute.class);
+    termAtt = dogDetector.getAttribute(TermAttribute.class);
     while (dogDetector.incrementToken()) {
       assertTrue("'" + termAtt.term() + "' is not equal to 'Dogs'", termAtt.term().equalsIgnoreCase("Dogs"));
       i++;
@@ -144,7 +144,7 @@
     source1.reset();
     TokenStream lowerCasing = new LowerCaseFilter(source1);
     i = 0;
-    termAtt = (TermAttribute) lowerCasing.getAttribute(TermAttribute.class);
+    termAtt = lowerCasing.getAttribute(TermAttribute.class);
     while (lowerCasing.incrementToken()) {
       assertEquals(tokens1[i].toLowerCase(), termAtt.term());
       i++;
@@ -171,8 +171,8 @@
       TokenStream sink = teeStream.newSinkTokenStream(new ModuloSinkFilter(100));
       teeStream.consumeAllTokens();
       TokenStream stream = new ModuloTokenFilter(new StandardFilter(new StandardTokenizer(new StringReader(buffer.toString()))), 100);
-      TermAttribute tfTok = (TermAttribute) stream.addAttribute(TermAttribute.class);
-      TermAttribute sinkTok = (TermAttribute) sink.addAttribute(TermAttribute.class);
+      TermAttribute tfTok = stream.addAttribute(TermAttribute.class);
+      TermAttribute sinkTok = sink.addAttribute(TermAttribute.class);
       for (int i=0; stream.incrementToken(); i++) {
         assertTrue(sink.incrementToken());
         assertTrue(tfTok + " is not equal to " + sinkTok + " at token: " + i, tfTok.equals(sinkTok) == true);
@@ -184,12 +184,12 @@
         long start = System.currentTimeMillis();
         for (int i = 0; i < 20; i++) {
           stream = new StandardFilter(new StandardTokenizer(new StringReader(buffer.toString())));
-          PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) stream.getAttribute(PositionIncrementAttribute.class);
+          PositionIncrementAttribute posIncrAtt = stream.getAttribute(PositionIncrementAttribute.class);
           while (stream.incrementToken()) {
             tfPos += posIncrAtt.getPositionIncrement();
           }
           stream = new ModuloTokenFilter(new StandardFilter(new StandardTokenizer(new StringReader(buffer.toString()))), modCounts[j]);
-          posIncrAtt = (PositionIncrementAttribute) stream.getAttribute(PositionIncrementAttribute.class);
+          posIncrAtt = stream.getAttribute(PositionIncrementAttribute.class);
           while (stream.incrementToken()) {
             tfPos += posIncrAtt.getPositionIncrement();
           }
@@ -202,12 +202,12 @@
         for (int i = 0; i < 20; i++) {
           teeStream = new TeeSinkTokenFilter(new StandardFilter(new StandardTokenizer(new StringReader(buffer.toString()))));
           sink = teeStream.newSinkTokenStream(new ModuloSinkFilter(modCounts[j]));
-          PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) teeStream.getAttribute(PositionIncrementAttribute.class);
+          PositionIncrementAttribute posIncrAtt = teeStream.getAttribute(PositionIncrementAttribute.class);
           while (teeStream.incrementToken()) {
             sinkPos += posIncrAtt.getPositionIncrement();
           }
           //System.out.println("Modulo--------");
-          posIncrAtt = (PositionIncrementAttribute) sink.getAttribute(PositionIncrementAttribute.class);
+          posIncrAtt = sink.getAttribute(PositionIncrementAttribute.class);
           while (sink.incrementToken()) {
             sinkPos += posIncrAtt.getPositionIncrement();
           }

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java Thu Oct  1 07:53:43 2009
@@ -188,8 +188,8 @@
 
   private static void consumeStreamNewAPI(TokenStream stream) throws IOException {
     stream.reset();
-    PayloadAttribute payloadAtt = (PayloadAttribute) stream.addAttribute(PayloadAttribute.class);
-    TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
+    PayloadAttribute payloadAtt = stream.addAttribute(PayloadAttribute.class);
+    TermAttribute termAtt = stream.addAttribute(TermAttribute.class);
     
     int i=0;
     while (stream.incrementToken()) {
@@ -350,7 +350,7 @@
     assertEquals("private 'bar' term should still be valid", "bar", bar.term());
     
     // and now we also use incrementToken()... (very bad, but should work)
-    TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("maeh", termAtt.term());    
     assertEquals("private 'bar' term should still be valid", "bar", bar.term());    
@@ -373,7 +373,7 @@
   public void testMixedOldApiConsumer2() throws Exception {
     // RoundRobinOldAPI is using TokenStream(next)
     TokenStream stream = new RoundRobinOldAPI();
-    TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class);
+    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     
     assertTrue(stream.incrementToken());
     Token bar = stream.next();

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java Thu Oct  1 07:53:43 2009
@@ -170,9 +170,9 @@
 
           }
 
-          TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-          PayloadAttribute payloadAtt = (PayloadAttribute) addAttribute(PayloadAttribute.class);
-          PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);          
+          TermAttribute termAtt = addAttribute(TermAttribute.class);
+          PayloadAttribute payloadAtt = addAttribute(PayloadAttribute.class);
+          PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);          
         };
       }
     };
@@ -209,7 +209,7 @@
       private String[] tokens = new String[] {"term1", "term2", "term3", "term2"};
       private int index = 0;
       
-      private TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+      private TermAttribute termAtt = addAttribute(TermAttribute.class);
       
       public boolean incrementToken() throws IOException {
         if (index == tokens.length) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Oct  1 07:53:43 2009
@@ -3540,8 +3540,8 @@
   // LUCENE-1255
   public void testNegativePositions() throws Throwable {
     final TokenStream tokens = new TokenStream() {
-      final TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      final PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
+      final TermAttribute termAtt = addAttribute(TermAttribute.class);
+      final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       
       final Iterator tokens = Arrays.asList(new String[]{"a","b","c"}).iterator();
       boolean first = true;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java Thu Oct  1 07:53:43 2009
@@ -102,7 +102,7 @@
     
     protected PayloadFilter(TokenStream input) {
       super(input);
-      payloadAtt = (PayloadAttribute) addAttribute(PayloadAttribute.class);
+      payloadAtt = addAttribute(PayloadAttribute.class);
     }
 
     public boolean incrementToken() throws IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java Thu Oct  1 07:53:43 2009
@@ -436,7 +436,7 @@
             this.data = data;
             this.length = length;
             this.offset = offset;
-            payloadAtt = (PayloadAttribute) addAttribute(PayloadAttribute.class);
+            payloadAtt = addAttribute(PayloadAttribute.class);
         }
         
         public boolean incrementToken() throws IOException {
@@ -526,8 +526,8 @@
             generateRandomData(payload);
             term = pool.bytesToString(payload);
             first = true;
-            payloadAtt = (PayloadAttribute) addAttribute(PayloadAttribute.class);
-            termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+            payloadAtt = addAttribute(PayloadAttribute.class);
+            termAtt = addAttribute(TermAttribute.class);
         }
         
         public boolean incrementToken() throws IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java Thu Oct  1 07:53:43 2009
@@ -126,9 +126,9 @@
     OffsetAttribute offsetAtt;
     
     public MyTokenStream() {
-      termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
-      offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
+      termAtt = addAttribute(TermAttribute.class);
+      posIncrAtt = addAttribute(PositionIncrementAttribute.class);
+      offsetAtt = addAttribute(OffsetAttribute.class);
     }
     
     public boolean incrementToken() {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java Thu Oct  1 07:53:43 2009
@@ -41,7 +41,7 @@
 
    public RepeatingTokenStream(String val) {
      this.value = val;
-     this.termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+     this.termAtt = addAttribute(TermAttribute.class);
    }
 
    public boolean incrementToken() throws IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java Thu Oct  1 07:53:43 2009
@@ -154,10 +154,10 @@
     
     public TestFilter(TokenStream in) {
       super(in);
-      termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
-      offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
-      typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
+      termAtt = addAttribute(TermAttribute.class);
+      posIncrAtt = addAttribute(PositionIncrementAttribute.class);
+      offsetAtt = addAttribute(OffsetAttribute.class);
+      typeAtt = addAttribute(TypeAttribute.class);
     }
 
     public final boolean incrementToken() throws java.io.IOException {
@@ -214,8 +214,8 @@
     
     public TestPosIncrementFilter(TokenStream in) {
       super(in);
-      termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
+      termAtt = addAttribute(TermAttribute.class);
+      posIncrAtt = addAttribute(PositionIncrementAttribute.class);
     }
 
     public final boolean incrementToken () throws java.io.IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=820553&r1=820552&r2=820553&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java Thu Oct  1 07:53:43 2009
@@ -87,8 +87,8 @@
      */
     public QPTestFilter(TokenStream in) {
       super(in);
-      termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-      offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class);
+      termAtt = addAttribute(TermAttribute.class);
+      offsetAtt = addAttribute(OffsetAttribute.class);
     }
 
     boolean inPhrase = false;



Mime
View raw message