|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.DataStructureImpl
net.i2p.data.SimpleDataStructure
net.i2p.data.Hash
public class Hash
Defines the hash as defined by the I2P data structure spec. A hash is the SHA-256 of some data, taking up 32 bytes.
Field Summary | |
---|---|
static Hash |
FAKE_HASH
|
static int |
HASH_LENGTH
|
Fields inherited from class net.i2p.data.SimpleDataStructure |
---|
_data |
Constructor Summary | |
---|---|
Hash()
|
|
Hash(byte[] data)
|
Method Summary | |
---|---|
static void |
clearCache()
|
static Hash |
create(byte[] data)
Pull from cache or return new WARNING - If the SDS is found in the cache, the passed-in byte array will be returned to the SimpleByteCache for reuse. |
static Hash |
create(byte[] data,
int off)
Pull from cache or return new |
static Hash |
create(InputStream in)
Pull from cache or return new |
int |
hashCode()
a Hash is a hash, so just use the first 4 bytes for speed |
int |
length()
The legal length of the byte array in this data structure |
void |
readBytes(InputStream in)
Sets the data. |
void |
setData(byte[] data)
Sets the data. |
String |
toBase64()
render the structure into modified base 64 notation |
Methods inherited from class net.i2p.data.SimpleDataStructure |
---|
calculateHash, equals, fromBase64, fromByteArray, getData, toByteArray, toString, writeBytes |
Methods inherited from class net.i2p.data.DataStructureImpl |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int HASH_LENGTH
public static final Hash FAKE_HASH
Constructor Detail |
---|
public Hash()
public Hash(byte[] data)
IllegalArgumentException
- if data is not 32 bytes (null is ok)Method Detail |
---|
public static Hash create(byte[] data)
IllegalArgumentException
- if data is not the correct number of bytespublic static Hash create(byte[] data, int off)
AIOOBE
- if not enough bytespublic static Hash create(InputStream in) throws IOException
IOException
public int length()
SimpleDataStructure
length
in class SimpleDataStructure
public void setData(byte[] data)
SimpleDataStructure
setData
in class SimpleDataStructure
data
- of correct length, or null
IllegalArgumentException
- if data is not 32 bytes (null is ok)public void readBytes(InputStream in) throws DataFormatException, IOException
SimpleDataStructure
readBytes
in interface DataStructure
readBytes
in class SimpleDataStructure
in
- the stream to read
DataFormatException
- if the data is improperly formatted
IOException
- if there was a problem reading the streampublic int hashCode()
hashCode
in class SimpleDataStructure
public String toBase64()
DataStructure
toBase64
in interface DataStructure
toBase64
in class SimpleDataStructure
public static void clearCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |