|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.util.SimpleByteSource
public class SimpleByteSource
Very simple ByteSource
implementation that maintains an internal byte[]
array and uses the
Hex
and Base64
codec classes to support the
toHex()
and toBase64()
implementations.
ByteSource
File
InputStream
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.shiro.util.ByteSource |
---|
ByteSource.Util |
Constructor Summary | |
---|---|
SimpleByteSource(byte[] bytes)
|
|
SimpleByteSource(ByteSource source)
Creates an instance using the sources bytes directly - it does not create a copy of the argument's byte array. |
|
SimpleByteSource(char[] chars)
Creates an instance by converting the characters to a byte array (assumes UTF-8 encoding). |
|
SimpleByteSource(File file)
Creates an instance by converting the file to a byte array. |
|
SimpleByteSource(InputStream stream)
Creates an instance by converting the stream to a byte array. |
|
SimpleByteSource(String string)
Creates an instance by converting the String to a byte array (assumes UTF-8 encoding). |
Method Summary | |
---|---|
boolean |
equals(Object o)
|
byte[] |
getBytes()
Returns the wrapped byte array. |
int |
hashCode()
|
static boolean |
isCompatible(Object o)
Returns true if the specified object is a recognized data type that can be easily converted to
bytes by instances of this class, false otherwise. |
boolean |
isEmpty()
Returns true if the underlying wrapped byte array is null or empty (zero length), false
otherwise. |
String |
toBase64()
Returns the Base 64-formatted String representation of the underlying wrapped byte array. |
String |
toHex()
Returns the Hex-formatted String representation of the underlying wrapped byte array. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimpleByteSource(byte[] bytes)
public SimpleByteSource(char[] chars)
chars
- the source characters to use to create the underlying byte array.public SimpleByteSource(String string)
string
- the source string to convert to a byte array (assumes UTF-8 encoding).public SimpleByteSource(ByteSource source)
source
- the source to use to populate the underlying byte array.public SimpleByteSource(File file)
file
- the file from which to acquire bytes.public SimpleByteSource(InputStream stream)
stream
- the stream from which to acquire bytes.Method Detail |
---|
public static boolean isCompatible(Object o)
true
if the specified object is a recognized data type that can be easily converted to
bytes by instances of this class, false
otherwise.
This implementation returns true
IFF the specified object is an instance of one of the following
types:
byte[]
char[]
ByteSource
String
File
InputStream
o
- the object to test to see if it can be easily converted to bytes by instances of this class.
true
if the specified object can be easily converted to bytes by instances of this class,
false
otherwise.public byte[] getBytes()
ByteSource
getBytes
in interface ByteSource
public boolean isEmpty()
ByteSource
true
if the underlying wrapped byte array is null or empty (zero length), false
otherwise.
isEmpty
in interface ByteSource
true
if the underlying wrapped byte array is null or empty (zero length), false
otherwise.public String toHex()
ByteSource
toHex
in interface ByteSource
public String toBase64()
ByteSource
toBase64
in interface ByteSource
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |