Package fr.dyade.aaa.common.encoding
Class EncodableHelper
- java.lang.Object
-
- fr.dyade.aaa.common.encoding.EncodableHelper
-
public final class EncodableHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static CharsetcharsetDefault charset used to encode/decode String.static StringENCODING_CHARSET_DFLTstatic StringENCODING_CHARSET_PROPERTYstatic StringENCODING_USE_JVM_CHARSET_PROPERTY(package private) static Loggerloggerprivate static booleanmultibyteAttributes allowing to compute encoded String size.private static booleanutf8
-
Constructor Summary
Constructors Constructor Description EncodableHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PropertiesdecodeProperties(Decoder decoder)static voidencodeProperties(Properties properties, Encoder encoder)static intgetByteArrayEncodedSize(byte[] byteArray)static intgetEncodedSize(Properties properties)static intgetNullableByteArrayEncodedSize(byte[] byteArray)static intgetNullableByteArrayEncodedSize(byte[] byteArray, int length)static intgetNullableStringEncodedSize(String s)Returns the size of an encoded string which value may be null.static intgetStringEncodedSize(String s)Returns the size of an encoded string.
-
-
-
Field Detail
-
logger
static Logger logger
-
ENCODING_CHARSET_PROPERTY
public static final String ENCODING_CHARSET_PROPERTY
- See Also:
- Constant Field Values
-
ENCODING_USE_JVM_CHARSET_PROPERTY
public static final String ENCODING_USE_JVM_CHARSET_PROPERTY
- See Also:
- Constant Field Values
-
ENCODING_CHARSET_DFLT
public static final String ENCODING_CHARSET_DFLT
- See Also:
- Constant Field Values
-
charset
static final Charset charset
Default charset used to encode/decode String.
-
multibyte
private static final boolean multibyte
Attributes allowing to compute encoded String size.
-
utf8
private static final boolean utf8
-
-
Method Detail
-
getStringEncodedSize
public static final int getStringEncodedSize(String s)
Returns the size of an encoded string. Be careful, String are now encoded as UTF-8.- Parameters:
s- the string to encode- Returns:
- the size of the encoded string
-
getNullableStringEncodedSize
public static final int getNullableStringEncodedSize(String s)
Returns the size of an encoded string which value may be null. Be careful, String are now encoded as UTF-8.- Parameters:
s- the string to encode- Returns:
- the size of the encoded string
-
getByteArrayEncodedSize
public static final int getByteArrayEncodedSize(byte[] byteArray)
-
getNullableByteArrayEncodedSize
public static final int getNullableByteArrayEncodedSize(byte[] byteArray)
-
getNullableByteArrayEncodedSize
public static final int getNullableByteArrayEncodedSize(byte[] byteArray, int length)
-
getEncodedSize
public static int getEncodedSize(Properties properties) throws Exception
- Throws:
Exception
-
encodeProperties
public static void encodeProperties(Properties properties, Encoder encoder) throws Exception
- Throws:
Exception
-
decodeProperties
public static Properties decodeProperties(Decoder decoder) throws Exception
- Throws:
Exception
-
-