Package net.i2p.data

Class SimpleDataStructure

  • All Implemented Interfaces:
    Serializable, DataStructure
    Direct Known Subclasses:
    EncryptedBuildRecord, Hash, Hash384, Hash512, NodeInfo, PrivateKey, PublicKey, SessionKey, SessionTag, SHA1Hash, Signature, SigningPrivateKey, SigningPublicKey

    public abstract class SimpleDataStructure
    extends DataStructureImpl
    A SimpleDataStructure contains only a single fixed-length byte array. The main reason to do this is to override toByteArray() and fromByteArray(), which are used by toBase64(), fromBase64(), and calculateHash() in DataStructureImpl - otherwise these would go through a wasteful array-to-stream-to-array pass. It also centralizes a lot of common code. Implemented in 0.8.2 and retrofitted over several of the classes in this package. As of 0.8.3, SDS objects may be cached. An SDS may be instantiated with null data, and setData(null) is also OK. However, once non-null data is set, the data reference is immutable; subsequent attempts to set the data via setData(), readBytes(), fromByteArray(), or fromBase64() will throw a RuntimeException.
    Since:
    0.8.2
    Author:
    zzz
    See Also:
    Serialized Form
    • Field Detail

      • _data

        protected byte[] _data
    • Constructor Detail

      • SimpleDataStructure

        public SimpleDataStructure()
        A new instance with the data set to null. Call readBytes(), setData(), or fromByteArray() after this to set the data
      • SimpleDataStructure

        public SimpleDataStructure​(byte[] data)
        Throws:
        IllegalArgumentException - if data is not the legal number of bytes (but null is ok)