@Test public void calculateUTF8Length() { for (final String input : TEST_DATA) { assertEquals("Incorrect string length calculated for string '"+input+"'",input.getBytes(StandardCharsets.UTF_8).length, StringType.calculateUTF8Length(input)); } }
static int calculateUTF8Length(final String s) { final int stringLength = s.length(); int utf8len = stringLength; int processed = 0; for (; processed < stringLength && s.charAt(processed) < 0x80; processed++) {} if (processed < stringLength) { utf8len = extendedCalculateUTF8Length(s, processed, stringLength, utf8len); } return utf8len; }
StringType extends AbstractPrimitiveType<String> { static int calculateUTF8Length(final String s) { final int stringLength = s.length(); int utf8len = stringLength; int processed = 0; for (; processed < stringLength && s.charAt(processed) < 0x80; processed++) {} if (processed < stringLength) { utf8len = extendedCalculateUTF8Length(s, processed, stringLength, utf8len); } return utf8len; } }
StringType extends AbstractPrimitiveType<String> { static int calculateUTF8Length(final String s) { final int stringLength = s.length(); int utf8len = stringLength; int processed = 0; for (; processed < stringLength && s.charAt(processed) < 0x80; processed++) {} if (processed < stringLength) { utf8len = extendedCalculateUTF8Length(s, processed, stringLength, utf8len); } return utf8len; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); }
StringType extends AbstractPrimitiveType<String> { static int calculateUTF8Length(final String s) { final int stringLength = s.length(); int utf8len = stringLength; int processed = 0; for (; processed < stringLength && s.charAt(processed) < 0x80; processed++) {} if (processed < stringLength) { utf8len = extendedCalculateUTF8Length(s, processed, stringLength, utf8len); } return utf8len; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); @Override Class<String> getTypeClass(); @Override StringEncoding getEncoding(final String val); @Override StringEncoding getCanonicalEncoding(); @Override Collection<StringEncoding> getAllEncodings(); }
StringType extends AbstractPrimitiveType<String> { static int calculateUTF8Length(final String s) { final int stringLength = s.length(); int utf8len = stringLength; int processed = 0; for (; processed < stringLength && s.charAt(processed) < 0x80; processed++) {} if (processed < stringLength) { utf8len = extendedCalculateUTF8Length(s, processed, stringLength, utf8len); } return utf8len; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); @Override Class<String> getTypeClass(); @Override StringEncoding getEncoding(final String val); @Override StringEncoding getCanonicalEncoding(); @Override Collection<StringEncoding> getAllEncodings();  }