test_class.file: ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/CharSequenceAccessorTest.java
test_class.identifier: CharSequenceAccessorTest
test_case.body: @Test
      public void usage() throws Exception {
          try {
              String s0 = "test";
              CharArrayWrapper wrapper = CharSequenceAccessor.access(s0);
              Assert.assertEquals(0, wrapper.offset);
              Assert.assertEquals(4, wrapper.length);
              Assert.assertArrayEquals(new char[] { 't','e','s','t' }, wrapper.value);
  
              // this usually retains same char[] but adjusts offset (may differ between JVMs)
              String s1 = s0.substring(1);
              wrapper = CharSequenceAccessor.access(s1);
              Assert.assertEquals(1, wrapper.offset);
              Assert.assertEquals(3, wrapper.length);
              Assert.assertArrayEquals(new char[] { 't','e','s','t' }, wrapper.value);
  
              StringBuilder sb = new StringBuilder("test");
              wrapper = CharSequenceAccessor.access(sb);
              Assert.assertEquals(0, wrapper.offset);
              Assert.assertEquals(4, wrapper.length);
              // appears JVM actually creates a default size of 20 -- more than 4 -- only compare first 4 chars
              Assert.assertArrayEquals(new char[] { 't','e','s','t' }, Arrays.copyOf(wrapper.value, 4));
  
              // stringbuffer isn't supported -- should return null
              StringBuffer sbf = new StringBuffer("test");
              wrapper = CharSequenceAccessor.access(sbf);
              Assert.assertNull(wrapper);
          } catch (Throwable t) {
              System.out.println("WARN: CharSequenceAccessor tests failed... optimizations disabled");
          }
      }
test_case.class_method_signature: CharSequenceAccessorTest.usage()
test_case.full_signature: @Test public void usage()
test_case.identifier: usage
test_case.invocations: access assertEquals assertEquals assertArrayEquals substring access assertEquals assertEquals assertArrayEquals access assertEquals assertEquals assertArrayEquals copyOf access assertNull println
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void usage()
focal_class.declarator: stringConstructor
focal_class.modifier: static private final
focal_class.original_string: static private final Constructor<String> stringConstructor;
focal_class.type: Constructor<String>
focal_class.var_name: stringConstructor
focal_class.declarator: stringValueField
focal_class.modifier: static private final
focal_class.original_string: static private final Field stringValueField;
focal_class.type: Field
focal_class.var_name: stringValueField
focal_class.declarator: stringOffsetField
focal_class.modifier: static private final
focal_class.original_string: static private final Field stringOffsetField;
focal_class.type: Field
focal_class.var_name: stringOffsetField
focal_class.declarator: stringCountField
focal_class.modifier: static private final
focal_class.original_string: static private final Field stringCountField;
focal_class.type: Field
focal_class.var_name: stringCountField
focal_class.declarator: hasStringFields
focal_class.modifier: static private final
focal_class.original_string: static private final boolean hasStringFields;
focal_class.type: boolean
focal_class.var_name: hasStringFields
focal_class.declarator: stringBuilderValueField
focal_class.modifier: static private final
focal_class.original_string: static private final Field stringBuilderValueField;
focal_class.type: Field
focal_class.var_name: stringBuilderValueField
focal_class.declarator: stringBuilderCountField
focal_class.modifier: static private final
focal_class.original_string: static private final Field stringBuilderCountField;
focal_class.type: Field
focal_class.var_name: stringBuilderCountField
focal_class.declarator: hasStringBuilderFields
focal_class.modifier: static private final
focal_class.original_string: static private final boolean hasStringBuilderFields;
focal_class.type: boolean
focal_class.var_name: hasStringBuilderFields
focal_class.file: ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/CharSequenceAccessor.java
focal_class.identifier: CharSequenceAccessor
focal_class.class_method_signature: CharSequenceAccessor.access(CharSequence str)
focal_class.full_signature: static public CharArrayWrapper access(CharSequence str)
focal_class.identifier: access
focal_class.modifiers: static public
focal_class.parameters: (CharSequence str)
focal_class.return: CharArrayWrapper
focal_class.signature: CharArrayWrapper access(CharSequence str)
focal_class.class_method_signature: CharSequenceAccessor.createOptimizedString(char[] buffer, int offset, int length)
focal_class.full_signature: static public String createOptimizedString(char[] buffer, int offset, int length)
focal_class.identifier: createOptimizedString
focal_class.modifiers: static public
focal_class.parameters: (char[] buffer, int offset, int length)
focal_class.return: String
focal_class.signature: String createOptimizedString(char[] buffer, int offset, int length)
focal_class.class_method_signature: CharSequenceAccessor.updateStringBuilder(StringBuilder sb, int newLength)
focal_class.full_signature: static public void updateStringBuilder(StringBuilder sb, int newLength)
focal_class.identifier: updateStringBuilder
focal_class.modifiers: static public
focal_class.parameters: (StringBuilder sb, int newLength)
focal_class.return: void
focal_class.signature: void updateStringBuilder(StringBuilder sb, int newLength)
focal_method.body: static public CharArrayWrapper access(CharSequence str) {
          if (str == null) {
              return null;
          }
          try {
              if (str instanceof String) {
                  if (hasStringFields) {
                      CharArrayWrapper w = new CharArrayWrapper();
                      w.value = (char[])stringValueField.get(str);
                      w.offset = stringOffsetField.getInt(str);
                      w.length = stringCountField.getInt(str);
                      return w;
                  }
              } else if (str instanceof StringBuilder) {
                  if (hasStringBuilderFields) {
                      CharArrayWrapper w = new CharArrayWrapper();
                      w.value = (char[])stringBuilderValueField.get(str);
                      w.length = stringBuilderCountField.getInt(str);
                      return w;
                  }
              }
          } catch (Throwable t) {
              // do nothing
          }
          return null;
      }
focal_method.class_method_signature: CharSequenceAccessor.access(CharSequence str)
focal_method.full_signature: static public CharArrayWrapper access(CharSequence str)
focal_method.identifier: access
focal_method.invocations: get getInt getInt get getInt
focal_method.modifiers: static public
focal_method.parameters: (CharSequence str)
focal_method.return: CharArrayWrapper
focal_method.signature: CharArrayWrapper access(CharSequence str)