Class StringBuilderExtensions
Inheritance
Inherited Members
Namespace: Lucene.Net.Support
Assembly: Lucene.Net.dll
Syntax
public static class StringBuilderExtensions
Methods
| Improve this Doc View SourceAppendCodePoint(StringBuilder, Int32)
Appends the string representation of the codePoint
argument to this sequence.
The argument is appended to the contents of this sequence. The length of this sequence increases by CharCount(Int32).
The overall effect is exactly as if the argument were converted to a System.Char array by the method ToChars(Int32) and the character in that array were then System.Text.StringBuilder.Append(System.Char[]) to this System.Text.StringBuilder.
Declaration
public static StringBuilder AppendCodePoint(this StringBuilder text, int codePoint)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | This System.Text.StringBuilder. |
System.Int32 | codePoint | a Unicode code point |
Returns
Type | Description |
---|---|
System.Text.StringBuilder | a reference to this object. |
CodePointAt(StringBuilder, Int32)
Returns the character (Unicode code point) at the specified index. The index refers to char values (Unicode code units) and ranges from 0 to Length - 1.
If the char value specified at the given index is in the high-surrogate range, the following index is less than the length of this sequence, and the char value at the following index is in the low-surrogate range, then the supplementary code point corresponding to this surrogate pair is returned. Otherwise, the char value at the given index is returned.
Declaration
public static int CodePointAt(this StringBuilder text, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | this System.Text.StringBuilder |
System.Int32 | index | the index to the char values |
Returns
Type | Description |
---|---|
System.Int32 | the code point value of the character at the index |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if the index argument is negative or not less than the length of this sequence. |
CodePointCount(StringBuilder, Int32, Int32)
Returns the number of Unicode code points in the specified text
range of this System.Text.StringBuilder. The text range begins at the specified
beginIndex
and extends to the System.Char at
index endIndex - 1
. Thus the length (in
System.Chars) of the text range is
endIndex-beginIndex
. Unpaired surrogates within
this sequence count as one code point each.
Declaration
public static int CodePointCount(this StringBuilder text, int beginIndex, int endIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | this System.Text.StringBuilder |
System.Int32 | beginIndex | the index to the first System.Char of the text range. |
System.Int32 | endIndex | the index after the last System.Char of the text range. |
Returns
Type | Description |
---|---|
System.Int32 | the number of Unicode code points in the specified text range. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if the |
GetChars(StringBuilder)
Copies the array from the System.Text.StringBuilder into a new array and returns it.
Declaration
public static char[] GetChars(this StringBuilder text)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | this System.Text.StringBuilder |
Returns
Type | Description |
---|---|
System.Char[] |
IndexOf(StringBuilder, String)
Searches for the first index of the specified character. The search for the character starts at the beginning and moves towards the end.
Declaration
public static int IndexOf(this StringBuilder text, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | This System.Text.StringBuilder. |
System.String | value | The string to find. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the specified character, or -1 if the character isn't found. |
IndexOf(StringBuilder, String, Int32)
Searches for the index of the specified character. The search for the character starts at the specified offset and moves towards the end.
Declaration
public static int IndexOf(this StringBuilder text, string value, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | This System.Text.StringBuilder. |
System.String | value | The string to find. |
System.Int32 | startIndex | The starting offset. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the specified character, or -1 if the character isn't found. |
Reverse(StringBuilder)
Causes this character sequence to be replaced by the reverse of the sequence. If there are any surrogate pairs included in the sequence, these are treated as single characters for the reverse operation. Thus, the order of the high-low surrogates is never reversed.
Let n
be the character length of this character sequence
(not the length in System.Char values) just prior to
execution of the Reverse(StringBuilder) method. Then the
character at index k
in the new character sequence is
equal to the character at index n-k-1
in the old
character sequence.
Note that the reverse operation may result in producing surrogate pairs that were unpaired low-surrogates and high-surrogates before the operation. For example, reversing "\uDC00\uD800" produces "\uD800\uDC00" which is a valid surrogate pair.
Declaration
public static StringBuilder Reverse(this StringBuilder text)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text | this System.Text.StringBuilder |
Returns
Type | Description |
---|---|
System.Text.StringBuilder | a reference to this System.Text.StringBuilder. |
ToCharSequence(StringBuilder)
Convenience method to wrap a string in a StringBuilderCharSequenceWrapper so a System.Text.StringBuilder can be used as ICharSequence in .NET.
Declaration
public static ICharSequence ToCharSequence(this StringBuilder text)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | text |
Returns
Type | Description |
---|---|
ICharSequence |