com.aspose.tasks

Interfaces

Classes

Exceptions

com.aspose.tasks

Class StringBuilder



  • public final class StringBuilder
    extends Object
    Represents a mutable string of characters. Cannot be extended.
    • Constructor Summary

      Constructors 
      Constructor and Description
      StringBuilder()
      Initializes a new instance of the StringBuilder class.
      StringBuilder(int capacity)
      Initializes a new instance of the StringBuilder class using the specified capacity.
      StringBuilder(int capacity, int maxCapacity)
      Initializes a new instance of the StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
      StringBuilder(String value)
      Initializes a new instance of the StringBuilder class using the specified string.
      StringBuilder(String value, int capacity)
      Initializes a new instance of the StringBuilder class using the specified string and capacity.
      StringBuilder(String value, int startIndex, int length, int capacity)
      Initializes a new instance of the StringBuilder class from the specified substring and capacity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      StringBuilder append(BigDecimal value)
      Appends the string representation of a specified BigDecimal number to this instance.
      StringBuilder append(boolean value)
      Appends the string representation of a specified boolean value to this instance.
      StringBuilder append(byte value)
      Appends the string representation of a specified byte to this instance.
      StringBuilder append(char value)
      Appends the string representation of a specified Unicode character to this instance.
      StringBuilder append(char[] value)
      Appends the string representation of the Unicode characters in a specified array to this instance.
      StringBuilder append(char[] value, int startIndex, int charCount)
      Appends the string representation of a specified subarray of Unicode characters to this instance.
      StringBuilder append(char value, int repeatCount)
      Appends a specified number of copies of the string representation of a Unicode character to this instance.
      StringBuilder append(double value)
      Appends the string representation of a specified double number to this instance.
      StringBuilder append(float value)
      Appends the string representation of a specified float number to this instance.
      StringBuilder append(int value)
      Appends the string representation of a specified int number to this instance.
      StringBuilder append(long value)
      Appends the string representation of a specified long number to this instance.
      StringBuilder append(Object value)
      Appends the string representation of a specified object to this instance.
      StringBuilder append(short value)
      Appends the string representation of a specified short number to this instance.
      StringBuilder append(String value)
      Appends a copy of the specified string to this instance.
      StringBuilder append(String value, int startIndex, int count)
      Appends a copy of a specified substring to this instance.
      StringBuilder appendFormat(String format, Object... args)
      Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
      StringBuilder appendLine()
      Appends the default line terminator to the end of the current StringBuilder object.
      StringBuilder appendLine(String value)
      Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.
      void copyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
      Copies the characters from a specified segment of this instance to a specified segment of a destination Char array.
      int ensureCapacity(int capacity)
      Ensures that the capacity of this instance of StringBuilder is at least the specified value.
      boolean equals(Object obj)
      Returns a value indicating whether this instance is equal to a specified object.
      int getCapacity()
      Gets the maximum number of characters that can be contained in the memory allocated by the current instance.
      int getLength()
      Gets the length of the current StringBuilder object.
      int getMaxCapacity()
      Gets the maximum capacity of this instance.
      int hashCode()
      Returns a hash code for this StringBuilder.
      StringBuilder insert(int index, BigDecimal value)
      Inserts the string representation of a decimal number into this instance at the specified character position.
      StringBuilder insert(int index, boolean value)
      Inserts the string representation of a boolean value into this instance at the specified character position.
      StringBuilder insert(int index, byte value)
      Inserts the string representation of a byte value into this instance at the specified character position.
      StringBuilder insert(int index, char value)
      Inserts the string representation of a specified Unicode character into this instance at the specified character position.
      StringBuilder insert(int index, char[] value)
      Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.
      StringBuilder insert(int index, char[] value, int startIndex, int charCount)
      Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.
      StringBuilder insert(int index, double value)
      Inserts the string representation of a double number into this instance at the specified character position.
      StringBuilder insert(int index, float value)
      Inserts the string representation of a float number into this instance at the specified character position.
      StringBuilder insert(int index, int value)
      Inserts the string representation of an int number into this instance at the specified character position.
      StringBuilder insert(int index, long value)
      Inserts the string representation of a long number into this instance at the specified character position.
      StringBuilder insert(int index, Object value)
      Inserts the string representation of an object into this instance at the specified character position.
      StringBuilder insert(int index, short value)
      Inserts the string representation of a short number into this instance at the specified character position.
      StringBuilder insert(int index, String value)
      Inserts a string into this instance at the specified character position.
      StringBuilder insert(int index, String value, int count)
      Inserts one or more copies of a specified string into this instance at the specified character position.
      StringBuilder remove(int startIndex, int length)
      Removes the specified range of characters from this instance.
      StringBuilder replace(char oldChar, char newChar)
      Replaces all occurrences of a specified character in this instance with another specified character.
      StringBuilder replace(char oldValue, char newValue, int startIndex, int count)
      Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.
      StringBuilder replace(String oldValue, String newValue)
      Replaces all occurrences of a specified string in this instance with another specified string.
      StringBuilder replace(String oldValue, String newValue, int startIndex, int count)
      Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
      void setCapacity(int value)
      Sets the maximum number of characters that can be contained in the memory allocated by the current instance.
      void setLength(int value)
      Sets the length of the current StringBuilder object.
      String toString()
      Converts the value of this instance to a String.
      String toString(int startIndex, int length)
      Converts the value of a substring of this instance to a String.
    • Constructor Detail

      • StringBuilder

        public StringBuilder()
        Initializes a new instance of the StringBuilder class.
      • StringBuilder

        public StringBuilder(int capacity)
        Initializes a new instance of the StringBuilder class using the specified capacity.
        Parameters:
        capacity - The suggested starting size of this instance.
      • StringBuilder

        public StringBuilder(int capacity,
                             int maxCapacity)
        Initializes a new instance of the StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
        Parameters:
        capacity - The suggested starting size of the StringBuilder.
        maxCapacity - The maximum number of characters the current string can contain.
      • StringBuilder

        public StringBuilder(String value)
        Initializes a new instance of the StringBuilder class using the specified string.
        Parameters:
        value - The string used to initialize the value of the instance.
      • StringBuilder

        public StringBuilder(String value,
                             int capacity)
        Initializes a new instance of the StringBuilder class using the specified string and capacity.
        Parameters:
        value - The string used to initialize the value of the instance.
        capacity - The suggested starting size of the StringBuilder.
      • StringBuilder

        public StringBuilder(String value,
                             int startIndex,
                             int length,
                             int capacity)
        Initializes a new instance of the StringBuilder class from the specified substring and capacity.
        Parameters:
        value - The string that contains the substring used to initialize the value of this instance.
        startIndex - The position within value where the substring begins.
        length - The number of characters in the substring.
        capacity - The suggested starting size of the StringBuilder.
    • Method Detail

      • getCapacity

        public int getCapacity()
        Gets the maximum number of characters that can be contained in the memory allocated by the current instance.
        Returns:
        The maximum number of characters that can be contained in the memory allocated by the current instance.
      • setCapacity

        public void setCapacity(int value)
        Sets the maximum number of characters that can be contained in the memory allocated by the current instance.
        Parameters:
        value - The maximum number of characters that can be contained in the memory allocated by the current instance.
      • getLength

        public int getLength()
        Gets the length of the current StringBuilder object.
        Returns:
        The length of this instance.
      • setLength

        public void setLength(int value)
        Sets the length of the current StringBuilder object.
        Parameters:
        value - The length of this instance.
      • getMaxCapacity

        public int getMaxCapacity()
        Gets the maximum capacity of this instance.
        Returns:
        The maximum number of characters this instance can hold.
      • append

        public StringBuilder append(String value)
        Appends a copy of the specified string to this instance.
        Parameters:
        value - The string to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(boolean value)
        Appends the string representation of a specified boolean value to this instance.
        Parameters:
        value - The boolean value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(BigDecimal value)
        Appends the string representation of a specified BigDecimal number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(double value)
        Appends the string representation of a specified double number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(short value)
        Appends the string representation of a specified short number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(int value)
        Appends the string representation of a specified int number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(char value)
        Appends the string representation of a specified Unicode character to this instance.
        Parameters:
        value - The Unicode character to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(char value,
                                    int repeatCount)
        Appends a specified number of copies of the string representation of a Unicode character to this instance.
        Parameters:
        value - The character to append.
        repeatCount - The number of times to append value.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(char[] value,
                                    int startIndex,
                                    int charCount)
        Appends the string representation of a specified subarray of Unicode characters to this instance.
        Parameters:
        value - A character array.
        startIndex - The starting position in value.
        charCount - The number of characters to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(String value,
                                    int startIndex,
                                    int count)
        Appends a copy of a specified substring to this instance.
        Parameters:
        value - The string that contains the substring to append.
        startIndex - The starting position of the substring within value.
        count - The number of characters in value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(long value)
        Appends the string representation of a specified long number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(Object value)
        Appends the string representation of a specified object to this instance.
        Parameters:
        value - The object to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(byte value)
        Appends the string representation of a specified byte to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(float value)
        Appends the string representation of a specified float number to this instance.
        Parameters:
        value - The value to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • append

        public StringBuilder append(char[] value)
        Appends the string representation of the Unicode characters in a specified array to this instance.
        Parameters:
        value - The array of characters to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • appendFormat

        public StringBuilder appendFormat(String format,
                                          Object... args)
        Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array.
        Parameters:
        format - A composite format string.
        args - An array of objects to format.
        Returns:
        A reference to this instance with format appended. Each format item in format is replaced by the string representation of the corresponding object argument.
      • appendLine

        public StringBuilder appendLine(String value)
        Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.
        Parameters:
        value - The string to append.
        Returns:
        A reference to this instance after the append operation has completed.
      • appendLine

        public StringBuilder appendLine()
        Appends the default line terminator to the end of the current StringBuilder object.
        Returns:
        A reference to this instance after the append operation has completed.
      • copyTo

        public void copyTo(int sourceIndex,
                           char[] destination,
                           int destinationIndex,
                           int count)
        Copies the characters from a specified segment of this instance to a specified segment of a destination Char array.
        Parameters:
        sourceIndex - The starting position in this instance where characters will be copied from. The index is zero-based.
        destination - The array where characters will be copied.
        destinationIndex - The starting position in destination where characters will be copied. The index is zero-based.
        count - The number of characters to be copied.
      • ensureCapacity

        public int ensureCapacity(int capacity)
        Ensures that the capacity of this instance of StringBuilder is at least the specified value.
        Parameters:
        capacity - The minimum capacity to ensure.
        Returns:
        The new capacity of this instance.
      • equals

        public boolean equals(Object obj)
        Returns a value indicating whether this instance is equal to a specified object.
        Overrides:
        equals in class Object
        Parameters:
        obj - An object to compare with this instance, or null.
        Returns:
        true if this instance and sb have equal string, Capacity, and MaxCapacity values; otherwise, false.
      • hashCode

        public int hashCode()
        Returns a hash code for this StringBuilder.
        Overrides:
        hashCode in class Object
        Returns:
        Returns a hash code value for this object.
      • insert

        public StringBuilder insert(int index,
                                    char value)
        Inserts the string representation of a specified Unicode character into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    BigDecimal value)
        Inserts the string representation of a decimal number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    double value)
        Inserts the string representation of a double number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    short value)
        Inserts the string representation of a short number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    boolean value)
        Inserts the string representation of a boolean value into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    char[] value)
        Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The character array to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    String value)
        Inserts a string into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The string to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    byte value)
        Inserts the string representation of a byte value into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    float value)
        Inserts the string representation of a float number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    String value,
                                    int count)
        Inserts one or more copies of a specified string into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The string to insert.
        count - The number of times to insert value.
        Returns:
        A reference to this instance after insertion has completed.
      • insert

        public StringBuilder insert(int index,
                                    char[] value,
                                    int startIndex,
                                    int charCount)
        Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - A character array.
        startIndex - The starting index within value.
        charCount - The number of characters to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    Object value)
        Inserts the string representation of an object into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The object to insert, or null.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    long value)
        Inserts the string representation of a long number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • insert

        public StringBuilder insert(int index,
                                    int value)
        Inserts the string representation of an int number into this instance at the specified character position.
        Parameters:
        index - The position in this instance where insertion begins.
        value - The value to insert.
        Returns:
        A reference to this instance after the insert operation has completed.
      • remove

        public StringBuilder remove(int startIndex,
                                    int length)
        Removes the specified range of characters from this instance.
        Parameters:
        startIndex - The zero-based position in this instance where removal begins.
        length - The number of characters to remove.
        Returns:
        A reference to this instance after the remove operation has completed.
      • replace

        public StringBuilder replace(char oldChar,
                                     char newChar)
        Replaces all occurrences of a specified character in this instance with another specified character.
        Parameters:
        oldChar - The character to replace.
        newChar - The character that replaces oldChar.
        Returns:
        A reference to this instance with oldChar replaced by newChar.
      • replace

        public StringBuilder replace(String oldValue,
                                     String newValue,
                                     int startIndex,
                                     int count)
        Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
        Parameters:
        oldValue - The string to replace.
        newValue - The string that replaces oldValue, or null.
        startIndex - The position in this instance where the substring begins.
        count - The length of the substring.
        Returns:
        A reference to this instance with all instances of oldValue replaced by newValue in the range from startIndex to startIndex + count - 1.
      • replace

        public StringBuilder replace(String oldValue,
                                     String newValue)
        Replaces all occurrences of a specified string in this instance with another specified string.
        Parameters:
        oldValue - The string to replace.
        newValue - The string that replaces oldValue, or null.
        Returns:
        A reference to this instance with all instances of oldValue replaced by newValue.
      • replace

        public StringBuilder replace(char oldValue,
                                     char newValue,
                                     int startIndex,
                                     int count)
        Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.
        Parameters:
        oldValue - The character to replace.
        newValue - The character that replaces oldChar.
        startIndex - The position in this instance where the substring begins.
        count - The length of the substring.
        Returns:
        A reference to this instance with oldChar replaced by newChar in the range from startIndex to startIndex + count -1.
      • toString

        public String toString()
        Converts the value of this instance to a String.
        Overrides:
        toString in class Object
        Returns:
        A string whose value is the same as this instance.
      • toString

        public String toString(int startIndex,
                               int length)
        Converts the value of a substring of this instance to a String.
        Parameters:
        startIndex - The starting position of the substring in this instance.
        length - The length of the substring.
        Returns:
        A string whose value is the same as the specified substring of this instance.