You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2012/04/13 18:33:38 UTC

svn commit: r1325831 [2/4] - in /incubator/lucene.net/trunk: src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ src/contrib/Analyzers/Compound/ src/contrib/Analyzers/De/ src/contrib/Analyzers/El/ sr...

Modified: incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs Fri Apr 13 16:33:33 2012
@@ -16,8 +16,7 @@
  */
 
 using System;
-
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
+using Lucene.Net.Analysis.Tokenattributes;
 
 namespace Lucene.Net.Analysis
 {
@@ -27,10 +26,10 @@ namespace Lucene.Net.Analysis
 	{
 		public LowerCaseFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
-            termAtt = AddAttribute<TermAttribute>();
+            termAtt = AddAttribute<ITermAttribute>();
 		}
 		
-		private TermAttribute termAtt;
+		private ITermAttribute termAtt;
 		
 		public override bool IncrementToken()
 		{

Modified: incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs Fri Apr 13 16:33:33 2012
@@ -16,14 +16,12 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Search;
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 using NumericUtils = Lucene.Net.Util.NumericUtils;
 using NumericField = Lucene.Net.Documents.NumericField;
 // javadocs
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
 
 namespace Lucene.Net.Analysis
 {
@@ -88,9 +86,9 @@ namespace Lucene.Net.Analysis
 	{
 		private void  InitBlock()
 		{
-            termAtt = AddAttribute<TermAttribute>();
-            typeAtt = AddAttribute<TypeAttribute>();
-            posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+            termAtt = AddAttribute<ITermAttribute>();
+            typeAtt = AddAttribute<ITypeAttribute>();
+            posIncrAtt = AddAttribute<IPositionIncrementAttribute>();
 		}
 		
 		/// <summary>The full precision token gets this token type assigned. </summary>
@@ -261,9 +259,9 @@ namespace Lucene.Net.Analysis
 		}
 		
 		// members
-		private TermAttribute termAtt;
-		private TypeAttribute typeAtt;
-		private PositionIncrementAttribute posIncrAtt;
+		private ITermAttribute termAtt;
+		private ITypeAttribute typeAtt;
+		private IPositionIncrementAttribute posIncrAtt;
 		
 		private int shift = 0, valSize = 0; // valSize==0 means not initialized
 		private int precisionStep;

Modified: incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs Fri Apr 13 16:33:33 2012
@@ -16,8 +16,7 @@
  */
 
 using System;
-
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
+using Lucene.Net.Analysis.Tokenattributes;
 
 namespace Lucene.Net.Analysis
 {
@@ -43,12 +42,12 @@ namespace Lucene.Net.Analysis
 	public sealed class PorterStemFilter:TokenFilter
 	{
 		private PorterStemmer stemmer;
-		private TermAttribute termAtt;
+		private ITermAttribute termAtt;
 		
 		public PorterStemFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
 			stemmer = new PorterStemmer();
-            termAtt = AddAttribute<TermAttribute>();
+            termAtt = AddAttribute<ITermAttribute>();
 		}
 		
 		public override bool IncrementToken()

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs Fri Apr 13 16:33:33 2012
@@ -16,12 +16,10 @@
  */
 
 using System;
-
+using Lucene.Net.Analysis.Tokenattributes;
 using Token = Lucene.Net.Analysis.Token;
 using TokenFilter = Lucene.Net.Analysis.TokenFilter;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
 
 namespace Lucene.Net.Analysis.Standard
 {
@@ -35,16 +33,16 @@ namespace Lucene.Net.Analysis.Standard
 		/// <summary>Construct filtering <i>in</i>. </summary>
 		public StandardFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
-            termAtt = AddAttribute<TermAttribute>();
-			typeAtt = AddAttribute<TypeAttribute>();
+            termAtt = AddAttribute<ITermAttribute>();
+			typeAtt = AddAttribute<ITypeAttribute>();
 		}
 		
 		private static readonly System.String APOSTROPHE_TYPE;
 		private static readonly System.String ACRONYM_TYPE;
 		
 		// this filters uses attribute type
-		private TypeAttribute typeAtt;
-		private TermAttribute termAtt;
+		private ITypeAttribute typeAtt;
+		private ITermAttribute termAtt;
 		
 		/// <summary>Returns the next token in the stream, or null at EOS.
 		/// <p/>Removes <tt>'s</tt> from the end of words.

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs Fri Apr 13 16:33:33 2012
@@ -16,14 +16,11 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Util;
 using CharReader = Lucene.Net.Analysis.CharReader;
 using Token = Lucene.Net.Analysis.Token;
 using Tokenizer = Lucene.Net.Analysis.Tokenizer;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 using Version = Lucene.Net.Util.Version;
 
@@ -142,18 +139,18 @@ namespace Lucene.Net.Analysis.Standard
 			    replaceInvalidAcronym = false;
 			}
 		    this.input = input;
-		    termAtt = AddAttribute<TermAttribute>();
-		    offsetAtt = AddAttribute<OffsetAttribute>();
-		    posIncrAtt = AddAttribute<PositionIncrementAttribute>();
-		    typeAtt = AddAttribute<TypeAttribute>();
+		    termAtt = AddAttribute<ITermAttribute>();
+		    offsetAtt = AddAttribute<IOffsetAttribute>();
+		    posIncrAtt = AddAttribute<IPositionIncrementAttribute>();
+		    typeAtt = AddAttribute<ITypeAttribute>();
 		}
 		
 		// this tokenizer generates three attributes:
 		// offset, positionIncrement and type
-		private TermAttribute termAtt;
-		private OffsetAttribute offsetAtt;
-		private PositionIncrementAttribute posIncrAtt;
-		private TypeAttribute typeAtt;
+		private ITermAttribute termAtt;
+		private IOffsetAttribute offsetAtt;
+		private IPositionIncrementAttribute posIncrAtt;
+		private ITypeAttribute typeAtt;
 		
 		///<summary>
 		/// (non-Javadoc)

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizerImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizerImpl.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizerImpl.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizerImpl.cs Fri Apr 13 16:33:33 2012
@@ -28,9 +28,8 @@
 */
 
 using System;
-
+using Lucene.Net.Analysis.Tokenattributes;
 using Token = Lucene.Net.Analysis.Token;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 
 namespace Lucene.Net.Analysis.Standard
 {
@@ -279,7 +278,7 @@ namespace Lucene.Net.Analysis.Standard
 		}
 		
 		/// <summary> Fills TermAttribute with the current token text.</summary>
-		internal void  GetText(TermAttribute t)
+		internal void  GetText(ITermAttribute t)
 		{
 			t.SetTermBuffer(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
 		}

Modified: incubator/lucene.net/trunk/src/core/Analysis/StopFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/StopFilter.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/StopFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/StopFilter.cs Fri Apr 13 16:33:33 2012
@@ -17,9 +17,8 @@
 
 using System;
 using System.Collections.Generic;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Util;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 using QueryParser = Lucene.Net.QueryParsers.QueryParser;
 using Version = Lucene.Net.Util.Version;
 
@@ -33,8 +32,8 @@ namespace Lucene.Net.Analysis
 		private CharArraySet stopWords;
 		private bool enablePositionIncrements = false;
 		
-		private TermAttribute termAtt;
-		private PositionIncrementAttribute posIncrAtt;
+		private ITermAttribute termAtt;
+		private IPositionIncrementAttribute posIncrAtt;
 		
 		/// <summary> Construct a token stream filtering the given input.
 		/// If <c>stopWords</c> is an instance of <see cref="CharArraySet" /> (true if
@@ -63,8 +62,8 @@ namespace Lucene.Net.Analysis
 		        this.stopWords.AddAll(stopWords);
 		    }
 		    this.enablePositionIncrements = enablePositionIncrements;
-		    termAtt = AddAttribute<TermAttribute>();
-            posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+		    termAtt = AddAttribute<ITermAttribute>();
+            posIncrAtt = AddAttribute<IPositionIncrementAttribute>();
 		}
 
 	    /// <summary> Constructs a filter which removes words from the input

Modified: incubator/lucene.net/trunk/src/core/Analysis/TeeSinkTokenFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/TeeSinkTokenFilter.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/TeeSinkTokenFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/TeeSinkTokenFilter.cs Fri Apr 13 16:33:33 2012
@@ -17,7 +17,7 @@
 
 using System;
 using System.Collections.Generic;
-using AttributeImpl = Lucene.Net.Util.AttributeImpl;
+using Attribute = Lucene.Net.Util.Attribute;
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 
 namespace Lucene.Net.Analysis
@@ -111,7 +111,7 @@ namespace Lucene.Net.Analysis
 				throw new System.ArgumentException("The supplied sink is not compatible to this tee");
 			}
 			// add eventually missing attribute impls to the existing sink
-            foreach (AttributeImpl impl in this.CloneAttributes().GetAttributeImplsIterator())
+            foreach (Attribute impl in this.CloneAttributes().GetAttributeImplsIterator())
             {
                 sink.AddAttributeImpl(impl);
             }

Modified: incubator/lucene.net/trunk/src/core/Analysis/Token.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Token.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Token.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Token.cs Fri Apr 13 16:33:33 2012
@@ -19,17 +19,10 @@ using System;
 using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Support;
 using Lucene.Net.Util;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
-using PayloadAttribute = Lucene.Net.Analysis.Tokenattributes.PayloadAttribute;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
 using Payload = Lucene.Net.Index.Payload;
 using TermPositions = Lucene.Net.Index.TermPositions;
 using ArrayUtil = Lucene.Net.Util.ArrayUtil;
 using Attribute = Lucene.Net.Util.Attribute;
-using AttributeImpl = Lucene.Net.Util.AttributeImpl;
-using FlagsAttribute = Lucene.Net.Analysis.Tokenattributes.FlagsAttribute;
 
 namespace Lucene.Net.Analysis
 {
@@ -54,10 +47,10 @@ namespace Lucene.Net.Analysis
 	/// </summary>
 	/// <summary><br/><br/>
 	/// </summary>
-	/// <summary><p/><b>NOTE:</b> As of 2.9, Token implements all <see cref="Attribute" /> interfaces
+	/// <summary><p/><b>NOTE:</b> As of 2.9, Token implements all <see cref="IAttribute" /> interfaces
 	/// that are part of core Lucene and can be found in the <see cref="Lucene.Net.Analysis.Tokenattributes"/> namespace.
 	/// Even though it is not necessary to use Token anymore, with the new TokenStream API it can
-	/// be used as convenience class that implements all <see cref="Attribute" />s, which is especially useful
+	/// be used as convenience class that implements all <see cref="IAttribute" />s, which is especially useful
 	/// to easily switch from the old to the new TokenStream API.
 	/// <br/><br/>
 	/// <p/>Tokenizers and TokenFilters should try to re-use a Token instance when
@@ -122,7 +115,7 @@ namespace Lucene.Net.Analysis
 	/// <seealso cref="Lucene.Net.Index.Payload">
 	/// </seealso>
 	[Serializable]
-	public class Token : AttributeImpl, TermAttribute, TypeAttribute, PositionIncrementAttribute, FlagsAttribute, OffsetAttribute, PayloadAttribute
+	public class Token : Attribute, ITermAttribute, ITypeAttribute, IPositionIncrementAttribute, IFlagsAttribute, IOffsetAttribute, IPayloadAttribute
 	{
 		public const System.String DEFAULT_TYPE = "word";
 		
@@ -786,7 +779,7 @@ namespace Lucene.Net.Analysis
 			payload = prototype.payload;
 		}
 		
-		public override void  CopyTo(AttributeImpl target)
+		public override void  CopyTo(Attribute target)
 		{
 			if (target is Token)
 			{
@@ -801,12 +794,12 @@ namespace Lucene.Net.Analysis
 			else
 			{
 				InitTermBuffer();
-				((TermAttribute) target).SetTermBuffer(termBuffer, 0, termLength);
-				((OffsetAttribute) target).SetOffset(startOffset, endOffset);
-				((PositionIncrementAttribute) target).PositionIncrement = positionIncrement;
-				((PayloadAttribute) target).Payload = (payload == null)?null:(Payload) payload.Clone();
-				((FlagsAttribute) target).Flags = flags;
-				((TypeAttribute) target).Type = type;
+				((ITermAttribute) target).SetTermBuffer(termBuffer, 0, termLength);
+				((IOffsetAttribute) target).SetOffset(startOffset, endOffset);
+				((IPositionIncrementAttribute) target).PositionIncrement = positionIncrement;
+				((IPayloadAttribute) target).Payload = (payload == null)?null:(Payload) payload.Clone();
+				((IFlagsAttribute) target).Flags = flags;
+				((ITypeAttribute) target).Type = type;
 			}
 		}
        
@@ -837,7 +830,7 @@ namespace Lucene.Net.Analysis
                 this._delegateFactory = delegateFactory;
             }
 
-            public override AttributeImpl CreateAttributeInstance<T>()
+            public override Attribute CreateAttributeInstance<T>()
             {
                 return typeof(T).IsAssignableFrom(typeof(Token))
                            ? new Token()

Modified: incubator/lucene.net/trunk/src/core/Analysis/TokenStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/TokenStream.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/TokenStream.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/TokenStream.cs Fri Apr 13 16:33:33 2012
@@ -16,12 +16,10 @@
  */
 
 using System;
-
+using Lucene.Net.Util;
 using Document = Lucene.Net.Documents.Document;
 using Field = Lucene.Net.Documents.Field;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
-using Attribute = Lucene.Net.Util.Attribute;
-using AttributeImpl = Lucene.Net.Util.AttributeImpl;
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 
 namespace Lucene.Net.Analysis
@@ -37,15 +35,15 @@ namespace Lucene.Net.Analysis
 	/// <c>TokenStream</c>.</item>
 	/// </list>
 	/// A new <c>TokenStream</c> API has been introduced with Lucene 2.9. This API
-	/// has moved from being <see cref="Token" /> based to <see cref="Attribute" /> based. While
+	/// has moved from being <see cref="Token" /> based to <see cref="IAttribute" /> based. While
 	/// <see cref="Token" /> still exists in 2.9 as a convenience class, the preferred way
-	/// to store the information of a <see cref="Token" /> is to use <see cref="AttributeImpl" />s.
+	/// to store the information of a <see cref="Token" /> is to use <see cref="Util.Attribute" />s.
 	/// <p/>
 	/// <c>TokenStream</c> now extends <see cref="AttributeSource" />, which provides
-	/// access to all of the token <see cref="Attribute" />s for the <c>TokenStream</c>.
-	/// Note that only one instance per <see cref="AttributeImpl" /> is created and reused
+	/// access to all of the token <see cref="IAttribute" />s for the <c>TokenStream</c>.
+	/// Note that only one instance per <see cref="Util.Attribute" /> is created and reused
 	/// for every token. This approach reduces object creation and allows local
-	/// caching of references to the <see cref="AttributeImpl" />s. See
+	/// caching of references to the <see cref="Util.Attribute" />s. See
 	/// <see cref="IncrementToken()" /> for further details.
 	/// <p/>
 	/// <b>The workflow of the new <c>TokenStream</c> API is as follows:</b>
@@ -87,14 +85,14 @@ namespace Lucene.Net.Analysis
             : base(input)
 		{ }
 		
-		/// <summary> A TokenStream using the supplied AttributeFactory for creating new <see cref="Attribute" /> instances.</summary>
+		/// <summary> A TokenStream using the supplied AttributeFactory for creating new <see cref="IAttribute" /> instances.</summary>
         protected internal TokenStream(AttributeFactory factory)
             : base(factory)
 		{ }
 
 	    /// <summary> Consumers (i.e., <see cref="IndexWriter" />) use this method to advance the stream to
 	    /// the next token. Implementing classes must implement this method and update
-	    /// the appropriate <see cref="AttributeImpl" />s with the attributes of the next
+	    /// the appropriate <see cref="Util.Attribute" />s with the attributes of the next
 	    /// token.
 	    /// 
 	    /// The producer must make no assumptions about the attributes after the
@@ -105,7 +103,7 @@ namespace Lucene.Net.Analysis
 	    /// This method is called for every token of a document, so an efficient
 	    /// implementation is crucial for good performance. To avoid calls to
 	    /// <see cref="AttributeSource.AddAttribute(Type)" /> and <see cref="AttributeSource.GetAttribute(Type)" />,
-	    /// references to all <see cref="AttributeImpl" />s that this stream uses should be
+	    /// references to all <see cref="Util.Attribute" />s that this stream uses should be
 	    /// retrieved during instantiation.
 	    /// 
 	    /// To ensure that filters and consumers know which attributes are available,

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/FlagsAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/FlagsAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/FlagsAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/FlagsAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,27 +16,70 @@
  */
 
 using System;
-
-using Tokenizer = Lucene.Net.Analysis.Tokenizer;
 using Attribute = Lucene.Net.Util.Attribute;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
-	/// <summary> This attribute can be used to pass different flags down the <see cref="Tokenizer" /> chain,
+	/// <summary> This attribute can be used to pass different flags down the tokenizer chain,
 	/// eg from one TokenFilter to another one. 
 	/// </summary>
-	public interface FlagsAttribute:Attribute
+	[Serializable]
+	public class FlagsAttribute:Util.Attribute, IFlagsAttribute, System.ICloneable
 	{
+		private int flags = 0;
+
 	    /// <summary> EXPERIMENTAL:  While we think this is here to stay, we may want to change it to be a long.
 	    /// <p/>
 	    /// 
-	    /// Get the bitset for any bits that have been set.  This is completely distinct from <see cref="TypeAttribute.Type()" />, although they do share similar purposes.
+	    /// Get the bitset for any bits that have been set.  This is completely distinct from <see cref="ITypeAttribute.Type()" />, although they do share similar purposes.
 	    /// The flags can be used to encode information about the token for use by other <see cref="Lucene.Net.Analysis.TokenFilter" />s.
 	    /// 
 	    /// 
 	    /// </summary>
 	    /// <value> The bits </value>
-	    int Flags { get; set; }
+	    public virtual int Flags
+	    {
+	        get { return flags; }
+	        set { this.flags = value; }
+	    }
+
+	    public override void  Clear()
+		{
+			flags = 0;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (this == other)
+			{
+				return true;
+			}
+			
+			if (other is FlagsAttribute)
+			{
+				return ((FlagsAttribute) other).flags == flags;
+			}
+			
+			return false;
+		}
+		
+		public override int GetHashCode()
+		{
+			return flags;
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			IFlagsAttribute t = (IFlagsAttribute) target;
+			t.Flags = flags;
+		}
+		
+		override public System.Object Clone()
+		{
+            FlagsAttribute impl = new FlagsAttribute();
+            impl.flags = this.flags;
+            return impl;
+		}
 	}
 }
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,41 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+using Tokenizer = Lucene.Net.Analysis.Tokenizer;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> This attribute can be used to pass different flags down the <see cref="Tokenizer" /> chain,
+	/// eg from one TokenFilter to another one. 
+	/// </summary>
+	public interface IFlagsAttribute:IAttribute
+	{
+	    /// <summary> EXPERIMENTAL:  While we think this is here to stay, we may want to change it to be a long.
+	    /// <p/>
+	    /// 
+	    /// Get the bitset for any bits that have been set.  This is completely distinct from <see cref="ITypeAttribute.Type()" />, although they do share similar purposes.
+	    /// The flags can be used to encode information about the token for use by other <see cref="Lucene.Net.Analysis.TokenFilter" />s.
+	    /// 
+	    /// 
+	    /// </summary>
+	    /// <value> The bits </value>
+	    int Flags { get; set; }
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,48 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The start and end character offset of a Token. </summary>
+	public interface IOffsetAttribute : IAttribute
+	{
+	    /// <summary>Returns this Token's starting offset, the position of the first character
+	    /// corresponding to this token in the source text.
+	    /// Note that the difference between endOffset() and startOffset() may not be
+	    /// equal to termText.length(), as the term text may have been altered by a
+	    /// stemmer or some other filter. 
+	    /// </summary>
+	    int StartOffset { get; }
+
+
+	    /// <summary>Set the starting and ending offset.
+        /// See StartOffset() and EndOffset()
+        /// </summary>
+		void  SetOffset(int startOffset, int endOffset);
+
+
+	    /// <summary>Returns this Token's ending offset, one greater than the position of the
+	    /// last character corresponding to this token in the source text. The length
+	    /// of the token in the source text is (endOffset - startOffset). 
+	    /// </summary>
+	    int EndOffset { get; }
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,31 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+using Payload = Lucene.Net.Index.Payload;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The payload of a Token. See also <see cref="Payload" />.</summary>
+	public interface IPayloadAttribute:IAttribute
+	{
+	    /// <summary> Returns this Token's payload.</summary>
+	    Payload Payload { get; set; }
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,59 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary>The positionIncrement determines the position of this token
+	/// relative to the previous Token in a TokenStream, used in phrase
+	/// searching.
+	/// 
+	/// <p/>The default value is one.
+	/// 
+	/// <p/>Some common uses for this are:<list>
+	/// 
+	/// <item>Set it to zero to put multiple terms in the same position.  This is
+	/// useful if, e.g., a word has multiple stems.  Searches for phrases
+	/// including either stem will match.  In this case, all but the first stem's
+	/// increment should be set to zero: the increment of the first instance
+	/// should be one.  Repeating a token with an increment of zero can also be
+	/// used to boost the scores of matches on that token.</item>
+	/// 
+	/// <item>Set it to values greater than one to inhibit exact phrase matches.
+	/// If, for example, one does not want phrases to match across removed stop
+	/// words, then one could build a stop word filter that removes stop words and
+	/// also sets the increment to the number of stop words removed before each
+	/// non-stop word.  Then exact phrase queries will only match when the terms
+	/// occur with no intervening stop words.</item>
+	/// 
+	/// </list>
+	/// 
+	/// </summary>
+	/// <seealso cref="Lucene.Net.Index.TermPositions">
+	/// </seealso>
+	public interface IPositionIncrementAttribute:IAttribute
+	{
+	    /// <summary>Gets or sets the position increment. The default value is one.
+	    /// 
+	    /// </summary>
+	    /// <value> the distance from the prior term </value>
+	    int PositionIncrement { set; get; }
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,104 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The term text of a Token.</summary>
+	public interface ITermAttribute:IAttribute
+	{
+		/// <summary>Returns the Token's term text.
+		/// 
+		/// This method has a performance penalty
+		/// because the text is stored internally in a char[].  If
+		/// possible, use <see cref="TermBuffer()" /> and <see cref="TermLength()" />
+		/// directly instead.  If you really need a
+		/// String, use this method, which is nothing more than
+		/// a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
+		/// </summary>
+		System.String Term();
+		
+		/// <summary>Copies the contents of buffer, starting at offset for
+		/// length characters, into the termBuffer array.
+		/// </summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		/// <param name="offset">the index in the buffer of the first character to copy
+		/// </param>
+		/// <param name="length">the number of characters to copy
+		/// </param>
+		void  SetTermBuffer(char[] buffer, int offset, int length);
+		
+		/// <summary>Copies the contents of buffer into the termBuffer array.</summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		void  SetTermBuffer(System.String buffer);
+		
+		/// <summary>Copies the contents of buffer, starting at offset and continuing
+		/// for length characters, into the termBuffer array.
+		/// </summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		/// <param name="offset">the index in the buffer of the first character to copy
+		/// </param>
+		/// <param name="length">the number of characters to copy
+		/// </param>
+		void  SetTermBuffer(System.String buffer, int offset, int length);
+		
+		/// <summary>Returns the internal termBuffer character array which
+		/// you can then directly alter.  If the array is too
+		/// small for your token, use <see cref="ResizeTermBuffer(int)" />
+		/// to increase it.  After
+		/// altering the buffer be sure to call <see cref="SetTermLength" />
+		/// to record the number of valid
+		/// characters that were placed into the termBuffer. 
+		/// </summary>
+		char[] TermBuffer();
+		
+		/// <summary>Grows the termBuffer to at least size newSize, preserving the
+		/// existing content. Note: If the next operation is to change
+		/// the contents of the term buffer use
+		/// <see cref="SetTermBuffer(char[], int, int)" />,
+		/// <see cref="SetTermBuffer(String)" />, or
+		/// <see cref="SetTermBuffer(String, int, int)" />
+		/// to optimally combine the resize with the setting of the termBuffer.
+		/// </summary>
+		/// <param name="newSize">minimum size of the new termBuffer
+		/// </param>
+		/// <returns> newly created termBuffer with length >= newSize
+		/// </returns>
+		char[] ResizeTermBuffer(int newSize);
+		
+		/// <summary>Return number of valid characters (length of the term)
+		/// in the termBuffer array. 
+		/// </summary>
+		int TermLength();
+		
+		/// <summary>Set number of valid characters (length of the term) in
+		/// the termBuffer array. Use this to truncate the termBuffer
+		/// or to synchronize with external manipulation of the termBuffer.
+		/// Note: to grow the size of the array,
+		/// use <see cref="ResizeTermBuffer(int)" /> first.
+		/// </summary>
+		/// <param name="length">the truncated length
+		/// </param>
+		void  SetTermLength(int length);
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,30 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> A Token's lexical type. The Default value is "word". </summary>
+	public interface ITypeAttribute:IAttribute
+	{
+	    /// <summary>Gets or sets this Token's lexical type.  Defaults to "word". </summary>
+	    string Type { get; set; }
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/OffsetAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/OffsetAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/OffsetAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/OffsetAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,34 +16,91 @@
  */
 
 using System;
-
 using Attribute = Lucene.Net.Util.Attribute;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
 	/// <summary> The start and end character offset of a Token. </summary>
-	public interface OffsetAttribute : Attribute
+	[Serializable]
+	public class OffsetAttribute:Attribute, IOffsetAttribute, System.ICloneable
 	{
+		private int startOffset;
+		private int endOffset;
+
 	    /// <summary>Returns this Token's starting offset, the position of the first character
 	    /// corresponding to this token in the source text.
 	    /// Note that the difference between endOffset() and startOffset() may not be
 	    /// equal to termText.length(), as the term text may have been altered by a
 	    /// stemmer or some other filter. 
 	    /// </summary>
-	    int StartOffset { get; }
+	    public virtual int StartOffset
+	    {
+	        get { return startOffset; }
+	    }
 
 
 	    /// <summary>Set the starting and ending offset.
         /// See StartOffset() and EndOffset()
         /// </summary>
-		void  SetOffset(int startOffset, int endOffset);
+		public virtual void  SetOffset(int startOffset, int endOffset)
+		{
+			this.startOffset = startOffset;
+			this.endOffset = endOffset;
+		}
 
 
 	    /// <summary>Returns this Token's ending offset, one greater than the position of the
 	    /// last character corresponding to this token in the source text. The length
 	    /// of the token in the source text is (endOffset - startOffset). 
 	    /// </summary>
-	    int EndOffset { get; }
+	    public virtual int EndOffset
+	    {
+	        get { return endOffset; }
+	    }
+
+
+	    public override void  Clear()
+		{
+			startOffset = 0;
+			endOffset = 0;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (other == this)
+			{
+				return true;
+			}
+			
+			if (other is OffsetAttribute)
+			{
+				OffsetAttribute o = (OffsetAttribute) other;
+				return o.startOffset == startOffset && o.endOffset == endOffset;
+			}
+			
+			return false;
+		}
+		
+		public override int GetHashCode()
+		{
+			int code = startOffset;
+			code = code * 31 + endOffset;
+			return code;
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			IOffsetAttribute t = (IOffsetAttribute) target;
+			t.SetOffset(startOffset, endOffset);
+		}
+		
+		override public System.Object Clone()
+		{
+            OffsetAttribute impl = new OffsetAttribute();
+            impl.endOffset = endOffset;
+            impl.startOffset = startOffset;
+            return impl;
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PayloadAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PayloadAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PayloadAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PayloadAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,17 +16,85 @@
  */
 
 using System;
-
-using Payload = Lucene.Net.Index.Payload;
 using Attribute = Lucene.Net.Util.Attribute;
+using Payload = Lucene.Net.Index.Payload;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
 	/// <summary> The payload of a Token. See also <see cref="Payload" />.</summary>
-	public interface PayloadAttribute:Attribute
+	[Serializable]
+	public class PayloadAttribute:Attribute, IPayloadAttribute, System.ICloneable
 	{
+		private Payload payload;
+		
+		/// <summary> Initialize this attribute with no payload.</summary>
+		public PayloadAttribute()
+		{
+		}
+		
+		/// <summary> Initialize this attribute with the given payload. </summary>
+		public PayloadAttribute(Payload payload)
+		{
+			this.payload = payload;
+		}
+
 	    /// <summary> Returns this Token's payload.</summary>
-	    Payload Payload { get; set; }
+	    public virtual Payload Payload
+	    {
+	        get { return this.payload; }
+	        set { this.payload = value; }
+	    }
+
+	    public override void  Clear()
+		{
+			payload = null;
+		}
+		
+		public override System.Object Clone()
+		{
+		    var clone = (PayloadAttribute) base.Clone();
+            if (payload != null)
+            {
+                clone.payload = (Payload) payload.Clone();
+            }
+		    return clone;
+            // TODO: This code use to be as below.  Any reason why?  the if(payload!=null) was missing...
+		    //PayloadAttributeImpl impl = new PayloadAttributeImpl();
+		    //impl.payload = new Payload(this.payload.data, this.payload.offset, this.payload.length);
+		    //return impl;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (other == this)
+			{
+				return true;
+			}
+			
+			if (other is IPayloadAttribute)
+			{
+				PayloadAttribute o = (PayloadAttribute) other;
+				if (o.payload == null || payload == null)
+				{
+					return o.payload == null && payload == null;
+				}
+				
+				return o.payload.Equals(payload);
+			}
+			
+			return false;
+		}
+		
+		public override int GetHashCode()
+		{
+			return (payload == null)?0:payload.GetHashCode();
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			IPayloadAttribute t = (IPayloadAttribute) target;
+			t.Payload = (payload == null)?null:(Payload) payload.Clone();
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PositionIncrementAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PositionIncrementAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PositionIncrementAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/PositionIncrementAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,14 +16,14 @@
  */
 
 using System;
-
 using Attribute = Lucene.Net.Util.Attribute;
+using TokenStream = Lucene.Net.Analysis.TokenStream;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
 	/// <summary>The positionIncrement determines the position of this token
-	/// relative to the previous Token in a TokenStream, used in phrase
+	/// relative to the previous Token in a <see cref="TokenStream" />, used in phrase
 	/// searching.
 	/// 
 	/// <p/>The default value is one.
@@ -45,16 +45,63 @@ namespace Lucene.Net.Analysis.Tokenattri
 	/// occur with no intervening stop words.</item>
 	/// 
 	/// </list>
-	/// 
 	/// </summary>
-	/// <seealso cref="Lucene.Net.Index.TermPositions">
-	/// </seealso>
-	public interface PositionIncrementAttribute:Attribute
+	[Serializable]
+	public class PositionIncrementAttribute:Attribute, IPositionIncrementAttribute, System.ICloneable
 	{
-	    /// <summary>Gets or sets the position increment. The default value is one.
+		private int positionIncrement = 1;
+
+	    /// <summary>Set the position increment. The default value is one.
 	    /// 
 	    /// </summary>
 	    /// <value> the distance from the prior term </value>
-	    int PositionIncrement { set; get; }
+	    public virtual int PositionIncrement
+	    {
+	        set
+	        {
+	            if (value < 0)
+	                throw new System.ArgumentException("Increment must be zero or greater: " + value);
+	            this.positionIncrement = value;
+	        }
+	        get { return positionIncrement; }
+	    }
+
+	    public override void  Clear()
+		{
+			this.positionIncrement = 1;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (other == this)
+			{
+				return true;
+			}
+			
+			if (other is PositionIncrementAttribute)
+			{
+				return positionIncrement == ((PositionIncrementAttribute) other).positionIncrement;
+			}
+			
+			return false;
+		}
+		
+		public override int GetHashCode()
+		{
+			return positionIncrement;
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			IPositionIncrementAttribute t = (IPositionIncrementAttribute) target;
+			t.PositionIncrement = positionIncrement;
+		}
+		
+		override public System.Object Clone()
+		{
+            PositionIncrementAttribute impl = new PositionIncrementAttribute();
+            impl.positionIncrement = positionIncrement;
+            return impl;
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TermAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TermAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TermAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TermAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,25 +16,36 @@
  */
 
 using System;
-
+using Lucene.Net.Support;
+using ArrayUtil = Lucene.Net.Util.ArrayUtil;
 using Attribute = Lucene.Net.Util.Attribute;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
 	/// <summary> The term text of a Token.</summary>
-	public interface TermAttribute:Attribute
+	[Serializable]
+	public class TermAttribute:Attribute, ITermAttribute, System.ICloneable
 	{
+		private static int MIN_BUFFER_SIZE = 10;
+		
+		private char[] termBuffer;
+		private int termLength;
+		
 		/// <summary>Returns the Token's term text.
 		/// 
 		/// This method has a performance penalty
 		/// because the text is stored internally in a char[].  If
-		/// possible, use <see cref="TermBuffer()" /> and <see cref="TermLength()" />
-		/// directly instead.  If you really need a
-		/// String, use this method, which is nothing more than
+		/// possible, use <see cref="TermBuffer()" /> and 
+		/// <see cref="TermLength()" /> directly instead.  If you 
+		/// really need a String, use this method, which is nothing more than
 		/// a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
 		/// </summary>
-		System.String Term();
+		public virtual System.String Term()
+		{
+			InitTermBuffer();
+			return new System.String(termBuffer, 0, termLength);
+		}
 		
 		/// <summary>Copies the contents of buffer, starting at offset for
 		/// length characters, into the termBuffer array.
@@ -45,12 +56,23 @@ namespace Lucene.Net.Analysis.Tokenattri
 		/// </param>
 		/// <param name="length">the number of characters to copy
 		/// </param>
-		void  SetTermBuffer(char[] buffer, int offset, int length);
+		public virtual void  SetTermBuffer(char[] buffer, int offset, int length)
+		{
+			GrowTermBuffer(length);
+			Array.Copy(buffer, offset, termBuffer, 0, length);
+			termLength = length;
+		}
 		
 		/// <summary>Copies the contents of buffer into the termBuffer array.</summary>
 		/// <param name="buffer">the buffer to copy
 		/// </param>
-		void  SetTermBuffer(System.String buffer);
+		public virtual void  SetTermBuffer(System.String buffer)
+		{
+			int length = buffer.Length;
+			GrowTermBuffer(length);
+			TextSupport.GetCharsFromString(buffer, 0, length, termBuffer, 0);
+			termLength = length;
+		}
 		
 		/// <summary>Copies the contents of buffer, starting at offset and continuing
 		/// for length characters, into the termBuffer array.
@@ -61,7 +83,14 @@ namespace Lucene.Net.Analysis.Tokenattri
 		/// </param>
 		/// <param name="length">the number of characters to copy
 		/// </param>
-		void  SetTermBuffer(System.String buffer, int offset, int length);
+		public virtual void  SetTermBuffer(System.String buffer, int offset, int length)
+		{
+			System.Diagnostics.Debug.Assert(offset <= buffer.Length);
+			System.Diagnostics.Debug.Assert(offset + length <= buffer.Length);
+			GrowTermBuffer(length);
+			TextSupport.GetCharsFromString(buffer, offset, offset + length, termBuffer, 0);
+			termLength = length;
+		}
 		
 		/// <summary>Returns the internal termBuffer character array which
 		/// you can then directly alter.  If the array is too
@@ -71,7 +100,11 @@ namespace Lucene.Net.Analysis.Tokenattri
 		/// to record the number of valid
 		/// characters that were placed into the termBuffer. 
 		/// </summary>
-		char[] TermBuffer();
+		public virtual char[] TermBuffer()
+		{
+			InitTermBuffer();
+			return termBuffer;
+		}
 		
 		/// <summary>Grows the termBuffer to at least size newSize, preserving the
 		/// existing content. Note: If the next operation is to change
@@ -85,12 +118,67 @@ namespace Lucene.Net.Analysis.Tokenattri
 		/// </param>
 		/// <returns> newly created termBuffer with length >= newSize
 		/// </returns>
-		char[] ResizeTermBuffer(int newSize);
+		public virtual char[] ResizeTermBuffer(int newSize)
+		{
+			if (termBuffer == null)
+			{
+				// The buffer is always at least MIN_BUFFER_SIZE
+				termBuffer = new char[ArrayUtil.GetNextSize(newSize < MIN_BUFFER_SIZE?MIN_BUFFER_SIZE:newSize)];
+			}
+			else
+			{
+				if (termBuffer.Length < newSize)
+				{
+					// Not big enough; create a new array with slight
+					// over allocation and preserve content
+					char[] newCharBuffer = new char[ArrayUtil.GetNextSize(newSize)];
+					Array.Copy(termBuffer, 0, newCharBuffer, 0, termBuffer.Length);
+					termBuffer = newCharBuffer;
+				}
+			}
+			return termBuffer;
+		}
+		
+		
+		/// <summary>Allocates a buffer char[] of at least newSize, without preserving the existing content.
+		/// its always used in places that set the content 
+		/// </summary>
+		/// <param name="newSize">minimum size of the buffer
+		/// </param>
+		private void  GrowTermBuffer(int newSize)
+		{
+			if (termBuffer == null)
+			{
+				// The buffer is always at least MIN_BUFFER_SIZE
+				termBuffer = new char[ArrayUtil.GetNextSize(newSize < MIN_BUFFER_SIZE?MIN_BUFFER_SIZE:newSize)];
+			}
+			else
+			{
+				if (termBuffer.Length < newSize)
+				{
+					// Not big enough; create a new array with slight
+					// over allocation:
+					termBuffer = new char[ArrayUtil.GetNextSize(newSize)];
+				}
+			}
+		}
+		
+		private void  InitTermBuffer()
+		{
+			if (termBuffer == null)
+			{
+				termBuffer = new char[ArrayUtil.GetNextSize(MIN_BUFFER_SIZE)];
+				termLength = 0;
+			}
+		}
 		
 		/// <summary>Return number of valid characters (length of the term)
 		/// in the termBuffer array. 
 		/// </summary>
-		int TermLength();
+		public virtual int TermLength()
+		{
+			return termLength;
+		}
 		
 		/// <summary>Set number of valid characters (length of the term) in
 		/// the termBuffer array. Use this to truncate the termBuffer
@@ -100,6 +188,78 @@ namespace Lucene.Net.Analysis.Tokenattri
 		/// </summary>
 		/// <param name="length">the truncated length
 		/// </param>
-		void  SetTermLength(int length);
+		public virtual void  SetTermLength(int length)
+		{
+			InitTermBuffer();
+			if (length > termBuffer.Length)
+				throw new System.ArgumentException("length " + length + " exceeds the size of the termBuffer (" + termBuffer.Length + ")");
+			termLength = length;
+		}
+		
+		public override int GetHashCode()
+		{
+			InitTermBuffer();
+			int code = termLength;
+			code = code * 31 + ArrayUtil.HashCode(termBuffer, 0, termLength);
+			return code;
+		}
+		
+		public override void  Clear()
+		{
+			termLength = 0;
+		}
+		
+		public override System.Object Clone()
+		{
+			TermAttribute t = (TermAttribute) base.Clone();
+			// Do a deep clone
+			if (termBuffer != null)
+			{
+				t.termBuffer = new char[termBuffer.Length];
+				termBuffer.CopyTo(t.termBuffer, 0);
+			}
+			return t;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (other == this)
+			{
+				return true;
+			}
+			
+			if (other is ITermAttribute)
+			{
+				InitTermBuffer();
+				TermAttribute o = ((TermAttribute) other);
+				o.InitTermBuffer();
+				
+				if (termLength != o.termLength)
+					return false;
+				for (int i = 0; i < termLength; i++)
+				{
+					if (termBuffer[i] != o.termBuffer[i])
+					{
+						return false;
+					}
+				}
+				return true;
+			}
+			
+			return false;
+		}
+		
+		public override System.String ToString()
+		{
+			InitTermBuffer();
+			return "term=" + new System.String(termBuffer, 0, termLength);
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			InitTermBuffer();
+			ITermAttribute t = (ITermAttribute) target;
+			t.SetTermBuffer(termBuffer, 0, termLength);
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TypeAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TypeAttribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TypeAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/TypeAttribute.cs Fri Apr 13 16:33:33 2012
@@ -16,16 +16,70 @@
  */
 
 using System;
-
 using Attribute = Lucene.Net.Util.Attribute;
 
 namespace Lucene.Net.Analysis.Tokenattributes
 {
 	
 	/// <summary> A Token's lexical type. The Default value is "word". </summary>
-	public interface TypeAttribute:Attribute
+	[Serializable]
+	public class TypeAttribute:Attribute, ITypeAttribute, System.ICloneable
 	{
-	    /// <summary>Gets or sets this Token's lexical type.  Defaults to "word". </summary>
-	    string Type { get; set; }
+		private System.String type;
+		public const System.String DEFAULT_TYPE = "word";
+		
+		public TypeAttribute():this(DEFAULT_TYPE)
+		{
+		}
+		
+		public TypeAttribute(System.String type)
+		{
+			this.type = type;
+		}
+
+	    /// <summary>Returns this Token's lexical type.  Defaults to "word". </summary>
+	    public virtual string Type
+	    {
+	        get { return type; }
+	        set { this.type = value; }
+	    }
+
+	    public override void  Clear()
+		{
+			type = DEFAULT_TYPE;
+		}
+		
+		public  override bool Equals(System.Object other)
+		{
+			if (other == this)
+			{
+				return true;
+			}
+			
+			if (other is TypeAttribute)
+			{
+				return type.Equals(((TypeAttribute) other).type);
+			}
+			
+			return false;
+		}
+		
+		public override int GetHashCode()
+		{
+			return type.GetHashCode();
+		}
+		
+		public override void  CopyTo(Attribute target)
+		{
+			ITypeAttribute t = (ITypeAttribute) target;
+			t.Type = type;
+		}
+		
+		override public System.Object Clone()
+		{
+            TypeAttribute impl = new TypeAttribute();
+            impl.type = type;
+            return impl;
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Index/DocInverterPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/DocInverterPerField.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/DocInverterPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/DocInverterPerField.cs Fri Apr 13 16:33:33 2012
@@ -16,10 +16,9 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Documents;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
 
 namespace Lucene.Net.Index
 {
@@ -151,8 +150,8 @@ namespace Lucene.Net.Index
 							
 							fieldState.attributeSource = stream;
 
-                            OffsetAttribute offsetAttribute = fieldState.attributeSource.AddAttribute<OffsetAttribute>();
-							PositionIncrementAttribute posIncrAttribute = fieldState.attributeSource.AddAttribute<PositionIncrementAttribute>();
+                            IOffsetAttribute offsetAttribute = fieldState.attributeSource.AddAttribute<IOffsetAttribute>();
+							IPositionIncrementAttribute posIncrAttribute = fieldState.attributeSource.AddAttribute<IPositionIncrementAttribute>();
 							
 							consumer.Start(field);
 							

Modified: incubator/lucene.net/trunk/src/core/Index/DocInverterPerThread.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/DocInverterPerThread.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/DocInverterPerThread.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/DocInverterPerThread.cs Fri Apr 13 16:33:33 2012
@@ -16,10 +16,9 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Util;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 
 namespace Lucene.Net.Index
 {
@@ -42,13 +41,13 @@ namespace Lucene.Net.Index
 		
 		internal class SingleTokenAttributeSource : AttributeSource
 		{
-			internal TermAttribute termAttribute;
-			internal OffsetAttribute offsetAttribute;
+			internal ITermAttribute termAttribute;
+			internal IOffsetAttribute offsetAttribute;
 
             internal SingleTokenAttributeSource()
 			{
-                termAttribute = AddAttribute<TermAttribute>();
-				offsetAttribute = AddAttribute<OffsetAttribute>();
+                termAttribute = AddAttribute<ITermAttribute>();
+				offsetAttribute = AddAttribute<IOffsetAttribute>();
 			}
 			
 			public void  Reinit(System.String stringValue, int startOffset, int endOffset)

Modified: incubator/lucene.net/trunk/src/core/Index/FreqProxTermsWriterPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/FreqProxTermsWriterPerField.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/FreqProxTermsWriterPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/FreqProxTermsWriterPerField.cs Fri Apr 13 16:33:33 2012
@@ -16,8 +16,8 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Documents;
-using PayloadAttribute = Lucene.Net.Analysis.Tokenattributes.PayloadAttribute;
 
 namespace Lucene.Net.Index
 {
@@ -34,7 +34,7 @@ namespace Lucene.Net.Index
 		internal DocumentsWriter.DocState docState;
 		internal FieldInvertState fieldState;
 		internal bool omitTermFreqAndPositions;
-		internal PayloadAttribute payloadAttribute;
+		internal IPayloadAttribute payloadAttribute;
 		
 		public FreqProxTermsWriterPerField(TermsHashPerField termsHashPerField, FreqProxTermsWriterPerThread perThread, FieldInfo fieldInfo)
 		{
@@ -87,9 +87,9 @@ namespace Lucene.Net.Index
 		
 		internal override void  Start(IFieldable f)
 		{
-            if (fieldState.attributeSource.HasAttribute<PayloadAttribute>())
+            if (fieldState.attributeSource.HasAttribute<IPayloadAttribute>())
 			{
-                payloadAttribute = fieldState.attributeSource.GetAttribute<PayloadAttribute>();
+                payloadAttribute = fieldState.attributeSource.GetAttribute<IPayloadAttribute>();
 			}
 			else
 			{

Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs Fri Apr 13 16:33:33 2012
@@ -16,8 +16,8 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Documents;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
 using IndexOutput = Lucene.Net.Store.IndexOutput;
 using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
 
@@ -39,7 +39,7 @@ namespace Lucene.Net.Index
 		internal bool doVectorOffsets;
 		
 		internal int maxNumPostings;
-		internal OffsetAttribute offsetAttribute = null;
+		internal IOffsetAttribute offsetAttribute = null;
 		
 		public TermVectorsTermsWriterPerField(TermsHashPerField termsHashPerField, TermVectorsTermsWriterPerThread perThread, FieldInfo fieldInfo)
 		{
@@ -224,7 +224,7 @@ namespace Lucene.Net.Index
 		{
 			if (doVectorOffsets)
 			{
-				offsetAttribute = fieldState.attributeSource.AddAttribute<OffsetAttribute>();
+				offsetAttribute = fieldState.attributeSource.AddAttribute<IOffsetAttribute>();
 			}
 			else
 			{

Modified: incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs Fri Apr 13 16:33:33 2012
@@ -16,9 +16,9 @@
  */
 
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Documents;
 using Lucene.Net.Support;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
 
 namespace Lucene.Net.Index
@@ -38,7 +38,7 @@ namespace Lucene.Net.Index
 		internal TermsHashPerThread perThread;
 		internal DocumentsWriter.DocState docState;
 		internal FieldInvertState fieldState;
-		internal TermAttribute termAtt;
+		internal ITermAttribute termAtt;
 		
 		// Copied from our perThread
 		internal CharBlockPool charPool;
@@ -287,7 +287,7 @@ namespace Lucene.Net.Index
 		
 		internal override void  Start(IFieldable f)
 		{
-			termAtt = fieldState.attributeSource.AddAttribute<TermAttribute>();
+			termAtt = fieldState.attributeSource.AddAttribute<ITermAttribute>();
 			consumer.Start(f);
 			if (nextPerField != null)
 			{

Modified: incubator/lucene.net/trunk/src/core/Lucene.Net.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Lucene.Net.csproj?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Lucene.Net.csproj (original)
+++ incubator/lucene.net/trunk/src/core/Lucene.Net.csproj Fri Apr 13 16:33:33 2012
@@ -194,17 +194,17 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Analysis\Tokenattributes\FlagsAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\FlagsAttributeImpl.cs" />
+    <Compile Include="Analysis\Tokenattributes\IFlagsAttribute.cs" />
+    <Compile Include="Analysis\Tokenattributes\IOffsetAttribute.cs" />
     <Compile Include="Analysis\Tokenattributes\OffsetAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\OffsetAttributeImpl.cs" />
+    <Compile Include="Analysis\Tokenattributes\IPayloadAttribute.cs" />
     <Compile Include="Analysis\Tokenattributes\PayloadAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\PayloadAttributeImpl.cs" />
+    <Compile Include="Analysis\Tokenattributes\IPositionIncrementAttribute.cs" />
     <Compile Include="Analysis\Tokenattributes\PositionIncrementAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\PositionIncrementAttributeImpl.cs" />
+    <Compile Include="Analysis\Tokenattributes\ITermAttribute.cs" />
     <Compile Include="Analysis\Tokenattributes\TermAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\TermAttributeImpl.cs" />
+    <Compile Include="Analysis\Tokenattributes\ITypeAttribute.cs" />
     <Compile Include="Analysis\Tokenattributes\TypeAttribute.cs" />
-    <Compile Include="Analysis\Tokenattributes\TypeAttributeImpl.cs" />
     <Compile Include="Analysis\TokenFilter.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -881,8 +881,8 @@
     <Compile Include="Support\WeakHashTable.cs" />
     <Compile Include="Support\WeakReference.cs" />
     <Compile Include="Util\ArrayUtil.cs" />
+    <Compile Include="Util\IAttribute.cs" />
     <Compile Include="Util\Attribute.cs" />
-    <Compile Include="Util\AttributeImpl.cs" />
     <Compile Include="Util\AttributeSource.cs" />
     <Compile Include="Util\AverageGuessMemoryModel.cs" />
     <Compile Include="Util\BitUtil.cs" />

Modified: incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.cs Fri Apr 13 16:33:33 2012
@@ -26,14 +26,13 @@ using System.Globalization;
 using System.IO;
 using System.Text;
 using Lucene.Net.Analysis;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Search;
 using Lucene.Net.Support;
 using Lucene.Net.Util;
 using Analyzer = Lucene.Net.Analysis.Analyzer;
 using CachingTokenFilter = Lucene.Net.Analysis.CachingTokenFilter;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 using DateField = Lucene.Net.Documents.DateField;
 using DateTools = Lucene.Net.Documents.DateTools;
 using Term = Lucene.Net.Index.Term;
@@ -514,8 +513,8 @@ namespace Lucene.Net.QueryParsers
                 source = analyzer.TokenStream(field, new StringReader(queryText));
             }
             CachingTokenFilter buffer = new CachingTokenFilter(source);
-            TermAttribute termAtt = null;
-            PositionIncrementAttribute posIncrAtt = null;
+            ITermAttribute termAtt = null;
+            IPositionIncrementAttribute posIncrAtt = null;
             int numTokens = 0;
 
             bool success = false;
@@ -530,13 +529,13 @@ namespace Lucene.Net.QueryParsers
             }
             if (success)
             {
-                if (buffer.HasAttribute<TermAttribute>())
+                if (buffer.HasAttribute<ITermAttribute>())
                 {
-                    termAtt = buffer.GetAttribute<TermAttribute>();
+                    termAtt = buffer.GetAttribute<ITermAttribute>();
                 }
-                if (buffer.HasAttribute<PositionIncrementAttribute>())
+                if (buffer.HasAttribute<IPositionIncrementAttribute>())
                 {
-                    posIncrAtt = buffer.GetAttribute<PositionIncrementAttribute>();
+                    posIncrAtt = buffer.GetAttribute<IPositionIncrementAttribute>();
                 }
             }
 

Modified: incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs Fri Apr 13 16:33:33 2012
@@ -18,11 +18,11 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Index;
 using Lucene.Net.Support;
 using Analyzer = Lucene.Net.Analysis.Analyzer;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 
 namespace Lucene.Net.Search
 {
@@ -63,7 +63,7 @@ namespace Lucene.Net.Search
 						bool hasMoreTokens = false;
 						
 						stream.Reset();
-                        TermAttribute termAtt = stream.AddAttribute<TermAttribute>();
+                        ITermAttribute termAtt = stream.AddAttribute<ITermAttribute>();
 						
 						hasMoreTokens = stream.IncrementToken();
 						while (hasMoreTokens)

Modified: incubator/lucene.net/trunk/src/core/Support/AttributeImplItem.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Support/AttributeImplItem.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Support/AttributeImplItem.cs (original)
+++ incubator/lucene.net/trunk/src/core/Support/AttributeImplItem.cs Fri Apr 13 16:33:33 2012
@@ -30,12 +30,12 @@ namespace Lucene.Net.Support
     /// </summary>
     internal sealed class AttributeImplItem
     {
-        internal AttributeImplItem(Type key, Util.AttributeImpl value)
+        internal AttributeImplItem(Type key, Util.Attribute value)
         {
             this.Key = key;
             this.Value = value;
         }
         internal Type Key;
-        internal Util.AttributeImpl Value;
+        internal Util.Attribute Value;
     }
 }

Modified: incubator/lucene.net/trunk/src/core/Util/Attribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/Attribute.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Util/Attribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Util/Attribute.cs Fri Apr 13 16:33:33 2012
@@ -20,8 +20,112 @@ using System;
 namespace Lucene.Net.Util
 {
 	
-	/// <summary> Base interface for attributes.</summary>
-	public interface Attribute
+	/// <summary> Base class for Attributes that can be added to a 
+	/// <see cref="Lucene.Net.Util.AttributeSource" />.
+	/// <p/>
+	/// Attributes are used to add data in a dynamic, yet type-safe way to a source
+	/// of usually streamed objects, e. g. a <see cref="Lucene.Net.Analysis.TokenStream" />.
+	/// </summary>
+	[Serializable]
+	public abstract class Attribute : System.ICloneable, IAttribute
 	{
+		/// <summary> Clears the values in this AttributeImpl and resets it to its 
+		/// default value. If this implementation implements more than one Attribute interface
+		/// it clears all.
+		/// </summary>
+		public abstract void  Clear();
+		
+		/// <summary> The default implementation of this method accesses all declared
+		/// fields of this object and prints the values in the following syntax:
+		/// 
+        /// <code>
+		/// public String toString() {
+		/// return "start=" + startOffset + ",end=" + endOffset;
+		/// }
+        /// </code>
+		/// 
+		/// This method may be overridden by subclasses.
+		/// </summary>
+		public override System.String ToString()
+		{
+			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
+			System.Type clazz = this.GetType();
+			System.Reflection.FieldInfo[] fields = clazz.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static);
+			try
+			{
+				for (int i = 0; i < fields.Length; i++)
+				{
+					System.Reflection.FieldInfo f = fields[i];
+					if (f.IsStatic)
+						continue;
+                    //f.setAccessible(true);   // {{Aroush-2.9}} java.lang.reflect.AccessibleObject.setAccessible
+					System.Object value_Renamed = f.GetValue(this);
+					if (buffer.Length > 0)
+					{
+						buffer.Append(',');
+					}
+					if (value_Renamed == null)
+					{
+						buffer.Append(f.Name + "=null");
+					}
+					else
+					{
+						buffer.Append(f.Name + "=" + value_Renamed);
+					}
+				}
+			}
+			catch (System.UnauthorizedAccessException e)
+			{
+				// this should never happen, because we're just accessing fields
+				// from 'this'
+				throw new System.SystemException(e.Message, e);
+			}
+			
+			return buffer.ToString();
+		}
+		
+		/// <summary> Subclasses must implement this method and should compute
+		/// a hashCode similar to this:
+		/// <code>
+		/// public int hashCode() {
+		/// int code = startOffset;
+		/// code = code * 31 + endOffset;
+		/// return code;
+		/// }
+		/// </code> 
+		/// 
+		/// see also <see cref="Equals(Object)" />
+		/// </summary>
+		abstract public override int GetHashCode();
+		
+		/// <summary> All values used for computation of <see cref="GetHashCode()" /> 
+		/// should be checked here for equality.
+		/// 
+		/// see also <see cref="Object.Equals(Object)" />
+		/// </summary>
+		abstract public override bool Equals(System.Object other);
+		
+		/// <summary> Copies the values from this Attribute into the passed-in
+		/// target attribute. The target implementation must support all the
+		/// Attributes this implementation supports.
+		/// </summary>
+		public abstract void  CopyTo(Attribute target);
+		
+		/// <summary> Shallow clone. Subclasses must override this if they 
+		/// need to clone any members deeply,
+		/// </summary>
+		public virtual System.Object Clone()
+		{
+			System.Object clone = null;
+			try
+			{
+				clone = base.MemberwiseClone();
+			}
+			catch (System.Exception e)
+			{
+				throw new System.SystemException(e.Message, e); // shouldn't happen
+			}
+			return clone;
+		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Util/AttributeSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/AttributeSource.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Util/AttributeSource.cs (original)
+++ incubator/lucene.net/trunk/src/core/Util/AttributeSource.cs Fri Apr 13 16:33:33 2012
@@ -18,13 +18,14 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using Lucene.Net.Support;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
 
 namespace Lucene.Net.Util
 {
 	
-	/// <summary> An AttributeSource contains a list of different <see cref="AttributeImpl" />s,
+	/// <summary> An AttributeSource contains a list of different <see cref="Attribute" />s,
 	/// and methods to add and get them. There can only be a single instance
 	/// of an attribute in the same AttributeSource instance. This is ensured
 	/// by passing in the actual type of the Attribute (Class&lt;Attribute&gt;) to 
@@ -34,14 +35,14 @@ namespace Lucene.Net.Util
 	/// </summary>
 	public class AttributeSource
 	{
-		/// <summary> An AttributeFactory creates instances of <see cref="AttributeImpl" />s.</summary>
+		/// <summary> An AttributeFactory creates instances of <see cref="Attribute" />s.</summary>
 		public abstract class AttributeFactory
 		{
-			/// <summary> returns an <see cref="AttributeImpl" /> for the supplied <see cref="Attribute" /> interface class.</summary>
-			public abstract AttributeImpl CreateAttributeInstance<T>() where T : Attribute;
+			/// <summary> returns an <see cref="Attribute" /> for the supplied <see cref="IAttribute" /> interface class.</summary>
+			public abstract Attribute CreateAttributeInstance<T>() where T : IAttribute;
 			
-			/// <summary> This is the default factory that creates <see cref="AttributeImpl" />s using the
-			/// class name of the supplied <see cref="Attribute" /> interface class by appending <c>Impl</c> to it.
+			/// <summary> This is the default factory that creates <see cref="Attribute" />s using the
+			/// class name of the supplied <see cref="IAttribute" /> interface class by appending <c>Impl</c> to it.
 			/// </summary>
 			public static readonly AttributeFactory DEFAULT_ATTRIBUTE_FACTORY = new DefaultAttributeFactory();
 			
@@ -55,11 +56,11 @@ namespace Lucene.Net.Util
 				{
 				}
 				
-				public override AttributeImpl CreateAttributeInstance<TAttImpl>()
+				public override Attribute CreateAttributeInstance<TAttImpl>()
 				{
 					try
 					{
-                        return (AttributeImpl)System.Activator.CreateInstance(GetClassForInterface<TAttImpl>());
+                        return (Attribute)System.Activator.CreateInstance(GetClassForInterface<TAttImpl>());
 					}
 					catch (System.UnauthorizedAccessException e)
                     {
@@ -71,7 +72,7 @@ namespace Lucene.Net.Util
                     //}
 				}
 
-                private static System.Type GetClassForInterface<T>() where T : Attribute
+                private static System.Type GetClassForInterface<T>() where T : IAttribute
 				{
 					lock (attClassImplMap)
 					{
@@ -82,7 +83,7 @@ namespace Lucene.Net.Util
 						{
 							try
 							{
-                                string name = attClass.FullName + "Impl, " + attClass.Assembly.FullName;
+                                string name = attClass.FullName.Replace(attClass.Name, attClass.Name.Substring(1)) + ", " + attClass.Assembly.FullName;
 								attClassImplMap.Add(attClass, new WeakReference( clazz = System.Type.GetType(name, true))); //OK
 							}
                             catch (System.TypeLoadException e) // was System.Exception
@@ -122,7 +123,7 @@ namespace Lucene.Net.Util
 			this.factory = input.factory;
 		}
 		
-		/// <summary> An AttributeSource using the supplied <see cref="AttributeFactory" /> for creating new <see cref="Attribute" /> instances.</summary>
+		/// <summary> An AttributeSource using the supplied <see cref="AttributeFactory" /> for creating new <see cref="IAttribute" /> instances.</summary>
 		public AttributeSource(AttributeFactory factory)
 		{
             this.attributes = new GeneralKeyedCollection<Type, AttributeImplItem>(att => att.Key);
@@ -156,7 +157,7 @@ namespace Lucene.Net.Util
         /// Signature for Java 1.5: <c>public Iterator&lt;AttributeImpl&gt; getAttributeImplsIterator()</c>
         /// </summary>
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
-        public virtual IEnumerable<AttributeImpl> GetAttributeImplsIterator()
+        public virtual IEnumerable<Attribute> GetAttributeImplsIterator()
         {
             var initState = GetCurrentState();
             while (initState != null)
@@ -180,7 +181,7 @@ namespace Lucene.Net.Util
         /// The recommended way to use custom implementations is using an <see cref="AttributeFactory"/>
         /// </font></p>
         /// </summary>
-		public virtual void  AddAttributeImpl(AttributeImpl att)
+		public virtual void  AddAttributeImpl(Attribute att)
 		{
 			System.Type clazz = att.GetType();
 			if (attributeImpls.Contains(clazz))
@@ -203,7 +204,7 @@ namespace Lucene.Net.Util
 						for (int i = 0; i < interfaces.Length; i++)
 						{
 							System.Type curInterface = interfaces[i];
-							if (curInterface != typeof(Attribute) && typeof(Attribute).IsAssignableFrom(curInterface))
+							if (curInterface != typeof(IAttribute) && typeof(IAttribute).IsAssignableFrom(curInterface))
 							{
 								foundInterfaces.AddLast(new WeakReference(curInterface));
 							}
@@ -240,12 +241,12 @@ namespace Lucene.Net.Util
 		/// new instance is created, added to this AttributeSource and returned. 
 		/// </summary>
 		// NOTE: Java has Class<T>, .NET has no Type<T>, this is not a perfect port
-        public virtual T AddAttribute<T>() where T : Attribute
+        public virtual T AddAttribute<T>() where T : IAttribute
 		{
 		    var attClass = typeof (T);
 			if (!attributes.ContainsKey(attClass))
 			{
-                if (!(attClass.IsInterface &&  typeof(Attribute).IsAssignableFrom(attClass))) 
+                if (!(attClass.IsInterface &&  typeof(IAttribute).IsAssignableFrom(attClass))) 
                 {
                     throw new ArgumentException(
                         "AddAttribute() only accepts an interface that extends Attribute, but " +
@@ -256,7 +257,7 @@ namespace Lucene.Net.Util
 				AddAttributeImpl(this.factory.CreateAttributeInstance<T>());
 			}
 
-            return (T)(Attribute)attributes[attClass].Value;
+            return (T)(IAttribute)attributes[attClass].Value;
 		}
 
 	    /// <summary>Returns true, iff this AttributeSource has any attributes </summary>
@@ -268,7 +269,7 @@ namespace Lucene.Net.Util
 	    /// <summary> The caller must pass in a Class&lt;? extends Attribute&gt; value. 
 		/// Returns true, iff this AttributeSource contains the passed-in Attribute.
         /// </summary>\
-		public virtual bool HasAttribute<T>() where T : Attribute
+		public virtual bool HasAttribute<T>() where T : IAttribute
 		{
 			return this.attributes.Contains(typeof(T));
 		}
@@ -286,7 +287,7 @@ namespace Lucene.Net.Util
         /// consuming), use <see cref="HasAttribute" />.
         /// </throws>
         // NOTE: Java has Class<T>, .NET has no Type<T>, this is not a perfect port
-		public virtual T GetAttribute<T>() where T : Attribute
+		public virtual T GetAttribute<T>() where T : IAttribute
 		{
 		    var attClass = typeof (T);
             if (!this.attributes.ContainsKey(attClass))
@@ -295,7 +296,7 @@ namespace Lucene.Net.Util
             }
             else
             {
-                return (T)(Attribute)this.attributes[attClass].Value;
+                return (T)(IAttribute)this.attributes[attClass].Value;
             }
 		}
 		
@@ -306,13 +307,13 @@ namespace Lucene.Net.Util
 		/// </seealso>
 		public sealed class State : System.ICloneable
 		{
-			internal /*private*/ AttributeImpl attribute;
+			internal /*private*/ Attribute attribute;
 			internal /*private*/ State next;
 			
 			public System.Object Clone()
 			{
 				State clone = new State();
-				clone.attribute = (AttributeImpl) attribute.Clone();
+				clone.attribute = (Attribute) attribute.Clone();
 				
 				if (next != null)
 				{
@@ -347,7 +348,7 @@ namespace Lucene.Net.Util
 		}
 
 		/// <summary> Resets all Attributes in this AttributeSource by calling
-		/// <see cref="AttributeImpl.Clear()" /> on each Attribute implementation.
+		/// <see cref="Attribute.Clear()" /> on each Attribute implementation.
 		/// </summary>
 		public virtual void  ClearAttributes()
 		{
@@ -475,7 +476,7 @@ namespace Lucene.Net.Util
 			return sb.Append(')').ToString();
 		}
 		
-		/// <summary> Performs a clone of all <see cref="AttributeImpl" /> instances returned in a new
+		/// <summary> Performs a clone of all <see cref="Attribute" /> instances returned in a new
 		/// AttributeSource instance. This method can be used to e.g. create another TokenStream
 		/// with exactly the same attributes (using <see cref="AttributeSource(AttributeSource)" />)
 		/// </summary>
@@ -488,7 +489,7 @@ namespace Lucene.Net.Util
 			{
                 for (var state = GetCurrentState(); state != null; state = state.next)
                 {
-                    var impl = (AttributeImpl) state.attribute.Clone();
+                    var impl = (Attribute) state.attribute.Clone();
 
                     if (!clone.attributeImpls.ContainsKey(impl.GetType()))
                     {

Added: incubator/lucene.net/trunk/src/core/Util/IAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/IAttribute.cs?rev=1325831&view=auto
==============================================================================
--- incubator/lucene.net/trunk/src/core/Util/IAttribute.cs (added)
+++ incubator/lucene.net/trunk/src/core/Util/IAttribute.cs Fri Apr 13 16:33:33 2012
@@ -0,0 +1,27 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Util
+{
+	
+	/// <summary> Base interface for attributes.</summary>
+	public interface IAttribute
+	{
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/Cn/TestChineseTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/Cn/TestChineseTokenizer.cs?rev=1325831&r1=1325830&r2=1325831&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/Cn/TestChineseTokenizer.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/Cn/TestChineseTokenizer.cs Fri Apr 13 16:33:33 2012
@@ -43,7 +43,7 @@ namespace Lucene.Net.Analyzers.Cn
 
             int correctStartOffset = 0;
             int correctEndOffset = 1;
-            OffsetAttribute offsetAtt = tokenizer.GetAttribute<OffsetAttribute>();
+            IOffsetAttribute offsetAtt = tokenizer.GetAttribute<IOffsetAttribute>();
             while (tokenizer.IncrementToken())
             {
                 Assert.AreEqual(correctStartOffset, offsetAtt.StartOffset);