Index: Document/Field.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Document/Field.cs,v
retrieving revision 1.3
diff -u -B -p -r1.3 Field.cs
--- Document/Field.cs 6 Oct 2005 19:29:55 -0000 1.3
+++ Document/Field.cs 16 Oct 2005 19:51:18 -0000
@@ -299,14 +299,7 @@ namespace Lucene.Net.Documents
///
public System.String StringValue()
{
- try
- {
- return (System.String) fieldsData;
- }
- catch (System.InvalidCastException ignore)
- {
- return null;
- }
+ return fieldsData as System.String;
}
/// The value of the field as a Reader, or null. If null, the String value
@@ -315,14 +308,7 @@ namespace Lucene.Net.Documents
///
public System.IO.TextReader ReaderValue()
{
- try
- {
- return (System.IO.TextReader) fieldsData;
- }
- catch (System.InvalidCastException ignore)
- {
- return null;
- }
+ return fieldsData as System.IO.TextReader;
}
/// The value of the field in Binary, or null. If null, the Reader or
@@ -331,14 +317,7 @@ namespace Lucene.Net.Documents
///
public byte[] BinaryValue()
{
- try
- {
- return (byte[]) fieldsData;
- }
- catch (System.InvalidCastException ignore)
- {
- return null;
- }
+ return fieldsData as byte[];
}
/// Create a field by specifying its name, value and how it will
@@ -740,4 +719,4 @@ namespace Lucene.Net.Documents
return result.ToString();
}
}
-}
\ No newline at end of file
+}
Index: Index/FieldInfos.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/FieldInfos.cs,v
retrieving revision 1.4
diff -u -B -p -r1.4 FieldInfos.cs
--- Index/FieldInfos.cs 6 Oct 2005 19:29:55 -0000 1.4
+++ Index/FieldInfos.cs 16 Oct 2005 19:51:18 -0000
@@ -196,16 +196,9 @@ namespace Lucene.Net.Index
public int FieldNumber(System.String fieldName)
{
- try
- {
- FieldInfo fi = FieldInfo(fieldName);
- if (fi != null)
- return fi.number;
- }
- catch (System.IndexOutOfRangeException ioobe)
- {
- return - 1;
- }
+ FieldInfo fi = FieldInfo(fieldName);
+ if (fi != null)
+ return fi.number;
return - 1;
}
@@ -224,14 +217,11 @@ namespace Lucene.Net.Index
///
public System.String FieldName(int fieldNumber)
{
- try
- {
- return FieldInfo(fieldNumber).name;
- }
- catch (System.NullReferenceException npe)
- {
- return "";
- }
+ FieldInfo info = FieldInfo(fieldNumber);
+ if (info == null)
+ return "";
+ else
+ return info.name;
}
/// Return the fieldinfo object referenced by the fieldNumber.
@@ -242,19 +232,12 @@ namespace Lucene.Net.Index
///
public FieldInfo FieldInfo(int fieldNumber)
{
- if (fieldNumber < 0)
+ if (fieldNumber < 0 || fieldNumber >= byNumber.Count)
{
return null;
}
- try
- {
- return (FieldInfo) byNumber[fieldNumber];
- }
- catch (System.IndexOutOfRangeException ioobe)
- {
- return null;
- }
+ return (FieldInfo) byNumber[fieldNumber];
}
public int Size()
@@ -324,4 +307,4 @@ namespace Lucene.Net.Index
}
}
}
-}
\ No newline at end of file
+}
Index: Analysis/Standard/CharStream.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Analysis/Standard/CharStream.cs,v
retrieving revision 1.2
diff -u -B -p -r1.2 CharStream.cs
--- Analysis/Standard/CharStream.cs 17 Jan 2005 19:54:28 -0000 1.2
+++ Analysis/Standard/CharStream.cs 16 Oct 2005 20:09:02 -0000
@@ -25,7 +25,7 @@ namespace Lucene.Net.Analysis.Standard
/// of selecting the input is the responsibility of the class
/// implementing this interface. Can throw any java.io.IOException.
///
- char ReadChar();
+ int ReadChar();
/// Returns the column position of the character last read.
///
@@ -72,7 +72,7 @@ namespace Lucene.Net.Analysis.Standard
/// All characters must remain in the buffer between two successive calls
/// to this method to implement backup correctly.
///
- char BeginToken();
+ int BeginToken();
/// Returns a string made up of characters from the marked token beginning
/// to the current buffer position. Implementations have the choice of returning
@@ -100,4 +100,4 @@ namespace Lucene.Net.Analysis.Standard
///
void Done();
}
-}
\ No newline at end of file
+}
Index: Analysis/Standard/FastCharStream.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Analysis/Standard/FastCharStream.cs,v
retrieving revision 1.2
diff -u -B -p -r1.2 FastCharStream.cs
--- Analysis/Standard/FastCharStream.cs 17 Jan 2005 19:54:28 -0000 1.2
+++ Analysis/Standard/FastCharStream.cs 16 Oct 2005 20:09:02 -0000
@@ -40,14 +40,15 @@ namespace Lucene.Net.Analysis.Standard
input = r;
}
- public char ReadChar()
+ public int ReadChar()
{
if (bufferPosition >= bufferLength)
- Refill();
+ if (!Refill())
+ return -1;
return buffer[bufferPosition++];
}
- private void Refill()
+ private bool Refill()
{
int newPosition = bufferLength - tokenStart;
@@ -81,12 +82,13 @@ namespace Lucene.Net.Analysis.Standard
int charsRead = input.Read(buffer, newPosition, buffer.Length - newPosition);
if (charsRead <= 0)
- throw new System.IO.IOException("read past eof");
- else
- bufferLength += charsRead;
+ return false;
+
+ bufferLength += charsRead;
+ return true;
}
- public char BeginToken()
+ public int BeginToken()
{
tokenStart = bufferPosition;
return ReadChar();
@@ -146,4 +148,4 @@ namespace Lucene.Net.Analysis.Standard
return 1;
}
}
-}
\ No newline at end of file
+}
Index: Analysis/Standard/StandardTokenizerTokenManager.cs
===================================================================
RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Analysis/Standard/StandardTokenizerTokenManager.cs,v
retrieving revision 1.3
diff -u -B -p -r1.3 StandardTokenizerTokenManager.cs
--- Analysis/Standard/StandardTokenizerTokenManager.cs 6 Oct 2005 19:29:55 -0000 1.3
+++ Analysis/Standard/StandardTokenizerTokenManager.cs 16 Oct 2005 20:09:04 -0000
@@ -1133,14 +1133,11 @@ namespace Lucene.Net.Analysis.Standard
++curPos;
if ((ii = jjnewStateCnt) == (startsAt = 73 - (jjnewStateCnt = startsAt)))
return curPos;
- try
- {
- curChar = input_stream.ReadChar();
- }
- catch (System.IO.IOException)
- {
+ int ret = input_stream.ReadChar();
+ if (ret != -1)
+ curChar = (char) ret;
+ else
return curPos;
- }
}
}
internal static readonly int[] jjnextStates = new int[]{22, 23, 24, 26, 30, 31, 33, 34, 38, 39, 40, 41, 47, 48, 49, 50, 60, 61, 2, 3, 5, 6, 12, 13, 23, 24, 26, 24, 25, 26, 63, 64, 66, 67, 70, 71, 2, 3, 12, 13, 18, 19, 44, 45, 68, 69, 7, 8, 9, 10, 16, 17, 35, 36, 42, 43, 51, 52, 55, 56, 57, 58};
@@ -1284,11 +1281,11 @@ namespace Lucene.Net.Analysis.Standard
for (; ; )
{
- try
- {
- curChar = input_stream.BeginToken();
- }
- catch (System.IO.IOException)
+
+ int ret = input_stream.BeginToken();
+ if (ret != -1)
+ curChar = (char) ret;
+ else
{
jjmatchedKind = 0;
matchedToken = JjFillToken();
@@ -1320,11 +1317,7 @@ namespace Lucene.Net.Analysis.Standard
int error_column = input_stream.GetEndColumn();
System.String error_after = null;
bool EOFSeen = false;
- try
- {
- input_stream.ReadChar(); input_stream.Backup(1);
- }
- catch (System.IO.IOException)
+ if (input_stream.ReadChar() == -1)
{
EOFSeen = true;
error_after = curPos <= 1?"":input_stream.GetImage();
@@ -1336,6 +1329,9 @@ namespace Lucene.Net.Analysis.Standard
else
error_column++;
}
+ else
+ input_stream.Backup(1);
+
if (!EOFSeen)
{
input_stream.Backup(1);
@@ -1347,4 +1343,4 @@ EOFLoop: ;
}
}
}
-}
\ No newline at end of file
+}