23 using System.Collections.Generic;
26 using Lucene.Net.Analysis.Tokenattributes;
28 namespace Lucene.Net.Analysis.Reverse
43 private readonly
char marker;
44 private const char NOMARKER =
'\uFFFF';
49 public const char START_OF_HEADING_MARKER =
'\u0001';
54 public const char INFORMATION_SEPARATOR_MARKER =
'\u001F';
59 public const char PUA_EC00_MARKER =
'\uEC00';
64 public const char RTL_DIRECTION_MARKER =
'\u200F';
96 termAtt = AddAttribute<ITermAttribute>();
99 public override bool IncrementToken()
101 if (input.IncrementToken())
103 int len = termAtt.TermLength();
104 if (marker != NOMARKER)
107 termAtt.ResizeTermBuffer(len);
108 termAtt.TermBuffer()[len - 1] = marker;
110 Reverse(termAtt.TermBuffer(), len);
111 termAtt.SetTermLength(len);
120 public static String Reverse(String input)
122 char[] charInput = input.ToCharArray();
124 return new String(charInput);
127 public static void Reverse(
char[] buffer)
129 Reverse(buffer, buffer.Length);
132 public static void Reverse(
char[] buffer,
int len)
134 Reverse(buffer, 0, len);
137 public static void Reverse(
char[] buffer,
int start,
int len)
139 if (len <= 1)
return;
141 for (
int i = start; i < (start + num); i++)
144 buffer[i] = buffer[start * 2 + len - i - 1];
145 buffer[start * 2 + len - i - 1] = c;