lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1142899 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document: FieldSelectorResult.cs MapFieldSelector.cs
Date Tue, 05 Jul 2011 06:36:45 GMT
Author: digy
Date: Tue Jul  5 06:36:44 2011
New Revision: 1142899

URL: http://svn.apache.org/viewvc?rev=1142899&view=rev
Log:
[LUCENENET-412] Changed FieldSelectorResult to enum as in Lucene.Java 3.0.3

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/MapFieldSelector.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs?rev=1142899&r1=1142898&r2=1142899&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/FieldSelectorResult.cs
Tue Jul  5 06:36:44 2011
@@ -21,100 +21,66 @@ using System.Runtime.InteropServices;
 
 namespace Lucene.Net.Documents
 {
-	/// <summary>  Provides information about what should be done with this Field 
-	/// 
-	/// 
-	/// </summary>
-	//Replace with an enumerated type in 1.5
-	[Serializable]
-	public sealed class FieldSelectorResult : IEquatable<FieldSelectorResult>
-	{
-		
-		/// <summary> Load this {@link Field} every time the {@link Document} is loaded,
reading in the data as it is encountered.
-		/// {@link Document#GetField(String)} and {@link Document#GetFieldable(String)} should
not return null.
-		/// <p/>
-		/// {@link Document#Add(Fieldable)} should be called by the Reader.
-		/// </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult LOAD = new FieldSelectorResult(0);
-		/// <summary> Lazily load this {@link Field}.  This means the {@link Field} is valid,
but it may not actually contain its data until
-		/// invoked.  {@link Document#GetField(String)} SHOULD NOT BE USED.  {@link Document#GetFieldable(String)}
is safe to use and should
-		/// return a valid instance of a {@link Fieldable}.
-		/// <p/>
-		/// {@link Document#Add(Fieldable)} should be called by the Reader.
-		/// </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult LAZY_LOAD = new FieldSelectorResult(1);
-		/// <summary> Do not load the {@link Field}.  {@link Document#GetField(String)} and
{@link Document#GetFieldable(String)} should return null.
-		/// {@link Document#Add(Fieldable)} is not called.
-		/// <p/>
-		/// {@link Document#Add(Fieldable)} should not be called by the Reader.
-		/// </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult NO_LOAD = new FieldSelectorResult(2);
-		/// <summary> Load this field as in the {@link #LOAD} case, but immediately return
from {@link Field} loading for the {@link Document}.  Thus, the
-		/// Document may not have its complete set of Fields.  {@link Document#GetField(String)}
and {@link Document#GetFieldable(String)} should
-		/// both be valid for this {@link Field}
-		/// <p/>
-		/// {@link Document#Add(Fieldable)} should be called by the Reader.
-		/// </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult LOAD_AND_BREAK = new FieldSelectorResult(3);
-		/// <summary> Behaves much like {@link #LOAD} but does not uncompress any compressed
data.  This is used for internal purposes.
-		/// {@link Document#GetField(String)} and {@link Document#GetFieldable(String)} should
not return null.
-		/// <p/>
-		/// {@link Document#Add(Fieldable)} should be called by
-		/// the Reader.
-		/// </summary>
-		/// <deprecated> This is an internal option only, and is
-		/// no longer needed now that {@link CompressionTools}
-		/// is used for field compression.
-		/// </deprecated>
+    /// <summary>  Provides information about what should be done with this Field 
+    /// 
+    /// 
+    /// </summary>
+    //Replace with an enumerated type in 1.5
+    [Serializable]
+    public enum FieldSelectorResult
+    {
+
+        /// <summary> Load this {@link Field} every time the {@link Document} is loaded,
reading in the data as it is encountered.
+        /// {@link Document#GetField(String)} and {@link Document#GetFieldable(String)} should
not return null.
+        /// <p/>
+        /// {@link Document#Add(Fieldable)} should be called by the Reader.
+        /// </summary>
+        LOAD,
+
+        /// <summary> Lazily load this {@link Field}.  This means the {@link Field}
is valid, but it may not actually contain its data until
+        /// invoked.  {@link Document#GetField(String)} SHOULD NOT BE USED.  {@link Document#GetFieldable(String)}
is safe to use and should
+        /// return a valid instance of a {@link Fieldable}.
+        /// <p/>
+        /// {@link Document#Add(Fieldable)} should be called by the Reader.
+        /// </summary>
+        LAZY_LOAD,
+
+        /// <summary> Do not load the {@link Field}.  {@link Document#GetField(String)}
and {@link Document#GetFieldable(String)} should return null.
+        /// {@link Document#Add(Fieldable)} is not called.
+        /// <p/>
+        /// {@link Document#Add(Fieldable)} should not be called by the Reader.
+        /// </summary>
+        NO_LOAD,
+
+        /// <summary> Load this field as in the {@link #LOAD} case, but immediately
return from {@link Field} loading for the {@link Document}.  Thus, the
+        /// Document may not have its complete set of Fields.  {@link Document#GetField(String)}
and {@link Document#GetFieldable(String)} should
+        /// both be valid for this {@link Field}
+        /// <p/>
+        /// {@link Document#Add(Fieldable)} should be called by the Reader.
+        /// </summary>
+        LOAD_AND_BREAK,
+
+        /// <summary>Expert:  Load the size of this {@link Field} rather than its value.
+        /// Size is measured as number of bytes required to store the field == bytes for
a binary or any compressed value, and 2*chars for a String value.
+        /// The size is stored as a binary value, represented as an int in a byte[], with
the higher order byte first in [0]
+        /// </summary>
+        SIZE,
+
+        /// <summary>Expert: Like {@link #SIZE} but immediately break from the field
loading loop, i.e., stop loading further fields, after the size is loaded </summary>
+        SIZE_AND_BREAK,
+
+        /// <summary> Behaves much like {@link #LOAD} but does not uncompress any compressed
data.  This is used for internal purposes.
+        /// {@link Document#GetField(String)} and {@link Document#GetFieldable(String)} should
not return null.
+        /// <p/>
+        /// {@link Document#Add(Fieldable)} should be called by
+        /// the Reader.
+        /// </summary>
+        /// <deprecated> This is an internal option only, and is
+        /// no longer needed now that {@link CompressionTools}
+        /// is used for field compression.
+        /// </deprecated>
         [Obsolete("This is an internal option only, and is no longer needed now that CompressionTools
is used for field compression.")]
-		[NonSerialized]
-		public static readonly FieldSelectorResult LOAD_FOR_MERGE = new FieldSelectorResult(4);
-		
-		/// <summary>Expert:  Load the size of this {@link Field} rather than its value.
-		/// Size is measured as number of bytes required to store the field == bytes for a binary
or any compressed value, and 2*chars for a String value.
-		/// The size is stored as a binary value, represented as an int in a byte[], with the higher
order byte first in [0]
-		/// </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult SIZE = new FieldSelectorResult(5);
-		
-		/// <summary>Expert: Like {@link #SIZE} but immediately break from the field loading
loop, i.e., stop loading further fields, after the size is loaded </summary>
-		[NonSerialized]
-		public static readonly FieldSelectorResult SIZE_AND_BREAK = new FieldSelectorResult(6);
-		
-		
-		
-		private int id;
-		
-		private FieldSelectorResult(int id)
-		{
-			this.id = id;
-		}
-		
-		public  override bool Equals(System.Object o)
-		{
-            return Equals(o as FieldSelectorResult);
-		}
-
-        public bool Equals(FieldSelectorResult other)
-        {
-            if (this == other)
-                return true;
-            if (other == null || GetType() != other.GetType())
-                return false;
-
-            if (id != other.id)
-                return false;
-
-            return true;
-        }
-		
-		public override int GetHashCode()
-		{
-			return id;
-		}
+        LOAD_FOR_MERGE
     }
-}
\ No newline at end of file
+}
+

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/MapFieldSelector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/MapFieldSelector.cs?rev=1142899&r1=1142898&r2=1142899&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/MapFieldSelector.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/MapFieldSelector.cs
Tue Jul  5 06:36:44 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Documents
 {
@@ -27,12 +28,12 @@ namespace Lucene.Net.Documents
 	public class MapFieldSelector : FieldSelector
 	{
 
-        internal Support.Dictionary<string, FieldSelectorResult> fieldSelections;
+        internal Dictionary<string, FieldSelectorResult> fieldSelections;
 		
 		/// <summary>Create a a MapFieldSelector</summary>
 		/// <param name="fieldSelections">maps from field names (String) to {@link FieldSelectorResult}s
 		/// </param>
-        public MapFieldSelector(Support.Dictionary<string, FieldSelectorResult> fieldSelections)
+        public MapFieldSelector(Dictionary<string, FieldSelectorResult> fieldSelections)
 		{
 			this.fieldSelections = fieldSelections;
 		}
@@ -42,7 +43,7 @@ namespace Lucene.Net.Documents
 		/// </param>
 		public MapFieldSelector(System.Collections.Generic.IList<string> fields)
 		{
-			fieldSelections = new Support.Dictionary<string, FieldSelectorResult>(fields.Count
* 5 / 3);
+			fieldSelections = new Dictionary<string, FieldSelectorResult>(fields.Count * 5 /
3);
 			for (int i = 0; i < fields.Count; i++)
 				fieldSelections[fields[i]] = FieldSelectorResult.LOAD;
 		}
@@ -52,7 +53,7 @@ namespace Lucene.Net.Documents
 		/// </param>
 		public MapFieldSelector(System.String[] fields)
 		{
-            fieldSelections = new Support.Dictionary<string, FieldSelectorResult>(fields.Length
* 5 / 3);
+            fieldSelections = new Dictionary<string, FieldSelectorResult>(fields.Length
* 5 / 3);
 			for (int i = 0; i < fields.Length; i++)
 				fieldSelections[fields[i]] = FieldSelectorResult.LOAD;
 		}
@@ -64,8 +65,8 @@ namespace Lucene.Net.Documents
 		/// </returns>
 		public virtual FieldSelectorResult Accept(System.String field)
 		{
-			FieldSelectorResult selection = (FieldSelectorResult) fieldSelections[field];
-			return selection != null?selection:FieldSelectorResult.NO_LOAD;
+            FieldSelectorResult selection = FieldSelectorResult.NO_LOAD;
+            return fieldSelections.TryGetValue(field, out selection) != false ? selection
: FieldSelectorResult.NO_LOAD;
 		}
 	}
 }
\ No newline at end of file



Mime
View raw message