Package org.elasticsearch.common
Class CharArrays
java.lang.Object
org.elasticsearch.common.CharArrays
public final class CharArrays
extends java.lang.Object
Helper class similar to Arrays to handle conversions for Char arrays
- 
Method Summary
Modifier and Type Method Description static booleancharsBeginsWith(java.lang.String prefix, char[] chars)Tests if a char[] contains a sequence of characters that match the prefix.static booleanconstantTimeEquals(char[] a, char[] b)Constant time equality check of char arrays to avoid potential timing attacks.static booleanconstantTimeEquals(java.lang.String a, java.lang.String b)Constant time equality check of strings to avoid potential timing attacks.static byte[]toUtf8Bytes(char[] chars)Encodes the provided char[] to a UTF-8 byte[].static char[]utf8BytesToChars(byte[] utf8Bytes)Decodes the provided byte[] to a UTF-8 char[]. 
- 
Method Details
- 
utf8BytesToChars
public static char[] utf8BytesToChars(byte[] utf8Bytes)Decodes the provided byte[] to a UTF-8 char[]. This is done while avoiding conversions to String. The provided byte[] is not modified by this method, so the caller needs to take care of clearing the value if it is sensitive. - 
toUtf8Bytes
public static byte[] toUtf8Bytes(char[] chars)Encodes the provided char[] to a UTF-8 byte[]. This is done while avoiding conversions to String. The provided char[] is not modified by this method, so the caller needs to take care of clearing the value if it is sensitive. - 
charsBeginsWith
public static boolean charsBeginsWith(java.lang.String prefix, char[] chars)Tests if a char[] contains a sequence of characters that match the prefix. This is likeString.startsWith(String)but does not require conversion of the char[] to a string. - 
constantTimeEquals
public static boolean constantTimeEquals(char[] a, char[] b)Constant time equality check of char arrays to avoid potential timing attacks. - 
constantTimeEquals
public static boolean constantTimeEquals(java.lang.String a, java.lang.String b)Constant time equality check of strings to avoid potential timing attacks. 
 -