Package org.apache.shiro.lang.util
Class ByteSource.Util
java.lang.Object
org.apache.shiro.lang.util.ByteSource.Util
- Enclosing interface:
ByteSource
Utility class that can construct ByteSource instances. This is slightly nicer than needing to know the
ByteSource implementation class to use.- Since:
- 1.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteSourcebytes(byte[] bytes) Returns a newByteSourceinstance representing the specified byte array.static ByteSourcebytes(char[] chars) Returns a newByteSourceinstance representing the specified character array's bytes.static ByteSourceReturns a newByteSourceinstance representing the specified File's bytes.static ByteSourcebytes(InputStream stream) Returns a newByteSourceinstance representing the specified InputStream's bytes.static ByteSourceReturns aByteSourceinstance representing the specified byte source argument.static ByteSourceReturns a newByteSourceinstance representing the specified string's bytes.static ByteSourcebytes(ByteSource source) Returns a newByteSourceinstance representing the specified ByteSource.static booleanisCompatible(Object source) Returnstrueif the specified object can be easily represented as aByteSourceusing theByteSource.Util's default heuristics,falseotherwise.
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
bytes
Returns a newByteSourceinstance representing the specified byte array.- Parameters:
bytes- the bytes to represent as aByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified byte array.
-
bytes
Returns a newByteSourceinstance representing the specified character array's bytes. The byte array is obtained assumingUTF-8encoding.- Parameters:
chars- the character array to represent as aByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified character array's bytes.
-
bytes
Returns a newByteSourceinstance representing the specified string's bytes. The byte array is obtained assumingUTF-8encoding.- Parameters:
string- the string to represent as aByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified string's bytes.
-
bytes
Returns a newByteSourceinstance representing the specified ByteSource.- Parameters:
source- the ByteSource to represent as a newByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified ByteSource.
-
bytes
Returns a newByteSourceinstance representing the specified File's bytes.- Parameters:
file- the file to represent as aByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified File's bytes.
-
bytes
Returns a newByteSourceinstance representing the specified InputStream's bytes.- Parameters:
stream- the InputStream to represent as aByteSourceinstance.- Returns:
- a new
ByteSourceinstance representing the specified InputStream's bytes.
-
isCompatible
Returnstrueif the specified object can be easily represented as aByteSourceusing theByteSource.Util's default heuristics,falseotherwise. This implementation merely returnsSimpleByteSource.isCompatible(source).- Parameters:
source- the object to test to see if it can be easily converted to ByteSource instances using default heuristics.- Returns:
trueif the specified object can be easily represented as aByteSourceusing theByteSource.Util's default heuristics,falseotherwise.
-
bytes
Returns aByteSourceinstance representing the specified byte source argument. If the argument cannot be easily converted to bytes (as is indicated by theisCompatible(Object)JavaDoc), this method will throw anIllegalArgumentException.- Parameters:
source- the byte-backed instance that should be represented as aByteSourceinstance.- Returns:
- a
ByteSourceinstance representing the specified byte source argument. - Throws:
IllegalArgumentException- if the argument cannot be easily converted to bytes (as indicated by theisCompatible(Object)JavaDoc)
-