@Test public void testCharAt() throws Exception { byte[] bytes = "FOOBAR".getBytes("UTF-8"); { ByteArrayCharSequence bacs = new ByteArrayCharSequence(bytes, 0, bytes.length); int i = 0; assertEquals('F', bacs.charAt(i++)); assertEquals('O', bacs.charAt(i++)); assertEquals('O', bacs.charAt(i++)); assertEquals('B', bacs.charAt(i++)); assertEquals('A', bacs.charAt(i++)); assertEquals('R', bacs.charAt(i)); } { ByteArrayCharSequence bacs = new ByteArrayCharSequence(bytes, 1, 5); int i = 0; assertEquals('O', bacs.charAt(i++)); assertEquals('O', bacs.charAt(i++)); assertEquals('B', bacs.charAt(i++)); assertEquals('A', bacs.charAt(i)); } }
@Override public char charAt(int index) { return (char) (bytes[index + start] & 0xFF); }
ByteArrayCharSequence implements CharSequence { @Override public char charAt(int index) { return (char) (bytes[index + start] & 0xFF); } }
ByteArrayCharSequence implements CharSequence { @Override public char charAt(int index) { return (char) (bytes[index + start] & 0xFF); } ByteArrayCharSequence(byte[] bytes, int start, int end); }
ByteArrayCharSequence implements CharSequence { @Override public char charAt(int index) { return (char) (bytes[index + start] & 0xFF); } ByteArrayCharSequence(byte[] bytes, int start, int end); @Override int length(); @Override char charAt(int index); @Override ByteArrayCharSequence subSequence(int start, int end); @Override String toString(); static byte[] toSingleByteUtf8Encoding(CharSequence charSequence); }
ByteArrayCharSequence implements CharSequence { @Override public char charAt(int index) { return (char) (bytes[index + start] & 0xFF); } ByteArrayCharSequence(byte[] bytes, int start, int end); @Override int length(); @Override char charAt(int index); @Override ByteArrayCharSequence subSequence(int start, int end); @Override String toString(); static byte[] toSingleByteUtf8Encoding(CharSequence charSequence);  }