Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Interface ICharTermAttribute

    The term text of a Token.

    Inherited Members
    IAttribute.CopyTo(IAttribute)
    ICharSequence.Subsequence(int, int)
    ICharSequence.ToString()
    ICharSequence.HasValue
    Namespace: Lucene.Net.Analysis.TokenAttributes
    Assembly: Lucene.Net.dll
    Syntax
    public interface ICharTermAttribute : IAttribute, ICharSequence, IAppendable

    Properties

    Buffer

    Returns the internal termBuffer character array which you can then directly alter. If the array is too small for your token, use ResizeBuffer(int) to increase it. After altering the buffer be sure to call SetLength(int) to record the number of valid characters that were placed into the termBuffer.

    NOTE: The returned buffer may be larger than the valid Length.

    Declaration
    char[] Buffer { get; }
    Property Value
    Type Description
    char[]

    this[int]

    The term text of a Token.

    Declaration
    char this[int index] { get; set; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type Description
    char

    Length

    Gets or Sets the number of valid characters (in the termBuffer array. SetLength(int)

    Declaration
    int Length { get; set; }
    Property Value
    Type Description
    int

    Methods

    Append(ICharSequence)

    Appends the contents of the J2N.Text.ICharSequence to this character sequence.

    The characters of the J2N.Text.ICharSequence argument are appended, in order, increasing the length of this sequence by the length of the argument. If value is null, this method is a no-op.

    IMPORTANT: This method uses .NET semantics. In Lucene, a nullvalue would append the string "null" to the instance, but in Lucene.NET a null value will be ignored.
    Declaration
    ICharTermAttribute Append(ICharSequence value)
    Parameters
    Type Name Description
    ICharSequence value
    Returns
    Type Description
    ICharTermAttribute

    Append(ICharSequence, int, int)

    Appends the a string representation of the specified J2N.Text.ICharSequence to this instance.

    The characters of the J2N.Text.ICharSequence argument are appended, in order, increasing the length of this sequence by the length of count. If value is null and startIndex and count are not 0, an ArgumentNullException is thrown.

    Declaration
    ICharTermAttribute Append(ICharSequence value, int startIndex, int count)
    Parameters
    Type Name Description
    ICharSequence value

    The sequence of characters to append.

    int startIndex

    The start index of the J2N.Text.ICharSequence to begin copying characters.

    int count

    The number of characters to append.

    Returns
    Type Description
    ICharTermAttribute
    Exceptions
    Type Condition
    ArgumentNullException

    value is null, and startIndex and count are not zero.

    ArgumentOutOfRangeException

    count is less than zero.

    -or-

    startIndex is less than zero.

    -or-

    startIndex + count is greater than the length of value.

    Append(ICharTermAttribute)

    Appends the contents of the other ICharTermAttribute to this character sequence.

    The characters of the ICharTermAttribute argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is null, this method is a no-op.

    This method uses .NET semantics. In Lucene, a nullvalue would append the string "null" to the instance, but in Lucene.NET a null value will be safely ignored.
    Declaration
    ICharTermAttribute Append(ICharTermAttribute value)
    Parameters
    Type Name Description
    ICharTermAttribute value

    The sequence of characters to append.

    Returns
    Type Description
    ICharTermAttribute

    Append(char)

    Appends the supplied char to this character sequence.

    Declaration
    ICharTermAttribute Append(char value)
    Parameters
    Type Name Description
    char value

    The char to append.

    Returns
    Type Description
    ICharTermAttribute

    Append(char[])

    Appends the contents of the char[] array to this character sequence.

    The characters of the char[] argument are appended, in order, increasing the length of this sequence by the length of the value. If value is null, this method is a no-op.

    This method uses .NET semantics. In Lucene, a nullvalue would append the string "null" to the instance, but in Lucene.NET a null value will be safely ignored.
    Declaration
    ICharTermAttribute Append(char[] value)
    Parameters
    Type Name Description
    char[] value

    The char[] array to append.

    Returns
    Type Description
    ICharTermAttribute
    Remarks

    LUCENENET specific method, added to simulate using the CharBuffer class in Java.

    Append(char[], int, int)

    Appends the string representation of the char[] array to this instance.

    The characters of the char[] argument are appended, in order, increasing the length of this sequence by the length of the value. If value is null and startIndex and count are not 0, an ArgumentNullException is thrown.

    Declaration
    ICharTermAttribute Append(char[] value, int startIndex, int count)
    Parameters
    Type Name Description
    char[] value

    The sequence of characters to append.

    int startIndex

    The start index of the char[] to begin copying characters.

    int count

    The number of characters to append.

    Returns
    Type Description
    ICharTermAttribute
    Remarks

    LUCENENET specific method, added to simulate using the CharBuffer class in Java. Note that the CopyBuffer(char[], int, int) method provides similar functionality.

    Exceptions
    Type Condition
    ArgumentNullException

    value is null, and startIndex and count are not zero.

    ArgumentOutOfRangeException

    count is less than zero.

    -or-

    startIndex is less than zero.

    -or-

    startIndex + count is greater than the length of value.

    Append(string)

    Appends the specified string to this character sequence.

    The characters of the string argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is null, this method is a no-op.

    This method uses .NET semantics. In Lucene, a nullvalue would append the string "null" to the instance, but in Lucene.NET a null value will be safely ignored.
    Declaration
    ICharTermAttribute Append(string value)
    Parameters
    Type Name Description
    string value

    The sequence of characters to append.

    Returns
    Type Description
    ICharTermAttribute
    Remarks

    LUCENENET specific method, added because the .NET string data type doesn't implement J2N.Text.ICharSequence.

    Append(string, int, int)

    Appends the contents of the string to this character sequence.

    The characters of the string argument are appended, in order, increasing the length of this sequence by the length of value. If value is null and startIndex and count are not 0, an ArgumentNullException is thrown.

    Declaration
    ICharTermAttribute Append(string value, int startIndex, int count)
    Parameters
    Type Name Description
    string value

    The sequence of characters to append.

    int startIndex

    The start index of the string to begin copying characters.

    int count

    The number of characters to append.

    Returns
    Type Description
    ICharTermAttribute
    Remarks

    LUCENENET specific method, added because the .NET string data type doesn't implement J2N.Text.ICharSequence.

    Exceptions
    Type Condition
    ArgumentNullException

    value is null, and startIndex and count are not zero.

    ArgumentOutOfRangeException

    count is less than zero.

    -or-

    startIndex is less than zero.

    -or-

    startIndex + count is greater than the length of value.

    Append(StringBuilder)

    Appends a string representation of the specified StringBuilder to this character sequence.

    The characters of the StringBuilder argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is null, this method is a no-op.

    This method uses .NET semantics. In Lucene, a nullvalue would append the string "null" to the instance, but in Lucene.NET a null value will be safely ignored.
    Declaration
    ICharTermAttribute Append(StringBuilder value)
    Parameters
    Type Name Description
    StringBuilder value
    Returns
    Type Description
    ICharTermAttribute

    Append(StringBuilder, int, int)

    Appends a string representation of the specified StringBuilder to this character sequence.

    The characters of the StringBuilder argument are appended, in order, increasing the length of this sequence by the length of the argument. If value is null and startIndex and count are not 0, an ArgumentNullException is thrown.
    Declaration
    ICharTermAttribute Append(StringBuilder value, int startIndex, int count)
    Parameters
    Type Name Description
    StringBuilder value

    The sequence of characters to append.

    int startIndex

    The start index of the StringBuilder to begin copying characters.

    int count

    The number of characters to append.

    Returns
    Type Description
    ICharTermAttribute
    Remarks

    LUCENENET specific method, added because the .NET StringBuilder data type doesn't implement J2N.Text.ICharSequence.

    Exceptions
    Type Condition
    ArgumentNullException

    value is null, and startIndex and count are not zero.

    ArgumentOutOfRangeException

    count is less than zero.

    -or-

    startIndex is less than zero.

    -or-

    startIndex + count is greater than the length of value.

    CopyBuffer(char[], int, int)

    Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.

    Declaration
    void CopyBuffer(char[] buffer, int offset, int length)
    Parameters
    Type Name Description
    char[] buffer

    the buffer to copy

    int offset

    the index in the buffer of the first character to copy

    int length

    the number of characters to copy

    ResizeBuffer(int)

    Grows the termBuffer to at least size newSize, preserving the existing content.

    Declaration
    char[] ResizeBuffer(int newSize)
    Parameters
    Type Name Description
    int newSize

    minimum size of the new termBuffer

    Returns
    Type Description
    char[]

    newly created termBuffer with length >= newSize

    SetEmpty()

    Sets the length of the termBuffer to zero. Use this method before appending contents.

    Declaration
    ICharTermAttribute SetEmpty()
    Returns
    Type Description
    ICharTermAttribute

    SetLength(int)

    Set number of valid characters (length of the term) in the termBuffer array. Use this to truncate the termBuffer or to synchronize with external manipulation of the termBuffer. Note: to grow the size of the array, use ResizeBuffer(int) first. NOTE: This is exactly the same operation as calling the Length setter, the primary difference is that this method returns a reference to the current object so it can be chained.

    obj.SetLength(30).Append("hey you");
    Declaration
    ICharTermAttribute SetLength(int length)
    Parameters
    Type Name Description
    int length

    the truncated length

    Returns
    Type Description
    ICharTermAttribute
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.