Documentation of 'javolution37.javolution.lang.TextBuilder' Java class
TextBuilder
javolution37.javolution.lang

Class TextBuilder

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Appendable, java.lang.CharSequence, Reusable, Realtime


    public class TextBuilder
    extends RealtimeObject
    implements java.lang.Appendable, java.lang.CharSequence, Reusable, java.io.Serializable

    This class represents an Appendable text whose capacity expands gently without incurring expensive resize/copy operations ever.

    This class is not intended for large documents manipulations which should be performed with the Text class directly (O(Log(n)) insertion and deletion capabilities).

    This implementation is not synchronized.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      TextBuilder()
      Creates a text builder of small initial capacity.
      TextBuilder(java.lang.CharSequence csq)
      Creates a text builder holding the specified character sequence.
      TextBuilder(int capacity)
      Creates a text builder of specified initial capacity.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      TextBuilder append(boolean b)
      Appends the textual representation of the specified boolean (equivalent to TypeFormat.format(b, this)).
      TextBuilder append(char c)
      Appends the specified character.
      TextBuilder append(char[] chars)
      Appends the characters from the char array argument.
      TextBuilder append(char[] chars, int offset, int length)
      Appends the characters from a subarray of the char array argument.
      TextBuilder append(java.lang.CharSequence csq)
      Appends the specified character sequence.
      TextBuilder append(java.lang.CharSequence csq, int start, int end)
      Appends a subsequence of the specified character sequence.
      TextBuilder append(double d)
      Appends the textual representation of the specified double (equivalent to TypeFormat.format(d, this)).
      TextBuilder append(double value, int digits, boolean scientific, boolean showZero)
      Appends the specified double value according to the specified formatting arguments.
      TextBuilder append(float f)
      Appends the textual representation of the specified float (equivalent to TypeFormat.format(f, this)).
      TextBuilder append(int i)
      Appends the decimal representation of the specified int (equivalent to TypeFormat.format(i, this)).
      TextBuilder append(int i, int radix)
      Appends the radix representation of the specified int argument.
      TextBuilder append(long l)
      Appends the decimal representation of the specified long (equivalent to TypeFormat.format(l, this)).
      TextBuilder append(long l, int radix)
      Appends the radix representation of the specified long argument.
      TextBuilder append(java.lang.Object obj)
      Appends the textual representation of the specified object.
      TextBuilder append(java.lang.String str)
      Appends the specified string to this text builder.
      TextBuilder append(java.lang.String str, int start, int end)
      Appends a subsequence of the specified string.
      TextBuilder append(Text text)
      Appends the specified text to this text builder.
      char charAt(int index)
      Returns the character at the specified index.
      TextBuilder delete(int start, int end)
      Removes the characters between the specified indices.
      boolean equals(java.lang.Object obj)
      Compares this text builder against the specified object for equality.
      void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
      Copies the character from this text builder into the destination character array.
      int hashCode()
      Returns the hash code for this text builder.
      TextBuilder insert(int index, java.lang.CharSequence csq)
      Inserts the specified character sequence at the specified location.
      int length()
      Returns the length (character count) of this text builder.
      static TextBuilder newInstance()
      Returns a text builder allocated from the "stack" when executing in a PoolContext).
      void reset()
      Resets this text builder for reuse (sets its length to 0).
      TextBuilder reverse()
      Reverses this character sequence.
      void setCharAt(int index, char c)
      Sets the character at the specified position.
      void setLength(int newLength)
      Sets the length of this character builder.
      java.lang.CharSequence subSequence(int start, int end)
      Returns an instance of Text (immutable) corresponding to the character sequence between the specified indexes.
      Text toText()
      Returns the Text corresponding to this TextBuilder (allocated on the "stack" when executing in a PoolContext).
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints, toString
    • Constructor Detail

      • TextBuilder

        public TextBuilder()
        Creates a text builder of small initial capacity.
      • TextBuilder

        public TextBuilder(java.lang.CharSequence csq)
        Creates a text builder holding the specified character sequence.
        Parameters:
        csq - the initial character sequence of this text builder.
      • TextBuilder

        public TextBuilder(int capacity)
        Creates a text builder of specified initial capacity. Unless the text length exceeds the specified capacity, operations on this text builder will not allocate memory.
        Parameters:
        capacity - the initial capacity.
    • Method Detail

      • newInstance

        public static TextBuilder newInstance()
        Returns a text builder allocated from the "stack" when executing in a PoolContext).
        Returns:
        a new, preallocated or recycled text builder instance.
      • length

        public final int length()
        Returns the length (character count) of this text builder.
        Specified by:
        length in interface java.lang.CharSequence
        Returns:
        the number of characters (16-bits Unicode).
      • charAt

        public final char charAt(int index)
        Returns the character at the specified index.
        Specified by:
        charAt in interface java.lang.CharSequence
        Parameters:
        index - the index of the character.
        Returns:
        the character at the specified index.
        Throws:
        java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= this.length()).
      • getChars

        public final void getChars(int srcBegin,
                                   int srcEnd,
                                   char[] dst,
                                   int dstBegin)
        Copies the character from this text builder into the destination character array.
        Parameters:
        srcBegin - this text start index.
        srcEnd - this text end index (not included).
        dst - the destination array to copy the data into.
        dstBegin - the offset into the destination array.
        Throws:
        java.lang.IndexOutOfBoundsException - if (srcBegin < 0) || (dstBegin < 0) || (srcBegin > srcEnd) || (srcEnd > this.length()) || ((dstBegin + srcEnd - srcBegin) > dst.length)
      • setCharAt

        public final void setCharAt(int index,
                                    char c)
        Sets the character at the specified position.
        Parameters:
        index - the index of the character to modify.
        c - the new character.
        Throws:
        java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= this.length())
      • setLength

        public final void setLength(int newLength)
        Sets the length of this character builder. If the length is greater than the current length; the null character '\u0000' is inserted.
        Parameters:
        newLength - the new length of this builder.
        Throws:
        java.lang.IndexOutOfBoundsException - if (newLength < 0)
      • subSequence

        public final java.lang.CharSequence subSequence(int start,
                                                        int end)
        Returns an instance of Text (immutable) corresponding to the character sequence between the specified indexes.
        Specified by:
        subSequence in interface java.lang.CharSequence
        Parameters:
        start - the index of the first character inclusive.
        end - the index of the last character exclusive.
        Returns:
        an immutable character sequence.
        Throws:
        java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())
      • append

        public final TextBuilder append(char c)
        Appends the specified character.
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        c - the character to append.
        Returns:
        this
      • append

        public final TextBuilder append(java.lang.CharSequence csq)
        Appends the specified character sequence. If the specified character sequence is null this method is equivalent to append("null").
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        csq - the character sequence to append or null.
        Returns:
        this
      • append

        public final TextBuilder append(java.lang.CharSequence csq,
                                        int start,
                                        int end)
        Appends a subsequence of the specified character sequence. If the specified character sequence is null this method is equivalent to append("null").
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        csq - the character sequence to append or null.
        start - the index of the first character to append.
        end - the index after the last character to append.
        Returns:
        this
        Throws:
        java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > csq.length())
      • append

        public final TextBuilder append(java.lang.Object obj)
        Appends the textual representation of the specified object. If the specified object is null this method is equivalent to append("null").
        Parameters:
        obj - the object to represent or null.
        Returns:
        this
      • append

        public final TextBuilder append(java.lang.String str)
        Appends the specified string to this text builder. If the specified string is null this method is equivalent to append("null").
        Parameters:
        str - the string to append or null.
        Returns:
        this
      • append

        public final TextBuilder append(java.lang.String str,
                                        int start,
                                        int end)
        Appends a subsequence of the specified string. If the specified character sequence is null this method is equivalent to append("null").
        Parameters:
        str - the string to append or null.
        start - the index of the first character to append.
        end - the index after the last character to append.
        Returns:
        this
        Throws:
        java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > csq.length())
      • append

        public TextBuilder append(Text text)
        Appends the specified text to this text builder. If the specified text is null this method is equivalent to append("null").
        Parameters:
        text - the text to append or null.
        Returns:
        this
      • append

        public final TextBuilder append(char[] chars)
        Appends the characters from the char array argument.
        Parameters:
        chars - the character array source.
        Returns:
        this
      • append

        public final TextBuilder append(char[] chars,
                                        int offset,
                                        int length)
        Appends the characters from a subarray of the char array argument.
        Parameters:
        chars - the character array source.
        offset - the index of the first character to append.
        length - the number of character to append.
        Returns:
        this
        Throws:
        java.lang.IndexOutOfBoundsException - if (offset < 0) || (length < 0) || ((offset + length) > chars.length)
      • append

        public final TextBuilder append(boolean b)
        Appends the textual representation of the specified boolean (equivalent to TypeFormat.format(b, this)).
        Parameters:
        b - the boolean to format.
        Returns:
        this
        See Also:
        TypeFormat
      • append

        public final TextBuilder append(int i)
        Appends the decimal representation of the specified int (equivalent to TypeFormat.format(i, this)).
        Parameters:
        i - the int to format.
        Returns:
        this
        See Also:
        TypeFormat
      • append

        public final TextBuilder append(int i,
                                        int radix)
        Appends the radix representation of the specified int argument.
        Parameters:
        i - the int to format.
        radix - the radix (e.g. 16 for hexadecimal).
        Returns:
        this
        See Also:
        TypeFormat
      • append

        public final TextBuilder append(long l)
        Appends the decimal representation of the specified long (equivalent to TypeFormat.format(l, this)).
        Parameters:
        l - the long to format.
        Returns:
        this
        See Also:
        TypeFormat
      • append

        public final TextBuilder append(long l,
                                        int radix)
        Appends the radix representation of the specified long argument.
        Parameters:
        l - the long to format.
        radix - the radix (e.g. 16 for hexadecimal).
        Returns:
        this
        See Also:
        TypeFormat
      • append

        public final TextBuilder append(float f)
        Appends the textual representation of the specified float (equivalent to TypeFormat.format(f, this)).
        Parameters:
        f - the float to format.
        Returns:
        this
        See Also:
        /
      • append

        public final TextBuilder append(double d)
        Appends the textual representation of the specified double (equivalent to TypeFormat.format(d, this)).
        Parameters:
        d - the double to format.
        Returns:
        this
        See Also:
        /
      • append

        public final TextBuilder append(double value,
                                        int digits,
                                        boolean scientific,
                                        boolean showZero)
        Appends the specified double value according to the specified formatting arguments.
        Parameters:
        value - the double value.
        digits - the number of significative digits (excludes exponent).
        scientific - true to forces the use of the scientific notation (e.g. 1.23E3); false otherwise.
        showZero - true if trailing fractional zeros are represented; false otherwise.
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if ((digits > 19) || (digits <= 0))) /
      • insert

        public final TextBuilder insert(int index,
                                        java.lang.CharSequence csq)
        Inserts the specified character sequence at the specified location.
        Parameters:
        index - the insertion position.
        csq - the character sequence being inserted.
        Returns:
        this
        Throws:
        java.lang.IndexOutOfBoundsException - if (index < 0) || (index > this.length())
      • delete

        public final TextBuilder delete(int start,
                                        int end)
        Removes the characters between the specified indices.
        Parameters:
        start - the beginning index, inclusive.
        end - the ending index, exclusive.
        Returns:
        this
        Throws:
        java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())
      • reverse

        public final TextBuilder reverse()
        Reverses this character sequence.
        Returns:
        this
      • reset

        public final void reset()
        Resets this text builder for reuse (sets its length to 0).
        Specified by:
        reset in interface Reusable
      • hashCode

        public final int hashCode()
        Returns the hash code for this text builder.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code value.
      • equals

        public final boolean equals(java.lang.Object obj)
        Compares this text builder against the specified object for equality. Returns true if the specified object is a text builder having the same character content.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare with or null.
        Returns:
        true if that is a text builder with the same character content as this text; false otherwise.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.