public abstract class CodecSupport extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
PREFERRED_ENCODING
Shiro's default preferred character encoding, equal to
UTF-8. |
| 构造器和说明 |
|---|
CodecSupport() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
toBytes(char[] chars) |
static byte[] |
toBytes(char[] chars,
String encoding) |
static byte[] |
toBytes(String source)
Converts the specified source argument to a byte array with Shiro's
PREFERRED_ENCODING. |
static byte[] |
toBytes(String source,
String encoding)
Converts the specified source to a byte array via the specified encoding, throwing a
CodecException if the encoding fails. |
static char[] |
toChars(byte[] bytes)
Returns the specified byte array as a character array using the
PREFERRED_ENCODING. |
static char[] |
toChars(byte[] bytes,
String encoding) |
static String |
toString(byte[] bytes)
Converts the specified byte array to a String using the
PREFERRED_ENCODING. |
static String |
toString(byte[] bytes,
String encoding)
Converts the specified byte array to a String using the specified character encoding.
|
public static byte[] toBytes(char[] chars)
chars - the character array to be converted to a byte array.public static byte[] toBytes(char[] chars,
String encoding)
throws org.apache.shiro.codec.CodecException
chars - the character array to be converted to a byte arrayencoding - the character encoding to use to when converting to bytes.org.apache.shiro.codec.CodecException - if the JVM does not support the specified encoding.public static byte[] toBytes(String source)
PREFERRED_ENCODING.source - the string to convert to a byte array.PREFERRED_ENCODING.toBytes(String, String)public static byte[] toBytes(String source, String encoding) throws org.apache.shiro.codec.CodecException
CodecException if the encoding fails.source - the source string to convert to a byte array.encoding - the encoding to use to use.org.apache.shiro.codec.CodecException - if the JVM does not support the specified encoding.public static String toString(byte[] bytes)
PREFERRED_ENCODING.bytes - the byte array to turn into a String.PREFERRED_ENCODING).toString(byte[], String)public static String toString(byte[] bytes, String encoding) throws org.apache.shiro.codec.CodecException
new String(byte[], encoding), but will
wrap any UnsupportedEncodingException with a nicer runtime CodecException, allowing you to
decide whether or not you want to catch the exception or let it propagate.bytes - the byte array to convert to a Stringencoding - the character encoding used to encode the String.org.apache.shiro.codec.CodecException - if the JVM does not support the specified encoding.public static char[] toChars(byte[] bytes)
PREFERRED_ENCODING.bytes - the byte array to convert to a char arrayPREFERRED_ENCODING).toChars(byte[], String)public static char[] toChars(byte[] bytes,
String encoding)
throws org.apache.shiro.codec.CodecException
bytes - the byte array to convert to a Stringencoding - the character encoding used to encode the bytes.org.apache.shiro.codec.CodecException - if the JVM does not support the specified encoding.Copyright © 2015-2017. All Rights Reserved.