All Known Implementing Classes:
SdkDataWriter

public interface DataWriter
Data writer interface for PowerAuth mobile SDK, see: https://github.com/wultra/powerauth-mobile-sdk/blob/develop/src/PowerAuth/utils/DataWriter.h
Author:
Roman Strobl, roman.strobl@wultra.com
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns maximum supported value which can be serialized as a counter.
    byte[]
    Returns serialized data.
    void
    Resets data writer object to its initial state.
    void
    writeByte(byte b)
    Writes one byte to the stream.
    boolean
    writeCount(int count)
    Writes a count to the stream in optimized binary format.
    void
    writeData(byte[] bytes)
    Writes number of bytes in byte range and actual data to the stream.
    void
    writeRaw(byte[] bytes)
    Writes only the content of byte range to the data stream.
    void
    Writes number of characters in string and actual content of string to the data stream.
  • Method Details

    • reset

      void reset()
      Resets data writer object to its initial state.
    • writeByte

      void writeByte(byte b)
      Writes one byte to the stream.
      Parameters:
      b - Byte to write.
    • writeData

      void writeData(byte[] bytes)
      Writes number of bytes in byte range and actual data to the stream. The size of range must not exceed value returned from getMaxCount() method.
      Parameters:
      bytes - Bytes to write.
    • writeString

      void writeString(String str)
      Writes number of characters in string and actual content of string to the data stream. The length of string must not exceed value returned from getMaxCount() method.
      Parameters:
      str - String to write.
    • writeRaw

      void writeRaw(byte[] bytes)
      Writes only the content of byte range to the data stream. Unlike the writeData(byte[]), this method doesn't store number of bytes as a size marker. It's up to you, how you determine the size of sequence during the data reading.
      Parameters:
      bytes - Data bytes.
    • writeCount

      boolean writeCount(int count)
      Writes a count to the stream in optimized binary format. The count parameter must be less or equal than value returned from getMaxCount() method. You should prefer this method for counter-type values over the writing 32-bit or 64-bit values to the stream, because it usually produces a shorter byte streams. For example, if count value is lesser than 128, then just one byte is serialized.
      Parameters:
      count - Count value to write.
      Returns:
      whether write succeeded
    • getSerializedData

      byte[] getSerializedData()
      Returns serialized data.
      Returns:
      Serialized data.
    • getMaxCount

      int getMaxCount()
      Returns maximum supported value which can be serialized as a counter. The returned value is the same for all supported platforms and CPU architectures.
      Returns:
      Maximum count value.