Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.web.util
Class StringCharArrayAccessor

    java.lang.Object
      org.codehaus.groovy.grails.web.util.StringCharArrayAccessor

    public class StringCharArrayAccessor

extends 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

Author:
  Lari Hotari, Sagire Software Oy

Field Summary
`(package private) static Field` | `countField`
`(package private) static boolean` | `enabled`
`(package private) static Field` | `offsetField`
`(package private) static Field` | `valueField`

Constructor Summary
`StringCharArrayAccessor()`

Method Summary
`static String` | `createString(char[] charBuf)` creates a new java.lang.String by setting the char array directly to the String instance with reflection.
`(package private) static char[]` | `getValue(String str)`
`(package private) static char[]` | `getValueFallback(String str)`
`static boolean` | `isEnabled()`
`static void` | `writeStringAsCharArray(Writer writer, 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
`static void` | `writeStringAsCharArray(Writer writer, 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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### enabled

    static volatile boolean enabled

### valueField

    static Field valueField

### countField

    static Field countField

### offsetField

    static Field offsetField

Constructor Detail

### StringCharArrayAccessor

    public StringCharArrayAccessor()

Method Detail

### writeStringAsCharArray

    public static void writeStringAsCharArray(Writer writer,
                                              String str)
                                       throws IOException

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

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

### writeStringAsCharArray

    public static void writeStringAsCharArray(Writer writer,
                                              String str,
                                              int off,
                                              int len)
                                       throws IOException

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

  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
  Throws:
    `IOException` - If an I/O error occurs

### getValue

    static char[] getValue(String str)

### getValueFallback

    static char[] getValueFallback(String str)

### createString

    public static 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

### isEnabled

    public static boolean isEnabled()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD