You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/02/04 20:32:31 UTC
[12/39] lucenenet git commit: Lucene.Net.Analysis.Util
(AbstractAnalysisFactory + AnalysisSPILoader + BufferedCharFilter +
CharacterUtils) refactor: member accessibility and documentation comments
Lucene.Net.Analysis.Util (AbstractAnalysisFactory + AnalysisSPILoader + BufferedCharFilter + CharacterUtils) refactor: member accessibility and documentation comments
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/47155b3f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/47155b3f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/47155b3f
Branch: refs/heads/api-work
Commit: 47155b3f515def19d907d8a0cf4e20ee24ac6e24
Parents: dc21329
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sat Feb 4 17:24:37 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sat Feb 4 23:08:17 2017 +0700
----------------------------------------------------------------------
.../Analysis/Util/AbstractAnalysisFactory.cs | 65 ++++++-----
.../Analysis/Util/AnalysisSPILoader.cs | 12 +--
.../Analysis/Util/BufferedCharFilter.cs | 2 +-
.../Analysis/Util/CharacterUtils.cs | 108 +++++++++----------
.../Analysis/Util/TestCharacterUtils.cs | 4 +-
5 files changed, 97 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/47155b3f/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
index 1eebb02..1d6d304 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
@@ -1,5 +1,4 @@
\ufeffusing Lucene.Net.Analysis.Core;
-using Lucene.Net.Support;
using Lucene.Net.Util;
using System;
using System.Collections.Generic;
@@ -32,11 +31,12 @@ namespace Lucene.Net.Analysis.Util
/// <see cref="TokenFilterFactory"/> and <see cref="CharFilterFactory"/>.
/// <para>
/// The typical lifecycle for a factory consumer is:
- /// <ol>
- /// <li>Create factory via its constructor (or via XXXFactory.forName)</li>
- /// <li>(Optional) If the factory uses resources such as files, <see cref="ResourceLoaderAware#inform(ResourceLoader)"/> is called to initialize those resources.</li>
- /// <li>Consumer calls create() to obtain instances.</li>
- /// </ol>
+ /// <list type="bullet">
+ /// <item>Create factory via its constructor (or via XXXFactory.ForName)</item>
+ /// <item>(Optional) If the factory uses resources such as files,
+ /// <see cref="IResourceLoaderAware.Inform(IResourceLoader)"/> is called to initialize those resources.</item>
+ /// <item>Consumer calls create() to obtain instances.</item>
+ /// </list>
/// </para>
/// </summary>
public abstract class AbstractAnalysisFactory
@@ -49,14 +49,14 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// the luceneVersion arg </summary>
- protected internal readonly LuceneVersion m_luceneMatchVersion;
+ protected readonly LuceneVersion m_luceneMatchVersion;
/// <summary>
/// Initialize this factory via a set of key-value pairs.
/// </summary>
- protected internal AbstractAnalysisFactory(IDictionary<string, string> args)
+ protected AbstractAnalysisFactory(IDictionary<string, string> args)
{
- ExplicitLuceneMatchVersion = false;
+ IsExplicitLuceneMatchVersion = false;
originalArgs = Collections.UnmodifiableMap(args);
string version = Get(args, LUCENE_MATCH_VERSION_PARAM);
// LUCENENET TODO: What should we do if the version is null?
@@ -75,11 +75,11 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// this method can be called in the <see cref="TokenizerFactory#create(java.io.Reader)"/>
- /// or <see cref="TokenFilterFactory#create(org.apache.lucene.analysis.TokenStream)"/> methods,
- /// to inform user, that for this factory a <see cref="#luceneMatchVersion"/> is required
+ /// this method can be called in the <see cref="TokenizerFactory.Create(TextReader)"/>
+ /// or <see cref="TokenFilterFactory.Create(TokenStream)"/> methods,
+ /// to inform user, that for this factory a <see cref="m_luceneMatchVersion"/> is required
/// </summary>
- protected internal void AssureMatchVersion()
+ protected void AssureMatchVersion() // LUCENENET TODO: Remove this method (not used anyway in .NET)
{
// LUCENENET NOTE: since luceneMatchVersion can never be null in .NET,
// this method effectively does nothing. However, leaving it in place because
@@ -148,14 +148,17 @@ namespace Lucene.Net.Analysis.Util
args.Remove(name);
return s ?? defaultVal;
}
+
public virtual string Get(IDictionary<string, string> args, string name, ICollection<string> allowedValues)
{
return Get(args, name, allowedValues, null); // defaultVal = null
}
+
public virtual string Get(IDictionary<string, string> args, string name, ICollection<string> allowedValues, string defaultVal)
{
return Get(args, name, allowedValues, defaultVal, true);
}
+
public virtual string Get(IDictionary<string, string> args, string name, ICollection<string> allowedValues, string defaultVal, bool caseSensitive)
{
string s = null;
@@ -188,11 +191,12 @@ namespace Lucene.Net.Analysis.Util
}
}
- protected internal int RequireInt(IDictionary<string, string> args, string name)
+ protected int RequireInt(IDictionary<string, string> args, string name)
{
return int.Parse(Require(args, name));
}
- protected internal int GetInt(IDictionary<string, string> args, string name, int defaultVal)
+
+ protected int GetInt(IDictionary<string, string> args, string name, int defaultVal)
{
string s;
if (args.TryGetValue(name, out s))
@@ -203,11 +207,12 @@ namespace Lucene.Net.Analysis.Util
return defaultVal;
}
- protected internal bool RequireBoolean(IDictionary<string, string> args, string name)
+ protected bool RequireBoolean(IDictionary<string, string> args, string name)
{
return bool.Parse(Require(args, name));
}
- protected internal bool GetBoolean(IDictionary<string, string> args, string name, bool defaultVal)
+
+ protected bool GetBoolean(IDictionary<string, string> args, string name, bool defaultVal)
{
string s;
if (args.TryGetValue(name, out s))
@@ -218,11 +223,12 @@ namespace Lucene.Net.Analysis.Util
return defaultVal;
}
- protected internal float RequireFloat(IDictionary<string, string> args, string name)
+ protected float RequireFloat(IDictionary<string, string> args, string name)
{
return float.Parse(Require(args, name));
}
- protected internal float GetFloat(IDictionary<string, string> args, string name, float defaultVal)
+
+ protected float GetFloat(IDictionary<string, string> args, string name, float defaultVal)
{
string s;
if (args.TryGetValue(name, out s))
@@ -237,6 +243,7 @@ namespace Lucene.Net.Analysis.Util
{
return Require(args, name)[0];
}
+
public virtual char GetChar(IDictionary<string, string> args, string name, char defaultVal)
{
string s;
@@ -284,9 +291,9 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Compiles a pattern for the value of the specified argument key <code>name</code>
+ /// Compiles a pattern for the value of the specified argument key <paramref name="name"/>
/// </summary>
- protected internal Regex GetPattern(IDictionary<string, string> args, string name)
+ protected Regex GetPattern(IDictionary<string, string> args, string name)
{
try
{
@@ -302,7 +309,7 @@ namespace Lucene.Net.Analysis.Util
/// Returns as <see cref="CharArraySet"/> from wordFiles, which
/// can be a comma-separated list of filenames
/// </summary>
- protected internal CharArraySet GetWordSet(IResourceLoader loader, string wordFiles, bool ignoreCase)
+ protected CharArraySet GetWordSet(IResourceLoader loader, string wordFiles, bool ignoreCase)
{
AssureMatchVersion();
IList<string> files = SplitFileNames(wordFiles);
@@ -324,16 +331,16 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// Returns the resource's lines (with content treated as UTF-8)
/// </summary>
- protected internal IList<string> GetLines(IResourceLoader loader, string resource)
+ protected IList<string> GetLines(IResourceLoader loader, string resource)
{
return WordlistLoader.GetLines(loader.OpenResource(resource), Encoding.UTF8);
}
/// <summary>
- /// same as <see cref="#getWordSet(ResourceLoader, String, boolean)"/>,
+ /// Same as <see cref="GetWordSet(IResourceLoader, string, bool)"/>,
/// except the input is in snowball format.
/// </summary>
- protected internal CharArraySet GetSnowballWordSet(IResourceLoader loader, string wordFiles, bool ignoreCase)
+ protected CharArraySet GetSnowballWordSet(IResourceLoader loader, string wordFiles, bool ignoreCase)
{
AssureMatchVersion();
IList<string> files = SplitFileNames(wordFiles);
@@ -363,7 +370,7 @@ namespace Lucene.Net.Analysis.Util
/// </summary>
/// <param name="fileNames"> the string containing file names </param>
/// <returns> a list of file names with the escaping backslashed removed </returns>
- protected internal IList<string> SplitFileNames(string fileNames)
+ protected IList<string> SplitFileNames(string fileNames)
{
if (fileNames == null)
{
@@ -382,8 +389,8 @@ namespace Lucene.Net.Analysis.Util
private const string CLASS_NAME = "class";
/// <returns> the string used to specify the concrete class name in a serialized representation: the class arg.
- /// If the concrete class name was not specified via a class arg, returns {@code getClass().getName()}. </returns>
- public virtual string ClassArg
+ /// If the concrete class name was not specified via a class arg, returns <c>GetType().Name</c>. </returns>
+ public virtual string ClassArg // LUCENENET TODO: Change to GetClassArg()
{
get
{
@@ -399,6 +406,6 @@ namespace Lucene.Net.Analysis.Util
}
}
- public virtual bool ExplicitLuceneMatchVersion { get; set; }
+ public virtual bool IsExplicitLuceneMatchVersion { get; set; }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/47155b3f/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
index 3ba2f08..c8502e6 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
@@ -1,10 +1,7 @@
\ufeffusing Lucene.Net.Support;
using Lucene.Net.Util;
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Globalization;
-using System.Reflection;
namespace Lucene.Net.Analysis.Util
{
@@ -31,7 +28,6 @@ namespace Lucene.Net.Analysis.Util
/// </summary>
internal sealed class AnalysisSPILoader<S> where S : AbstractAnalysisFactory
{
-
private volatile IDictionary<string, Type> services = Collections.EmptyMap<string, Type>();
private readonly Type clazz = typeof(S);
private readonly string[] suffixes;
@@ -49,14 +45,14 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Reloads the internal SPI list from the given <see cref="ClassLoader"/>.
+ /// Reloads the internal SPI list.
/// Changes to the service list are visible after the method ends, all
- /// iterators (<see cref="#iterator()"/>,...) stay consistent.
+ /// iterators (e.g, from <see cref="AvailableServices"/>,...) stay consistent.
///
- /// <p><b>NOTE:</b> Only new service providers are added, existing ones are
+ /// <para/><b>NOTE:</b> Only new service providers are added, existing ones are
/// never removed or replaced.
///
- /// <p><em>this method is expensive and should only be called for discovery
+ /// <para/><em>this method is expensive and should only be called for discovery
/// of new service providers on the given classpath/classloader!</em>
/// </summary>
public void Reload()
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/47155b3f/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
index 84cf093..c6103f3 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/BufferedCharFilter.cs
@@ -40,7 +40,7 @@ namespace Lucene.Net.Analysis.Util
private static int defaultExpectedLineLength = 80;
/// <summary>
- /// LUCENENET specific to throw an exception if the user calls Close() instead of Dispose()
+ /// LUCENENET specific to throw an exception if the user calls <see cref="Close()"/> instead of <see cref="TextReader.Dispose()"/>
/// </summary>
private bool isDisposing = false;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/47155b3f/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
index 3d8801d..d1177ca 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
@@ -1,13 +1,12 @@
-\ufeffusing System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using Lucene.Net.Support;
+\ufeffusing Lucene.Net.Support;
using Lucene.Net.Util;
-using Reader = System.IO.TextReader;
-using Version = Lucene.Net.Util.LuceneVersion;
+using System;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
namespace Lucene.Net.Analysis.Util
{
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -24,6 +23,7 @@ namespace Lucene.Net.Analysis.Util
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/// <summary>
/// <see cref="CharacterUtils"/> provides a unified interface to Character-related
/// operations to implement backwards compatible character operations based on a
@@ -62,10 +62,10 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Returns the code point at the given index of the <see cref="CharSequence"/>.
+ /// Returns the code point at the given index of the <see cref="ICharSequence"/>.
/// Depending on the <see cref="LuceneVersion"/> passed to
- /// <see cref="CharacterUtils#getInstance(Version)"/> this method mimics the behavior
- /// of <see cref="Character#codePointAt(char[], int)"/> as it would have been
+ /// <see cref="CharacterUtils.GetInstance(LuceneVersion)"/> this method mimics the behavior
+ /// of <c>Character.CodePointAt(char[], int)</c> as it would have been
/// available on a Java 1.4 JVM or on a later virtual machine version.
/// </summary>
/// <param name="seq">
@@ -74,20 +74,21 @@ namespace Lucene.Net.Analysis.Util
/// the offset to the char values in the chars array to be converted
/// </param>
/// <returns> the Unicode code point at the given index </returns>
- /// <exception cref="NullPointerException">
+ /// <exception cref="NullReferenceException">
/// - if the sequence is null. </exception>
- /// <exception cref="IndexOutOfBoundsException">
+ /// <exception cref="IndexOutOfRangeException">
/// - if the value offset is negative or not less than the length of
/// the character sequence. </exception>
public abstract int CodePointAt(string seq, int offset);
+
public abstract int CodePointAt(ICharSequence seq, int offset);
/// <summary>
/// Returns the code point at the given index of the char array where only elements
/// with index less than the limit are used.
/// Depending on the <see cref="LuceneVersion"/> passed to
- /// <see cref="CharacterUtils#getInstance(Version)"/> this method mimics the behavior
- /// of <see cref="Character#codePointAt(char[], int)"/> as it would have been
+ /// <see cref="CharacterUtils.GetInstance(LuceneVersion)"/> this method mimics the behavior
+ /// of <c>Character.CodePointAt(char[], int)</c> as it would have been
/// available on a Java 1.4 JVM or on a later virtual machine version.
/// </summary>
/// <param name="chars">
@@ -98,23 +99,23 @@ namespace Lucene.Net.Analysis.Util
/// codepoint.
/// </param>
/// <returns> the Unicode code point at the given index </returns>
- /// <exception cref="NullPointerException">
+ /// <exception cref="NullReferenceException">
/// - if the array is null. </exception>
- /// <exception cref="IndexOutOfBoundsException">
+ /// <exception cref="IndexOutOfRangeException">
/// - if the value offset is negative or not less than the length of
/// the char array. </exception>
public abstract int CodePointAt(char[] chars, int offset, int limit);
/// <summary>
- /// Return the number of characters in <code>seq</code>. </summary>
+ /// Return the number of characters in <paramref name="seq"/>. </summary>
public abstract int CodePointCount(string seq);
/// <summary>
- /// Creates a new <see cref="CharacterBuffer"/> and allocates a <code>char[]</code>
+ /// Creates a new <see cref="CharacterBuffer"/> and allocates a <see cref="T:char[]"/>
/// of the given bufferSize.
/// </summary>
/// <param name="bufferSize">
- /// the internal char buffer size, must be <code>>= 2</code> </param>
+ /// the internal char buffer size, must be <c>>= 2</c> </param>
/// <returns> a new <see cref="CharacterBuffer"/> instance. </returns>
public static CharacterBuffer NewCharacterBuffer(int bufferSize)
{
@@ -127,7 +128,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
- /// Converts each unicode codepoint to lowerCase via <see cref="Character#toLowerCase(int)"/> starting
+ /// Converts each unicode codepoint to lowerCase via <see cref="Character.ToLowerCase(int)"/> starting
/// at the given offset. </summary>
/// <param name="buffer"> the char buffer to lowercase </param>
/// <param name="offset"> the offset to start at </param>
@@ -145,7 +146,7 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Converts each unicode codepoint to UpperCase via <see cref="Character#toUpperCase(int)"/> starting
+ /// Converts each unicode codepoint to UpperCase via <see cref="Character.ToUpperCase(int)"/> starting
/// at the given offset. </summary>
/// <param name="buffer"> the char buffer to UPPERCASE </param>
/// <param name="offset"> the offset to start at </param>
@@ -163,9 +164,9 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Converts a sequence of Java characters to a sequence of unicode code points. </summary>
+ /// Converts a sequence of .NET characters to a sequence of unicode code points. </summary>
/// <returns> the number of code points written to the destination buffer </returns>
- public int toCodePoints(char[] src, int srcOff, int srcLen, int[] dest, int destOff)
+ public int ToCodePoints(char[] src, int srcOff, int srcLen, int[] dest, int destOff)
{
if (srcLen < 0)
{
@@ -183,9 +184,9 @@ namespace Lucene.Net.Analysis.Util
}
/// <summary>
- /// Converts a sequence of unicode code points to a sequence of Java characters. </summary>
+ /// Converts a sequence of unicode code points to a sequence of .NET characters. </summary>
/// <returns> the number of chars written to the destination buffer </returns>
- public int toChars(int[] src, int srcOff, int srcLen, char[] dest, int destOff)
+ public int ToChars(int[] src, int srcOff, int srcLen, char[] dest, int destOff)
{
if (srcLen < 0)
{
@@ -201,27 +202,27 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// Fills the <see cref="CharacterBuffer"/> with characters read from the given
- /// reader <see cref="Reader"/>. This method tries to read <code>numChars</code>
+ /// reader <see cref="TextReader"/>. This method tries to read <code>numChars</code>
/// characters into the <see cref="CharacterBuffer"/>, each call to fill will start
- /// filling the buffer from offset <code>0</code> up to <code>numChars</code>.
+ /// filling the buffer from offset <c>0</c> up to <paramref name="numChars"/>.
/// In case code points can span across 2 java characters, this method may
- /// only fill <code>numChars - 1</code> characters in order not to split in
+ /// only fill <c>numChars - 1</c> characters in order not to split in
/// the middle of a surrogate pair, even if there are remaining characters in
- /// the <see cref="Reader"/>.
+ /// the <see cref="TextReader"/>.
/// <para>
/// Depending on the <see cref="LuceneVersion"/> passed to
- /// <see cref="CharacterUtils#getInstance(Version)"/> this method implements
+ /// <see cref="CharacterUtils.GetInstance(LuceneVersion)"/> this method implements
/// supplementary character awareness when filling the given buffer. For all
- /// <see cref="LuceneVersion"/> > 3.0 <see cref="#fill(CharacterBuffer, Reader, int)"/> guarantees
+ /// <see cref="LuceneVersion"/> > 3.0 <see cref="Fill(CharacterBuffer, TextReader, int)"/> guarantees
/// that the given <see cref="CharacterBuffer"/> will never contain a high surrogate
/// character as the last element in the buffer unless it is the last available
/// character in the reader. In other words, high and low surrogate pairs will
/// always be preserved across buffer boarders.
/// </para>
/// <para>
- /// A return value of <code>false</code> means that this method call exhausted
+ /// A return value of <c>false</c> means that this method call exhausted
/// the reader, but there may be some bytes which have been read, which can be
- /// verified by checking whether <code>buffer.getLength() > 0</code>.
+ /// verified by checking whether <c>buffer.Length > 0</c>.
/// </para>
/// </summary>
/// <param name="buffer">
@@ -233,22 +234,22 @@ namespace Lucene.Net.Analysis.Util
/// <returns> <code>false</code> if and only if reader.read returned -1 while trying to fill the buffer </returns>
/// <exception cref="IOException">
/// if the reader throws an <see cref="IOException"/>. </exception>
- public abstract bool Fill(CharacterBuffer buffer, Reader reader, int numChars);
+ public abstract bool Fill(CharacterBuffer buffer, TextReader reader, int numChars);
/// <summary>
- /// Convenience method which calls <code>fill(buffer, reader, buffer.buffer.length)</code>. </summary>
- public virtual bool Fill(CharacterBuffer buffer, Reader reader)
+ /// Convenience method which calls <c>Fill(buffer, reader, buffer.Buffer.Length)</c>. </summary>
+ public virtual bool Fill(CharacterBuffer buffer, TextReader reader)
{
- return Fill(buffer, reader, buffer.buffer.Length);
+ return Fill(buffer, reader, buffer.Buffer.Length);
}
/// <summary>
- /// Return the index within <code>buf[start:start+count]</code> which is by <code>offset</code>
- /// code points from <code>index</code>.
+ /// Return the index within <c>buf[start:start+count]</c> which is by <paramref name="offset"/>
+ /// code points from <paramref name="index"/>.
/// </summary>
public abstract int OffsetByCodePoints(char[] buf, int start, int count, int index, int offset);
- internal static int ReadFully(Reader reader, char[] dest, int offset, int len)
+ private static int ReadFully(TextReader reader, char[] dest, int offset, int len)
{
int read = 0;
while (read < len)
@@ -276,17 +277,17 @@ namespace Lucene.Net.Analysis.Util
public override int CodePointAt(char[] chars, int offset, int limit)
{
- return Character.CodePointAt(chars, offset, limit);
+ return Character.CodePointAt(chars, offset, limit); // LUCENENET TODO: This will throw a NullReferenceException if chars is null. Should this be an ArgumentNullException in .NET?
}
- public override bool Fill(CharacterBuffer buffer, Reader reader, int numChars)
+ public override bool Fill(CharacterBuffer buffer, TextReader reader, int numChars)
{
- Debug.Assert(buffer.buffer.Length >= 2);
- if (numChars < 2 || numChars > buffer.buffer.Length)
+ Debug.Assert(buffer.Buffer.Length >= 2);
+ if (numChars < 2 || numChars > buffer.Buffer.Length)
{
throw new System.ArgumentException("numChars must be >= 2 and <= the buffer size");
}
- char[] charBuffer = buffer.buffer;
+ char[] charBuffer = buffer.Buffer;
buffer.offset = 0;
int offset;
@@ -337,6 +338,7 @@ namespace Lucene.Net.Analysis.Util
{
return seq[offset];
}
+
public override int CodePointAt(ICharSequence seq, int offset)
{
return seq[offset];
@@ -348,18 +350,18 @@ namespace Lucene.Net.Analysis.Util
{
throw new System.IndexOutOfRangeException("offset must be less than limit");
}
- return chars[offset];
+ return chars[offset]; // LUCENENET TODO: This will throw a NullReferenceException if chars is null. Should this be an ArgumentNullException in .NET?
}
- public override bool Fill(CharacterBuffer buffer, Reader reader, int numChars)
+ public override bool Fill(CharacterBuffer buffer, TextReader reader, int numChars)
{
- Debug.Assert(buffer.buffer.Length >= 1);
- if (numChars < 1 || numChars > buffer.buffer.Length)
+ Debug.Assert(buffer.Buffer.Length >= 1);
+ if (numChars < 1 || numChars > buffer.Buffer.Length)
{
throw new System.ArgumentException("numChars must be >= 1 and <= the buffer size");
}
buffer.offset = 0;
- int read = ReadFully(reader, buffer.buffer, 0, numChars);
+ int read = ReadFully(reader, buffer.Buffer, 0, numChars);
buffer.length = read;
buffer.lastTrailingHighSurrogate = (char)0;
return read == numChars;
@@ -379,17 +381,15 @@ namespace Lucene.Net.Analysis.Util
}
return result;
}
-
}
/// <summary>
/// A simple IO buffer to use with
- /// <see cref="CharacterUtils#fill(CharacterBuffer, Reader)"/>.
+ /// <see cref="CharacterUtils.Fill(CharacterBuffer, TextReader)"/>.
/// </summary>
public sealed class CharacterBuffer
{
-
- internal readonly char[] buffer;
+ private readonly char[] buffer;
internal int offset;
internal int length;
// NOTE: not private so outer class can access without
@@ -431,7 +431,7 @@ namespace Lucene.Net.Analysis.Util
/// <summary>
/// Return the length of the data in the internal buffer starting at
- /// <see cref="#getOffset()"/>
+ /// <see cref="Offset"/>
/// </summary>
/// <returns> the length </returns>
public int Length
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/47155b3f/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
index 306f16c..2a842c9 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
@@ -159,8 +159,8 @@ namespace Lucene.Net.Analysis.Util
var o1 = TestUtil.NextInt(Random(), 0, Math.Min(5, orig.Length));
var o2 = TestUtil.NextInt(Random(), 0, o1);
var o3 = TestUtil.NextInt(Random(), 0, o1);
- var codePointCount = charUtils.toCodePoints(orig, o1, orig.Length - o1, buf, o2);
- var charCount = charUtils.toChars(buf, o2, codePointCount, restored, o3);
+ var codePointCount = charUtils.ToCodePoints(orig, o1, orig.Length - o1, buf, o2);
+ var charCount = charUtils.ToChars(buf, o2, codePointCount, restored, o3);
assertEquals(orig.Length - o1, charCount);
assertArrayEquals(Arrays.CopyOfRange(orig, o1, o1 + charCount), Arrays.CopyOfRange(restored, o3, o3 + charCount));
}