Class ByteArray

java.lang.Object
org.symbol.sdk.ByteArray
All Implemented Interfaces:

Serializer

Direct Known Subclasses:

Address, Address, CryptoTypes.Hash256, CryptoTypes.PrivateKey, CryptoTypes.PublicKey, CryptoTypes.SharedKey256, CryptoTypes.Signature, Hash256, Hash512, ProofGamma, ProofScalar, ProofVerificationHash, PublicKey, Signature, UnresolvedAddress, VotingPublicKey


public abstract class ByteArray extends Object implements Serializer
ByteArray

Fixed-size byte-backed value (key, hash, signature, address, …) extended by every byte-array POD. The base class owns the value semantics (equals/hashCode/toString/serialize) that an interface cannot provide for Object methods.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ByteArray(byte[] bytes, int size)
    Creates a fixed-size byte value, validating its length.
  • Method Summary

    Modifier and Type
    Method
    Description
    final byte[]
    Returns the raw bytes backing this value.
    final boolean
    equals(Object other)
     
    final int
     
    final byte[]
    Serializes this object to a fresh byte array.
    final int
    Returns the size, in bytes, of the serialized form of this object.
    static byte[]
    toBytes(Object value)
    Converts a raw value (byte[], hex String, or any ByteArray) to raw bytes.
    final String
    JSON-safe representation; delegates to toString() so each subclass's external format flows through.
    Returns the external string representation — hex by default.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteArray

      protected ByteArray(byte[] bytes, int size)
      Creates a fixed-size byte value, validating its length.
      Parameters:

      bytes - Raw bytes (defensively copied).

      size - Required length.

  • Method Details

    • bytes

      public final byte[] bytes()
      ByteArray.bytes

      Returns the raw bytes backing this value. The returned array is the internal buffer — callers must not mutate it.

      Returns:

      Raw bytes.

    • size

      public final int size()
      ByteArray.size

      Description copied from interface: Serializer

      Returns the size, in bytes, of the serialized form of this object.
      Specified by:

      size in interface Serializer

      Returns:

      Size in bytes.

    • serialize

      public final byte[] serialize()
      ByteArray.serialize

      Description copied from interface: Serializer

      Serializes this object to a fresh byte array.
      Specified by:

      serialize in interface Serializer

      Returns:

      Serialized bytes.

    • toString

      public String toString()
      ByteArray.toString

      Returns the external string representation — hex by default.

      Overrides:

      toString in class Object

      Returns:

      String representation of this value.

    • toJson

      public final String toJson()
      ByteArray.toJson

      JSON-safe representation; delegates to toString() so each subclass's external format flows through.

      Returns:

      String representation of this value.

    • equals

      public final boolean equals(Object other)
      Overrides:

      equals in class Object

    • hashCode

      public final int hashCode()
      Overrides:

      hashCode in class Object

    • toBytes

      public static byte[] toBytes(Object value)
      ByteArray.toBytes

      Converts a raw value (byte[], hex String, or any ByteArray) to raw bytes. A String is read as hex, not UTF-8.

      Parameters:

      value - Raw value.

      Returns:

      Converted bytes.