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 2011/11/12 11:44:27 UTC
[Lucene.Net] svn commit: r1201243 [5/8] - in
/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/
src/core/Analysis/ src/core/Analysis/Standard/
src/core/Analysis/Tokenattributes/ src/core/Document/ src/core/Index/
src/core/QueryParser/ src/core/Search/...
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Sort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Sort.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Sort.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Sort.cs Sat Nov 12 10:44:21 2011
@@ -16,6 +16,7 @@
*/
using System;
+using Lucene.Net.Support;
namespace Lucene.Net.Search
{
@@ -300,7 +301,7 @@ namespace Lucene.Net.Search
// TODO in Java 1.5: switch to Arrays.hashCode(). The
// Java 1.4 workaround below calculates the same hashCode
// as Java 1.5's new Arrays.hashCode()
- return 0x45aaf665 + SupportClass.EquatableList<SortField>.GetHashCode(fields);
+ return 0x45aaf665 + EquatableList<SortField>.GetHashCode(fields);
}
static Sort()
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SortField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SortField.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SortField.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SortField.cs Sat Nov 12 10:44:21 2011
@@ -16,9 +16,10 @@
*/
using System;
-
+using Lucene.Net.Support;
using NumericField = Lucene.Net.Documents.NumericField;
using IndexReader = Lucene.Net.Index.IndexReader;
+using Single = Lucene.Net.Support.Single;
using Term = Lucene.Net.Index.Term;
using TermEnum = Lucene.Net.Index.TermEnum;
using StringHelper = Lucene.Net.Util.StringHelper;
@@ -671,7 +672,7 @@ namespace Lucene.Net.Search
int tmpI32; long tmpI64; float tmpF;
if (System.Int32.TryParse(termtext, out tmpI32)) ret = SortField.INT;
else if (System.Int64.TryParse(termtext, out tmpI64)) ret = SortField.LONG;
- else if (SupportClass.Single.TryParse(termtext, out tmpF)) ret = SortField.FLOAT;
+ else if (Single.TryParse(termtext, out tmpF)) ret = SortField.FLOAT;
else ret = SortField.STRING;
}
else
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs Sat Nov 12 10:44:21 2011
@@ -17,6 +17,7 @@
using System;
using Lucene.Net.Index;
+using Lucene.Net.Support;
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
using Query = Lucene.Net.Search.Query;
@@ -199,7 +200,7 @@ namespace Lucene.Net.Search.Spans
public override int GetHashCode()
{
int h = match.GetHashCode();
- h ^= ((h << 8) | (SupportClass.Number.URShift(h, 25))); // reversible
+ h ^= ((h << 8) | (Number.URShift(h, 25))); // reversible
h ^= System.Convert.ToInt32(GetBoost()) ^ end;
return h;
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs Sat Nov 12 10:44:21 2011
@@ -18,6 +18,7 @@
using System;
using System.Linq;
using Lucene.Net.Index;
+using Lucene.Net.Support;
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
using Query = Lucene.Net.Search.Query;
@@ -219,7 +220,7 @@ namespace Lucene.Net.Search.Spans
// Mix bits before folding in things like boost, since it could cancel the
// last element of clauses. This particular mix also serves to
// differentiate SpanNearQuery hashcodes from others.
- result ^= ((result << 14) | (SupportClass.Number.URShift(result, 19))); // reversible
+ result ^= ((result << 14) | (Number.URShift(result, 19))); // reversible
result += System.Convert.ToInt32(GetBoost());
result += slop;
result ^= (inOrder ? (long) 0x99AFD3BD : 0);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs Sat Nov 12 10:44:21 2011
@@ -17,6 +17,7 @@
using System;
using Lucene.Net.Index;
+using Lucene.Net.Support;
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
using Query = Lucene.Net.Search.Query;
@@ -246,9 +247,9 @@ namespace Lucene.Net.Search.Spans
public override int GetHashCode()
{
int h = include.GetHashCode();
- h = (h << 1) | (SupportClass.Number.URShift(h, 31)); // rotate left
+ h = (h << 1) | (Number.URShift(h, 31)); // rotate left
h ^= exclude.GetHashCode();
- h = (h << 1) | (SupportClass.Number.URShift(h, 31)); // rotate left
+ h = (h << 1) | (Number.URShift(h, 31)); // rotate left
h ^= System.Convert.ToInt32(GetBoost());
return h;
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs Sat Nov 12 10:44:21 2011
@@ -17,6 +17,7 @@
using System;
using Lucene.Net.Index;
+using Lucene.Net.Support;
using Lucene.Net.Util;
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
@@ -160,7 +161,7 @@ namespace Lucene.Net.Search.Spans
}
}
- private SupportClass.EquatableList<SpanQuery> clauses;
+ private EquatableList<SpanQuery> clauses;
private System.String field;
/// <summary>Construct a SpanOrQuery merging the provided clauses. </summary>
@@ -168,7 +169,7 @@ namespace Lucene.Net.Search.Spans
{
// copy clauses array into an ArrayList
- this.clauses = new SupportClass.EquatableList<SpanQuery>(clauses.Length);
+ this.clauses = new EquatableList<SpanQuery>(clauses.Length);
for (int i = 0; i < clauses.Length; i++)
{
SpanQuery clause = clauses[i];
@@ -284,7 +285,7 @@ namespace Lucene.Net.Search.Spans
public override int GetHashCode()
{
int h = clauses.GetHashCode();
- h ^= ((h << 10) | (SupportClass.Number.URShift(h, 23)));
+ h ^= ((h << 10) | (Number.URShift(h, 23)));
h ^= System.Convert.ToInt32(GetBoost());
return h;
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TimeLimitingCollector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TimeLimitingCollector.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TimeLimitingCollector.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TimeLimitingCollector.cs Sat Nov 12 10:44:21 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Support;
using IndexReader = Lucene.Net.Index.IndexReader;
namespace Lucene.Net.Search
@@ -48,7 +48,7 @@ namespace Lucene.Net.Search
private bool greedy;
- private sealed class TimerThread:SupportClass.ThreadClass
+ private sealed class TimerThread:ThreadClass
{
// NOTE: we can avoid explicit synchronization here for several reasons:
@@ -85,7 +85,7 @@ namespace Lucene.Net.Search
}
catch (System.Threading.ThreadInterruptedException ie)
{
- SupportClass.ThreadClass.Current().Interrupt();
+ ThreadClass.Current().Interrupt();
throw new System.SystemException(ie.Message, ie);
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexInput.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexInput.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexInput.cs Sat Nov 12 10:44:21 2011
@@ -16,6 +16,7 @@
*/
using System;
+using Lucene.Net.Support;
namespace Lucene.Net.Store
{
@@ -26,12 +27,12 @@ namespace Lucene.Net.Store
public class ChecksumIndexInput:IndexInput
{
internal IndexInput main;
- internal SupportClass.Checksum digest;
+ internal IChecksum digest;
public ChecksumIndexInput(IndexInput main)
{
this.main = main;
- digest = new SupportClass.CRC32();
+ digest = new CRC32();
}
public override byte ReadByte()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexOutput.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexOutput.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexOutput.cs Sat Nov 12 10:44:21 2011
@@ -16,9 +16,8 @@
*/
using System;
-
-using Checksum = SupportClass.Checksum;
-using CRC32 = SupportClass.CRC32;
+using Lucene.Net.Support;
+using CRC32 = Lucene.Net.Support.CRC32;
namespace Lucene.Net.Store
{
@@ -29,7 +28,7 @@ namespace Lucene.Net.Store
public class ChecksumIndexOutput:IndexOutput
{
internal IndexOutput main;
- internal Checksum digest;
+ internal IChecksum digest;
public ChecksumIndexOutput(IndexOutput main)
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs Sat Nov 12 10:44:21 2011
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
// Used only for WRITE_LOCK_NAME in deprecated create=true case:
+using Lucene.Net.Support;
using IndexFileNameFilter = Lucene.Net.Index.IndexFileNameFilter;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Constants = Lucene.Net.Util.Constants;
@@ -107,7 +108,7 @@ namespace Lucene.Net.Store
{
try
{
- DIGESTER = SupportClass.Cryptography.GetHashAlgorithm();
+ DIGESTER = Cryptography.GetHashAlgorithm();
}
catch (System.Exception e)
{
@@ -374,7 +375,7 @@ namespace Lucene.Net.Store
try
{
file = new System.IO.FileStream(fullFile.FullName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
- SupportClass.FileSupport.Sync(file);
+ FileSupport.Sync(file);
success = true;
}
finally
@@ -397,7 +398,7 @@ namespace Lucene.Net.Store
// In 3.0 we will change this to throw
// InterruptedException instead
// TODO: Change this to throwing a new ThreadInterruptedException when class is build
- SupportClass.ThreadClass.Current().Interrupt();
+ ThreadClass.Current().Interrupt();
throw new System.SystemException(ie.ToString(), ie);
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexOutput.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexOutput.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexOutput.cs Sat Nov 12 10:44:21 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Support;
using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
namespace Lucene.Net.Store
@@ -81,7 +81,7 @@ namespace Lucene.Net.Store
while ((i & ~ 0x7F) != 0)
{
WriteByte((byte) ((i & 0x7f) | 0x80));
- i = SupportClass.Number.URShift(i, 7);
+ i = Number.URShift(i, 7);
}
WriteByte((byte) i);
}
@@ -106,7 +106,7 @@ namespace Lucene.Net.Store
while ((i & ~ 0x7F) != 0)
{
WriteByte((byte) ((i & 0x7f) | 0x80));
- i = SupportClass.Number.URShift(i, 7);
+ i = Number.URShift(i, 7);
}
WriteByte((byte) i);
}
@@ -150,7 +150,7 @@ namespace Lucene.Net.Store
}
else
{
- WriteByte((byte) (0xE0 | (SupportClass.Number.URShift(code, 12))));
+ WriteByte((byte) (0xE0 | (Number.URShift(code, 12))));
WriteByte((byte) (0x80 | ((code >> 6) & 0x3F)));
WriteByte((byte) (0x80 | (code & 0x3F)));
}
@@ -184,7 +184,7 @@ namespace Lucene.Net.Store
}
else
{
- WriteByte((byte) (0xE0 | (SupportClass.Number.URShift(code, 12))));
+ WriteByte((byte) (0xE0 | (Number.URShift(code, 12))));
WriteByte((byte) (0x80 | ((code >> 6) & 0x3F)));
WriteByte((byte) (0x80 | (code & 0x3F)));
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs Sat Nov 12 10:44:21 2011
@@ -16,6 +16,7 @@
*/
using System;
+using Lucene.Net.Support;
namespace Lucene.Net.Store
{
@@ -107,11 +108,7 @@ namespace Lucene.Net.Store
}
catch (System.Threading.ThreadInterruptedException e)
{
- // In 3.0 we will change this to throw
- // InterruptedException instead
- // TODO: Revisit rewriting in ThreadInterruptedException
- SupportClass.ThreadClass.Current().Interrupt();
- throw new System.IO.IOException(e.ToString());
+ throw;
}
locked = Obtain();
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs Sat Nov 12 10:44:21 2011
@@ -104,20 +104,6 @@ namespace Lucene.Net.Store
maxBBuf = Constants.JRE_IS_64BIT?System.Int32.MaxValue:(256 * 1024 * 1024);
}
- /// <summary>Create a new MMapDirectory for the named location.
- ///
- /// </summary>
- /// <param name="path">the path of the directory
- /// </param>
- /// <param name="lockFactory">the lock factory to use, or null for the default.
- /// </param>
- /// <throws> IOException </throws>
- [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
- public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName), lockFactory)
- {
- InitBlock();
- }
-
/// <summary>Create a new MMapDirectory for the named location.
///
/// </summary>
@@ -126,36 +112,23 @@ namespace Lucene.Net.Store
/// <param name="lockFactory">the lock factory to use, or null for the default.
/// </param>
/// <throws> IOException </throws>
- public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory)
+ public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory)
+ : base(path, lockFactory)
{
InitBlock();
}
-
- /// <summary>Create a new MMapDirectory for the named location and the default lock factory.
- ///
- /// </summary>
- /// <param name="path">the path of the directory
- /// </param>
- /// <throws> IOException </throws>
- [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
- public MMapDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName), null)
- {
- InitBlock();
- }
-
- /// <summary>Create a new MMapDirectory for the named location and the default lock factory.
+
+ /// <summary>Create a new MMapDirectory for the named location and the default lock factory.
///
/// </summary>
/// <param name="path">the path of the directory
/// </param>
/// <throws> IOException </throws>
- public MMapDirectory(System.IO.DirectoryInfo path) : base(path, null)
- {
- InitBlock();
- }
-
- internal static readonly System.Type[] NO_PARAM_TYPES = new System.Type[0];
- internal static readonly System.Object[] NO_PARAMS = new System.Object[0];
+ public MMapDirectory(System.IO.DirectoryInfo path)
+ : base(path, null)
+ {
+ InitBlock();
+ }
private bool useUnmapHack = false;
private int maxBBuf;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NativeFSLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NativeFSLockFactory.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NativeFSLockFactory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NativeFSLockFactory.cs Sat Nov 12 10:44:21 2011
@@ -230,7 +230,7 @@ namespace Lucene.Net.Store
// thread trying to obtain this lock, so we own
// the only instance of a channel against this
// file:
- LOCK_HELD.Add(canonicalPath, canonicalPath);
+ LOCK_HELD.Add(canonicalPath);
markedHeld = true;
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NoLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NoLockFactory.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NoLockFactory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NoLockFactory.cs Sat Nov 12 10:44:21 2011
@@ -28,7 +28,7 @@ namespace Lucene.Net.Store
/// <seealso cref="LockFactory">
/// </seealso>
- public class NoLockFactory:LockFactory
+ public class NoLockFactory : LockFactory
{
// Single instance returned whenever makeLock is called.
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs?rev=1201243&r1=1201242&r2=1201243&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs Sat Nov 12 10:44:21 2011
@@ -16,6 +16,7 @@
*/
using System;
+using Lucene.Net.Support;
namespace Lucene.Net.Store
{
@@ -23,7 +24,6 @@ namespace Lucene.Net.Store
/// <summary> A memory-resident <see cref="Directory"/> implementation. Locking
/// implementation is by default the <see cref="SingleInstanceLockFactory"/>
/// but can be changed with <see cref="Directory.SetLockFactory"/>.
- ///
/// </summary>
[Serializable]
public class RAMDirectory:Directory
@@ -31,7 +31,7 @@ namespace Lucene.Net.Store
private const long serialVersionUID = 1L;
- internal protected SupportClass.HashMap<string, RAMFile> fileMap = new SupportClass.HashMap<string, RAMFile>();
+ internal protected HashMap<string, RAMFile> fileMap = new HashMap<string, RAMFile>();
internal protected long sizeInBytes = 0;
// *****
@@ -148,7 +148,7 @@ namespace Lucene.Net.Store
{
// In 3.0 we will change this to throw
// InterruptedException instead
- SupportClass.ThreadClass.Current().Interrupt();
+ ThreadClass.Current().Interrupt();
throw new System.SystemException(ie.Message, ie);
}
ts2 = System.DateTime.Now.Ticks;
@@ -252,7 +252,7 @@ namespace Lucene.Net.Store
Close();
}
- public SupportClass.HashMap<string, RAMFile> fileMap_ForNUnit
+ public HashMap<string, RAMFile> fileMap_ForNUnit
{
get { return fileMap; }
}
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AppSettings.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AppSettings.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AppSettings.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AppSettings.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,138 @@
+using System;
+using System.Configuration;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class AppSettings
+ {
+ static System.Collections.Specialized.ListDictionary settings = new System.Collections.Specialized.ListDictionary();
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ public static void Set(System.String key, int defValue)
+ {
+ settings[key] = defValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ public static void Set(System.String key, long defValue)
+ {
+ settings[key] = defValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ public static void Set(System.String key, System.String defValue)
+ {
+ settings[key] = defValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ public static void Set(System.String key, bool defValue)
+ {
+ settings[key] = defValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ /// <returns></returns>
+ public static int Get(System.String key, int defValue)
+ {
+ if (settings[key] != null)
+ {
+ return (int)settings[key];
+ }
+
+ System.String theValue = ConfigurationManager.AppSettings.Get(key);
+ if (theValue == null)
+ {
+ return defValue;
+ }
+ int retValue = Convert.ToInt32(theValue.Trim());
+ settings[key] = retValue;
+ return retValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ /// <returns></returns>
+ public static long Get(System.String key, long defValue)
+ {
+ if (settings[key] != null)
+ {
+ return (long)settings[key];
+ }
+
+ System.String theValue = ConfigurationManager.AppSettings.Get(key);
+ if (theValue == null)
+ {
+ return defValue;
+ }
+ long retValue = Convert.ToInt64(theValue.Trim());
+ settings[key] = retValue;
+ return retValue;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="defValue"></param>
+ /// <returns></returns>
+ public static System.String Get(System.String key, System.String defValue)
+ {
+ if (settings[key] != null)
+ {
+ return (System.String)settings[key];
+ }
+
+ System.String theValue = ConfigurationManager.AppSettings.Get(key);
+ if (theValue == null)
+ {
+ return defValue;
+ }
+ settings[key] = theValue;
+ return theValue;
+ }
+
+ public static bool Get(System.String key, bool defValue)
+ {
+ if (settings[key] != null)
+ {
+ return (bool)settings[key];
+ }
+
+ System.String theValue = ConfigurationManager.AppSettings.Get(key);
+ if (theValue == null)
+ {
+ return defValue;
+ }
+ bool retValue = Convert.ToBoolean(theValue.Trim());
+ settings[key] = retValue;
+ return retValue;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AttributeImplItem.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AttributeImplItem.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AttributeImplItem.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/AttributeImplItem.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,20 @@
+using System;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// A simple wrapper to allow for the use of the GeneralKeyedCollection. The
+ /// wrapper is required as there can be several keys for an object depending
+ /// on how many interfaces it implements.
+ /// </summary>
+ internal sealed class AttributeImplItem
+ {
+ internal AttributeImplItem(Type key, Util.AttributeImpl value)
+ {
+ this.Key = key;
+ this.Value = value;
+ }
+ internal Type Key;
+ internal Util.AttributeImpl Value;
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BitSetSupport.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BitSetSupport.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BitSetSupport.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BitSetSupport.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,67 @@
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// This class provides supporting methods of java.util.BitSet
+ /// that are not present in System.Collections.BitArray.
+ /// </summary>
+ public class BitSetSupport
+ {
+ /// <summary>
+ /// Returns the next set bit at or after index, or -1 if no such bit exists.
+ /// </summary>
+ /// <param name="bitArray"></param>
+ /// <param name="index">the index of bit array at which to start checking</param>
+ /// <returns>the next set bit or -1</returns>
+ public static int NextSetBit(System.Collections.BitArray bitArray, int index)
+ {
+ while (index < bitArray.Length)
+ {
+ // if index bit is set, return it
+ // otherwise check next index bit
+ if (bitArray.Get(index))
+ return index;
+ else
+ index++;
+ }
+ // if no bits are set at or after index, return -1
+ return -1;
+ }
+
+ /// <summary>
+ /// Returns the next un-set bit at or after index, or -1 if no such bit exists.
+ /// </summary>
+ /// <param name="bitArray"></param>
+ /// <param name="index">the index of bit array at which to start checking</param>
+ /// <returns>the next set bit or -1</returns>
+ public static int NextClearBit(System.Collections.BitArray bitArray, int index)
+ {
+ while (index < bitArray.Length)
+ {
+ // if index bit is not set, return it
+ // otherwise check next index bit
+ if (!bitArray.Get(index))
+ return index;
+ else
+ index++;
+ }
+ // if no bits are set at or after index, return -1
+ return -1;
+ }
+
+ /// <summary>
+ /// Returns the number of bits set to true in this BitSet.
+ /// </summary>
+ /// <param name="bits">The BitArray object.</param>
+ /// <returns>The number of bits set to true in this BitSet.</returns>
+ public static int Cardinality(System.Collections.BitArray bits)
+ {
+ int count = 0;
+ for (int i = 0; i < bits.Count; i++)
+ {
+ if (bits[i])
+ count++;
+ }
+ return count;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BuildType.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BuildType.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BuildType.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/BuildType.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,11 @@
+namespace Lucene.Net.Support
+{
+ public class BuildType
+ {
+#if DEBUG
+ public static bool Debug = true;
+#else
+ public static bool Debug = false;
+#endif
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CRC32.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CRC32.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CRC32.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CRC32.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,59 @@
+using System;
+
+namespace Lucene.Net.Support
+{
+ public class CRC32 : IChecksum
+ {
+ private static readonly UInt32[] crcTable = InitializeCRCTable();
+
+ private static UInt32[] InitializeCRCTable()
+ {
+ UInt32[] crcTable = new UInt32[256];
+ for (UInt32 n = 0; n < 256; n++)
+ {
+ UInt32 c = n;
+ for (int k = 8; --k >= 0; )
+ {
+ if ((c & 1) != 0)
+ c = 0xedb88320 ^ (c >> 1);
+ else
+ c = c >> 1;
+ }
+ crcTable[n] = c;
+ }
+ return crcTable;
+ }
+
+ private UInt32 crc = 0;
+
+ public Int64 GetValue()
+ {
+ return (Int64)crc & 0xffffffffL;
+ }
+
+ public void Reset()
+ {
+ crc = 0;
+ }
+
+ public void Update(int bval)
+ {
+ UInt32 c = ~crc;
+ c = crcTable[(c ^ bval) & 0xff] ^ (c >> 8);
+ crc = ~c;
+ }
+
+ public void Update(byte[] buf, int off, int len)
+ {
+ UInt32 c = ~crc;
+ while (--len >= 0)
+ c = crcTable[(c ^ buf[off++]) & 0xff] ^ (c >> 8);
+ crc = ~c;
+ }
+
+ public void Update(byte[] buf)
+ {
+ Update(buf, 0, buf.Length);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Character.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Character.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Character.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Character.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,60 @@
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// Mimics Java's Character class.
+ /// </summary>
+ public class Character
+ {
+ private const char charNull = '\0';
+ private const char charZero = '0';
+ private const char charA = 'a';
+
+ /// <summary>
+ /// </summary>
+ public static int MAX_RADIX
+ {
+ get
+ {
+ return 36;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public static int MIN_RADIX
+ {
+ get
+ {
+ return 2;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="digit"></param>
+ /// <param name="radix"></param>
+ /// <returns></returns>
+ public static char ForDigit(int digit, int radix)
+ {
+ // if radix or digit is out of range,
+ // return the null character.
+ if (radix < Character.MIN_RADIX)
+ return charNull;
+ if (radix > Character.MAX_RADIX)
+ return charNull;
+ if (digit < 0)
+ return charNull;
+ if (digit >= radix)
+ return charNull;
+
+ // if digit is less than 10,
+ // return '0' plus digit
+ if (digit < 10)
+ return (char)((int)charZero + digit);
+
+ // otherwise, return 'a' plus digit.
+ return (char)((int)charA + digit - 10);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CloseableThreadLocalProfiler.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,24 @@
+using System;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// For Debuging purposes.
+ /// </summary>
+ public class CloseableThreadLocalProfiler
+ {
+ public static bool _EnableCloseableThreadLocalProfiler = false;
+ public static System.Collections.Generic.List<WeakReference> Instances = new System.Collections.Generic.List<WeakReference>();
+
+ public static bool EnableCloseableThreadLocalProfiler
+ {
+ get { return _EnableCloseableThreadLocalProfiler; }
+ set
+ {
+ _EnableCloseableThreadLocalProfiler = value;
+ lock (Instances)
+ Instances.Clear();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CollectionsHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CollectionsHelper.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CollectionsHelper.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/CollectionsHelper.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,305 @@
+using System;
+using System.Collections;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// Support class used to handle Hashtable addition, which does a check
+ /// first to make sure the added item is unique in the hash.
+ /// </summary>
+ public class CollectionsHelper
+ {
+ public static void Add(System.Collections.Hashtable hashtable, System.Object item)
+ {
+ hashtable.Add(item, item);
+ }
+
+ public static void AddIfNotContains(System.Collections.Hashtable hashtable, System.Object item)
+ {
+ if (hashtable.Contains(item) == false)
+ {
+ hashtable.Add(item, item);
+ }
+ }
+
+ public static void AddIfNotContains(System.Collections.ArrayList hashtable, System.Object item)
+ {
+ if (hashtable.Contains(item) == false)
+ {
+ hashtable.Add(item);
+ }
+ }
+
+ public static void AddAll(System.Collections.Hashtable hashtable, System.Collections.ICollection items)
+ {
+ System.Collections.IEnumerator iter = items.GetEnumerator();
+ System.Object item;
+ while (iter.MoveNext())
+ {
+ item = iter.Current;
+ hashtable.Add(item, item);
+ }
+ }
+
+ public static void AddAllIfNotContains(System.Collections.Hashtable hashtable, System.Collections.IList items)
+ {
+ System.Object item;
+ for (int i = 0; i < items.Count; i++)
+ {
+ item = items[i];
+ if (hashtable.Contains(item) == false)
+ {
+ hashtable.Add(item, item);
+ }
+ }
+ }
+
+ public static void AddAllIfNotContains(System.Collections.Hashtable hashtable, System.Collections.ICollection items)
+ {
+ System.Collections.IEnumerator iter = items.GetEnumerator();
+ System.Object item;
+ while (iter.MoveNext())
+ {
+ item = iter.Current;
+ if (hashtable.Contains(item) == false)
+ {
+ hashtable.Add(item, item);
+ }
+ }
+ }
+
+ public static void AddAllIfNotContains(System.Collections.Generic.IDictionary<string, string> hashtable, System.Collections.Generic.ICollection<string> items)
+ {
+ foreach (string s in items)
+ {
+ if (hashtable.ContainsKey(s) == false)
+ {
+ hashtable.Add(s, s);
+ }
+ }
+ }
+
+ public static void AddAll(System.Collections.Generic.IDictionary<string, string> hashtable, System.Collections.Generic.ICollection<string> items)
+ {
+ foreach (string s in items)
+ {
+ hashtable.Add(s, s);
+ }
+ }
+
+ public static bool Contains(System.Collections.Generic.ICollection<string> col, string item)
+ {
+ foreach (string s in col) if (s == item) return true;
+ return false;
+ }
+
+ public static bool Contains(System.Collections.ICollection col, System.Object item)
+ {
+ System.Collections.IEnumerator iter = col.GetEnumerator();
+ while (iter.MoveNext())
+ {
+ if (iter.Current.Equals(item))
+ return true;
+ }
+ return false;
+ }
+
+
+ public static System.String CollectionToString(System.Collections.Generic.IDictionary<string, string> c)
+ {
+ Hashtable t = new Hashtable();
+ foreach (string key in c.Keys)
+ {
+ t.Add(key, c[key]);
+ }
+ return CollectionToString(t);
+ }
+
+ /// <summary>
+ /// Converts the specified collection to its string representation.
+ /// </summary>
+ /// <param name="c">The collection to convert to string.</param>
+ /// <returns>A string representation of the specified collection.</returns>
+ public static System.String CollectionToString(System.Collections.ICollection c)
+ {
+ System.Text.StringBuilder s = new System.Text.StringBuilder();
+
+ if (c != null)
+ {
+
+ System.Collections.ArrayList l = new System.Collections.ArrayList(c);
+
+ bool isDictionary = (c is System.Collections.BitArray || c is System.Collections.Hashtable || c is System.Collections.IDictionary || c is System.Collections.Specialized.NameValueCollection || (l.Count > 0 && l[0] is System.Collections.DictionaryEntry));
+ for (int index = 0; index < l.Count; index++)
+ {
+ if (l[index] == null)
+ s.Append("null");
+ else if (!isDictionary)
+ s.Append(l[index]);
+ else
+ {
+ isDictionary = true;
+ if (c is System.Collections.Specialized.NameValueCollection)
+ s.Append(((System.Collections.Specialized.NameValueCollection)c).GetKey(index));
+ else
+ s.Append(((System.Collections.DictionaryEntry)l[index]).Key);
+ s.Append("=");
+ if (c is System.Collections.Specialized.NameValueCollection)
+ s.Append(((System.Collections.Specialized.NameValueCollection)c).GetValues(index)[0]);
+ else
+ s.Append(((System.Collections.DictionaryEntry)l[index]).Value);
+
+ }
+ if (index < l.Count - 1)
+ s.Append(", ");
+ }
+
+ if (isDictionary)
+ {
+ if (c is System.Collections.ArrayList)
+ isDictionary = false;
+ }
+ if (isDictionary)
+ {
+ s.Insert(0, "{");
+ s.Append("}");
+ }
+ else
+ {
+ s.Insert(0, "[");
+ s.Append("]");
+ }
+ }
+ else
+ s.Insert(0, "null");
+ return s.ToString();
+ }
+
+ /// <summary>
+ /// Compares two string arrays for equality.
+ /// </summary>
+ /// <param name="l1">First string array list to compare</param>
+ /// <param name="l2">Second string array list to compare</param>
+ /// <returns>true if the strings are equal in both arrays, false otherwise</returns>
+ public static bool CompareStringArrays(System.String[] l1, System.String[] l2)
+ {
+ if (l1.Length != l2.Length)
+ return false;
+ for (int i = 0; i < l1.Length; i++)
+ {
+ if (l1[i] != l2[i])
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Sorts an IList collections
+ /// </summary>
+ /// <param name="list">The System.Collections.IList instance that will be sorted</param>
+ /// <param name="Comparator">The Comparator criteria, null to use natural comparator.</param>
+ public static void Sort(System.Collections.IList list, System.Collections.IComparer Comparator)
+ {
+ if (((System.Collections.ArrayList)list).IsReadOnly)
+ throw new System.NotSupportedException();
+
+ if ((Comparator == null) || (Comparator is System.Collections.Comparer))
+ {
+ try
+ {
+ ((System.Collections.ArrayList)list).Sort();
+ }
+ catch (System.InvalidOperationException e)
+ {
+ throw new System.InvalidCastException(e.Message);
+ }
+ }
+ else
+ {
+ try
+ {
+ ((System.Collections.ArrayList)list).Sort(Comparator);
+ }
+ catch (System.InvalidOperationException e)
+ {
+ throw new System.InvalidCastException(e.Message);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Fills the array with an specific value from an specific index to an specific index.
+ /// </summary>
+ /// <param name="array">The array to be filled.</param>
+ /// <param name="fromindex">The first index to be filled.</param>
+ /// <param name="toindex">The last index to be filled.</param>
+ /// <param name="val">The value to fill the array with.</param>
+ public static void Fill(System.Array array, System.Int32 fromindex, System.Int32 toindex, System.Object val)
+ {
+ System.Object Temp_Object = val;
+ System.Type elementtype = array.GetType().GetElementType();
+ if (elementtype != val.GetType())
+ Temp_Object = Convert.ChangeType(val, elementtype);
+ if (array.Length == 0)
+ throw (new System.NullReferenceException());
+ if (fromindex > toindex)
+ throw (new System.ArgumentException());
+ if ((fromindex < 0) || ((System.Array)array).Length < toindex)
+ throw (new System.IndexOutOfRangeException());
+ for (int index = (fromindex > 0) ? fromindex-- : fromindex; index < toindex; index++)
+ array.SetValue(Temp_Object, index);
+ }
+
+
+ /// <summary>
+ /// Fills the array with an specific value.
+ /// </summary>
+ /// <param name="array">The array to be filled.</param>
+ /// <param name="val">The value to fill the array with.</param>
+ public static void Fill(System.Array array, System.Object val)
+ {
+ Fill(array, 0, array.Length, val);
+ }
+
+ /// <summary>
+ /// Compares the entire members of one array whith the other one.
+ /// </summary>
+ /// <param name="array1">The array to be compared.</param>
+ /// <param name="array2">The array to be compared with.</param>
+ /// <returns>Returns true if the two specified arrays of Objects are equal
+ /// to one another. The two arrays are considered equal if both arrays
+ /// contain the same number of elements, and all corresponding pairs of
+ /// elements in the two arrays are equal. Two objects e1 and e2 are
+ /// considered equal if (e1==null ? e2==null : e1.equals(e2)). In other
+ /// words, the two arrays are equal if they contain the same elements in
+ /// the same order. Also, two array references are considered equal if
+ /// both are null.</returns>
+ public static bool Equals(System.Array array1, System.Array array2)
+ {
+ bool result = false;
+ if ((array1 == null) && (array2 == null))
+ result = true;
+ else if ((array1 != null) && (array2 != null))
+ {
+ if (array1.Length == array2.Length)
+ {
+ int length = array1.Length;
+ result = true;
+ for (int index = 0; index < length; index++)
+ {
+ System.Object o1 = array1.GetValue(index);
+ System.Object o2 = array2.GetValue(index);
+ if (o1 == null && o2 == null)
+ continue; // they match
+ else if (o1 == null || !o1.Equals(o2))
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Compare.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Compare.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Compare.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Compare.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,28 @@
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// Summary description for TestSupportClass.
+ /// </summary>
+ public class Compare
+ {
+ /// <summary>
+ /// Compares two Term arrays for equality.
+ /// </summary>
+ /// <param name="t1">First Term array to compare</param>
+ /// <param name="t2">Second Term array to compare</param>
+ /// <returns>true if the Terms are equal in both arrays, false otherwise</returns>
+ public static bool CompareTermArrays(Index.Term[] t1, Index.Term[] t2)
+ {
+ if (t1.Length != t2.Length)
+ return false;
+ for (int i = 0; i < t1.Length; i++)
+ {
+ if (t1[i].CompareTo(t2[i]) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Cryptography.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Cryptography.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Cryptography.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Cryptography.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,21 @@
+using System.Security.Cryptography;
+
+namespace Lucene.Net.Support
+{
+ public class Cryptography
+ {
+ static public bool FIPSCompliant = false;
+
+ static public System.Security.Cryptography.HashAlgorithm GetHashAlgorithm()
+ {
+ if (FIPSCompliant)
+ {
+ //LUCENENET-175
+ //No Assumptions should be made on the HashAlgorithm. It may change in time.
+ //SHA256 SHA384 SHA512 etc.
+ return SHA1.Create();
+ }
+ return MD5.Create();
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Deflater.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Deflater.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Deflater.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Deflater.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,76 @@
+using System;
+
+namespace Lucene.Net.Support
+{
+ public class Deflater
+ {
+ delegate void SetLevelDelegate(int level);
+ delegate void SetInputDelegate(byte[] input, int offset, int count);
+ delegate void FinishDelegate();
+ delegate bool GetIsFinishedDelegate();
+ delegate int DeflateDelegate(byte[] output);
+
+ SetLevelDelegate setLevelMethod;
+ SetInputDelegate setInputMethod;
+ FinishDelegate finishMethod;
+ GetIsFinishedDelegate getIsFinishedMethod;
+ DeflateDelegate deflateMethod;
+
+ public const int BEST_COMPRESSION = 9;
+
+ internal Deflater(object deflaterInstance)
+ {
+ Type type = deflaterInstance.GetType();
+
+ setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
+ typeof(SetLevelDelegate),
+ deflaterInstance,
+ type.GetMethod("SetLevel", new Type[] { typeof(int) }));
+
+ setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
+ typeof(SetInputDelegate),
+ deflaterInstance,
+ type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
+
+ finishMethod = (FinishDelegate)Delegate.CreateDelegate(
+ typeof(FinishDelegate),
+ deflaterInstance,
+ type.GetMethod("Finish", Type.EmptyTypes));
+
+ getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
+ typeof(GetIsFinishedDelegate),
+ deflaterInstance,
+ type.GetMethod("get_IsFinished", Type.EmptyTypes));
+
+ deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
+ typeof(DeflateDelegate),
+ deflaterInstance,
+ type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));
+ }
+
+ public void SetLevel(int level)
+ {
+ setLevelMethod(level);
+ }
+
+ public void SetInput(byte[] input, int offset, int count)
+ {
+ setInputMethod(input, offset, count);
+ }
+
+ public void Finish()
+ {
+ finishMethod();
+ }
+
+ public bool IsFinished
+ {
+ get { return getIsFinishedMethod(); }
+ }
+
+ public int Deflate(byte[] output)
+ {
+ return deflateMethod(output);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Double.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Double.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Double.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/Double.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,23 @@
+using System;
+using System.Globalization;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class Double
+ {
+ public static System.Double Parse(System.String s)
+ {
+ try
+ {
+ return System.Double.Parse(s.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
+ }
+ catch (OverflowException)
+ {
+ return System.Double.MaxValue;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/EquatableList.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/EquatableList.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/EquatableList.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/EquatableList.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,318 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>Represents a strongly typed list of objects that can be accessed by index.
+ /// Provides methods to search, sort, and manipulate lists. Also provides functionality
+ /// to compare lists against each other through an implementations of
+ /// <see cref="IEquatable{T}"/>.</summary>
+ /// <typeparam name="T">The type of elements in the list.</typeparam>
+ [Serializable]
+ public class EquatableList<T> : System.Collections.Generic.List<T>,
+ IEquatable<System.Collections.Generic.IEnumerable<T>>,
+ ICloneable
+ {
+ /// <summary>Initializes a new instance of the
+ /// <see cref="EquatableList{T}"/> class that is empty and has the
+ /// default initial capacity.</summary>
+ public EquatableList() : base() { }
+
+ /// <summary>Initializes a new instance of the <see cref="EquatableList{T}"/>
+ /// class that contains elements copied from the specified collection and has
+ /// sufficient capacity to accommodate the number of elements copied.</summary>
+ /// <param name="collection">The collection whose elements are copied to the new list.</param>
+ public EquatableList(System.Collections.Generic.IEnumerable<T> collection) : base(collection) { }
+
+ /// <summary>Initializes a new instance of the <see cref="EquatableList{T}"/>
+ /// class that is empty and has the specified initial capacity.</summary>
+ /// <param name="capacity">The number of elements that the new list can initially store.</param>
+ public EquatableList(int capacity) : base(capacity) { }
+
+ /// <summary>Adds a range of objects represented by the <see cref="ICollection"/>
+ /// implementation.</summary>
+ /// <param name="c">The <see cref="ICollection"/>
+ /// implementation to add to this list.</param>
+ public void AddRange(ICollection c)
+ {
+ // If the collection is null, throw an exception.
+ if (c == null) throw new ArgumentNullException("c");
+
+ // Pre-compute capacity.
+ Capacity = Math.Max(c.Count + Count, Capacity);
+
+ // Cycle through the items and add.
+ foreach (T item in c)
+ {
+ // Add the item.
+ Add(item);
+ }
+ }
+
+ /// <summary>Compares the counts of two <see cref="System.Collections.Generic.IEnumerable{T}"/>
+ /// implementations.</summary>
+ /// <remarks>This uses a trick in LINQ, sniffing types for implementations
+ /// of interfaces that might supply shortcuts when trying to make comparisons.
+ /// In this case, that is the <see cref="System.Collections.Generic.ICollection{T}"/> and
+ /// <see cref="ICollection"/> interfaces, either of which can provide a count
+ /// which can be used in determining the equality of sequences (if they don't have
+ /// the same count, then they can't be equal).</remarks>
+ /// <param name="x">The <see cref="System.Collections.Generic.IEnumerable{T}"/> from the left hand side of the
+ /// comparison to check the count of.</param>
+ /// <param name="y">The <see cref="System.Collections.Generic.IEnumerable{T}"/> from the right hand side of the
+ /// comparison to check the count of.</param>
+ /// <returns>Null if the result is indeterminate. This occurs when either <paramref name="x"/>
+ /// or <paramref name="y"/> doesn't implement <see cref="ICollection"/> or <see cref="System.Collections.Generic.ICollection{T}"/>.
+ /// Otherwise, it will get the count from each and return true if they are equal, false otherwise.</returns>
+ private static bool? EnumerableCountsEqual(System.Collections.Generic.IEnumerable<T> x, System.Collections.Generic.IEnumerable<T> y)
+ {
+ // Get the ICollection<T> and ICollection interfaces.
+ System.Collections.Generic.ICollection<T> xOfTCollection = x as System.Collections.Generic.ICollection<T>;
+ System.Collections.Generic.ICollection<T> yOfTCollection = y as System.Collections.Generic.ICollection<T>;
+ ICollection xCollection = x as ICollection;
+ ICollection yCollection = y as ICollection;
+
+ // The count in x and y.
+ int? xCount = xOfTCollection != null ? xOfTCollection.Count : xCollection != null ? xCollection.Count : (int?)null;
+ int? yCount = yOfTCollection != null ? yOfTCollection.Count : yCollection != null ? yCollection.Count : (int?)null;
+
+ // If either are null, return null, the result is indeterminate.
+ if (xCount == null || yCount == null)
+ {
+ // Return null, indeterminate.
+ return null;
+ }
+
+ // Both counts are non-null, compare.
+ return xCount == yCount;
+ }
+
+ /// <summary>Compares the contents of a <see cref="System.Collections.Generic.IEnumerable{T}"/>
+ /// implementation to another one to determine equality.</summary>
+ /// <remarks>Thinking of the <see cref="System.Collections.Generic.IEnumerable{T}"/> implementation as
+ /// a string with any number of characters, the algorithm checks
+ /// each item in each list. If any item of the list is not equal (or
+ /// one list contains all the elements of another list), then that list
+ /// element is compared to the other list element to see which
+ /// list is greater.</remarks>
+ /// <param name="x">The <see cref="System.Collections.Generic.IEnumerable{T}"/> implementation
+ /// that is considered the left hand side.</param>
+ /// <param name="y">The <see cref="System.Collections.Generic.IEnumerable{T}"/> implementation
+ /// that is considered the right hand side.</param>
+ /// <returns>True if the items are equal, false otherwise.</returns>
+ private static bool Equals(System.Collections.Generic.IEnumerable<T> x,
+ System.Collections.Generic.IEnumerable<T> y)
+ {
+ // If x and y are null, then return true, they are the same.
+ if (x == null && y == null)
+ {
+ // They are the same, return 0.
+ return true;
+ }
+
+ // If one is null, then return a value based on whether or not
+ // one is null or not.
+ if (x == null || y == null)
+ {
+ // Return false, one is null, the other is not.
+ return false;
+ }
+
+ // Check to see if the counts on the IEnumerable implementations are equal.
+ // This is a shortcut, if they are not equal, then the lists are not equal.
+ // If the result is indeterminate, then get out.
+ bool? enumerableCountsEqual = EnumerableCountsEqual(x, y);
+
+ // If the enumerable counts have been able to be calculated (indicated by
+ // a non-null value) and it is false, then no need to iterate through the items.
+ if (enumerableCountsEqual != null && !enumerableCountsEqual.Value)
+ {
+ // The sequences are not equal.
+ return false;
+ }
+
+ // The counts of the items in the enumerations are equal, or indeterminate
+ // so a full iteration needs to be made to compare each item.
+ // Get the default comparer for T first.
+ System.Collections.Generic.EqualityComparer<T> defaultComparer =
+ EqualityComparer<T>.Default;
+
+ // Get the enumerator for y.
+ System.Collections.Generic.IEnumerator<T> otherEnumerator = y.GetEnumerator();
+
+ // Call Dispose on IDisposable if there is an implementation on the
+ // IEnumerator<T> returned by a call to y.GetEnumerator().
+ using (otherEnumerator as IDisposable)
+ {
+ // Cycle through the items in this list.
+ foreach (T item in x)
+ {
+ // If there isn't an item to get, then this has more
+ // items than that, they are not equal.
+ if (!otherEnumerator.MoveNext())
+ {
+ // Return false.
+ return false;
+ }
+
+ // Perform a comparison. Must check this on the left hand side
+ // and that on the right hand side.
+ bool comparison = defaultComparer.Equals(item, otherEnumerator.Current);
+
+ // If the value is false, return false.
+ if (!comparison)
+ {
+ // Return the value.
+ return comparison;
+ }
+ }
+
+ // If there are no more items, then return true, the sequences
+ // are equal.
+ if (!otherEnumerator.MoveNext())
+ {
+ // The sequences are equal.
+ return true;
+ }
+
+ // The other sequence has more items than this one, return
+ // false, these are not equal.
+ return false;
+ }
+ }
+
+ #region IEquatable<IEnumerable<T>> Members
+ /// <summary>Compares this sequence to another <see cref="System.Collections.Generic.IEnumerable{T}"/>
+ /// implementation, returning true if they are equal, false otherwise.</summary>
+ /// <param name="other">The other <see cref="System.Collections.Generic.IEnumerable{T}"/> implementation
+ /// to compare against.</param>
+ /// <returns>True if the sequence in <paramref name="other"/>
+ /// is the same as this one.</returns>
+ public bool Equals(System.Collections.Generic.IEnumerable<T> other)
+ {
+ // Compare to the other sequence. If 0, then equal.
+ return Equals(this, other);
+ }
+ #endregion
+
+ /// <summary>Compares this object for equality against other.</summary>
+ /// <param name="obj">The other object to compare this object against.</param>
+ /// <returns>True if this object and <paramref name="obj"/> are equal, false
+ /// otherwise.</returns>
+ public override bool Equals(object obj)
+ {
+ // Call the strongly typed version.
+ return Equals(obj as System.Collections.Generic.IEnumerable<T>);
+ }
+
+ /// <summary>Gets the hash code for the list.</summary>
+ /// <returns>The hash code value.</returns>
+ public override int GetHashCode()
+ {
+ // Call the static method, passing this.
+ return GetHashCode(this);
+ }
+
+#if __MonoCS__
+ public static int GetHashCode<T>(System.Collections.Generic.IEnumerable<T> source)
+#else
+ /// <summary>Gets the hash code for the list.</summary>
+ /// <param name="source">The <see cref="System.Collections.Generic.IEnumerable{T}"/>
+ /// implementation which will have all the contents hashed.</param>
+ /// <returns>The hash code value.</returns>
+ public static int GetHashCode(System.Collections.Generic.IEnumerable<T> source)
+#endif
+ {
+ // If source is null, then return 0.
+ if (source == null) return 0;
+
+ // Seed the hash code with the hash code of the type.
+ // This is done so that you don't have a lot of collisions of empty
+ // ComparableList instances when placed in dictionaries
+ // and things that rely on hashcodes.
+ int hashCode = typeof(T).GetHashCode();
+
+ // Iterate through the items in this implementation.
+ foreach (T item in source)
+ {
+ // Adjust the hash code.
+ hashCode = 31 * hashCode + (item == null ? 0 : item.GetHashCode());
+ }
+
+ // Return the hash code.
+ return hashCode;
+ }
+
+ // TODO: When diverging from Java version of Lucene, can uncomment these to adhere to best practices when overriding the Equals method and implementing IEquatable<T>.
+ ///// <summary>Overload of the == operator, it compares a
+ ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+ ///// implementation.</summary>
+ ///// <param name="x">The <see cref="ComparableList{T}"/> to compare
+ ///// against <paramref name="y"/>.</param>
+ ///// <param name="y">The <see cref="IEnumerable{T}"/> to compare
+ ///// against <paramref name="x"/>.</param>
+ ///// <returns>True if the instances are equal, false otherwise.</returns>
+ //public static bool operator ==(EquatableList<T> x, System.Collections.Generic.IEnumerable<T> y)
+ //{
+ // // Call Equals.
+ // return Equals(x, y);
+ //}
+
+ ///// <summary>Overload of the == operator, it compares a
+ ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+ ///// implementation.</summary>
+ ///// <param name="y">The <see cref="ComparableList{T}"/> to compare
+ ///// against <paramref name="x"/>.</param>
+ ///// <param name="x">The <see cref="IEnumerable{T}"/> to compare
+ ///// against <paramref name="y"/>.</param>
+ ///// <returns>True if the instances are equal, false otherwise.</returns>
+ //public static bool operator ==(System.Collections.Generic.IEnumerable<T> x, EquatableList<T> y)
+ //{
+ // // Call equals.
+ // return Equals(x, y);
+ //}
+
+ ///// <summary>Overload of the != operator, it compares a
+ ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+ ///// implementation.</summary>
+ ///// <param name="x">The <see cref="ComparableList{T}"/> to compare
+ ///// against <paramref name="y"/>.</param>
+ ///// <param name="y">The <see cref="IEnumerable{T}"/> to compare
+ ///// against <paramref name="x"/>.</param>
+ ///// <returns>True if the instances are not equal, false otherwise.</returns>
+ //public static bool operator !=(EquatableList<T> x, System.Collections.Generic.IEnumerable<T> y)
+ //{
+ // // Return the negative of the equals operation.
+ // return !(x == y);
+ //}
+
+ ///// <summary>Overload of the != operator, it compares a
+ ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+ ///// implementation.</summary>
+ ///// <param name="y">The <see cref="ComparableList{T}"/> to compare
+ ///// against <paramref name="x"/>.</param>
+ ///// <param name="x">The <see cref="IEnumerable{T}"/> to compare
+ ///// against <paramref name="y"/>.</param>
+ ///// <returns>True if the instances are not equal, false otherwise.</returns>
+ //public static bool operator !=(System.Collections.Generic.IEnumerable<T> x, EquatableList<T> y)
+ //{
+ // // Return the negative of the equals operation.
+ // return !(x == y);
+ //}
+
+ #region ICloneable Members
+
+ /// <summary>Clones the <see cref="EquatableList{T}"/>.</summary>
+ /// <remarks>This is a shallow clone.</remarks>
+ /// <returns>A new shallow clone of this
+ /// <see cref="EquatableList{T}"/>.</returns>
+ public object Clone()
+ {
+ // Just create a new one, passing this to the constructor.
+ return new EquatableList<T>(this);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/FileSupport.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/FileSupport.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/FileSupport.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/FileSupport.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,93 @@
+using System;
+using System.IO;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>
+ /// Represents the methods to support some operations over files.
+ /// </summary>
+ public class FileSupport
+ {
+ /// <summary>
+ /// Returns an array of abstract pathnames representing the files and directories of the specified path.
+ /// </summary>
+ /// <param name="path">The abstract pathname to list it childs.</param>
+ /// <returns>An array of abstract pathnames childs of the path specified or null if the path is not a directory</returns>
+ public static System.IO.FileInfo[] GetFiles(System.IO.FileInfo path)
+ {
+ if ((path.Attributes & FileAttributes.Directory) > 0)
+ {
+ String[] fullpathnames = Directory.GetFileSystemEntries(path.FullName);
+ System.IO.FileInfo[] result = new System.IO.FileInfo[fullpathnames.Length];
+ for (int i = 0; i < result.Length; i++)
+ result[i] = new System.IO.FileInfo(fullpathnames[i]);
+ return result;
+ }
+ else
+ return null;
+ }
+
+ /// <summary>
+ /// Returns a list of files in a give directory.
+ /// </summary>
+ /// <param name="fullName">The full path name to the directory.</param>
+ /// <param name="indexFileNameFilter"></param>
+ /// <returns>An array containing the files.</returns>
+ public static System.String[] GetLuceneIndexFiles(System.String fullName,
+ Index.IndexFileNameFilter indexFileNameFilter)
+ {
+ System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(fullName);
+ System.Collections.ArrayList list = new System.Collections.ArrayList();
+ foreach (System.IO.FileInfo fInfo in dInfo.GetFiles())
+ {
+ if (indexFileNameFilter.Accept(fInfo, fInfo.Name) == true)
+ {
+ list.Add(fInfo.Name);
+ }
+ }
+ System.String[] retFiles = new System.String[list.Count];
+ list.CopyTo(retFiles);
+ return retFiles;
+ }
+
+ // Disable the obsolete warning since we must use FileStream.Handle
+ // because Mono does not support FileSystem.SafeFileHandle at present.
+#pragma warning disable 618
+
+ /// <summary>
+ /// Flushes the specified file stream. Ensures that all buffered
+ /// data is actually written to the file system.
+ /// </summary>
+ /// <param name="fileStream">The file stream.</param>
+ public static void Sync(System.IO.FileStream fileStream)
+ {
+ if (fileStream == null)
+ throw new ArgumentNullException("fileStream");
+
+ fileStream.Flush();
+
+ //if (OS.IsWindows)
+ //{
+ // if (!FlushFileBuffers(fileStream.Handle))
+ // throw new System.IO.IOException();
+ //}
+ //else if (OS.IsUnix)
+ //{
+ // if (fsync(fileStream.Handle) != IntPtr.Zero)
+ // throw new System.IO.IOException();
+ //}
+ //else
+ //{
+ // throw new NotImplementedException();
+ //}
+ }
+
+#pragma warning restore 618
+
+ //[System.Runtime.InteropServices.DllImport("libc")]
+ //extern static IntPtr fsync(IntPtr fd);
+
+ //[System.Runtime.InteropServices.DllImport("kernel32.dll")]
+ //extern static bool FlushFileBuffers(IntPtr hFile);
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/GeneralKeyedCollection.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/GeneralKeyedCollection.cs?rev=1201243&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/GeneralKeyedCollection.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/GeneralKeyedCollection.cs Sat Nov 12 10:44:21 2011
@@ -0,0 +1,70 @@
+using System;
+using System.Diagnostics;
+
+namespace Lucene.Net.Support
+{
+ /// <summary>A collection of <typeparamref name="TItem"/> which can be
+ /// looked up by instances of <typeparamref name="TKey"/>.</summary>
+ /// <typeparam name="TItem">The type of the items contains in this
+ /// collection.</typeparam>
+ /// <typeparam name="TKey">The type of the keys that can be used to look
+ /// up the items.</typeparam>
+ internal class GeneralKeyedCollection<TKey, TItem> : System.Collections.ObjectModel.KeyedCollection<TKey, TItem>
+ {
+ /// <summary>Creates a new instance of the
+ /// <see cref="GeneralKeyedCollection{TKey, TItem}"/> class.</summary>
+ /// <param name="converter">The <see cref="Converter{TInput, TOutput}"/> which will convert
+ /// instances of <typeparamref name="TItem"/> to <typeparamref name="TKey"/>
+ /// when the override of <see cref="GetKeyForItem(TItem)"/> is called.</param>
+ internal GeneralKeyedCollection(Converter<TItem, TKey> converter)
+ : base()
+ {
+ // If the converter is null, throw an exception.
+ if (converter == null) throw new ArgumentNullException("converter");
+
+ // Store the converter.
+ this.converter = converter;
+
+ // That's all folks.
+ return;
+ }
+
+ /// <summary>The <see cref="Converter{TInput, TOutput}"/> which will convert
+ /// instances of <typeparamref name="TItem"/> to <typeparamref name="TKey"/>
+ /// when the override of <see cref="GetKeyForItem(TItem)"/> is called.</summary>
+ private readonly Converter<TItem, TKey> converter;
+
+ /// <summary>Converts an item that is added to the collection to
+ /// a key.</summary>
+ /// <param name="item">The instance of <typeparamref name="TItem"/>
+ /// to convert into an instance of <typeparamref name="TKey"/>.</param>
+ /// <returns>The instance of <typeparamref name="TKey"/> which is the
+ /// key for this item.</returns>
+ protected override TKey GetKeyForItem(TItem item)
+ {
+ // The converter is not null.
+ Debug.Assert(converter != null);
+
+ // Call the converter.
+ return converter(item);
+ }
+
+ /// <summary>Determines if a key for an item exists in this
+ /// collection.</summary>
+ /// <param name="key">The instance of <typeparamref name="TKey"/>
+ /// to see if it exists in this collection.</param>
+ /// <returns>True if the key exists in the collection, false otherwise.</returns>
+ public bool ContainsKey(TKey key)
+ {
+ // Call the dictionary - it is lazily created when the first item is added
+ if (Dictionary != null)
+ {
+ return Dictionary.ContainsKey(key);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file