CharSequences (Grails 6.0.0)

Package: org.grails.charsequences

## [Java] Class CharSequences

- org.grails.charsequences.CharSequences

-     public class CharSequences
      extends java.lang.Object

  Utility functions for handling java.lang.CharSequence instances

  Authors:
    Lari Hotari
  Since:
    2.3.10

- - ### Constructor Summary

    Constructors
    Constructor and description
    `private CharSequences ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static boolean` | `canUseOriginalForSubSequence(java.lang.CharSequence str, int start, int count)` Checks if start == 0 and count == length of CharSequence It does this check only for String, StringBuilder and StringBuffer classes which have a fast way to check length
    `` | `public static java.lang.CharSequence` | `createCharSequence(char[] chars)`
    `` | `public static java.lang.CharSequence` | `createCharSequence(char[] chars, int start, int count)`
    `` | `public static java.lang.CharSequence` | `createCharSequence(java.lang.CharSequence str, int start, int count)`
    `` | `public static java.lang.CharSequence` | `createSingleCharSequence(int c)`
    `` | `public static java.lang.CharSequence` | `createSingleCharSequence(char ch)`
    `` | `public static void` | `getChars(java.lang.CharSequence csq, int srcBegin, int srcEnd, char[] dst, int dstBegin)` Provides an optimized way to copy CharSequence content to target array.
    `` | `public static void` | `writeCharSequence(java.io.Writer target, java.lang.CharSequence csq, int start, int end)` Writes a CharSequence instance in the most optimal way to the target writer
    `` | `public static void` | `writeCharSequence(java.io.Writer target, java.lang.CharSequence csq)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### private CharSequences()

  - ### Method Detail

    - #### public static boolean canUseOriginalForSubSequence(java.lang.CharSequence str, int start, int count)

      Checks if start == 0 and count == length of CharSequence It does this check only for String, StringBuilder and StringBuffer classes which have a fast way to check length Calculating length on GStringImpl requires building the result which is costly. This helper method is to avoid calling length on other that String, StringBuilder and StringBuffer classes when checking if the input CharSequence instance is already the same as the requested sub sequence

      Parameters:
        `str` - CharSequence input
        `start` - start index
        `count` - length on sub sequence
      Returns:
        true if input is String, StringBuilder or StringBuffer class, start is 0 and count is length of input sequence

    - #### public static java.lang.CharSequence createCharSequence(char[] chars)

    - #### public static java.lang.CharSequence createCharSequence(char[] chars, int start, int count)

    - #### public static java.lang.CharSequence createCharSequence(java.lang.CharSequence str, int start, int count)

    - #### public static java.lang.CharSequence createSingleCharSequence(int c)

    - #### public static java.lang.CharSequence createSingleCharSequence(char ch)

    - #### public static void getChars(java.lang.CharSequence csq, int srcBegin, int srcEnd, char[] dst, int dstBegin)

      Provides an optimized way to copy CharSequence content to target array. Uses getChars method available on String, StringBuilder and StringBuffer classes. Characters are copied from the source sequence `csq` into the destination character array `dst`. The first character to be copied is at index `srcBegin`; the last character to be copied is at index `srcEnd-1`. The total number of characters to be copied is `srcEnd-srcBegin`. The characters are copied into the subarray of `dst` starting at index `dstBegin` and ending at index:

      >      dstbegin + (srcEnd-srcBegin) - 1

      throws:
        NullPointerException if `dst` is `null`.
      throws:
        IndexOutOfBoundsException if any of the following is true:
        - `srcBegin` is negative
        - `dstBegin` is negative
        - the `srcBegin` argument is greater than the `srcEnd` argument.
        - `srcEnd` is greater than `this.length()`.
        - `dstBegin+srcEnd-srcBegin` is greater than `dst.length`
      Parameters:
        `csq` - the source CharSequence instance.
        `srcBegin` - start copying at this offset.
        `srcEnd` - stop copying at this offset.
        `dst` - the array to copy the data into.
        `dstBegin` - offset into `dst`.

    - #### public static void writeCharSequence(java.io.Writer target, java.lang.CharSequence csq, int start, int end)

      Writes a CharSequence instance in the most optimal way to the target writer

      throws:
        IOException
      Parameters:
        `target` - writer
        `csq` - source CharSequence instance
        `start` - start/offset index
        `end` - end index + 1

    - #### public static void writeCharSequence(java.io.Writer target, java.lang.CharSequence csq)