DataStructure
EncryptedBuildRecord
, Hash
, Hash384
, Hash512
, NodeInfo
, PrivateKey
, PublicKey
, SessionKey
, SessionTag
, SHA1Hash
, Signature
, SigningPrivateKey
, SigningPublicKey
public abstract class SimpleDataStructure extends DataStructureImpl
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected byte[] |
_data |
コンストラクタ | 説明 |
---|---|
SimpleDataStructure() |
A new instance with the data set to null.
|
SimpleDataStructure(byte[] data) |
修飾子とタイプ | メソッド | 説明 |
---|---|---|
Hash |
calculateHash() |
Calculate the SHA256 value of this object (useful for a few scenarios)
|
boolean |
equals(java.lang.Object obj) |
Warning - this returns true for two different classes with the same size
and same data, e.g.
|
void |
fromBase64(java.lang.String data) |
Sets the data.
|
void |
fromByteArray(byte[] data) |
Overridden for efficiency.
|
byte[] |
getData() |
Get the data reference (not a copy)
|
int |
hashCode() |
We assume the data has enough randomness in it, so use the first 4 bytes for speed.
|
abstract int |
length() |
The legal length of the byte array in this data structure
|
void |
readBytes(java.io.InputStream in) |
Sets the data.
|
void |
setData(byte[] data) |
Sets the data.
|
java.lang.String |
toBase64() |
render the structure into modified base 64 notation
|
byte[] |
toByteArray() |
Overridden for efficiency.
|
java.lang.String |
toString() |
|
void |
writeBytes(java.io.OutputStream out) |
Write out the data structure to the stream, using the format defined in the
I2P data structure specification.
|
read
public SimpleDataStructure()
public SimpleDataStructure(byte[] data)
java.lang.IllegalArgumentException
- if data is not the legal number of bytes (but null is ok)public abstract int length()
public byte[] getData()
public void setData(byte[] data)
data
- of correct length, or nulljava.lang.IllegalArgumentException
- if data is not the legal number of bytes (but null is ok)java.lang.RuntimeException
- if data already set.public void readBytes(java.io.InputStream in) throws DataFormatException, java.io.IOException
in
- the stream to readjava.lang.RuntimeException
- if data already set.DataFormatException
- if the data is improperly formattedjava.io.IOException
- if there was a problem reading the streampublic void writeBytes(java.io.OutputStream out) throws DataFormatException, java.io.IOException
DataStructure
out
- stream to write toDataFormatException
- if the data was incomplete or not yet ready to be writtenjava.io.IOException
- if there was a problem writing to the streampublic java.lang.String toBase64()
DataStructure
toBase64
インタフェース内 DataStructure
toBase64
クラス内 DataStructureImpl
public void fromBase64(java.lang.String data) throws DataFormatException
fromBase64
インタフェース内 DataStructure
fromBase64
クラス内 DataStructureImpl
DataFormatException
- if decoded data is not the legal number of bytes or on decoding errorjava.lang.RuntimeException
- if data already set.public Hash calculateHash()
DataStructure
calculateHash
インタフェース内 DataStructure
calculateHash
クラス内 DataStructureImpl
public byte[] toByteArray()
toByteArray
インタフェース内 DataStructure
toByteArray
クラス内 DataStructureImpl
public void fromByteArray(byte[] data) throws DataFormatException
fromByteArray
インタフェース内 DataStructure
fromByteArray
クラス内 DataStructureImpl
data
- non-nullDataFormatException
- if null or wrong lengthjava.lang.RuntimeException
- if data already set.public java.lang.String toString()
toString
クラス内 java.lang.Object
public int hashCode()
hashCode
クラス内 java.lang.Object
public boolean equals(java.lang.Object obj)
equals
クラス内 java.lang.Object