StringCharArrayAccessor (Grails 6.0.0)

Package: org.grails.buffer

## [Java] Class StringCharArrayAccessor

- org.grails.buffer.StringCharArrayAccessor

-     public class StringCharArrayAccessor
      extends java.lang.Object

  Provides optimized access to java.lang.String internals - Optimized way of creating java.lang.String by reusing a char[] buffer - Optimized way of writing String to java.io.Writer java.lang.String creation reusing a char[] buffer requires Java 1.5+ System property "stringchararrayaccessor.disabled" disables this hack. -Dstringchararrayaccessor.disabled=true Read JSR-133, "9.1.1 Post-Construction Modification of Final Fields" http://www.cs.umd.edu/~pugh/java/memoryModel/jsr133.pdf

  Authors:
    Lari Hotari, Sagire Software Oy

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.reflect.Field` | `countField` |
    `static boolean` | `enabled` |
    `static boolean` | `jdk7_string` |
    `static java.lang.reflect.Field` | `offsetField` |
    `static java.lang.reflect.Field` | `valueField` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `private StringCharArrayAccessor ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static java.lang.String` | `createString(char[] charBuf)` creates a new java.lang.String by setting the char array directly to the String instance with reflection.
    `` | `private static java.lang.String` | `createStringFallback(char[] charBuf)`
    `` | `static char[]` | `getValue(java.lang.String str)`
    `` | `static char[]` | `getValueFallback(java.lang.String str)`
    `` | `private static void` | `handleError(java.lang.Exception e)`
    `` | `public static boolean` | `isEnabled()`
    `` | `public static void` | `writeStringAsCharArray(java.io.Writer writer, java.lang.String str)` Writes a portion of a string to a target java.io.Writer with direct access to the char[] of the java.lang.String
    `` | `public static void` | `writeStringAsCharArray(java.io.Writer writer, java.lang.String str, int off, int len)` Writes a portion of a string to a target java.io.Writer with direct access to the char[] of the java.lang.String
    `` | `private static void` | `writeStringFallback(java.io.Writer writer, java.lang.String str, int off, int len)`

  - ### 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()`

- - ### Field Detail

    - #### static java.lang.reflect.Field countField

    - #### static boolean enabled

    - #### static boolean jdk7_string

    - #### static java.lang.reflect.Field offsetField

    - #### static java.lang.reflect.Field valueField

  - ### Constructor Detail

    - #### private StringCharArrayAccessor()

  - ### Method Detail

    - #### public static java.lang.String createString(char[] charBuf)

      creates a new java.lang.String by setting the char array directly to the String instance with reflection.

      Parameters:
        `charBuf` - char array to be used as java.lang.String content, don't modify it after passing it.
      Returns:
        new java.lang.String

    - #### private static java.lang.String createStringFallback(char[] charBuf)

    - #### static char[] getValue(java.lang.String str)

    - #### static char[] getValueFallback(java.lang.String str)

    - #### private static void handleError(java.lang.Exception e)

    - #### public static boolean isEnabled()

    - #### public static void writeStringAsCharArray(java.io.Writer writer, java.lang.String str)

      Writes a portion of a string to a target java.io.Writer with direct access to the char[] of the java.lang.String

      throws:
        IOException If an I/O error occurs
      Parameters:
        `writer` - target java.io.Writer for output
        `str` - A String

    - #### public static void writeStringAsCharArray(java.io.Writer writer, java.lang.String str, int off, int len)

      Writes a portion of a string to a target java.io.Writer with direct access to the char[] of the java.lang.String

      throws:
        IOException If an I/O error occurs
      Parameters:
        `writer` - target java.io.Writer for output
        `str` - A String
        `off` - Offset from which to start writing characters
        `len` - Number of characters to write

    - #### private static void writeStringFallback(java.io.Writer writer, java.lang.String str, int off, int len)